Changes between Initial Version and Version 1 of Ticket #27121


Ignore:
Timestamp:
Aug 24, 2016, 6:56:38 PM (8 years ago)
Author:
Tim Graham
Comment:

Duplicate of #26180

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #27121

    • Property Component Database layer (models, ORM)Migrations
    • Property Resolutionduplicate
    • Property Status newclosed
  • Ticket #27121 – Description

    initial v1  
    11I discovered a bug that causes a migration to fail when a column is deleted in a migration and unique together is modified in the same migration.  The following are the steps to reproduce the bug:
    2 
     2{{{
    33   # Consider this your model:
    44   class Fruit (models.Model):
     
    99        class Meta:
    1010          unique_together = ('taste', 'color', 'shape')
    11 
     11}}}
    1212Now, if you delete the field 'shape' and remove it from the unique together in the same migration so the model looks as follows:
    13 
     13{{{
    1414   # Updated model:
    1515   class Fruit (models.Model):
     
    1919        class Meta:
    2020          unique_together = ('taste', 'color')
    21 
     21}}
    2222Migration will fail in modifying the unique_together and throw an error that the Fruit has no field named 'shape'  I think that this is because the delete of the column is processed before the unique index is updated.
    23 
Back to Top