#23452: Infinite migrations with empty unique_together
-------------------------------+--------------------
     Reporter:  fwkroon        |      Owner:  nobody
         Type:  Uncategorized  |     Status:  new
    Component:  Migrations     |    Version:  1.7
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 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?

--
Ticket URL: <https://code.djangoproject.com/ticket/23452>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.b12e6e540b3871ca78d11d6b5ea9b2fa%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to