Django migration dependencies reference nonexistent parent node

房东的猫 提交于 2019-12-04 05:22:39

问题


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

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 fix all this errors, I get other:

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

I cant solve that. I can drop database and do makemigrations again... but in production environment I want know how fix correctly, without drop database haha.

Thanks!


回答1:


Next time when you rollback:

  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.



来源:https://stackoverflow.com/questions/44182633/django-migration-dependencies-reference-nonexistent-parent-node

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!