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.
* type: Bug => Cleanup/optimization
* stage: Unreviewed => Accepted
Comment:
Managed to reproduce with the provided patch.
--
Ticket URL: <https://code.djangoproject.com/ticket/27717#comment:1>
* Attachment "0001-Refs-27717-Added-a-regression-test.patch" added.
* status: new => assigned
* owner: nobody => Ed Morley
Comment:
Thank you for the testcase - PR with that and fix opened :-)
--
Ticket URL: <https://code.djangoproject.com/ticket/27717#comment:2>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/27717#comment:3>
* stage: Accepted => Ready for checkin
Comment:
Patch and tests look sensible to me.
--
Ticket URL: <https://code.djangoproject.com/ticket/27717#comment:4>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"7156a6c9c47fe599207673e1653b056cc46082f6" 7156a6c9]:
{{{
#!CommitTicketReference repository=""
revision="7156a6c9c47fe599207673e1653b056cc46082f6"
Fixed #27717 -- Allowed migration optimization across AlterModelOptions.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27717#comment:5>