From ce2768e45f4d71479bbaee9fffd3d60c075b2baa Mon Sep 17 00:00:00 2001 From: j Date: Sat, 31 Dec 2016 23:31:17 +0100 Subject: [PATCH] lookup name and column in indexdef, fixes ./manage.py sqlfindindex --- pandora/item/management/commands/sqlfindindex.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pandora/item/management/commands/sqlfindindex.py b/pandora/item/management/commands/sqlfindindex.py index 8b2fa88db..8eb8f2294 100644 --- a/pandora/item/management/commands/sqlfindindex.py +++ b/pandora/item/management/commands/sqlfindindex.py @@ -36,18 +36,18 @@ class Command(BaseCommand): import entity.models import document.models for table, column in ( - (models.ItemFind._meta.db_table, 'value'), # Item Find - (models.Clip._meta.db_table, 'findvalue'), # Clip Find - (models.Annotation._meta.db_table, 'findvalue'), # Annotation Find - (entity.models.Find._meta.db_table, 'value'), # Entity Find - (document.models.Find._meta.db_table, 'value'), # Document Find + (models.ItemFind._meta.db_table, 'value'), # Item Find + (models.Clip._meta.db_table, 'findvalue'), # Clip Find + (models.Annotation._meta.db_table, 'findvalue'), # Annotation Find + (entity.models.Find._meta.db_table, 'value'), # Entity Find + (document.models.Find._meta.db_table, 'value'), # Document Find ): cursor = connection.cursor() indexes = connection.introspection.get_indexes(cursor, table) drop = [] if column in indexes: sql = "SELECT indexname, indexdef FROM pg_catalog.pg_indexes " + \ - "WHERE indexname LIKE '%{table}%' AND indexname LIKE '%{column}%'".format(table=table, column=column) + "WHERE indexdef LIKE '%ON {table}%' AND indexdef LIKE '%{column}%'".format(table=table, column=column) cursor.execute(sql) for r in cursor: if 'USING gin' not in r[1]: