Opened 10 years ago
Closed 10 years ago
#24537 closed Bug (fixed)
Migration autodetector not detecting RenameModel if foreign keys are defined before sibling fields
Reported by: | David Sanders | Owned by: | Markus Holtermann |
---|---|---|---|
Component: | Migrations | Version: | dev |
Severity: | Normal | Keywords: | RenameModel |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
(This may be related to #22931 as there was some discussion about failure to detect model renaming there, although that ticket focused more on exceptions being raised.)
Django Migrations seems to generate model migrations with foreign keys placed last in a CreateModel migration, regardless of where they are defined in the model. This can affect later model renames as the autodetector fails to recognise that the model is the same; the newly generated model state will have the same order as the model.
I've created a test case to confirm that the autodetector won't detect a rename if the foreign keys are in a different order: https://github.com/rapilabs/django/blob/master/tests/migrations/test_autodetector.py#L660
Change History (4)
comment:1 by , 10 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 10 years ago
Has patch: | set |
---|
PR: https://github.com/django/django/pull/4404