Search code examples
djangodjango-migrationspythonanywhere

Django migration non existent parent node after moving to production server


I'm trying to deploy my app on PythonAnywhere and when i go to apply the migrations i get an error that a migration dependency does not exist.

I've completely reset the migrations by deleting them from the migrations folder, dropping the database and re-creating it, and running makemigrations.

I only have my one initial migration now and everything works on my local machine.

workflow goes like this:

1 - clone the current version I'm using to PythonAnywhere. 2 - run ./manage migrate to initialize the database (the very first time) and get error:

(rwe) 17:00 ~/rwe (develop)$ ./manage.py migrate
asyncio      DEBUG    Using selector: EpollSelector
Traceback (most recent call last):
  File "./manage.py", line 21, in <module>
    main()
  File "./manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/home/IAMCB/.virtualenvs/rwe-Cn2YEGYr/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/home/IAMCB/.virtualenvs/rwe-Cn2YEGYr/lib/python3.7/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/IAMCB/.virtualenvs/rwe-Cn2YEGYr/lib/python3.7/site-packages/django/core/management/base.py", line 328, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/IAMCB/.virtualenvs/rwe-Cn2YEGYr/lib/python3.7/site-packages/django/core/management/base.py", line 369, in execute
    output = self.handle(*args, **options)
  File "/home/IAMCB/.virtualenvs/rwe-Cn2YEGYr/lib/python3.7/site-packages/django/core/management/base.py", line 83, in wrapped
    res = handle_func(*args, **kwargs)
  File "/home/IAMCB/.virtualenvs/rwe-Cn2YEGYr/lib/python3.7/site-packages/django/core/management/commands/migrate.py", line 86, in handle
    executor = MigrationExecutor(connection, self.migration_progress_callback)
  File "/home/IAMCB/.virtualenvs/rwe-Cn2YEGYr/lib/python3.7/site-packages/django/db/migrations/executor.py", line 18, in __init__
    self.loader = MigrationLoader(self.connection)
  File "/home/IAMCB/.virtualenvs/rwe-Cn2YEGYr/lib/python3.7/site-packages/django/db/migrations/loader.py", line 49, in __init__
    self.build_graph()
  File "/home/IAMCB/.virtualenvs/rwe-Cn2YEGYr/lib/python3.7/site-packages/django/db/migrations/loader.py", line 274, in build_graph
    raise exc
  File "/home/IAMCB/.virtualenvs/rwe-Cn2YEGYr/lib/python3.7/site-packages/django/db/migrations/loader.py", line 248, in build_graph
    self.graph.validate_consistency()
  File "/home/IAMCB/.virtualenvs/rwe-Cn2YEGYr/lib/python3.7/site-packages/django/db/migrations/graph.py", line 195, in validate_consistency
    [n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)]
  File "/home/IAMCB/.virtualenvs/rwe-Cn2YEGYr/lib/python3.7/site-packages/django/db/migrations/graph.py", line 195, in <listcomp>
    [n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)]
  File "/home/IAMCB/.virtualenvs/rwe-Cn2YEGYr/lib/python3.7/site-packages/django/db/migrations/graph.py", line 58, in raise_error
    raise NodeNotFoundError(self.error_message, self.key, origin=self.origin)
django.db.migrations.exceptions.NodeNotFoundError: Migration backend.0001_initial dependencies reference nonexistent parent node ('auth', '0013_delete_users')
(rwe) 17:12 ~/rwe (develop)$

The website loads, and I can browse, etc.. I just can't use anything that relies on the database considering the initial migration hasn't been applied.

The only real change between the systems is the secret key is different for production and DEBUG=False


Solution

  • I figured it out.

    I updated django from 2.2.3 to 3.0.3 and the migrations I am missing must have generated during my use of 2.2.3.

    worked for me but not for my PythonAnywhere server. I've recreated my virtualenv on my dev machine and reset all my migrations. Everything is now matching up without issue.