mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #35022 -- Fixed RenameIndex() crash on unnamed indexes if exists unique constraint on the same fields.
This commit is contained in:
committed by
Mariusz Felisiak
parent
6c08dba517
commit
7045661069
@@ -3626,6 +3626,26 @@ class OperationTests(OperationTestBase):
|
||||
with self.assertRaisesMessage(ValueError, msg):
|
||||
operation.database_forwards(app_label, editor, project_state, new_state)
|
||||
|
||||
@skipUnlessDBFeature("allows_multiple_constraints_on_same_fields")
|
||||
def test_rename_index_unnamed_index_with_unique_index(self):
|
||||
app_label = "test_rninuniwui"
|
||||
project_state = self.set_up_test_model(
|
||||
app_label,
|
||||
multicol_index=True,
|
||||
unique_together=True,
|
||||
)
|
||||
table_name = app_label + "_pony"
|
||||
self.assertIndexNotExists(table_name, "new_pony_test_idx")
|
||||
operation = migrations.RenameIndex(
|
||||
"Pony", new_name="new_pony_test_idx", old_fields=["pink", "weight"]
|
||||
)
|
||||
new_state = project_state.clone()
|
||||
operation.state_forwards(app_label, new_state)
|
||||
# Rename index.
|
||||
with connection.schema_editor() as editor:
|
||||
operation.database_forwards(app_label, editor, project_state, new_state)
|
||||
self.assertIndexNameExists(table_name, "new_pony_test_idx")
|
||||
|
||||
def test_add_index_state_forwards(self):
|
||||
project_state = self.set_up_test_model("test_adinsf")
|
||||
index = models.Index(fields=["pink"], name="test_adinsf_pony_pink_idx")
|
||||
|
||||
Reference in New Issue
Block a user