FieldDoesNotExist error in migration with deleted fields and unique_together constraint
I had a model that had a ForeignKey field and a unique_together constraint involving that field. I deleted both the field and the unique_together constraint in my model and ran makemigrations. The migration created RemoveField operation and a AlterUniqueTogether operation with unique_together=set([]). When I tried to run the migration, a django.db.models.fields.FieldDoesNotExist exception occured. I edited the migration manually to put the AlterUniqueTogether operation before the RemoveField operation and then the migration worked.
NOTE: After upgrading, you must remove the bad migration file and re-run makemigrations
or manually move the AlterUniqueTogether
operation manually as stated above; i.e. upgrading does not fix the existing migration.
Change History
(8)
Triage Stage: |
Unreviewed → Accepted
|
Type: |
Uncategorized → Bug
|
Version: |
1.7 → master
|
Owner: |
changed from nobody to Andrzej Pragacz
|
Status: |
new → assigned
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
Has patch: |
set
|
Resolution: |
fixed
|
Status: |
closed → new
|
Resolution: |
→ fixed
|
Status: |
new → closed
|
Description: |
modified (diff)
|
Managed to reproduce against master.