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
--
Ticket URL: <https://code.djangoproject.com/ticket/24537>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/24537#comment:1>
* status: new => assigned
* owner: nobody => MarkusH
--
Ticket URL: <https://code.djangoproject.com/ticket/24537#comment:2>
* has_patch: 0 => 1
Comment:
PR: https://github.com/django/django/pull/4404
--
Ticket URL: <https://code.djangoproject.com/ticket/24537#comment:3>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"c7ec3c07e78e288a48e87b979dbd12e1fa44fe66" c7ec3c0]:
{{{
#!CommitTicketReference repository=""
revision="c7ec3c07e78e288a48e87b979dbd12e1fa44fe66"
Fixed #24537 -- Ignored field order in RenameModel detection
Thanks to David Sanders for the report and test and Simon Charette for
the review.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24537#comment:4>