Fix migration script

This commit is contained in:
Matvey Arye 2017-11-27 12:35:47 -05:00 committed by RobAtticus
parent 2c2aba8fad
commit 72b612cb7a
2 changed files with 2593 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -4,3 +4,22 @@ DROP FUNCTION _timescaledb_cache.invalidate_relcache(oid);
DROP FUNCTION drop_chunks(bigint,name,name,boolean);
DROP FUNCTION drop_chunks(timestamptz,name,name,boolean);
WITH ind AS (
SELECT chunk_con.chunk_id, pg_chunk_index_class.relname AS index_name
FROM _timescaledb_catalog.chunk_constraint chunk_con
INNER JOIN _timescaledb_catalog.chunk chunk ON (chunk_con.chunk_id = chunk.id)
INNER JOIN _timescaledb_catalog.hypertable hypertable ON (chunk.hypertable_id = hypertable.id)
INNER JOIN pg_constraint pg_chunk_con ON (
pg_chunk_con.conrelid = format('%I.%I', chunk.schema_name, chunk.table_name)::regclass
AND pg_chunk_con.conname = chunk_con.constraint_name
AND pg_chunk_con.contype = 'f'
)
INNER JOIN pg_class pg_chunk_index_class ON (
pg_chunk_con.conindid = pg_chunk_index_class.oid
)
)
DELETE
FROM _timescaledb_catalog.chunk_index ci
USING ind
WHERE ci.chunk_id = ind.chunk_id AND ci.index_name = ind.index_name;