mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Refs #32743 -- Fixed recreation of foreign key constraints when altering type of referenced primary key with MTI.
Follow up to 325d7710ce
.
This commit is contained in:
parent
11879530a3
commit
3d9040a50b
3 changed files with 25 additions and 2 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue