Ticket #806 (new defect)
Opened 22 months ago
Removing column with index results in broken migrations
|Reported by:||Dan Loewenherz <dan@…>||Owned by:||andrew|
Let's say you rename a column that was previous a ForeignKey to a CharField. When this migration is applied, there will be a failure, because the directive to remove the index occurs after the column is removed. In SQLite, this throws an error.
Same goes for the backwards migration. The column for the foreign key (foo_id) does not exist, but the first thing the backwards migration will attempt to do is create an index on this (nonexistent) column.
By simply reversing the order of these directives, the issue is fixed, at least for SQLite. For example:
Forwards: delete index, THEN delete column
Backwards: create column, THEN create index