[Django] #25327: Handling removed apps with dependent migrations?

15 views
Skip to first unread message

Django

unread,
Aug 29, 2015, 8:00:40 PM8/29/15
to django-...@googlegroups.com
#25327: Handling removed apps with dependent migrations?
-------------------------------+--------------------
Reporter: darkpixel | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/25327>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 29, 2015, 8:23:01 PM8/29/15
to django-...@googlegroups.com
#25327: Handling removed apps with dependent migrations?
-------------------------------+--------------------------------------

Reporter: darkpixel | Owner: nobody
Type: Uncategorized | Status: new
Component: Migrations | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by darkpixel):

* needs_better_patch: => 0
* component: Uncategorized => Migrations
* needs_tests: => 0
* needs_docs: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/25327#comment:1>

Django

unread,
Aug 30, 2015, 3:16:23 AM8/30/15
to django-...@googlegroups.com
#25327: Handling removed apps with dependent migrations?
-------------------------------+--------------------------------------

Reporter: darkpixel | Owner: nobody
Type: Uncategorized | Status: new
Component: Migrations | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by aaugustin):

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

--
Ticket URL: <https://code.djangoproject.com/ticket/25327#comment:2>

Django

unread,
Aug 30, 2015, 7:12:36 AM8/30/15
to django-...@googlegroups.com
#25327: Handling removed apps with dependent migrations?
-------------------------------+--------------------------------------
Reporter: darkpixel | Owner: nobody
Type: Uncategorized | Status: closed
Component: Migrations | Version: 1.8
Severity: Normal | Resolution: worksforme
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by MarkusH):

* status: new => closed
* resolution: => worksforme


Comment:

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

--
Ticket URL: <https://code.djangoproject.com/ticket/25327#comment:3>

Reply all
Reply to author
Forward
0 new messages