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 Tim Graham, 10 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Markus Holtermann, 10 years ago

Owner: changed from nobody to Markus Holtermann
Status: newassigned

comment:3 by Markus Holtermann, 10 years ago

Has patch: set

comment:4 by Markus Holtermann <info@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In c7ec3c0:

Fixed #24537 -- Ignored field order in RenameModel detection

Thanks to David Sanders for the report and test and Simon Charette for
the review.

Note: See TracTickets for help on using tickets.
Back to Top