﻿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
23452	Infinite migrations with empty unique_together	fwkroon	Markus Holtermann	"Creating a model with an empty unique_together causes makemigrations to continuously generate migrations.

To reproduce, create a model with an empty unique_together:

{{{#!python
from django.db import models

class EmptyUniqueTogether(models.Model):
    class Meta:
        unique_together = ()

    name = models.CharField(max_length=256, db_index=True)
}}}

python manage.py makemigrations
{{{
Migrations for 'uniquetest':
  0001_initial.py:
    - Create model EmptyUniqueTogether
}}}

Immediately running makemigrations again results in an infinite series of migrations:
{{{
$ python manage.py makemigrations
Migrations for 'uniquetest':
  0002_auto_20140908_1923.py:
    - Alter unique_together for emptyuniquetogether (0 constraint(s))

$ python manage.py makemigrations
Migrations for 'uniquetest':
  0003_auto_20140908_1923.py:
    - Alter unique_together for emptyuniquetogether (0 constraint(s))
}}}

The generated migrations all look like the following:
{{{#!python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

    dependencies = [
        ('uniquetest', '0001_initial'),
    ]

    operations = [
        migrations.AlterUniqueTogether(
            name='emptyuniquetogether',
            unique_together=set([]),
        ),
    ]
}}}


Tested with both python 2.7 and python 3.3, on Django 1.7 as well as the development trunk. All combinations behaved identically.

I think an empty unique_together is probably not meaningful, so perhaps an exception should be raised instead?"	Bug	closed	Migrations	1.7	Normal	fixed		info+coding@…	Accepted	1	0	0	0	0	0
