deckhearth/migrations/1779853647565_add-pg-trgm-card-name-index.js

26 lines
635 B
JavaScript
Raw Permalink Normal View History

/**
* Enable pg_trgm + GIN index on cards.name for Layer-1 OCR text matching.
*
* @type {import('node-pg-migrate').ColumnDefinitions | undefined}
*/
export const shorthands = undefined;
/**
* @param {import('node-pg-migrate').MigrationBuilder} pgm
*/
export const up = (pgm) => {
pgm.sql(`
CREATE EXTENSION IF NOT EXISTS pg_trgm;
CREATE INDEX IF NOT EXISTS idx_cards_name_trgm
ON cards USING gin (name gin_trgm_ops);
`);
};
/**
* @param {import('node-pg-migrate').MigrationBuilder} pgm
*/
export const down = (pgm) => {
throw new Error('Down migration not supported for add-pg-trgm-card-name-index');
};