fix findindex in postgresql 10

This commit is contained in:
j 2019-03-12 17:48:03 +00:00
parent 894a609f3f
commit 302af9cda4

View file

@ -45,8 +45,12 @@ 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 " + \
"WHERE indexdef LIKE '%ON {table}%' AND indexdef LIKE '%{column}%'".format(table=table, column=column),
"SELECT indexname, indexdef FROM pg_catalog.pg_indexes " + \
"WHERE indexdef LIKE '%ON public.{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]: