Opened 10 years ago

Closed 9 years ago

Last modified 9 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 Changed 10 years ago by Andrew Godwin

Status: newassigned

comment:2 Changed 10 years ago by Andrew Godwin

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 Changed 10 years ago by Aymeric Augustin

Triage Stage: UnreviewedAccepted

comment:4 Changed 10 years ago by Tim Graham

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 Changed 9 years ago by Andrew Godwin <andrew@…>

Resolution: fixed
Status: assignedclosed

In 4ce7a6bc84c68406e39f48550434faeef3277eba:

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

comment:6 Changed 9 years ago by Andrew Godwin <andrew@…>

In b568bdf8da30fe5940a31add9f3a2b8029ecb04d:

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

comment:7 Changed 9 years ago by Stratos Moros

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 Changed 9 years ago by Stratos Moros

Has patch: set
Triage Stage: AcceptedUnreviewed

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

comment:9 Changed 9 years ago by Simon Charette

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 Changed 9 years ago by Stratos Moros

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

comment:11 Changed 9 years ago by Markus Holtermann

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

comment:12 Changed 9 years ago by Stratos Moros <stratos@…>

Resolution: fixed
Status: newclosed

In cf7a2a000e16b86dd721a021f1a2001529d8d707:

Fixed #22248 -- Made RenameModel reversible

comment:13 Changed 9 years ago by Tim Graham <timograham@…>

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