From 3d9040a50b160f8b4bb580e09f4120d4979fe29e Mon Sep 17 00:00:00 2001 From: Jordan Bae Date: Mon, 26 Jul 2021 23:56:05 +0900 Subject: Refs #32743 -- Fixed recreation of foreign key constraints when altering type of referenced primary key with MTI. Follow up to 325d7710ce9f6155bb55610ad6b4580d31263557. --- tests/migrations/test_operations.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests') 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): -- cgit v1.3