-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit-db.sql
More file actions
21 lines (17 loc) · 723 Bytes
/
init-db.sql
File metadata and controls
21 lines (17 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
-- Initialize PostgreSQL database with pgvector extension
-- This script runs when the database container starts
-- Enable pgvector extension
CREATE EXTENSION IF NOT EXISTS vector;
-- Create a custom function to calculate cosine similarity
CREATE OR REPLACE FUNCTION cosine_similarity(a vector, b vector)
RETURNS float AS $$
BEGIN
RETURN 1 - (a <=> b);
END;
$$ LANGUAGE plpgsql;
-- Create indexes for better performance
-- Note: These will be created after the tables are created by SQLAlchemy
-- Grant permissions
GRANT ALL PRIVILEGES ON DATABASE hyperlogic_ai TO hyperlogic;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO hyperlogic;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO hyperlogic;