Opened 11 years ago

Closed 10 years ago

Last modified 10 years ago

#22248 closed Bug (fixed)

Model renaming doesn't work backwards

Reported by: Andrew Godwin Owned by: Andrew Godwin
Component: Migrations Version: dev
Severity: Normal Keywords:
Cc: Stratos Moros, info+coding@… Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

Because of the way ModelRename also triggers AlterField on the foreign keys of other models, it doesn't work in reverse, as that way round the foreign keys are repointed to the old model before it is re-created.

Since some backends (e.g. PostgreSQL) repoint constraints along with renames, we need to make sure that no AlterField is triggered with a rename and then have RenameModel deal with the FKs on MySQL (and perhaps Oracle?)

Change History (13)

comment:1 by Andrew Godwin, 11 years ago

Status: newassigned

comment:2 by Andrew Godwin, 11 years ago

Severity: Release blockerNormal

I'm marking model renames as irreversible for now in order to move this away from release blocker status; there's other irreversible core operations, and we can address this if we get time before the final.

comment:3 by Aymeric Augustin, 11 years ago

Triage Stage: UnreviewedAccepted

comment:4 by Tim Graham, 11 years ago

There's a test in tests/migrations/test_operations.py (test_rename_model_with_related) that should be uncommented when this is fixed.

comment:5 by Andrew Godwin <andrew@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In 4ce7a6bc84c68406e39f48550434faeef3277eba:

Fixed #22750, #22248: Model renaming now also alters field FKs

comment:6 by Andrew Godwin <andrew@…>, 10 years ago

In b568bdf8da30fe5940a31add9f3a2b8029ecb04d:

[1.7.x] Fixed #22750, #22248: Model renaming now also alters field FKs

comment:7 by Stratos Moros, 10 years ago

Cc: Stratos Moros added
Resolution: fixed
Status: closednew

Although this seems to be fixed by b568bdf, RenameModel.reversible is still False making RenameModel unreversible.

comment:8 by Stratos Moros, 10 years ago

Has patch: set
Triage Stage: AcceptedUnreviewed

I've made a pull request for this: https://github.com/django/django/pull/3572.

comment:9 by Simon Charette, 10 years ago

Triage Stage: UnreviewedAccepted

The Triage State refers to the ticket and not the patch.

Having Has patch checked with Patch needs improvement unchecked will ensure your patch shows up in the review queue.

comment:10 by Stratos Moros, 10 years ago

Sorry about that, this is my first code contribution to Django. I'll keep it in mind for the future.

comment:11 by Markus Holtermann, 10 years ago

Cc: info+coding@… added
Needs documentation: set
Patch needs improvement: set

comment:12 by Stratos Moros <stratos@…>, 10 years ago

Resolution: fixed
Status: newclosed

In cf7a2a000e16b86dd721a021f1a2001529d8d707:

Fixed #22248 -- Made RenameModel reversible

comment:13 by Tim Graham <timograham@…>, 10 years ago

In 50434aebe2d3307263ca55f6dd9fa7ace2f87d8f:

[1.7.x] Fixed #22248 -- Made RenameModel reversible

Backport of cf7a2a000e from master

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