-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit.sql
More file actions
32 lines (23 loc) · 1010 Bytes
/
init.sql
File metadata and controls
32 lines (23 loc) · 1010 Bytes
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
-- Initialize the healthchatbot database
-- This script runs when the PostgreSQL container starts
-- Create the database if it doesn't exist
SELECT 'CREATE DATABASE healthchatbot'
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'healthchatbot')\gexec
-- Connect to the healthchatbot database
\c healthchatbot;
-- Create a dedicated user for the application (optional)
-- CREATE USER healthchatbot_user WITH PASSWORD 'app_password';
-- GRANT ALL PRIVILEGES ON DATABASE healthchatbot TO healthchatbot_user;
-- Enable necessary extensions
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
-- Set timezone
SET timezone = 'UTC';
-- Create a simple test table to verify the setup
CREATE TABLE IF NOT EXISTS db_setup_check (
id SERIAL PRIMARY KEY,
setup_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
message TEXT DEFAULT 'Database setup completed successfully'
);
-- Insert a test record
INSERT INTO db_setup_check (message) VALUES ('HealthChatbot database initialized')
ON CONFLICT DO NOTHING;