#23740: Cannot drop unique_together constraint on a single field with its own
unique=True constraint
---------------------------------+------------------------------------
     Reporter:  lanzz            |                    Owner:  nobody
         Type:  Bug              |                   Status:  new
    Component:  Migrations       |                  Version:  1.7
     Severity:  Normal           |               Resolution:
     Keywords:  unique_together  |             Triage Stage:  Accepted
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+------------------------------------

Comment (by matthewwestcott):

 Can't see a good way of fixing this without breaking backwards
 compatibility. The alter_unique_together logic in db/backends/schema.py
 relies on the UNIQUE constraints generated by unique_together to be
 distinguishable within the database from constraints generated through
 other mechanisms (e.g. unique=True) - but this isn't possible when the
 unique_together rule only contains a single field.

 Another way this manifests itself is to perform the following steps, in
 separate migrations:

 * create a model
 * add unique=True to one if its fields
 * add a unique_together constraint for that same field

 This results in two identical calls to _create_unique_sql, leading to a
 'relation "foo_bar_name_1e64ed8ec8cfa1c7_uniq" already exists' error.

--
Ticket URL: <https://code.djangoproject.com/ticket/23740#comment:5>
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.c39a21255137485a0a27923cbd25f683%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to