mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #32256 -- Fixed migration optimization crash when swapping field names.
This disables optimization of RenameField operation when an old field name is referenced in subsequent operations. Co-authored-by: InvalidInterrupt <InvalidInterrupt@users.noreply.github.com>
This commit is contained in:
committed by
Mariusz Felisiak
parent
ab58f07250
commit
7c18b22e2f
@@ -572,6 +572,23 @@ class OptimizerTests(SimpleTestCase):
|
||||
],
|
||||
)
|
||||
|
||||
def test_swapping_fields_names(self):
|
||||
self.assertDoesNotOptimize(
|
||||
[
|
||||
migrations.CreateModel(
|
||||
'MyModel',
|
||||
[
|
||||
('field_a', models.IntegerField()),
|
||||
('field_b', models.IntegerField()),
|
||||
],
|
||||
),
|
||||
migrations.RunPython(migrations.RunPython.noop),
|
||||
migrations.RenameField('MyModel', 'field_a', 'field_c'),
|
||||
migrations.RenameField('MyModel', 'field_b', 'field_a'),
|
||||
migrations.RenameField('MyModel', 'field_c', 'field_b'),
|
||||
],
|
||||
)
|
||||
|
||||
def test_create_model_remove_field(self):
|
||||
"""
|
||||
RemoveField should optimize into CreateModel.
|
||||
|
||||
Reference in New Issue
Block a user