Route Layer-2 identification through Vercel AI Gateway (AI_GATEWAY_API_KEY, default google/gemini-2.5-flash-lite). Add Layer-1 browser Tesseract name-strip OCR with pg_trgm fuzzy catalog match via /api/cards/identify-by-text before escalating to vision. Co-authored-by: Cursor <cursoragent@cursor.com>
25 lines
635 B
JavaScript
25 lines
635 B
JavaScript
/**
|
|
* 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');
|
|
};
|