For example, the consider this migration:
{{{
#!div style="font-size: 80%"
{{{#!python
class Migration(migrations.Migration):
dependencies = [
('core', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='employee',
name='salary',
field=models.BigIntegerField(),
preserve_default=True,
),
migrations.AlterField(
model_name='employee',
name='academic_degrees',
field=models.CharField(max_length=200),
preserve_default=True,
),
]
}}}
}}}
This currently results in two ALTER TABLE statments being executed:
{{{
#!div style="font-size: 80%"
{{{#!sql
ALTER TABLE employee MODIFY COLUMN salary bigint;
ALTER TABLE employee MODIFY COLUMN academic_degrees varchar(200);
}}}
}}}
But this takes twice as long as using only one ALTER TABLE statement since
the whole table is essentially recreated twice (at least in MySQL but IIRC
it is the same in PG):
{{{
#!div style="font-size: 80%"
{{{#!sql
ALTER TABLE employee MODIFY COLUMN salary bigint, MODIFY COLUMN
academic_degrees varchar(200);
}}}
}}}
This is particulary annoying because it essentially multiplies the time
the migration runs by the number of modified fields and thus causes much
longer downtimes of the service.
NOTE: this is most likely related to #24203 which refers to adding columns
instead of modifying.
--
Ticket URL: <https://code.djangoproject.com/ticket/24363>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_docs: => 0
* needs_better_patch: => 0
* type: Uncategorized => New feature
* needs_tests: => 0
* stage: Unreviewed => Someday/Maybe
Comment:
As I said in #24203, some performance numbers would be useful to assess
the benefits of this versus the cost of additional code complexity.
--
Ticket URL: <https://code.djangoproject.com/ticket/24363#comment:1>
* owner: nobody => ambivalentno
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/24363#comment:2>
* cc: emorley@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/24363#comment:3>
* cc: Phil Krylov (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/24363#comment:4>
* cc: Adam (Chainz) Johnson (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/24363#comment:5>
* cc: elonzh (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/24363#comment:6>
* cc: elonzh (removed)
--
Ticket URL: <https://code.djangoproject.com/ticket/24363#comment:7>
* cc: elonzh (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/24363#comment:8>