-- Run once on your Aurora PostgreSQL cluster
-- Requires Aurora PostgreSQL 15.x+ with pgvector installed

-- 1. Create the database
CREATE DATABASE ragdb;

-- 2. Connect to ragdb, then run:
CREATE EXTENSION IF NOT EXISTS vector;

-- 3. The app creates the table automatically on first run,
--    but here it is for reference:
CREATE TABLE IF NOT EXISTS docs (
    id        SERIAL PRIMARY KEY,
    content   TEXT    NOT NULL,
    embedding vector(1024)
);

CREATE INDEX IF NOT EXISTS docs_emb_idx
ON docs USING ivfflat (embedding vector_cosine_ops)
WITH (lists = 50);
