Migrated issue, originally created by Fredrik Blomqvist ()
When autogenerating migrations alembic wants to drop the excludeconstraint from my DB.
INFO [alembic.autogenerate.compare] Detected removed index 'quarters_period_excl' on 'quarters'
The database in use is PostgreSQL 9.6.5. The ExcludeConstraint is defined in the table_args at the end of the model, and it is created when doing SQLAlchemy create_all.
The import:
from sqlalchemy.dialects.postgresql import ExcludeConstraint
The table args:
__table_args__ = (
ExcludeConstraint(('period', '&&'), name='quarters_period_excl'),
db.UniqueConstraint('year', 'name', 'university_id'),
db.CheckConstraint(name.in_(['Fall', 'Winter', 'Spring', 'Summer'])) )
This is the code alembic generates:
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index('quarters_period_excl', table_name='quarters')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_index('quarters_period_excl', 'quarters', ['period'], unique=False)
# ### end Alembic commands ###
If this does not ring a bell, I can try to put together an MCV example.
该提问来源于开源项目:sqlalchemy/alembic