Thursday, October 27, 2016

Re: Repetitve/Infinite migrations generated on ManyToManyField

Hi,

I noticed this behavior when changing the case of a app/model/field name. See if the name has the same case in the initial creation migration and in the model.

Cheers,

Olivier


On 27 Sep 2016 03:39, "Marvin Mednick" <mmednick@gmail.com> wrote:
I've the the following models related to a many-to-many relationship.   (Django 1.9.4  and sqlite)

Each time I run makemigrations, it generates an AlterField migration, which migrate successfully executes (no errors), but running makemigrations again will generate the identical migration.

Everything seems to be functional, but it shouldn't be doing this.  

Any guidance on what is causing this and ow to resolve or workaround this?

Classes:
class BugbaseFilter(models.Model):
    AND = 'AND'
    OR = 'OR'
    NONE = 'NONE'
    ASSOC_TYPE = (
        (AND,"AND of all items"),
        (OR,"OR of all items"),
        (NONE,"Single Item")
    )
    filterName = models.CharField(max_length=50)
    association = models.CharField(max_length=4,choices=ASSOC_TYPE,default=AND)


class BugbaseFilterItem(models.Model):
    fieldName   = models.CharField(max_length=100)
    checkValue = models.CharField(max_length=100)
    invert = models.BooleanField(default=False)
    regex = models.BooleanField(default=False)
    bugFilter = models.ManyToManyField(BugbaseFilter, related_name='items', related_query_name='item')
    alias = models.CharField(max_length=25, blank=True)

Migration generated:
class Migration(migrations.Migration):

    dependencies = [
        ('BugReporter', '0027_bugbasefilteritem_bugfilter'),
    ]

    operations = [
        migrations.AlterField(
            model_name='bugbasefilteritem',
            name='bugFilter',
            field=models.ManyToManyField(related_name='items', related_query_name='item', to='BugReporter.BugbaseFilter'),
        ),
    ]

The Table that is in my database looks like the following
CREATE TABLE "BugReporter_bugbasefilteritem_bugFilter" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "bugbasefilteritem_id" integer NOT NULL REFERENCES "BugReporter_bugbasefilteritem" ("id"), "bugbasefilter_id" integer NOT NULL REFERENCES "BugReporter_bugbasefilter" ("id"))


FYI... I've tried removing the related_name and related_query_item and doesn't make any difference.




--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9944f984-22c9-41b0-b592-dcec2a950dd8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAExk7p15gc%2BhDTLp2P7b4CT_VgtxAM6%2BDzP73cDXRWDCSiyNQA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment