I get the following error when I run any python manage.py function:
raise NodeNotFoundError(self.error_message, self.key, origin=self.origin)
django.db.migrations.exceptions.NodeNotFoundError: Migration auth.0010_user_following dependencies reference nonexistent parent node ('accounts', '0002_auto_20180615_2021')
It happened after I tried to reset my migrations by manually deleting the migration files in the migration folders (except the init files - no other files are left in the migration folders).
I have tried dropping the database with python manage.py flush, which also doesn't run.
Any suggestions? Thanks!
SOLUTION: After a week of google search I ended up reconstructing the referenced migration files manually using the documentation: https://docs.djangoproject.com/en/2.0/howto/writing-migrations/
After that the manage.py migrate and makemigration functions worked again. Never delete migration files without taking a backup first!
SOLUTION: After a week of google search I ended up reconstructing the referenced migration files manually using the documentation: https://docs.djangoproject.com/en/2.0/howto/writing-migrations/
After that the manage.py migrate and makemigration functions worked again. Never delete migration files without taking a backup first!
Unfortunately, manually deleting migrations doesn't reset them. The database knows which migrations have been run, and the error you're seeing is from Django trying to check whether the state of the models in your models modules matches the state of the migrations that have been run (which is to say, whether or not you need to create migrations to match) and also whether there are migrations that have been created but not run--these cases would create warnings. In trying to check these things, it tries to load migrations and can't find any of them.
If you want to reset your migrations, and just have a single migration per app to go from an empty database to your current schema in a single step, I recommend using the squash migrations command. You'll need to have the migrations files back first, though.
Alternatively, if you do want to drop and re-create the database altogether, you'll need to do that outside of the management commands, since those do the above checks when they run. Then you can have an empty database and run ./manage.py makemigrations
and you'll get initial migrations that represent models as they are.
I faced the exact same error, and found the constructing the whole database a little complicated I found a way to simply delete the whole database and reload it , (if its useful for you) using the following commands:
Step 1:
find . -path "/migrations/.py" -not -name "init.py" -delete
find . -path "/migrations/.pyc" -delete
Step 2:
Delete the database (sqlite3 in my case)
Step 3: Run
python manage.py makemigrations
python manage.py migrate
They should now run successfully
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With