[Django] #24354: Migrations that rename subclasses cause problems with relations

12 views
Skip to first unread message

Django

unread,
Feb 16, 2015, 3:50:16 PM2/16/15
to django-...@googlegroups.com
#24354: Migrations that rename subclasses cause problems with relations
-------------------------------+--------------------
Reporter: MatthewWilkes | Owner: nobody
Type: Uncategorized | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
On a Django 1.7.4 site (and 1.7.x), if you have a model that is the
destination of a relation and subclass that model then migrations for the
subclass incorrectly cause the relations aimed at the parent to be
repointed. The generated migrations look like noops, as the models in
question aren't actually changed. I had this issue today on a DjangoCMS
site, causing migrations to be generated in my django-cms egg.

For example:

{{{
class Author(models.Model):
real_name = models.CharField('name', max_length=50)

class Pseudonym(Author):
pseudonym = models.CharField('name', max_length=50)

class Book(models.Model):
author = models.ForeignKey(Author)
}}}

If the class Pseudonym is renamed then later migrations will ''always''
attempt to reset the author field on book.

This is already fixed on 1.8 and master.

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

Django

unread,
Feb 16, 2015, 3:52:56 PM2/16/15
to django-...@googlegroups.com
#24354: Migrations that rename subclasses cause problems with relations
-------------------------------+--------------------------------------

Reporter: MatthewWilkes | Owner: nobody
Type: Uncategorized | Status: new
Component: Migrations | Version: 1.7
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 MatthewWilkes):

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


Comment:

Please see https://github.com/django/django/pull/4155 for a fix

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

Django

unread,
Feb 17, 2015, 4:48:41 AM2/17/15
to django-...@googlegroups.com
#24354: Migrations that rename subclasses cause problems with relations
-------------------------------+--------------------------------------
Reporter: MatthewWilkes | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* has_patch: 0 => 1
* type: Uncategorized => Bug


Comment:

Mark as having patch.

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

Django

unread,
Feb 17, 2015, 2:21:46 PM2/17/15
to django-...@googlegroups.com
#24354: Migrations that rename subclasses cause problems with relations
-------------------------------+--------------------------------------
Reporter: MatthewWilkes | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

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

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

Comment (by timgraham):

Bisect the fix on master/1.8 to b29f3b51204d53c1c8745966476543d068c173a2.

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

Django

unread,
Feb 17, 2015, 2:36:35 PM2/17/15
to django-...@googlegroups.com
#24354: Migrations that rename subclasses cause problems with relations
-------------------------------+--------------------------------------
Reporter: MatthewWilkes | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

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

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

Comment (by MatthewWilkes):

I'm sorry, are you asking me to bisect the current state or saying though
found that commit from bisecting?

Either way, that's right. That PR fixes the issue and it was present on
master immediately prior to it being merged. I know this because that's
where I originally fixed it, and had to change my PR to target 1.7 as
MarkusH's PR landed while I was working in it.

He advised that the changes on 1.8 would not be back ported to the 1.7
line.

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

Django

unread,
Feb 17, 2015, 2:52:40 PM2/17/15
to django-...@googlegroups.com
#24354: Migrations that rename subclasses cause problems with relations
-------------------------------+------------------------------------
Reporter: MatthewWilkes | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

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

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

* stage: Unreviewed => Accepted


Comment:

Sorry, I had a typo in my earlier comment; edited to fix it and reviewed
your PR.

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

Django

unread,
Feb 21, 2015, 12:25:09 PM2/21/15
to django-...@googlegroups.com
#24354: Migrations that rename subclasses cause problems with relations
-------------------------------------+-------------------------------------
Reporter: MatthewWilkes | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

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

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

* stage: Accepted => Ready for checkin


Comment:

Looks good to me, hopefully a migrations expert can give a final +1.

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

Django

unread,
Feb 24, 2015, 7:50:42 PM2/24/15
to django-...@googlegroups.com
#24354: Migrations that rename subclasses cause problems with relations
-------------------------------+------------------------------------
Reporter: MatthewWilkes | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

* needs_better_patch: 0 => 1
* stage: Ready for checkin => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/24354#comment:7>

Django

