Opened 21 months ago

Closed 21 months ago

Last modified 21 months 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 Changed 21 months ago by Tim Graham

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 Changed 21 months ago by Simon Charette

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 Changed 21 months ago by Carlton Gibson

Triage Stage: AcceptedReady for checkin

Yep. Looks good.

comment:4 Changed 21 months ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In a4495f4b:

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

comment:5 Changed 21 months ago by Tim Graham <timograham@…>

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