Opened 9 years ago

Closed 9 years ago

#25327 closed Uncategorized (worksforme)

Handling removed apps with dependent migrations?

Reported by: Aaron C. de Bruyn Owned by: nobody
Component: Migrations Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

At one point, I wrote and never released an app called 'djcontacts'. It stored contact information.
I used it in a large project a few years ago, so I had a lot of ForeignKeys that referenced various models in djcontacts.
Fast-forward to today, and 'djcontacts' needs to die because of various limitations.
I used migrations several months back to migrate all the data, so I have no ForeignKeys referencing djcontacts models, and everything works perfectly.

I finally decided to remove the 'djcontacts' entry from my INSTALLED_APPS, and now I'm getting this:

System check identified no issues (0 silenced).
Unhandled exception in thread started by <function wrapper at 0x7f6addae8848>
Traceback (most recent call last):
  File "/home/aaron/.virtualenvs/uitintranet/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "/home/aaron/.virtualenvs/uitintranet/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 112, in inner_run
    self.check_migrations()
  File "/home/aaron/.virtualenvs/uitintranet/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 164, in check_migrations
    executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
  File "/home/aaron/.virtualenvs/uitintranet/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 19, in __init__
    self.loader = MigrationLoader(self.connection)
  File "/home/aaron/.virtualenvs/uitintranet/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 47, in __init__
    self.build_graph()
  File "/home/aaron/.virtualenvs/uitintranet/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 312, in build_graph
    _reraise_missing_dependency(migration, parent, e)
  File "/home/aaron/.virtualenvs/uitintranet/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 282, in _reraise_missing_dependency
    raise exc
django.db.migrations.graph.NodeNotFoundError: Migration smiles.0001_initial dependencies reference nonexistent parent node (u'djcontacts', u'0001_initial')

*The* very first migration I had in my 'smiles' app years ago referenced 'djcontacts'. Even though 'smiles' currently doesn't have ForeignKeys to djcontacts, it looks like I might need to keep the decrepit app around forever...

One work-around is commenting out the dependency in 0001_initial, but that seems 'hacky' and I'm guessing might cause problems if I ever deploy the application from scratch somewhere else.

Change History (3)

comment:1 by Aaron C. de Bruyn, 9 years ago

Component: UncategorizedMigrations

comment:2 by Aymeric Augustin, 9 years ago

If you squash migrations, you should be able to remove unused applications.

comment:3 by Markus Holtermann, 9 years ago

Resolution: worksforme
Status: newclosed

As explained by Aymeric please use squashmigrations as described in the documentation.

Note: See TracTickets for help on using tickets.
Back to Top