From bd96f63599f511894b0ecac11d0ebfebe5e14255 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Thu, 16 May 2019 15:46:12 +0200 Subject: [PATCH] new: [postgres] new ``init-sql`` option in relation to init any database with given sql --- postgres/hooks/postgres_database-relation-joined | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/postgres/hooks/postgres_database-relation-joined b/postgres/hooks/postgres_database-relation-joined index 35d61f5..5dfc31a 100755 --- a/postgres/hooks/postgres_database-relation-joined +++ b/postgres/hooks/postgres_database-relation-joined @@ -52,6 +52,10 @@ ensure_db_docker_running ## XXXvlab: should send all these into only one docker... if ! db_has_database "$DBNAME"; then db_create "$DBNAME" || exit 1 + + if sql=$(relation-get init-sql); then + ddb "$DBNAME" > /dev/null < <(e "$sql") || exit 1 + fi fi if [ "${#extensions[@]}" -gt 0 ]; then db_install_extensions "$DBNAME" "${extensions[@]}" || exit 1