Django迁移依存关系参考不存在的父节点 [英] Django migration dependencies reference nonexistent parent node

查看:374
本文介绍了Django迁移依存关系参考不存在的父节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Django迁移有问题.我收到此错误:

I have a problem with django migrations. I get this error:

django.db.migrations.exceptions.NodeNotFoundError:迁移user.0050_merge_20170523_1254依赖项引用不存在的父节点('user','0049_auto_20170519_1934')

django.db.migrations.exceptions.NodeNotFoundError: Migration user.0050_merge_20170523_1254 dependencies reference nonexistent parent node ('user', '0049_auto_20170519_1934')

我修复了错误,删除了一些行,但是在修复所有这些错误之后,我又得到了另一个提示:

I fix the errors, deleting some lines but after I fix all these errors, I get another:

ValueError:找不到{'0050_merge_20170523_1254','0007_auto_20170524_1540'}的共同祖先

ValueError: Could not find common ancestor of {'0050_merge_20170523_1254', '0007_auto_20170524_1540'}

我无法解决.我可以删除数据库并再次进行迁移...但是在生产环境中,我想知道如何正确解决此问题,而无需删除数据库哈哈.

I can't solve that. I can drop database and do makemigrations again... but in production environment, I'd want to know how to fix this correctly, without drop database haha.

谢谢!

推荐答案

下次回滚时:

  1. 进入应用程序中的迁移"文件夹.
  2. 寻找您想返回的迁移文件. (例如"0012_post_category.py")
  3. 在终端中输入:./manage.py migrate yourAppName 0012(这只是示例编号),然后按Enter键
  4. 一切顺利.删除迁移文件夹中此编号之后的其他迁移.
  1. Go into the migrations folder in your app.
  2. Look for the migration file where you would like to go back to. (for example "0012_post_category.py")
  3. go in the terminal write: ./manage.py migrate yourAppName 0012 (this is just the example number) and hit enter
  4. if everything goes well. Delete the other migrations which came after this number in your migrations folder.

不要只删除迁移!希望有帮助.

Do not just delete migrations! Hope that helps.

这篇关于Django迁移依存关系参考不存在的父节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