2017-05-25 117 views
0

我有一個django遷移的問題。我得到這個錯誤:Django遷移依賴項引用不存在的父節點

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

我修復錯誤,刪除了一些行,但修復這一切的錯誤後,我得到其他:

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

我不能解決。我可以刪除數據庫並再次執行遷移...但在生產環境中,我想知道如何正確修復,而不需要drop數據庫哈哈。

謝謝!

+1

您將不得不從每個遷移中「回溯」依賴項,直到樹被正確構建。 –

回答

4

當你回滾下一次:

  1. 走進你的應用程序的遷移文件夾。
  2. 查找您想要返回的遷移文件。 (例如「0012_post_category.py」)
  3. 進入終端寫入:./manage.py migrate yourAppName 0012(這只是示例編號)並按回車鍵
  4. 如果一切順利。刪除您的遷移文件夾中此編號後面的其他遷移。

不只是刪除遷移!希望有所幫助。

+0

謝謝!完美的作品! –

+1

很高興我能幫忙:) – hansTheFranz

相關問題