mirror of
https://github.com/docmost/docmost.git
synced 2026-08-26 00:07:04 +08:00
feat: add trigram index on attachment file names
This commit is contained in:
@@ -4,8 +4,14 @@ export async function up(db: Kysely<any>): Promise<void> {
|
||||
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<any>): Promise<void> {
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user