@@ -57,11 +57,21 @@ def test_make_migration_create_partitioned_model(fake_app, model_config):
5757 migration = make_migration (model ._meta .app_label )
5858 ops = migration .operations
5959
60- # should have one operation to create the partitioned model
61- # and one more to add a default partition
62- assert len (ops ) == 2
63- assert isinstance (ops [0 ], operations .PostgresCreatePartitionedModel )
64- assert isinstance (ops [1 ], operations .PostgresAddDefaultPartition )
60+ if model_config ["partitioning_options" ]["method" ] == PostgresPartitioningMethod .HASH :
61+ # should have one operation to create the partitioned model
62+ # and no default partition
63+ assert len (ops ) == 1
64+ assert isinstance (ops [0 ], operations .PostgresCreatePartitionedModel )
65+ else :
66+ # should have one operation to create the partitioned model
67+ # and one more to add a default partition
68+ assert len (ops ) == 2
69+ assert isinstance (ops [0 ], operations .PostgresCreatePartitionedModel )
70+ assert isinstance (ops [1 ], operations .PostgresAddDefaultPartition )
71+
72+ # make sure the default partition is named "default"
73+ assert ops [1 ].model_name == model .__name__
74+ assert ops [1 ].name == "default"
6575
6676 # make sure the base is set correctly
6777 assert len (ops [0 ].bases ) == 1
@@ -70,10 +80,6 @@ def test_make_migration_create_partitioned_model(fake_app, model_config):
7080 # make sure the partitioning options got copied correctly
7181 assert ops [0 ].partitioning_options == model_config ["partitioning_options" ]
7282
73- # make sure the default partition is named "default"
74- assert ops [1 ].model_name == model .__name__
75- assert ops [1 ].name == "default"
76-
7783
7884@postgres_patched_migrations ()
7985def test_make_migration_create_view_model (fake_app ):
0 commit comments