﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
31834	Cannot sqlmigrate on Django migrations that change unique_together	Brіаn Lаі	nobody	"Somewhat similar to #26624, but forward sqlmigrate, reproduced on Django 3.0.8 and Postgres 10.x.

If a model with a unique_together of

{{{
unique_together = [
    (a, b)
]
}}}

and then this becomes

{{{
unique_together = [
    (a, b, c)
]
}}}

, although the makemigrations command successfully generates the corresponding AlterUniqueTogether() operation, the operation cannot be inspected with the sqlmigrate command.


Reproduce bug with the following (the project may also be attached)

{{{
class Model1(models.Model):
    id = models.IntegerField(primary_key=True)
    name = models.CharField(max_length=255, unique=True)


class Model2(models.Model):
    id = models.IntegerField(primary_key=True)
    link_id = models.CharField(max_length=255)
    settings = models.ForeignKey(Model1, on_delete=models.CASCADE)


class Model3(models.Model):
    id = models.IntegerField(primary_key=True)
    order = models.IntegerField()
    model_2 = models.ForeignKey(Model2, on_delete=models.CASCADE)
    direct = models.BooleanField(default=True)

    class Meta:
        unique_together = [
            ('model_2', 'order')
            # To get the bug, change this to ('model_2', 'order', 'direct') and sqlmigrate the migration that this creates.
        ]
}}}"	Bug	new	Database layer (models, ORM)	3.0	Normal		sqlmigrate		Unreviewed	0	0	0	0	0	0
