-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit-db.sql
More file actions
63 lines (55 loc) · 1.48 KB
/
Copy pathinit-db.sql
File metadata and controls
63 lines (55 loc) · 1.48 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
-- OpenScroll Database Initialization
-- This script runs when the database is first created
-- Enable pgvector extension for vector search
CREATE EXTENSION IF NOT EXISTS vector;
-- Enable pg_trgm for fuzzy text search
CREATE EXTENSION IF NOT EXISTS pg_trgm;
-- Enable uuid-ossp for UUID generation
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
-- Create custom types
DO $$ BEGIN
CREATE TYPE acu_type AS ENUM (
'statement',
'question',
'answer',
'code_snippet',
'formula',
'table',
'image',
'tool_call',
'unknown'
);
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
DO $$ BEGIN
CREATE TYPE acu_category AS ENUM (
'technical',
'conceptual',
'procedural',
'personal',
'general'
);
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
DO $$ BEGIN
CREATE TYPE sharing_policy AS ENUM (
'self',
'circle',
'network'
);
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
-- Grant permissions
GRANT ALL PRIVILEGES ON DATABASE openscroll TO openscroll;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO openscroll;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO openscroll;
-- Log initialization
DO $$
BEGIN
RAISE NOTICE 'OpenScroll database initialized successfully';
RAISE NOTICE 'Extensions enabled: vector, pg_trgm, uuid-ossp';
RAISE NOTICE 'Custom types created: acu_type, acu_category, sharing_policy';
END $$;