#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:  1                  |      Needs documentation:  0
  Needs tests:  0                  |  Patch needs improvement:  0
Easy pickings:  0                  |                    UI/UX:  0
-----------------------------------+------------------------------------

Comment (by Simon Charette):

 I had a look at the issue and I came to the conclusion that the only
 solution for now is to disable `AlterFooTogether` optimization when a
 `RemoveField` on the same model is involved.

 As mentioned by Ramiro we'd need to have access to the ''previous''
 `foo_together` value to determine whether or not the optimization can take
 place. This is a class of problem that also came up when working on #27768
 where I had to disable an optimization from taking place because I didn't
 have the ''previous'' context of a `RemoveField`.

 I guess I'd be possible to have newly generated operation embed a such a
 ''previous'' state to allow the optimization to take place but I figured
 out what I believe is a clever way of working around this disabled
 optimization. By implementing `CreateModel`/`AlterFooOperation` reduction
 most of the negative side effect during migration squashing where the
 optimizer perform a complete reduction are gone because the former is able
 to reduce `RemoveField` operation.

 All of these ideas are implemented in this
 [https://github.com/django/django/pull/10178 PR].

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28862#comment:22>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/063.05c44dd9062f806f93f1cb5cdd2a3903%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to