From a66b8820dfc3f7a037939a7e389dd9261ff2d236 Mon Sep 17 00:00:00 2001 From: Dana Lambert Date: Wed, 6 Oct 2021 14:37:14 +1300 Subject: [PATCH] Add database initialisation scripts --- database/init/001_init_righttree.sql | 6 ++++++ database/init_database.sh | 3 +++ docker-compose.yaml | 1 + 3 files changed, 10 insertions(+) create mode 100644 database/init/001_init_righttree.sql create mode 100755 database/init_database.sh diff --git a/database/init/001_init_righttree.sql b/database/init/001_init_righttree.sql new file mode 100644 index 0000000..1df3382 --- /dev/null +++ b/database/init/001_init_righttree.sql @@ -0,0 +1,6 @@ +CREATE DATABASE right_tree; + +\c right_tree +CREATE EXTENSION IF NOT EXISTS postgis; +GRANT ALL ON geometry_columns TO PUBLIC; +GRANT ALL ON spatial_ref_sys TO PUBLIC; diff --git a/database/init_database.sh b/database/init_database.sh new file mode 100755 index 0000000..04ad0fe --- /dev/null +++ b/database/init_database.sh @@ -0,0 +1,3 @@ +docker-compose down --remove-orphans --volumes +docker-compose up postgres | sed '/PostgreSQL init process complete; ready for start up./q' +docker-compose down diff --git a/docker-compose.yaml b/docker-compose.yaml index ecf4239..c68f1c0 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -38,6 +38,7 @@ services: container_name: postgres volumes: - local-postgres-data:/var/lib/postgresql/data + - ./database/init:/docker-entrypoint-initdb.d ports: - "5432:5432" environment: