Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ docker run --name postgresql -itd \

The above command enables the `unaccent` and `pg_trgm` modules on the databases listed in `DB_NAME`, namely `db1` and `db2`.

Each comma separated field can contain whitespace, allowing you to set arbitrary options (such as `CASCADE` ). For full syntax, refer official documentation about [CREATE EXTENSION](https://www.postgresql.org/docs/current/sql-createextension.html).

> **NOTE**:
>
> This option deprecates the `DB_UNACCENT` parameter.
Expand Down
10 changes: 8 additions & 2 deletions runtime/functions
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,13 @@ load_extensions() {
psql -U ${PG_USER} -d ${database} -c "CREATE EXTENSION IF NOT EXISTS unaccent;" >/dev/null 2>&1
fi

for extension in $(awk -F',' '{for (i = 1 ; i <= NF ; i++) print $i}' <<< "${DB_EXTENSION}"); do
local IFS_ORG=$IFS
IFS=,
for extension in ${DB_EXTENSION}; do
echo "‣ Loading ${extension} extension..."
psql -U ${PG_USER} -d ${database} -c "CREATE EXTENSION IF NOT EXISTS ${extension};" >/dev/null 2>&1
done
IFS=$IFS_ORG
}

create_database() {
Expand All @@ -331,7 +334,9 @@ create_database() {
echo "INFO! Database cannot be created on a $REPLICATION_MODE node. Skipping..."
;;
*)
for database in $(awk -F',' '{for (i = 1 ; i <= NF ; i++) print $i}' <<< "${DB_NAME}"); do
local IFS_ORG=$IFS
IFS=,
for database in ${DB_NAME}; do
echo "Creating database: ${database}..."
if [[ -z $(psql -U ${PG_USER} -Atc "SELECT 1 FROM pg_catalog.pg_database WHERE datname = '${database}'";) ]]; then
psql -U ${PG_USER} -c "CREATE DATABASE \"${database}\" WITH TEMPLATE = \"${DB_TEMPLATE}\";" >/dev/null
Expand All @@ -344,6 +349,7 @@ create_database() {
psql -U ${PG_USER} -c "GRANT ALL PRIVILEGES ON DATABASE \"${database}\" to \"${DB_USER}\";" >/dev/null
fi
done
IFS=$IFS_ORG
;;
esac
fi
Expand Down
Loading