Opened 10 years ago

Closed 10 years ago

#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

Description

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.

Example:

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
BEGIN;
CREATE INDEX "app_human_city_id" ON "app_human" ("city_id");

COMMIT;

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

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

COMMIT;

Change History (5)

comment:1 by anonymous, 10 years ago

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

comment:2 by Tim Graham, 10 years ago

Version: 1.7-beta-21.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 by Aymeric Augustin, 10 years ago

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

comment:4 by fisadev, 10 years ago

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

comment:5 by Claude Paroz, 10 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #22611

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