I'm using Alembic with Flask-SQLAlchemy, and I'm trying to remove a unique constraint on a column in one of my tables. Looking over the migrations - this constraint was never named: sa.UniqueConstraint('title')
, obviously when I update the model, Alembic can't pick up that I removed unique=True
off of it.
How do I create a migration that removes the constraint?
I tried this, but it didn't work:
with op.batch_alter_table('note', schema=None) as batch_op:
batch_op.create_unique_constraint('title_uniq', 'title')
batch_op.drop_constraint('title_uniq', type_='unique')
What ended up working was I had to have two migrations - one to create a named index and one to remove it.