#31503: Moving a unique constraint from unique_together to Field.unique 
generate an
invalid migration.
-------------------------------------+-------------------------------------
     Reporter:  Xiang Wang           |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Migrations           |                  Version:  3.0
     Severity:  Normal               |               Resolution:
     Keywords:  unique_together      |             Triage Stage:  Accepted
  unique migrations                  |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

 * stage:  Unreviewed => Accepted


Comment:

 Thank your for your report.

 I guess this is a bug in the auto-detector where the `AlterUniqueTogether`
 should appear before the `AlterField` that adds the `Field.unique=True`. I
 assume this is the case because `generate_altered_unique_together` is run
 after `generate_altered_fields` and the former doesn't add any
 dependencies on ensure operations are properly re-ordered.

 Not sure it's worth adjusting `AddConstraint` ordering as well since the
 chance of adding a `UniqueConstraint` with a colliding `.name` are really
 slim.

 Xiang, can you confirm that re-ordering your operations so that
 `AlterUniqueTogether` is performed before `AlterField` addresses your
 issue?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31503#comment:1>
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/064.1379d4741ab6666f6e7ca5cf94761ad9%40djangoproject.com.

Reply via email to