@@ -6562,6 +6562,9 @@ def test_add_field_after_generated_field(self):
6562
6562
def test_composite_pk_operations (self ):
6563
6563
app_label = "test_d8d90af6"
6564
6564
project_state = self .set_up_test_model (app_label )
6565
+ operation_0 = migrations .AlterField (
6566
+ "Pony" , "id" , models .IntegerField (primary_key = True )
6567
+ )
6565
6568
operation_1 = migrations .AddField (
6566
6569
"Pony" , "pk" , models .CompositePrimaryKey ("id" , "pink" )
6567
6570
)
@@ -6571,12 +6574,12 @@ def test_composite_pk_operations(self):
6571
6574
6572
6575
# 1. Add field (pk).
6573
6576
new_state = project_state .clone ()
6574
- operation_1 . state_forwards ( app_label , new_state )
6575
- with connection . schema_editor () as editor :
6576
- operation_1 . database_forwards ( app_label , editor , project_state , new_state )
6577
+ new_state = self . apply_operations (
6578
+ app_label , new_state , [ operation_0 , operation_1 ]
6579
+ )
6577
6580
self .assertColumnNotExists (table_name , "pk" )
6578
6581
Pony = new_state .apps .get_model (app_label , "pony" )
6579
- obj_1 = Pony .objects .create (weight = 1 )
6582
+ obj_1 = Pony .objects .create (id = 1 , weight = 1 )
6580
6583
msg = (
6581
6584
f"obj_1={ obj_1 } , "
6582
6585
f"obj_1.id={ obj_1 .id } , "
0 commit comments