/** * pgvector + cards.embedding for Layer-0 visual catalog search. * * @type {import('node-pg-migrate').ColumnDefinitions | undefined} */ export const shorthands = undefined; /** Must match lib/card-embed.js EMBED_DIMENSION. */ const EMBED_DIMENSION = 1024; /** * @param {import('node-pg-migrate').MigrationBuilder} pgm */ export const up = (pgm) => { pgm.sql(` CREATE EXTENSION IF NOT EXISTS vector; ALTER TABLE cards ADD COLUMN IF NOT EXISTS embedding vector(${EMBED_DIMENSION}), ADD COLUMN IF NOT EXISTS embedded_at TIMESTAMP; CREATE INDEX IF NOT EXISTS idx_cards_embedding_hnsw ON cards USING hnsw (embedding vector_cosine_ops) WHERE embedding IS NOT NULL; `); }; /** * @param {import('node-pg-migrate').MigrationBuilder} pgm */ export const down = (pgm) => { throw new Error('Down migration not supported for add-card-embeddings'); };