Opened 4 years ago

Closed 4 years ago

#23086 closed Uncategorized (duplicate)

Migrations keep altering unique_together

Reported by: aigarius@… Owned by: nobody
Component: Migrations Version: 1.7-rc-1
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Each new migration adds AlterUniqueTogether operation even if that has not changed.

Reproducing:

  1. Create the following models.py
    class A(Model):
        bar = IntegerField()
        foo = IntegerField()
        baz = IntegerField()
        class Meta:
            unique_together = (('bar', 'foo'), )
    
    class B(Model):
        x = IntegerField()
    
  1. Create an initial migration. All is good.
  2. Add a field "y = IntegerField()" to B
  3. Create a new auto migration.

Expected:
New migration contains only one operation: AddFiled

Actual:
New migration contains the expected AddField operation *and* the following:

        migrations.AlterUniqueTogether(
            name='a',
            unique_together=set([(b'bar', b'foo')]),

Change History (1)

comment:1 Changed 4 years ago by Tim Graham

Resolution: duplicate
Status: newclosed

It's a regression in #23014 which I reopened.

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