#33710: RenameIndex() crashes when unnamed index is moving backward and forward.
--------------------------------------------+------------------------
Reporter: Mariusz Felisiak | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: dev
Severity: Release blocker | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
--------------------------------------------+------------------------
`RenameIndex()` should restore the old auto-generated name when an unnamed
index for `unique_together` is moving backward. Now re-applying
`RenameIndex()` crashes. For example:
{{{#!diff
diff --git a/tests/migrations/test_operations.py
b/tests/migrations/test_operations.py
index cfd28b1b39..c0a55023bb 100644
--- a/tests/migrations/test_operations.py
+++ b/tests/migrations/test_operations.py
@@ -2988,6 +2988,10 @@ class OperationTests(OperationTestBase):
with connection.schema_editor() as editor,
self.assertNumQueries(0):
operation.database_backwards(app_label, editor, new_state,
project_state)
self.assertIndexNameExists(table_name, "new_pony_test_idx")
+ # Re-apply renaming.
+ with connection.schema_editor() as editor:
+ operation.database_forwards(app_label, editor, project_state,
new_state)
+ self.assertIndexNameExists(table_name, "new_pony_test_idx")
# Deconstruction.
definition = operation.deconstruct()
self.assertEqual(definition[0], "RenameIndex")
}}}
crashes on PostgreSQL:
{{{
django.db.utils.ProgrammingError: relation "new_pony_test_idx" already
exists
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33710>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070180cb5e7e5f-1c7b90e1-b8d1-4c6d-b431-6b4279e669d4-000000%40eu-central-1.amazonses.com.