changeset 80:5c093612ce89

DEP-10: add uuid extension to database
author smith@nwoca.org
date Fri, 08 Apr 2016 21:40:03 +0100
parents 85957628f4c0
children 53671513b240
files postgres/Dockerfile postgres/setupExtensions.sh
diffstat 2 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/postgres/Dockerfile	Wed Apr 06 19:03:16 2016 +0100
+++ b/postgres/Dockerfile	Fri Apr 08 21:40:03 2016 +0100
@@ -12,4 +12,8 @@
 
 COPY setupDatabase.sh /docker-entrypoint-initdb.d/setupDatabase.sh
 
-RUN chmod 755 /docker-entrypoint-initdb.d/setupDatabase.sh
+COPY setupExtensions.sh /docker-entrypoint-initdb.d/setupExtensions.sh
+
+RUN chmod 755 /docker-entrypoint-initdb.d/setupDatabase.sh \
+    & chmod 755 /docker-entrypoint-initdb.d/setupExtensions.sh
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/postgres/setupExtensions.sh	Fri Apr 08 21:40:03 2016 +0100
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+export PGUSER=postgres
+TEST=`psql <<- EOSQL
+   SELECT 1 FROM pg_database WHERE datname='$DB_NAME';
+EOSQL`
+
+if [[ $TEST == "1" ]]; then
+    psql $DB_NAME <<- EOSQL
+    CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
+EOSQL
+  echo "Set extensions on $DB_NAME"
+fi
+