19 lines
1.0 KiB
SQL
19 lines
1.0 KiB
SQL
-- Proposed optional phase. NOT applied by the ordinary migration runner.
|
|
-- Requires an approved pgvector installation in the SAME InvestMoz database,
|
|
-- a benchmarked embedding model and a reviewed backup/rollback plan.
|
|
-- BGE-M3 candidate dimension: 1024. Changing the model requires a new embedding
|
|
-- version and reindexing, not mixing incomparable vectors.
|
|
CREATE TABLE ai_embeddings (
|
|
chunk_id uuid NOT NULL REFERENCES ai_chunks(id) ON DELETE RESTRICT,
|
|
model_id text NOT NULL,
|
|
model_revision text NOT NULL,
|
|
content_checksum char(64) NOT NULL,
|
|
embedding vector(1024) NOT NULL,
|
|
created_at timestamptz NOT NULL DEFAULT now(),
|
|
PRIMARY KEY (chunk_id, model_id, model_revision)
|
|
);
|
|
-- Start with exact filtered search, then benchmark HNSW with real ACL filters.
|
|
-- Eligible sources must be filtered using the same rules as EvidenceRepository;
|
|
-- matching model/revision/checksum is mandatory BEFORE fusion and reranking.
|
|
-- Do not run CREATE EXTENSION against an unverified PostgreSQL installation.
|