我正在使用sqlalchemy和postgres数据库开发flask应用程序。我正在迁移我的数据与烧瓶迁移。
我不得不更改数据库中某个表的名称,当尝试迁移(flask migrate)时,出现了一个错误
sqlalchemy.exc.InternalError: (psycopg2.InternalError) cannot drop table category_announcement_date because other objects depend on it
DETAIL: constraint announcement_dates_id_fkey on table announcement_dates depends on table category_announcement_date
HINT: Use DROP ... CASCADE to drop the dependent objects too.
[SQL: '\nDROP TABLE category_announcement_date']
我不知道如何告诉flask migrate关于这个问题,所以我想出了一个手动操作的好主意,所以我转到psql并按照错误消息的建议将表和CASCADE命令一起删除一切都很好,但现在我不能完成迁移了?当运行升级时
python manage.py db upgrade
...
sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) table "category_announcement_date" does not exist
那可能是因为我刚手动放下桌子?
有人知道我怎样才能摆脱这场混乱吗?
谢谢卡尔
最佳答案
好的,我注意到删除版本文件并重复迁移就可以了
干杯
佛罗里达州
关于python - flask-migrate:如果“表不存在”,则无法升级数据库,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36373897/