CREATE SCHEMA IF NOT EXISTS advisoryai;

-- pg_trgm: required for trigram fuzzy matching (Sprint 101 / G5).
-- Included in standard PostgreSQL contrib — always available.
CREATE EXTENSION IF NOT EXISTS pg_trgm;

-- pgvector: required for vector(384) embedding columns and cosine similarity.
-- NOT included in postgres:alpine by default — requires pgvector/pgvector image or manual install.
-- AKS degrades gracefully to array embeddings fallback if missing.
DO $$
BEGIN
    CREATE EXTENSION IF NOT EXISTS vector;
EXCEPTION
    WHEN OTHERS THEN
        RAISE NOTICE 'pgvector extension unavailable in test DB image; AKS falls back to array embeddings.';
END
$$;
