summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJordan Bae <qoentlr37@naver.com>2021-07-26 23:56:05 +0900
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-07-27 07:30:33 +0200
commit3d9040a50b160f8b4bb580e09f4120d4979fe29e (patch)
tree27f74b190707709a9cdf92c6ce0e08e23704ce7a /tests
parent11879530a34616e6dfa4186fef783d9fce0dac28 (diff)
Refs #32743 -- Fixed recreation of foreign key constraints when altering type of referenced primary key with MTI.
Follow up to 325d7710ce9f6155bb55610ad6b4580d31263557.
Diffstat (limited to 'tests')
-rw-r--r--tests/migrations/test_operations.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py
index 84f1b89ba5..6d016a2a25 100644
--- a/tests/migrations/test_operations.py
+++ b/tests/migrations/test_operations.py
@@ -1551,10 +1551,32 @@ class OperationTests(OperationTestBase):
with connection.schema_editor() as editor:
operation.database_forwards(app_label, editor, project_state, new_state)
assertIdTypeEqualsMTIFkType()
+ if connection.features.supports_foreign_keys:
+ self.assertFKExists(
+ f'{app_label}_shetlandpony',
+ ['pony_ptr_id'],
+ (f'{app_label}_pony', 'id'),
+ )
+ self.assertFKExists(
+ f'{app_label}_shetlandrider',
+ ['pony_id'],
+ (f'{app_label}_shetlandpony', 'pony_ptr_id'),
+ )
# Reversal.
with connection.schema_editor() as editor:
operation.database_backwards(app_label, editor, new_state, project_state)
assertIdTypeEqualsMTIFkType()
+ if connection.features.supports_foreign_keys:
+ self.assertFKExists(
+ f'{app_label}_shetlandpony',
+ ['pony_ptr_id'],
+ (f'{app_label}_pony', 'id'),
+ )
+ self.assertFKExists(
+ f'{app_label}_shetlandrider',
+ ['pony_id'],
+ (f'{app_label}_shetlandpony', 'pony_ptr_id'),
+ )
@skipUnlessDBFeature('supports_foreign_keys')
def test_alter_field_reloads_state_on_fk_with_to_field_target_type_change(self):