Opened 8 years ago
Last modified 8 years ago
#28339 new Cleanup/optimization
Setting db_index=False on a ForeignKey doesn't actually remove the index — at Initial Version
Description ¶
- Make a
ForeignKey
. Don't specify a value fordb_index
(django sets it toTrue
by default) - Make a migration for the foreignkey. This creates an index:
CREATE INDEX "a_c_b_id_5a026661" ON "a_c" ("b_id");
- Explicitly set
db_index=False
and create another migration - Check
sqlmigrate
for the new migration. Index is never actually removed:
BEGIN; -- -- Alter field b on c -- COMMIT;
One note: This is with postgres settings. I'm not sure if it's db-specific
According to the ticket's flags, the next step(s) to move this issue forward are:
- To provide a patch by sending a pull request. Claim the ticket when you start working so that someone else doesn't duplicate effort. Before sending a pull request, review your work against the patch review checklist. Check the "Has patch" flag on the ticket after sending a pull request and include a link to the pull request in the ticket comment when making that update. The usual format is:
[https://github.com/django/django/pull/#### PR]
.
Note:
See TracTickets
for help on using tickets.