unread,
Mar 14, 2015, 1:34:50 PM3/14/15
to django-...@googlegroups.com
#24354: Migrations that rename subclasses cause problems with relations
-------------------------------+------------------------------------
Reporter: MatthewWilkes | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by MatthewWilkes):

I have made the requested changes and updated the pull request. Sorry for
the slow!

--
Ticket URL: <https://code.djangoproject.com/ticket/24354#comment:8>

Django

unread,
Mar 14, 2015, 3:35:36 PM3/14/15
to django-...@googlegroups.com
#24354: Migrations that rename subclasses cause problems with relations
-------------------------------+------------------------------------
Reporter: MatthewWilkes | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.7
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

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


Comment:

In [changeset:"d0607a7eee75121527cd03c89de82a222e298eae" d0607a7e]:
{{{
#!CommitTicketReference repository=""
revision="d0607a7eee75121527cd03c89de82a222e298eae"
[1.7.x] Fixed #24354 -- Prevented repointing of relations on superclasses
when migrating a subclass's name change
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24354#comment:9>

Django

unread,
Mar 14, 2015, 3:47:07 PM3/14/15
to django-...@googlegroups.com
#24354: Migrations that rename subclasses cause problems with relations
-------------------------------+------------------------------------
Reporter: MatthewWilkes | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.7

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"ae87ad005f7b62f5fa5a29ef07443fa1bbb9baf0" ae87ad0]:
{{{
#!CommitTicketReference repository=""
revision="ae87ad005f7b62f5fa5a29ef07443fa1bbb9baf0"
Refs #24354 -- Prevented repointing of relations on superclasses when


migrating a subclass's name change

Forwardport of test and release note from stable/1.7.x
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24354#comment:10>

Django

unread,
Mar 14, 2015, 3:47:24 PM3/14/15
to django-...@googlegroups.com
#24354: Migrations that rename subclasses cause problems with relations
-------------------------------+------------------------------------
Reporter: MatthewWilkes | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.7

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"22a67d22e98c86fe4b1665c97ace6f4251a99cac" 22a67d22]:
{{{
#!CommitTicketReference repository=""
revision="22a67d22e98c86fe4b1665c97ace6f4251a99cac"
[1.8.x] Refs #24354 -- Prevented repointing of relations on superclasses


when migrating a subclass's name change

Forwardport of test and release note from stable/1.7.x

Backport of ae87ad005f7b62f5fa5a29ef07443fa1bbb9baf0 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24354#comment:11>

Django

unread,
Apr 21, 2015, 5:52:25 AM4/21/15
to django-...@googlegroups.com
#24354: Migrations that rename subclasses cause problems with relations
-------------------------------+------------------------------------
Reporter: MatthewWilkes | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.7

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by Markus Holtermann <info@…>):

In [changeset:"e4b7daec11c3849f5dae46ddfad5fe9ef03c2482" e4b7daec]:
{{{
#!CommitTicketReference repository=""
revision="e4b7daec11c3849f5dae46ddfad5fe9ef03c2482"


Refs #24354 -- Prevented repointing of relations on superclasses when
migrating a subclass's name change

The issue was hidden on 1.8+ until #24573 due to a bug inside the model
reloading process.

Forwardport of patch from ae87ad005f7b62f5fa5a29ef07443fa1bbb9baf0
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24354#comment:12>

Django

unread,
Apr 21, 2015, 6:29:20 AM4/21/15
to django-...@googlegroups.com
#24354: Migrations that rename subclasses cause problems with relations
-------------------------------+------------------------------------
Reporter: MatthewWilkes | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.7

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by Markus Holtermann <info@…>):

In [changeset:"697317f3340b1d1f40586262098ad4dbae9aebaf" 697317f]:
{{{
#!CommitTicketReference repository=""
revision="697317f3340b1d1f40586262098ad4dbae9aebaf"
[1.8.x] Refs #24354 -- Prevented repointing of relations on superclasses


when migrating a subclass's name change

The issue was hidden on 1.8+ until #24573 due to a bug inside the model
reloading process.

Forwardport of patch from ae87ad005f7b62f5fa5a29ef07443fa1bbb9baf0
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24354#comment:13>

Reply all
Reply to author
Forward
0 new messages