Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Migration Error - NodeNotFoundError

Django verstion 1.8

Trying to migrate a newly added app in my project. Here is the traceback error:

Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 346, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 394, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 445, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/makemigrations.py", line 63, in handle
    loader = MigrationLoader(None, ignore_no_migrations=True)
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 47, in __init__
    self.build_graph()
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 318, in build_graph
    _reraise_missing_dependency(migration, parent, e)
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 288, in _reraise_missing_dependency
    raise exc
django.db.migrations.graph.NodeNotFoundError: Migration weather.0001_initial dependencies reference nonexistent parent node (u'machines', u'0006_auto_20150921_1327')

I have not found much helpful information in researching this. Syntax is correct in all models. Here is what doesn't make sense: this is just a copy of a working project. So it works on one computer, but not here. The machines model it's referencing has already been created and is working. Any ideas???

like image 597
Nicoale Avatar asked Nov 12 '15 16:11

Nicoale


People also ask

How do I reset Django migrations?

Django's migration can be reset by cleaning all the migration files except __init__.py files under each project app directory, followed by dropping the database and creating migration again using python manage.py makemigrations and python manage.py migrate .

What is Django migration?

Migrations are Django's way of propagating changes you make to your models (adding a field, deleting a model, etc.) into your database schema. They're designed to be mostly automatic, but you'll need to know when to make migrations, when to run them, and the common problems you might run into.


1 Answers

You are getting the error because the migration you are trying to run, weather.0001_initial, depends on a migration machines.0006_auto_20150921_1327 which does not exist.

If you can't find the missing migration file, you'll have to delete and recreate the migrations for the weather app, so that they don't depend on the missing migration.

like image 165
Alasdair Avatar answered Oct 06 '22 04:10

Alasdair