#27717: Squashmigrations doesn't optimize AlterModelOptions verbose_name_plural
into CreateModel
--------------------------------------+----------------------------------
Reporter: Ed Morley | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Keywords: squashmigrations
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
--------------------------------------+----------------------------------
The `squashmigrations` command doesn't combine a `AlterModelOptions()`
with `CreateModel()` in the case below.
For example (using Django master):
testapp/models.py
{{{#!python
from django.db import models
class Credentials(models.Model):
description = models.TextField()
class Meta:
db_table = 'credentials'
# This was added after 0001_initial.py was generated:
verbose_name_plural = 'credentials'
}}}
testapp/migrations/0001_initial.py
{{{#!python
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Credentials',
fields=[
('id', models.AutoField(auto_created=True,
primary_key=True, serialize=False, verbose_name='ID')),
('description', models.TextField()),
],
options={
'db_table': 'credentials',
},
),
]
}}}
testapp/migrations/0002_add_verbose_name_plural.py
{{{#!python
class Migration(migrations.Migration):
dependencies = [
('testapp', '0001_initial'),
]
operations = [
migrations.AlterModelOptions(
name='credentials',
options={'verbose_name_plural': 'credentials'},
),
]
}}}
Expected squashed migration (via `./manage.py squashmigrations testapp
0002`):
{{{#!python
class Migration(migrations.Migration):
replaces = [('testapp', '0001_initial'), ('testapp',
'0002_add_verbose_name_plural')]
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Credentials',
fields=[
('id', models.AutoField(auto_created=True,
primary_key=True, serialize=False, verbose_name='ID')),
('description', models.TextField()),
],
options={
'db_table': 'credentials',
'verbose_name_plural': 'credentials',
},
),
]
}}}
Actual squashed migration:
{{{#!python
class Migration(migrations.Migration):
replaces = [('testapp', '0001_initial'), ('testapp',
'0002_add_verbose_name_plural')]
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Credentials',
fields=[
('id', models.AutoField(auto_created=True,
primary_key=True, serialize=False, verbose_name='ID')),
('description', models.TextField()),
],
options={
'db_table': 'credentials',
},
),
migrations.AlterModelOptions(
name='credentials',
options={'verbose_name_plural': 'credentials'},
),
]
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27717>
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/051.0a9ba99bc08ed13d1233348fd26f02a4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.