#28862: Removing a field from index_together/unique_together and from the model generates a migration that crashes -----------------------------------+------------------------------------ Reporter: Artem Maslovskiy | Owner: Jeff Type: Bug | Status: assigned Component: Migrations | Version: 1.9 Severity: Normal | Resolution: Keywords: models migrations | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -----------------------------------+------------------------------------
Comment (by Jeff): Looking into overwriting the `FieldRelatedOptionOperation`'s reduce method to additionally: 1) check if the current operation is a `RemoveField` (and maybe `RenameField`, I need to confirm if it is also problematic) 2) if it is a `RemoveField` operation, to look into the model (as it exists in the DB) and if the field being removed is in `unique_together`, `index_together`, or `order_with_respect_to`, to skip the operation. This would correct the optimizer's erroneous migrations and I do not think would cause any other tests to fail. I am still new to the codebase, could anyone point me in the right direction on how I can get the current state of the table in the DB? Using `apps.config`'s `get_model()` is returning the state of the model from `models.py`, not the current state of the model as it exists in the DB. I am trying to use `ProjectState` at the moment. I plan to continue down this path, but please let me know if you can guide me to a more correct method of inspecting the current DB table as a model. -- Ticket URL: <https://code.djangoproject.com/ticket/28862#comment:17> 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/063.424a8b5b3b29b0a18a082cb6f393e4cd%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.