-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-db-init.sql
More file actions
28 lines (24 loc) · 1.06 KB
/
docker-db-init.sql
File metadata and controls
28 lines (24 loc) · 1.06 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
-- =============================================================================
-- PostGIS initialization script
-- Runs once on first container creation via /docker-entrypoint-initdb.d/
-- =============================================================================
-- Enable PostGIS extension
CREATE EXTENSION IF NOT EXISTS postgis;
CREATE EXTENSION IF NOT EXISTS postgis_topology;
-- Create application user (if not exists)
DO $$
BEGIN
IF NOT EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = 'agent_user') THEN
CREATE ROLE agent_user WITH LOGIN PASSWORD 'change_me_strong_password' NOSUPERUSER NOBYPASSRLS;
END IF;
END
$$;
-- Grant privileges
GRANT CONNECT ON DATABASE gis_agent TO agent_user;
GRANT USAGE ON SCHEMA public TO agent_user;
GRANT CREATE ON SCHEMA public TO agent_user;
-- Default privileges for future tables/sequences created by postgres
ALTER DEFAULT PRIVILEGES IN SCHEMA public
GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO agent_user;
ALTER DEFAULT PRIVILEGES IN SCHEMA public
GRANT USAGE, SELECT ON SEQUENCES TO agent_user;