Browse Source

new: [postgres] allow relation options ``encoding``, ``lc-collate``, ``lc-ctype``, ``template``

These options are only used upon creation of the database.

Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
pull/22/head
Valentin Lab 3 years ago
parent
commit
366c2810b3
  1. 11
      postgres/hooks/postgres_database-relation-joined
  2. 3
      postgres/lib/common

11
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

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