add pg vector and embed

This commit is contained in:
2025-08-22 19:34:54 +07:00
parent 21567a0a7c
commit b77beb2d85
27 changed files with 5273 additions and 216 deletions

View File

@@ -0,0 +1,32 @@
-- =====================================================
-- Claim Guard Database Initialization Script
-- =====================================================
-- Create database if it doesn't exist (handled by POSTGRES_DB env var)
-- But we can create additional databases if needed
-- Enable pgvector extension
CREATE EXTENSION IF NOT EXISTS vector;
-- Enable other useful extensions
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE EXTENSION IF NOT EXISTS "pg_trgm";
CREATE EXTENSION IF NOT EXISTS "btree_gin";
CREATE EXTENSION IF NOT EXISTS "btree_gist";
-- Create application user if needed (optional)
-- The main user is already created via POSTGRES_USER
-- Set up database permissions
GRANT ALL PRIVILEGES ON DATABASE claim_guard TO postgres;
-- Create schema for application (optional, Prisma will use public by default)
-- CREATE SCHEMA IF NOT EXISTS claim_guard;
-- Log successful initialization
DO $$
BEGIN
RAISE NOTICE 'Claim Guard database initialized successfully';
RAISE NOTICE 'pgvector extension: %', (SELECT EXISTS(SELECT 1 FROM pg_extension WHERE extname = 'vector'));
RAISE NOTICE 'Database ready for Prisma migrations';
END $$;