#25863: RenameModel migration does not rename indexes, subsequent index creation
fails
-------------------------------+--------------------
     Reporter:  jbaum-cmcrc    |      Owner:  nobody
         Type:  Bug            |     Status:  new
    Component:  Uncategorized  |    Version:  1.9
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 The Django RenameModel operation does not rename indexes; this can lead to
 index name collisions later if the old model name is reused.

 Steps to reproduce:
 * Make a model "A" with at least one index (db_index=True or
 index_together or unique_together).
  * python manage.py makemigrations
 * Rename model "A" to "B".
  * python manage.py makemigrations
 * Create new model called "A", with some of the same fields and indexes.
  * python manage.py makemigrations
 * Run tests (no tests need to exist for this step).
  * python manage.py test

 Observed behaviour: django.db.utils.OperationalError: index
 polls_question_b61a98bd already exists

 Expected behaviour: "Ran 0 tests in 0.000s OK"

 Comments:
 * This is a regression; these steps do not give an error under Django 1.8.
  * I initially saw the error on upgrading to 1.9 and running the tests
 with already-existing migrations.
  * I have not checked whether the operation under Django 1.8 is correct,
 certainly the indexes are not renamed, but they do not give an error in
 normal use or in the test. It is possible that some corner cases in 1.8
 will operate on the wrong index in this scenario.
 * Our use case is that we renamed a model Foo to FooRaw, then created a
 new model Foo to contain a processed version of the data.

--
Ticket URL: <https://code.djangoproject.com/ticket/25863>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/054.8290b6dcc23c8de48ca75bcef3f79607%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to