Opened 8 years ago
Closed 8 years ago
#27121 closed Bug (duplicate)
Migrate Fails When Column is Deleted and Unique Together is modified in the same migration
Reported by: | Chris Reedy | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | 1.9 |
Severity: | Normal | Keywords: | migration failure no field |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
I 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:
# Consider this your model: class Fruit (models.Model): taste = models.CharField(max_length=40) color = models.CharField(max_length=40) shape = models.CharField(max_length=40) class Meta: unique_together = ('taste', 'color', 'shape')
Now, if you delete the field 'shape' and remove it from the unique together in the same migration so the model looks as follows:
# Updated model: class Fruit (models.Model): taste = models.CharField(max_length=40) color = models.CharField(max_length=40) class Meta: unique_together = ('taste', 'color') }} Migration 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.
Change History (1)
comment:1 by , 8 years ago
Component: | Database layer (models, ORM) → Migrations |
---|---|
Description: | modified (diff) |
Resolution: | → duplicate |
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Duplicate of #26180