我将Alembic与Flask-SQLAlchemy一起使用,并且试图删除对我的一张表中的列的唯一约束。查看迁移-此约束从未命名为:sa.UniqueConstraint('title')
,显然,当我更新模型时,Alembic无法拿起我从模型中删除的约束unique=True
。
如何创建消除约束的迁移?
我试过了,但是没有用:
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')
最终起作用的是,我必须进行两次迁移-一次创建命名索引,一次删除它。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句