#28339: Setting db_index=False on a field doesn't actually remove the index
----------------------------------+--------------------------------------
     Reporter:  Craig de Stigter  |                    Owner:  nobody
         Type:  Bug               |                   Status:  new
    Component:  Migrations        |                  Version:  1.11
     Severity:  Normal            |               Resolution:
     Keywords:                    |             Triage Stage:  Unreviewed
    Has patch:  0                 |      Needs documentation:  0
  Needs tests:  0                 |  Patch needs improvement:  0
Easy pickings:  0                 |                    UI/UX:  0
----------------------------------+--------------------------------------
Description changed by Craig de Stigter:

Old description:

> 1. Make a `ForeignKey`. Don't specify a value for `db_index` (django sets
> it to `True` by default)
> 2. Make a migration for the foreignkey. This creates an index:
>
> {{{
> #!sql
> CREATE INDEX "a_c_b_id_5a026661" ON "a_c" ("b_id");
> }}}
>
> 3. Explicitly set `db_index=False` and create another migration
> 4. Check `sqlmigrate` for the new migration. Index is never actually
> removed:
>
> {{{
> #!sql
> BEGIN;
> --
> -- Alter field b on c
> --
> COMMIT;
> }}}
>
> One note: This is with postgres settings. I'm not sure if it's db-
> specific

New description:

 1. Make a field with `db_index=True` (for `ForeignKey`, django sets this
 by default)
 2. Make a migration. This creates an index:

 {{{
 #!sql
 CREATE INDEX "a_c_b_id_5a026661" ON "a_c" ("b_id");
 }}}

 3. Explicitly set `db_index=False` and create another migration
 4. Check `sqlmigrate` for the new migration. Index is never actually
 removed:

 {{{
 #!sql
 BEGIN;
 --
 -- Alter field b on c
 --
 COMMIT;
 }}}


 One note: This is with postgres settings. I'm not sure if it's db-
 specific.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/28339#comment:4>
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/065.72f573a58d36eaaa181415bbe071f82e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to