Browse Source

[NEW] add options entry to pass to posgresql command line

pull/19/head
default 2 years ago
parent
commit
1624b8063c
  1. 13
      postgres/hooks/postgres_database-relation-joined
  2. 3
      postgres/lib/common

13
postgres/hooks/postgres_database-relation-joined

@ -22,6 +22,7 @@ USER=$(relation-get user) || {
set -e
## YYY: check that password was not already generated/set for the same user
## use session state storage.
@ -47,12 +48,20 @@ fi
array_read-0 extensions < <(relation-get extensions 2>/dev/null | shyaml get-values-0)
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

3
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."
}

Loading…
Cancel
Save