diff --git a/postgres/hooks/postgres_database-relation-joined b/postgres/hooks/postgres_database-relation-joined index 5dfc31a..9c23f8b 100755 --- a/postgres/hooks/postgres_database-relation-joined +++ b/postgres/hooks/postgres_database-relation-joined @@ -51,8 +51,15 @@ ensure_db_docker_running ## XXXvlab: should send all these into only one docker... if ! db_has_database "$DBNAME"; then - db_create "$DBNAME" || exit 1 - + INITDB_ARGS=(encoding lc-collate lc-ctype template) + CREATEDB_OPTS=() + for option in "${INITDB_ARGS[@]}"; do + value="$(relation-get "$option" 2>/dev/null)" || true + if [ -n "$value" ]; then + CREATEDB_OPTS+=("--$option=$value") + fi + done + db_create "$DBNAME" "${CREATEDB_OPTS[@]}" || exit 1 if sql=$(relation-get init-sql); then ddb "$DBNAME" > /dev/null < <(e "$sql") || exit 1 fi diff --git a/postgres/lib/common b/postgres/lib/common index a6feb29..20947b2 100644 --- a/postgres/lib/common +++ b/postgres/lib/common @@ -63,7 +63,8 @@ db_drop () { db_create () { local dbname="$1" - dcmd createdb "$dbname" || return 1 + shift + dcmd createdb "$dbname" "$@" || return 1 info "Database '$dbname' created." }