Opened 7 years ago
Closed 7 years ago
#28366 closed Bug (duplicate)
AlterUniqueTogether and RemoveField on same field lead to migration error
Reported by: | Rhaskaas | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | 1.11 |
Severity: | Normal | Keywords: | AlterUniqueTogether RemoveField migrate makemigrations |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Consider a model with a field who's used in unique_together.
You want to remove this field and so change the uniquet_together Meta at the same time (in models.py).
When you do this and apply "makemigrations", the resulting migration file is not usable.
Indeed, "migrations.RemoveField" is use "before migrations.AlterUniqueTogether" and lead to "django.core.exceptions.FieldDoesNotExist" error.
If you change order manualy in migration file (i.e. alter first and remove after) there is no more problem.
Looks like a duplicate of #26180.