-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sql
More file actions
38 lines (33 loc) · 1.15 KB
/
init.sql
File metadata and controls
38 lines (33 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
-- Script de inicialização do banco de dados RAG
-- Este script é executado automaticamente quando o container PostgreSQL é criado
-- Habilitar extensão pgvector
CREATE EXTENSION IF NOT EXISTS vector;
-- Verificar se a extensão foi criada com sucesso
SELECT * FROM pg_extension WHERE extname = 'vector';
-- Criar tabela de exemplo para testar (opcional)
CREATE TABLE IF NOT EXISTS test_vectors (
id SERIAL PRIMARY KEY,
content TEXT,
embedding vector(1536) -- Dimensão padrão do text-embedding-3-small
);
-- Criar índice para busca vetorial (opcional)
CREATE INDEX IF NOT EXISTS test_vectors_embedding_idx
ON test_vectors
USING ivfflat (embedding vector_cosine_ops)
WITH (lists = 100);
-- Verificar se tudo foi criado corretamente
SELECT
'pgvector extension' as check_item,
CASE
WHEN EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector')
THEN 'OK'
ELSE 'FAILED'
END as status
UNION ALL
SELECT
'test_vectors table' as check_item,
CASE
WHEN EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'test_vectors')
THEN 'OK'
ELSE 'FAILED'
END as status;