forked from 0x2620/pandora
fix findindex in postgresql 10
This commit is contained in:
parent
894a609f3f
commit
302af9cda4
1 changed files with 10 additions and 6 deletions
|
@ -45,12 +45,16 @@ class Command(BaseCommand):
|
||||||
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 " + \
|
for sql in (
|
||||||
"WHERE indexdef LIKE '%ON {table}%' AND indexdef LIKE '%{column}%'".format(table=table, column=column)
|
"SELECT indexname, indexdef FROM pg_catalog.pg_indexes " + \
|
||||||
cursor.execute(sql)
|
"WHERE indexdef LIKE '%ON {table}%' AND indexdef LIKE '%{column}%'".format(table=table, column=column),
|
||||||
for r in cursor:
|
"SELECT indexname, indexdef FROM pg_catalog.pg_indexes " + \
|
||||||
if 'USING gin' not in r[1]:
|
"WHERE indexdef LIKE '%ON public.{table}%' AND indexdef LIKE '%{column}%'".format(table=table, column=column),
|
||||||
drop.append(r[0])
|
):
|
||||||
|
cursor.execute(sql)
|
||||||
|
for r in cursor:
|
||||||
|
if 'USING gin' not in r[1]:
|
||||||
|
drop.append(r[0])
|
||||||
if drop:
|
if drop:
|
||||||
for idx in drop:
|
for idx in drop:
|
||||||
sql = 'DROP INDEX ' + idx
|
sql = 'DROP INDEX ' + idx
|
||||||
|
|
Loading…
Reference in a new issue