From e80d315ce60fe09f55af1d25fae2f30d8919e2b8 Mon Sep 17 00:00:00 2001 From: Kevin Abatan Date: Fri, 17 Jan 2025 16:00:23 +0100 Subject: [PATCH] chore: update fuzzey match migration --- .../20250117095221_fuzzy_match_on_case_name.sql | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/repositories/migrations/20250117095221_fuzzy_match_on_case_name.sql b/repositories/migrations/20250117095221_fuzzy_match_on_case_name.sql index d314c5c4..e6ccdf3d 100644 --- a/repositories/migrations/20250117095221_fuzzy_match_on_case_name.sql +++ b/repositories/migrations/20250117095221_fuzzy_match_on_case_name.sql @@ -1,12 +1,15 @@ +-- +goose NO TRANSACTION -- +goose Up --- +goose StatementBegin CREATE EXTENSION pg_trgm; ALTER DATABASE marble SET pg_trgm.similarity_threshold = 0.1; -CREATE INDEX trgm_cases_on_name ON cases USING GIN (name gin_trgm_ops); --- +goose StatementEnd +CREATE INDEX CONCURRENTLY trgm_cases_on_name ON cases USING GIN (name gin_trgm_ops); +CREATE INDEX CONCURRENTLY case_org_id_idx_2 ON cases(org_id, created_at DESC) INCLUDE(inbox_id, status, name); +DROP INDEX CONCURRENTLY IF EXISTS case_org_id_idx; +DROP INDEX CONCURRENTLY IF EXISTS case_status_idx; -- +goose Down --- +goose StatementBegin -DROP INDEX trgm_cases_on_name; +CREATE INDEX CONCURRENTLY case_status_idx ON cases(org_id, status, created_at DESC); +CREATE INDEX CONCURRENTLY case_org_id_idx ON cases(org_id, created_at DESC); +DROP INDEX CONCURRENTLY IF EXISTS case_org_id_idx_2; +DROP INDEX CONCURRENTLY IF EXISTS trgm_cases_on_name; DROP EXTENSION pg_trgm; --- +goose StatementEnd