#22910 closed Bug (duplicate)

sqldropindexes yields wrong indexes names when using postgresql_psycopg2

Reported by: anonymous Owned by: nobody
Component: Database layer (models, ORM) Version: 1.6
Severity: Normal Keywords: sqldropindexes, postgresql
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


If you are using a postgres database (with postgresql_psycopg2), and run:

./manage.py sqldropindexes example_app

The DROP INDEX commands printed have the index names wrong, with random strings at the end of them.


With these simple models:

class City(models.Model):
    name = models.CharField(max_length=50)

class Human(models.Model):
    name = models.CharField(max_length=50)
    city = models.ForeignKey(City)

If you run the sqlindexes command (which works ok), it outputs this:

./manage.py sqlindexes example_app
CREATE INDEX "app_human_city_id" ON "app_human" ("city_id");


But if you run the sqldropindexes command, it outputs this, which has the indexes names broken:

/manage.py sqldropindexes example_app
DROP INDEX "app_human_b376980e" ;


Change History (5)

comment:1 Changed 16 months ago by anonymous

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

I have tried in django 1.6, and the bug is present too.

comment:2 Changed 16 months ago by timo

  • Version changed from 1.7-beta-2 to 1.6

If confirmed, it's a candidate for backporting to 1.6 as it'd be a bug in a new feature, see d7429defe6f8d1dce49976cf49827d18ff6be025. However, the command is likely to be dropped in Django 2.0 along with apps without migrations as noted in this comment so if the fix is difficult, it may not be worth it.

comment:3 Changed 16 months ago by aaugustin

The bug may be in sqlindexes, in which case the fix would not need to be backported.

comment:4 Changed 16 months ago by fisadev

I was the reporter, forgot to log in. Just in case anybody needs extra info on how to reproduce it.

comment:5 Changed 16 months ago by claudep

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #22611

Note: See TracTickets for help on using tickets.
Back to Top