Я автоматически сгенерировал новый скрипт миграции Alembic, и теперь alembic upgrade head
терпит неудачу со следующей ошибкой (вырезал остальную часть трассировки стека, потому что я сомневаюсь, что это актуально):
db_migrations_1_c70e60f22f2f | sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) relation "exchange_rate_history" does not exist
db_migrations_1_c70e60f22f2f | [SQL: '\n ALTER TABLE exchange_rate_history\n SET (autovacuum_vacuum_scale_factor = 0.1);\n\n ALTER TABLE exchange_rate_history\n SET (autovacuum_vacuu
m_threshold = 5000);\n\n ALTER TABLE exchange_rate_history\n SET (autovacuum_analyze_scale_factor = 0.1);\n\n ALTER TABLE exchange_rate_history\n SET (autovacuum_analyze_threshold = 5
000);\n '] (Background on this error at: http://sqlalche.me/e/f405)
(технически,это внутри контейнера Docker, который выполняет alembic.command.upgrade(alembic_cfg, revision="head")
в БД PostgreSQL, работающей внутри другого контейнера Docker, с которым он связан по сети)
Насколько я могу судить, сценарий и модель довольно просты, насколько я могу судить.
Модель:
@generic_repr
class ExchangeRateHistory(Base):
__tablename__ = 'exchange_rate_history'
id = Column(Integer, autoincrement=True, primary_key=True)
base_currency = Column(Enum(Currencies), nullable=False)
target_currency = Column(Enum(Currencies), nullable=False)
exchange_rate = Column(Float, nullable=False)
date = Column(Date, nullable=False, index=True)
Сценарий:
"""Add exchange rate history table
Revision ID: 053
Revises: 052
Create Date: 2019-04-16 12:11:43.994327
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = '053'
down_revision = '052'
branch_labels = None
depends_on = None
currencies = postgresql.ENUM(
'USD', 'GBP', 'CNY', 'BRL', name='currencies', create_type=False
)
def upgrade():
op.create_table(
'exchange_rate_history',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('base_currency', currencies, nullable=False),
sa.Column('target_currency', currencies, nullable=False),
sa.Column('exchange_rate', sa.Float(), nullable=False),
sa.Column('date', sa.Date(), nullable=False),
sa.PrimaryKeyConstraint('id'),
)
op.create_index(
op.f('ix_exchange_rate_history_date'),
'exchange_rate_history',
['date'],
unique=False,
)
def downgrade():
op.drop_index(
op.f('ix_exchange_rate_history_date'),
table_name='exchange_rate_history',
)
op.drop_table('exchange_rate_history')
Это может быть довольно конкретный вопрос, но я, честно говоря, весьма озадачен этим и был бы очень признателен за любые рекомендации,Спасибо!