-- Schema RAG do projeto Doza. -- Idempotente: seguro rodar múltiplas vezes (CREATE ... IF NOT EXISTS). -- Ao copiar este arquivo para um projeto novo, trocar "doza" pelo nome -- do novo sistema no CREATE SCHEMA e nas referências de tabela abaixo. CREATE EXTENSION IF NOT EXISTS vector; CREATE EXTENSION IF NOT EXISTS pg_trgm; CREATE SCHEMA IF NOT EXISTS doza; CREATE TABLE IF NOT EXISTS doza.code_chunks ( id bigserial PRIMARY KEY, file_path text NOT NULL, content text NOT NULL, chunk_index int, embedding vector(768), updated_at timestamp DEFAULT now() ); CREATE INDEX IF NOT EXISTS code_chunks_embedding_idx ON doza.code_chunks USING ivfflat (embedding vector_cosine_ops) WITH (lists = 100); -- Hash de conteúdo por arquivo, usado pelo indexador para pular arquivos -- que não mudaram desde a última rodada (reindexação incremental). CREATE TABLE IF NOT EXISTS doza.indexed_files ( file_path text PRIMARY KEY, content_hash text NOT NULL, updated_at timestamp DEFAULT now() );