Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#29755 closed Bug (fixed)

Infinite migrations created after removing Meta.default_related_name

Reported by: Aamir Rind Owned by: Simon Charette
Component: Migrations Version: 1.11
Severity: Normal Keywords: migrations, unlimited, infinite, makemigrations
Cc: aamir.adnan.rind@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Consider there exists following models:

from django.db import models


class Parent(models.Model):
    name = models.CharField(max_length=50)


class Child(models.Model):
    parent = models.ForeignKey('polls.Parent')
    
    class Meta:
        default_related_name = 'children'
        ordering = ('id', )
  • Run makemigrations command this will create 0001_initial.py migration.
  • Now go to models.py and remove default_related_name from Child model.
  • Run makemigrations multiple times and it will create same migration again and again.

I have created a project to reproduce this issue: https://github.com/intellisense/django-infinite-migrations

Change History (5)

comment:1 by Tim Graham, 6 years ago

Component: Core (Management commands)Migrations
Summary: Infinite Django MigrationsInfinite migrations created after removing Meta.default_related_name
Triage Stage: UnreviewedAccepted
Version: 2.11.11

Bug report seems to be against Django 1.11 but I verified that it affects master as of today (1b1f64ee5a78cc217fead52cbae23114502cf564).

comment:2 by Simon Charette, 6 years ago

Has patch: set
Owner: changed from nobody to Simon Charette
Status: newassigned

It was a simple matter of adding the option to AlterModelOptions.ALTER_OPTION_KEYS

https://github.com/django/django/pull/10389

comment:3 by Carlton Gibson, 6 years ago

Triage Stage: AcceptedReady for checkin

Yep. Looks good.

comment:4 by Tim Graham <timograham@…>, 6 years ago

Resolution: fixed
Status: assignedclosed

In a4495f4b:

Fixed #29755 -- Made migrations detect changes to Meta.default_related_name.

comment:5 by Tim Graham <timograham@…>, 6 years ago

In 4c5a8c6:

[2.1.x] Fixed #29755 -- Made migrations detect changes to Meta.default_related_name.

Backport of a4495f4b989dc919d80fcf9f38e31e247faa94fb from master

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