forked from 0x2620/pandora
lookup name and column in indexdef, fixes ./manage.py sqlfindindex
This commit is contained in:
parent
6ad112a3b8
commit
ce2768e45f
1 changed files with 6 additions and 6 deletions
|
@ -36,18 +36,18 @@ class Command(BaseCommand):
|
||||||
import entity.models
|
import entity.models
|
||||||
import document.models
|
import document.models
|
||||||
for table, column in (
|
for table, column in (
|
||||||
(models.ItemFind._meta.db_table, 'value'), # Item Find
|
(models.ItemFind._meta.db_table, 'value'), # Item Find
|
||||||
(models.Clip._meta.db_table, 'findvalue'), # Clip Find
|
(models.Clip._meta.db_table, 'findvalue'), # Clip Find
|
||||||
(models.Annotation._meta.db_table, 'findvalue'), # Annotation Find
|
(models.Annotation._meta.db_table, 'findvalue'), # Annotation Find
|
||||||
(entity.models.Find._meta.db_table, 'value'), # Entity Find
|
(entity.models.Find._meta.db_table, 'value'), # Entity Find
|
||||||
(document.models.Find._meta.db_table, 'value'), # Document Find
|
(document.models.Find._meta.db_table, 'value'), # Document Find
|
||||||
):
|
):
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
indexes = connection.introspection.get_indexes(cursor, table)
|
indexes = connection.introspection.get_indexes(cursor, table)
|
||||||
drop = []
|
drop = []
|
||||||
if column in indexes:
|
if column in indexes:
|
||||||
sql = "SELECT indexname, indexdef FROM pg_catalog.pg_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)
|
cursor.execute(sql)
|
||||||
for r in cursor:
|
for r in cursor:
|
||||||
if 'USING gin' not in r[1]:
|
if 'USING gin' not in r[1]:
|
||||||
|
|
Loading…
Reference in a new issue