Opened 6 years ago

Closed 6 years ago

#30065 closed Bug (duplicate)

Migration crash on removal of field in unique together.

Reported by: ZaArsProgger Owned by: nobody
Component: Migrations Version: 1.11
Severity: Normal Keywords: migration, unique, together, model
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by ZaArsProgger)

I found bug in migrations.

I had Model2 with FK to other Model1 and unique_key (model1, ...)
Then I changed Model2 - removed FK to Model1, created FK to Model3 and changed unique_key on (model3, ...)

It resulted as follows:

        migrations.RemoveField(
            model_name='model1',
            name='model1',
        ),
        migrations.AlterUniqueTogether(
            name='model1',
            unique_together=set([('model3', 'day', 'comment')]),
        ),

Applying migrations raised django.core.exceptions.FieldDoesNotExist

It was corrected when I interchanged operations

        migrations.AlterUniqueTogether(
            name='model1',
            unique_together=set([('model3', 'day', 'comment')]),
        ),
        migrations.RemoveField(
            model_name='model1',
            name='model1',
        ),

Change History (2)

comment:1 by ZaArsProgger, 6 years ago

Description: modified (diff)

comment:2 by Simon Charette, 6 years ago

Resolution: duplicate
Status: newclosed
Summary: Bug in django migrationsMigration crash on removal of field in unique together.

Duplicate of #28862 which will be fixed in Django 2.2 which is planned to be released in April 2019.

Note: See TracTickets for help on using tickets.
Back to Top