在修改 models.py
中的架构后,我正在尝试迁移数据库。我的应用程序在 Django 中的文件。当我尝试使用 ./manage.py migrate <app-name>
进行迁移时,它给出以下消息:
! These migrations are in the database but not on disk:
当我浏览schemamigration_table
时和文件,我注意到,对于我上次的架构迁移,该文件(成功在另一个表中添加了一个表和一个列)由于某种原因不存在。有什么方法可以在不重置数据库的情况下执行迁移?
最佳答案
是的,
如果您对迁移已应用到数据库绝对有信心,您可以安全地使用--fake
option.
./manage.py migrate <app-name> --fake
这会将迁移转发到最近的迁移。
--fake: Records the migration sequence as having been applied, but doesn’t actually run it. Useful for Converting An App.
关于Django-南: "! These migrations are in the database but not on disk:",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20027354/