#26180: Altering unique_together still sometimes missing deleted fields -------------------------------+------------------------------------ Reporter: julianandrews | Owner: nobody Type: Bug | Status: new Component: Migrations | Version: 1.9 Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------+------------------------------------
Comment (by akki): This is happening because the `RemoveField` operation is called before calling the `AlterUniqueTogether` operation, resulting in the dropping of the field before the index. In the `autodetector.py`, although the `RemoveField` operations are created before the `AlterUniqueTogether` operations but the [https://github.com/django/django/blob/20d39325ca1da57a709f3ba38299dc7b0fc4bdfb/django/db/migrations/autodetector.py#L188 `_sort_migrations` method] corrects the order of these operations to bring `AlterUniqueTogether` before `RemoveField`. But the [https://github.com/django/django/blob/20d39325ca1da57a709f3ba38299dc7b0fc4bdfb/django/db/migrations/autodetector.py#L190 `_optimize_migrations` method] again reverses this order in `self.migrations` (which is finally what gets returned by the `_detect_changes` method. This change is related to https://github.com/django/django/commit/e470f311d654267ec86f9a6325ec500345b9dff2 -- Ticket URL: <https://code.djangoproject.com/ticket/26180#comment:2> 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/071.34716c180ce6f5dd76b104523db65c4e%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.