sqlalchemy.exc.InternalError: (pymysql.err.InternalError) (1091, "Can't DROP 'users_ibfk_1'; check that column/key exists") [SQL: ALTER TABLE users DROP FOREIGN KEY users_ibfk_1]

 

flask 迁移数据库报错

报错:

sqlalchemy.exc.InternalError: (pymysql.err.InternalError) (1091, "Can't DROP 'users_ibfk_1'; check that column/key exists")
[SQL: ALTER TABLE users DROP FOREIGN KEY users_ibfk_1]

解决办法:

将每个数据库表类型InnoDB转为 MyISAM

 

如果报错ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constrain fails。

需要删除每个表的外键限制

如果需要表类型InnoDB,迁移完在转回去

sqlalchemy.exc.InternalError: (pymysql.err.InternalError) (1091,

你可能感兴趣的:(sqlalchemy.exc.InternalError: (pymysql.err.InternalError) (1091, "Can't DROP 'users_ibfk_1'; check that column/key exists") [SQL: ALTER TABLE users DROP FOREIGN KEY users_ibfk_1])