#27558: Setting db_index=False on existing ForeignKey causes constraint to be
recreated
-------------------------------------+-------------------------------------
Reporter: Ed Morley | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: db-indexes, mysql | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Ed Morley):
As a workaround in the meantime, I was thinking of replacing the auto-
generated migration with something like:
{{{#!python
migrations.RunSQL(
"DROP INDEX `<name>` ON `foo_album`;",
state_operations=[
migrations.AlterField(
model_name='album',
name='artist',
field=models.ForeignKey(db_index=False,
on_delete=django.db.models.deletion.CASCADE, to='foo.Musician'),
),
],
)
}}}
However I haven't yet figured out the best way to get the existing index
name from Django.
--
Ticket URL: <https://code.djangoproject.com/ticket/27558#comment:1>
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/066.2cad2468fb5f0eec5b1a7cb20b1f230a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.