sqlindexes doesn't create indexes for ForeignKeys on normal ManyToManyFields
|Reported by:||Craig de Stigter||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.2|
|Has patch:||yes||Needs documentation:||yes|
|Needs tests:||no||Patch needs improvement:||no|
this comment implies that the ForeignKeys created by ManyToManyField tables should also have indexes (makes sense, right? Otherwise we'll have to always create them with custom SQL, or define a through relation every time, gross.)
However sqlindexes doesn't create the indexes. It does create the (from, to) unique constraints, but that's actually not very useful for many queries...
The fix is to change django/core/management/sql.py#L140:
for model in models.get_models(app):
for model in models.get_models(app, include_auto_created=True):
Tested in 1.2.4 and trunk (r15153).
Change History (6)
comment:2 Changed 6 years ago by
|Component:||Core framework → Database layer (models, ORM)|
|Triage Stage:||Ready for checkin → Accepted|