mirror of
https://github.com/django/django.git
synced 2025-11-25 05:04:26 +00:00
Refs #26709 -- Checked allow_migrate_model() in Add/RemoveIndex operations.
This commit is contained in:
parent
3551fb537f
commit
fc3ac65735
2 changed files with 30 additions and 8 deletions
|
|
@ -2347,3 +2347,21 @@ class SwappableOperationTests(OperationTestBase):
|
|||
with connection.schema_editor() as editor:
|
||||
operation.database_backwards("test_adfligsw", editor, new_state, project_state)
|
||||
self.assertTableNotExists("test_adfligsw_pony")
|
||||
|
||||
@override_settings(TEST_SWAP_MODEL='migrations.SomeFakeModel')
|
||||
def test_indexes_ignore_swapped(self):
|
||||
"""
|
||||
Add/RemoveIndex operations ignore swapped models.
|
||||
"""
|
||||
operation = migrations.AddIndex('Pony', models.Index(fields=['pink'], name='my_name_idx'))
|
||||
project_state, new_state = self.make_test_state('test_adinigsw', operation)
|
||||
with connection.schema_editor() as editor:
|
||||
# No database queries should be run for swapped models
|
||||
operation.database_forwards('test_adinigsw', editor, project_state, new_state)
|
||||
operation.database_backwards('test_adinigsw', editor, new_state, project_state)
|
||||
|
||||
operation = migrations.RemoveIndex('Pony', models.Index(fields=['pink'], name='my_name_idx'))
|
||||
project_state, new_state = self.make_test_state("test_rminigsw", operation)
|
||||
with connection.schema_editor() as editor:
|
||||
operation.database_forwards('test_rminigsw', editor, project_state, new_state)
|
||||
operation.database_backwards('test_rminigsw', editor, new_state, project_state)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue