#24354 closed Bug (fixed)
Migrations that rename subclasses cause problems with relations
Reported by: | Matthew Wilkes | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | 1.7 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
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.
Change History (13)
comment:1 by , 10 years ago
comment:3 by , 10 years ago
Bisect the fix on master/1.8 to b29f3b51204d53c1c8745966476543d068c173a2.
comment:4 by , 10 years ago
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.
comment:5 by , 10 years ago
Triage Stage: | Unreviewed → Accepted |
---|
Sorry, I had a typo in my earlier comment; edited to fix it and reviewed your PR.
comment:6 by , 10 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Looks good to me, hopefully a migrations expert can give a final +1.
comment:7 by , 10 years ago
Patch needs improvement: | set |
---|---|
Triage Stage: | Ready for checkin → Accepted |
comment:8 by , 10 years ago
I have made the requested changes and updated the pull request. Sorry for the slow!
Please see https://github.com/django/django/pull/4155 for a fix