#31335: [mysql] Renaming a foreign key field that's also included in an index 
fails
with "Cannot drop index 'foo_idx': needed in a foreign key constraint"
-------------------------------------+-------------------------------------
     Reporter:  Stephen Finucane     |                    Owner:  Sanskar
                                     |  Jaiswal
         Type:  Bug                  |                   Status:  assigned
    Component:  Migrations           |                  Version:  3.0
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  1                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Sanskar Jaiswal):

 I have a working patch, but I am having trouble writing a clean test case
 for the same. The test involves removing an index on ForiegnKey, renaming
 the ForeignKey and adding the index back on the same. Since the schema
 tests involve using the editor directly, it doesn't affect the ModelState,
 which leads to a bit of a problem. When we alter the ForeignKey field, the
 column name is changed, while the field name remains the same. This leads
 to an inconsistent state when I try to add the index back on the renamed
 ForiegnKey field.
 Since, the fields property of `Model._meta` is immutable, is it advisable
 to use migration operations to update the same?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31335#comment:9>
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/068.f5b705c15814e743a526ad1b6c017690%40djangoproject.com.

Reply via email to