2

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') 

1 Answer 1

1

What ended up working was I had to have two migrations - one to create a named index and one to remove it.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.