Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#23794 closed Bug (fixed)

FieldDoesNotExist error in migration with deleted fields and unique_together constraint

Reported by: Nico Benitez Owned by: Andrzej Pragacz
Component: Migrations Version: dev
Severity: Normal Keywords: migration unique_together removefield
Cc: info+coding@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by berto)

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)

comment:1 Changed 9 years ago by Simon Charette

Triage Stage: UnreviewedAccepted
Type: UncategorizedBug
Version: 1.7master

Managed to reproduce against master.

comment:2 Changed 9 years ago by Andrzej Pragacz

Owner: changed from nobody to Andrzej Pragacz
Status: newassigned

comment:3 Changed 9 years ago by Andrzej Pragacz

Resolution: fixed
Status: assignedclosed

comment:4 Changed 9 years ago by Simon Charette

Has patch: set
Resolution: fixed
Status: closednew

comment:5 Changed 9 years ago by Markus Holtermann

Cc: info+coding@… added

comment:6 Changed 9 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In 72729f844e0dd9bd01b3874171b89ab0d136a40e:

Fixed #23794 -- Fixed migrations crash when removing a field that's part of index/unique_together.

comment:7 Changed 9 years ago by Tim Graham <timograham@…>

In feded19104b14bc28aaccf550265157df84593ba:

[1.7.x] Fixed #23794 -- Fixed migrations crash when removing a field that's part of index/unique_together.

Backport of 72729f844e0dd9bd01b3874171b89ab0d136a40e from master

comment:8 Changed 8 years ago by berto

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top