Django manage.py:迁移在依赖之前应用

编程入门 行业动态 更新时间:2024-10-26 22:24:59
本文介绍了Django manage.py:迁移在依赖之前应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

运行 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:迁移在依赖之前应用

本文发布于:2023-10-28 08:46:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1536136.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Django   manage   py

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!