-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sql
More file actions
30 lines (25 loc) · 949 Bytes
/
Copy pathinit.sql
File metadata and controls
30 lines (25 loc) · 949 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
-- Initialization script for Excel to PostgreSQL import system
-- This script runs automatically when the container is first created
-- Create the user with password (if not exists)
DO $$
BEGIN
CREATE USER excel_user WITH PASSWORD 'excel_password';
EXCEPTION WHEN DUPLICATE_OBJECT THEN
-- User already exists, update password just in case
ALTER USER excel_user WITH PASSWORD 'excel_password';
END
$$;
-- Enable UUID extension (useful for generating unique IDs)
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
-- Create a schema for imported tables (optional)
-- CREATE SCHEMA IF NOT EXISTS imported_data;
-- Grant privileges to the user
ALTER ROLE excel_user WITH CREATEDB;
GRANT ALL PRIVILEGES ON DATABASE excel_import TO excel_user;
-- Log successful initialization
DO $$
BEGIN
RAISE NOTICE 'Excel Import Database initialized successfully!';
RAISE NOTICE 'Database: excel_import';
RAISE NOTICE 'User: excel_user';
END $$;