#27297: infinite AlterField migrations created for foreign key after case-only
model name change
--------------------------------+------------------------------------
Reporter: Daniel Musketa | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+------------------------------------
Description changed by Daniel Musketa:
Old description:
> Tested and affected Django versions:
> - 1.7
> - 1.8
> - 1.9
> - 1.9.6
> - 1.10.1
>
> A ''case-only'' rename of a model is not detected. This leads to infinite
> migrations on a foreign key field that refers to the renamed model.
>
> I created a minimal working example to reproduce this
> behaviour: https://github.com/vlt/django_ticket_27297_capitalization
>
> When you run {{{./manage.py makemigrations}}} it will create
> the following migration over and over again:
>
> {{{
> Migrations for 'app1':
> app1/migrations/0003_auto_20161001_2136.py:
> - Alter field fk_to_model1 on model2
> }}}
>
> The new file {{{0003_auto_20161001_2136.py}}}:
>
> {{{
> # -*- coding: utf-8 -*-
> # Generated by Django 1.10.2 on 2016-10-01 21:36
> from __future__ import unicode_literals
>
> from django.db import migrations, models
> import django.db.models.deletion
>
> class Migration(migrations.Migration):
>
> dependencies = [
> ('app1', '0002_model2'),
> ]
>
> operations = [
> migrations.AlterField(
> model_name='model2',
> name='fk_to_model1',
> field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
> to='app1.moDEl1'),
> ),
> ]
> }}}
>
> I have no idea why the Autodetector in migrations uses lower() in he
> first place.
New description:
Tested and affected Django versions:
- 1.7
- 1.8
- 1.9
- 1.9.6
- 1.10.1
A ''case-only'' rename of a model is not detected. This leads to infinite
migrations on a foreign key field that refers to the renamed model.
I created a minimal working example to reproduce this
behaviour: https://github.com/vlt/django_ticket_27297_capitalization
When you run {{{./manage.py makemigrations}}} it will create
the following migration over and over again:
{{{
Migrations for 'app1':
app1/migrations/0003_auto_20161001_2136.py:
- Alter field fk_to_model1 on model2
}}}
The new file {{{0003_auto_20161001_2136.py}}}:
{{{
# -*- coding: utf-8 -*-
# Generated by Django 1.10.2 on 2016-10-01 21:36
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('app1', '0002_model2'),
]
operations = [
migrations.AlterField(
model_name='model2',
name='fk_to_model1',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
to='app1.moDEl1'),
),
]
}}}
I have no idea why the Autodetector in migrations uses lower() in the
first place.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/27297#comment:6>
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/061.e7fc8443ec7f4a1bb2d7c8a164347277%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.