#24934: Can't drop or change unique_together index in MySql
----------------------------+--------------------
     Reporter:  user0007    |      Owner:  nobody
         Type:  Bug         |     Status:  new
    Component:  Migrations  |    Version:  1.8
     Severity:  Normal      |   Keywords:
 Triage Stage:  Unreviewed  |  Has patch:  0
Easy pickings:  0           |      UI/UX:  0
----------------------------+--------------------
 Hello,

 I'm using Django 1.8.2 and Mysql 5.6. I created model with two fields in
 unique_together:


 {{{
     class Meta:
         unique_together = ('user', 'product')
 }}}

 the table was created sucessfully. Later I removed unique_together:

 {{{
     class Meta:
         pass
 }}}

 so Django created migration:

 {{{
     operations = [
         migrations.AlterUniqueTogether(
             name='mymodel',
             unique_together=set([]),
         ),
     ]
 }}}

 but when i try to apply this migrattion I have got an error:

 {{{
     django.db.utils.OperationalError: (1061, "Duplicate key name
 'myapp_mymodel_1ba366c5'")
 }}}

 Django is trying to create this index, instead of removed them.

 The same situation is when I try to add third field to my unique_together
 list:

 {{{
     class Meta:
         unique_together = ('user', 'product', 'category')
 }}}

 {{{
     django.db.utils.OperationalError: (1061, "Duplicate key name
 'myapp_mymodel_1ba366c5'")
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24934>
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/051.681e2221c393c2c0dcdb96954b2be4c9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to