Flask-migrate迁移注意事项

Flask-Migrate使用upgrade/downgrade命令删除表的列时,出现DROP错误:

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) near "DROP": syntax error [SQL: 'ALTER TABLE "Records" DROP COLUMN username']

解决方案:

with op.batch_alter_table('comment') as batch_op:

    batch_op.drop_column('date')

    batch_op.drop_column('text')

详情:https://blog.csdn.net/white_idiot/article/details/78533046

你可能感兴趣的:(Flask-migrate迁移注意事项)