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_type_id' % table_name) not in existing_indexes: |
|
1374 |
cur.execute( |
|
1375 |
'''CREATE INDEX %s_formdef_type_id ON %s(formdef_type, formdef_id)''' % (table_name, table_name) |
|
1376 |
) |
|
1377 | ||
1364 | 1378 |
conn.commit() |
1365 | 1379 |
cur.close() |
1366 | 1380 | |
... | ... | |
4372 | 4386 |
# latest migration, number + description (description is not used |
4373 | 4387 |
# programmaticaly but will make sure git conflicts if two migrations are |
4374 | 4388 |
# separately added with the same number) |
4375 |
SQL_LEVEL = (65, 'index users(name_identifiers)')
|
|
4389 |
SQL_LEVEL = (66, 'index custom_views(formdef_type, formdef_id)')
|
|
4376 | 4390 | |
4377 | 4391 | |
4378 | 4392 |
def migrate_global_views(conn, cur): |
... | ... | |
4490 | 4504 |
if sql_level < 64: |
4491 | 4505 |
# 64: add transient data table |
4492 | 4506 |
do_transient_data_table() |
4493 |
if sql_level < 44:
|
|
4507 |
if sql_level < 66:
|
|
4494 | 4508 |
# 37: create custom_views table |
4495 | 4509 |
# 44: add is_default column to custom_views table |
4510 |
# 66: index the formdef_id column |
|
4496 | 4511 |
do_custom_views_table() |
4497 | 4512 |
if sql_level < 57: |
4498 | 4513 |
# 57: store tokens in SQL |
4499 |
- |