#31255: Migrations create a redundant RemoveField operation when deleting 2
models
with related fields.
-------------------------------------+-------------------------------------
Reporter: Panagis | Owner: Rohit Jha
Alisandratos |
Type: | Status: assigned
Cleanup/optimization |
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: migration,optimizer | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):
Sankar it's bit more complicated than that.
If you remove two interelated models (or any model cycle) at the same time
fields have to be removed to break the cycle before hand
Given
{{{#!python
class Foo(models.Model):
bar = models.ForeignKey('Bar')
class Bar(models.Model):
foo = models.ForeignKey(Foo)
}}}
Removing both models and running `makemigrations` must generate a
migration that either drop `Foo.bar` or `Bar.foo` before proceeding with
the model removal. I'm pretty sure we have auto-detector tests for this
case.
The optimizer likely need to be adjusted somehow but I doubt
`generate_deleted_models`'s generation of `RemoveField` is to blame.
--
Ticket URL: <https://code.djangoproject.com/ticket/31255#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.fa65a269eb208c765d91db9e0e5a4db5%40djangoproject.com.