[英]Deleting Migration Files and Getting django.db.migrations.exceptions.NodeNotFoundError:
I have deleted all of migration files and now I am trying to $ python manage.py makemigrations
but it is returning django.db.migrations.exceptions.NodeNotFoundError: Migration notifications.0001_initial dependencies reference nonexistent parent node ('blog', '0012_auto_20201118_22 55')
我已经删除了所有迁移文件,现在我正在尝试
$ python manage.py makemigrations
但它正在返回django.db.migrations.exceptions.NodeNotFoundError: Migration notifications.0001_initial dependencies reference nonexistent parent node ('blog', '0012_auto_20201118_22 55')
How should I fix this error and start migrating from the beginning?我应该如何修复此错误并从头开始迁移? The reason for deleting the migration files is due to removing a function that kept returning an error due one of the migration files so I decided to start clean with them.
删除迁移文件的原因是由于删除了一个 function,它由于其中一个迁移文件而不断返回错误,所以我决定开始清理它们。
Any ideas on what step I should take to start migrations and migrate again?关于我应该采取什么步骤来开始迁移和再次迁移的任何想法?
It looks like your notifications
app references model(s) within your blog
app, which means that it has migration files that are dependent on blog
.看起来您的
notifications
应用程序在您的blog
应用程序中引用了模型,这意味着它具有依赖于blog
的迁移文件。
To fix this you will need to clear the migrations for all of your apps, and delete your database.要解决此问题,您需要清除所有应用程序的迁移,并删除您的数据库。
It's also a good idea to delete your __pycache__
folders (they have caused migration issues for me in the past).删除你的
__pycache__
文件夹也是一个好主意(它们在过去给我带来了迁移问题)。
If you are using a unix-like command line, you can do this easily with the following:如果您使用的是类 unix命令行,则可以使用以下命令轻松完成此操作:
find . -path "*/migrations/*.py" -not -path "*/site-packages/*" -delete
find . -type d -name "__pycache__" -exec rm -rf {} +
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.