Files

21 lines
912 B
SQL

-- The schema the application expects. docker-compose.yml runs this on first start, and
-- scripts/pg-up.sh runs it against a local PostgreSQL. initialize-schema is false in
-- application.yml, so the application never creates or alters any of this itself.
CREATE EXTENSION IF NOT EXISTS vector;
CREATE SCHEMA IF NOT EXISTS rag;
-- metadata is json, the type Spring AI's PgVectorStore writes and its filter queries cast from.
-- 1536 is the size of a text-embedding-3-small vector; change it together with the model.
CREATE TABLE IF NOT EXISTS rag.document_chunks (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
content text,
metadata json,
embedding vector(1536)
);
-- HNSW with cosine distance, matching index-type and distance-type in application.yml.
CREATE INDEX IF NOT EXISTS document_chunks_embedding_idx
ON rag.document_chunks USING hnsw (embedding vector_cosine_ops);