[Django] #22970: Migration dependencies not correctly calculated

4 views
Skip to first unread message

Django

unread,
Jul 7, 2014, 8:30:14 AM7/7/14
to django-...@googlegroups.com
#22970: Migration dependencies not correctly calculated
---------------------------------+----------------------
Reporter: dekkers | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7-rc-1
Severity: Release blocker | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+----------------------
When working with the new migrations I hit a bug that dependencies between
migrations aren't correctly calculated. Migrations that add a ForeignKey
to a model in another app that was created in the second or later
migrations of that other app have a depenency on the first migration
instead of the later migration. Steps to reproduce:

* Start a new project and create two apps myapp1 and myapp2
* Add a model named Model1 to myapp1
* Run makemigrations, resulting in 0001_initial.py that creates Model1
* Add a model named Model2 to myapp1
* Run makemigrations, resulting in 0002_model2.py that creates Model2
* Add a model named Model3 with a !ForeignKey to 'myapp1.Model2' to myapp2
* Run makemigrations, resulting in 0001_initial.py that creates Model3

The 0001_initial.py of myapp2 will then have `('myapp1', '__first__')` as
dependency while Model2 is created in the second migration.

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

Django

unread,
Jul 7, 2014, 9:11:55 AM7/7/14
to django-...@googlegroups.com
#22970: Migration dependencies not correctly calculated
---------------------------------+--------------------------------------

Reporter: dekkers | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7-rc-1
Severity: Release blocker | 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 timo):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Possibly related/duplicate of #22944.

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

Django

unread,
Jul 8, 2014, 3:11:06 AM7/8/14
to django-...@googlegroups.com
#22970: Migration dependencies not correctly calculated
---------------------------------+----------------------------------------
Reporter: dekkers | Owner: andrewgodwin
Type: Bug | Status: assigned
Component: Migrations | Version: 1.7-rc-1
Severity: Release blocker | 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 andrewgodwin):

* owner: nobody => andrewgodwin
* status: new => assigned


Comment:

I suspect what's needed here is for the migration to depend on
``__last__``, which we definitely used to do and I backed out for some
reason.

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

Django

unread,
Jul 10, 2014, 2:54:23 AM7/10/14
to django-...@googlegroups.com
#22970: Migration dependencies not correctly calculated
---------------------------------+----------------------------------------
Reporter: dekkers | Owner: andrewgodwin
Type: Bug | Status: closed
Component: Migrations | Version: 1.7-rc-1
Severity: Release blocker | Resolution: fixed
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 Andrew Godwin <andrew@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"008bff92b7028673cdab872a6733770606efce83"]:
{{{
#!CommitTicketReference repository=""
revision="008bff92b7028673cdab872a6733770606efce83"
Fixed #22970: Incorrect dependencies for existing migrated apps
}}}

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

Django

unread,
Jul 10, 2014, 2:54:26 AM7/10/14
to django-...@googlegroups.com
#22970: Migration dependencies not correctly calculated
---------------------------------+----------------------------------------
Reporter: dekkers | Owner: andrewgodwin
Type: Bug | Status: closed
Component: Migrations | Version: 1.7-rc-1
Severity: Release blocker | Resolution: fixed
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 Andrew Godwin <andrew@…>):

In [changeset:"aba75e73db6a0baca1b721698ca24f026bb4a745"]:
{{{
#!CommitTicketReference repository=""
revision="aba75e73db6a0baca1b721698ca24f026bb4a745"
[1.7.x] Fixed #22970: Incorrect dependencies for existing migrated apps
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22970#comment:4>

Django

unread,
Jul 14, 2014, 3:16:34 PM7/14/14
to django-...@googlegroups.com
#22970: Migration dependencies not correctly calculated
---------------------------------+----------------------------------------
Reporter: dekkers | Owner: andrewgodwin
Type: Bug | Status: new
Component: Migrations | Version: 1.7-rc-1
Severity: Release blocker | 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 dekkers):

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


Comment:

Your fix didn't work, when I ran migrate I got the following error:

{{{
KeyError: u"Dependency references nonexistent parent node (u'myapp1',
u'__last__')"
}}}

It looks like {{{__last__}}} isn't implemented, there isn't any other
mention of it in the source. I took a look at the code and fixed it in a
different way: get the name of the app's last migration from the graph and
use that. I did some quick tests and everything seems to work fine.

Pull request: https://github.com/django/django/pull/2917

--
Ticket URL: <https://code.djangoproject.com/ticket/22970#comment:5>

Django

unread,
Jul 14, 2014, 3:36:57 PM7/14/14
to django-...@googlegroups.com
#22970: Migration dependencies not correctly calculated
---------------------------------+----------------------------------------
Reporter: dekkers | Owner: andrewgodwin
Type: Bug | Status: closed
Component: Migrations | Version: 1.7-rc-1
Severity: Release blocker | Resolution: fixed
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 timo):

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


Comment:

There was a typo and it should be `__latest__`; see #23008.

--
Ticket URL: <https://code.djangoproject.com/ticket/22970#comment:6>

Reply all
Reply to author
Forward
0 new messages