Django迁移依赖引用不存在的父节点 [英] Django migration dependencies reference nonexistent parent node

查看:23
本文介绍了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(这只是示例编号)并回车
  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天全站免登陆