From bbc7ff39c01612f191cc562ea3c6ca9ac750809d Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Mon, 24 Aug 2026 22:11:23 +0100 Subject: [PATCH] feat: add trigram index on attachment file names --- .../migrations/20260824T211732-page-title-trgm-index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/server/src/database/migrations/20260824T211732-page-title-trgm-index.ts b/apps/server/src/database/migrations/20260824T211732-page-title-trgm-index.ts index def048f3f..3cadad07b 100644 --- a/apps/server/src/database/migrations/20260824T211732-page-title-trgm-index.ts +++ b/apps/server/src/database/migrations/20260824T211732-page-title-trgm-index.ts @@ -4,8 +4,14 @@ export async function up(db: Kysely): Promise { await sql`CREATE INDEX IF NOT EXISTS pages_title_trgm_idx ON pages USING gin (lower(f_unaccent(title)) gin_trgm_ops)`.execute( db, ); + + // separators normalized to spaces so space-typed queries match How_to_export.pdf + await sql`CREATE INDEX IF NOT EXISTS attachments_file_name_trgm_idx ON attachments USING gin (lower(f_unaccent(translate(file_name, '_.-', ' '))) gin_trgm_ops)`.execute( + db, + ); } export async function down(db: Kysely): Promise { + await sql`DROP INDEX IF EXISTS attachments_file_name_trgm_idx`.execute(db); await sql`DROP INDEX IF EXISTS pages_title_trgm_idx`.execute(db); }