运行 python manage.py migration 时遇到此错误:
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration <appname>.0016_auto_<date2>_<time2> is applied before its dependency <appname>.0001_squashed_0015_auto_<date1>_<time1>正在运行showmigrations返回:
running showmigrations returns:
<appname> [X] 0001_squashed_0015_auto_<date1>_<time1> (15 squashed migrations) [X] 0016_auto_<date2>_<time2> [ ] 0017_<modelname>_squashed_0019_auto_<date3>_<time3> (3 squashed migrations)昨天,我在尝试django扩展时,后来一切都搞砸了我运行一些直接的SQL查询,并使用git进行了重置。我仍在学习迁移,所以我不明白出什么问题了,因为在我看来这两个迁移都已应用。
I was trying out django-extensions yesterday, when it all got messed up after me running some direct SQL queries and I reset hard using git. I'm still learning about migrations, so I don't understand what is wrong, since it seems to me that both migrations already have been applied.
感谢您的
推荐答案您已压缩了迁移,因此 0016_auto_< date2> _< ; time2> 现在已成为新创建的压缩迁移的一部分。同时 0016_auto_< date2> _< time2> 已经运行,现在您要运行压缩的迁移。
You have squashed the migrations, so one of the dependencies that 0016_auto_<date2>_<time2> had is now part of the newly created squashed migrations. Meanwhile the 0016_auto_<date2>_<time2> has already been run and now you're trying to run the squashed migration.
我个人不知道是否有任何方法可以自动解决此问题。您将需要自己解决问题。如果您具有版本控制,请还原这些更改并尝试重新考虑如何压缩迁移而不影响旧版本。
I personally don't know if there's any way to fix this automatically. You will need to fix the issues yourself. If you have version control, revert these changes and try to rethink how you should squash the migration without affecting old ones.
更多推荐
Django manage.py:迁移在依赖之前应用
发布评论