0002-CustomView-index-the-formdef_id-column-we-are-going-.patch
wcs/sql.py | ||
---|---|---|
1361 | 1361 |
for field in existing_fields - needed_fields: |
1362 | 1362 |
cur.execute('''ALTER TABLE %s DROP COLUMN %s''' % (table_name, field)) |
1363 | 1363 | |
1364 |
# add indexes |
|
1365 |
cur.execute( |
|
1366 |
'''SELECT indexname |
|
1367 |
FROM pg_indexes |
|
1368 |
WHERE schemaname = 'public' |
|
1369 |
AND tablename = %s''', |
|
1370 |
(table_name,), |
|
1371 |
) |
|
1372 |
existing_indexes = {x[0] for x in cur.fetchall()} |
|
1373 |
if ('%s_formdef_id' % table_name) not in existing_indexes: |
|
1374 |
cur.execute( |
|
1375 |
'''CREATE INDEX %s_formdef_id ON %s(formdef_id)''' |
|
1376 |
% (table_name, table_name) |
|
1377 |
) |
|
1378 | ||
1364 | 1379 |
conn.commit() |
1365 | 1380 |
cur.close() |
1366 | 1381 | |
1367 |
- |