#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
Status: | new → assigned |
---|
comment:2 Changed 10 years ago by
Severity: | Release blocker → Normal |
---|
comment:3 Changed 10 years ago by
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 Changed 10 years ago by
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
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:7 Changed 9 years ago by
Cc: | Stratos Moros added |
---|---|
Resolution: | fixed |
Status: | closed → new |
Although this seems to be fixed by b568bdf, RenameModel.reversible is still False making RenameModel unreversible.
comment:8 Changed 9 years ago by
Has patch: | set |
---|---|
Triage Stage: | Accepted → Unreviewed |
I've made a pull request for this: https://github.com/django/django/pull/3572.
comment:9 Changed 9 years ago by
Triage Stage: | Unreviewed → Accepted |
---|
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
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
Cc: | info+coding@… added |
---|---|
Needs documentation: | set |
Patch needs improvement: | set |
comment:12 Changed 9 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
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.