#23794: FieldDoesNotExist error in migration with deleted fields and
unique_together constraint
-------------------------------------+-------------------------------------
     Reporter:  heybuddy             |                    Owner:  trg
         Type:  Bug                  |                   Status:  closed
    Component:  Migrations           |                  Version:  master
     Severity:  Normal               |               Resolution:  fixed
     Keywords:  migration            |             Triage Stage:  Accepted
  unique_together removefield        |
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by berto:

Old description:

> 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.

New description:

 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.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/23794#comment:8>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.25c38f5377be8abb7b20705284d2083b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to