|
|
@ -44,17 +44,26 @@ db_create () { |
|
|
|
local dbname="$1" |
|
|
|
dcmd createdb "$dbname" || return 1 |
|
|
|
info "Database '$dbname' created." |
|
|
|
if [ "$POSTGIS" ]; then |
|
|
|
ddb -d "$dbname" < <(echo "CREATE EXTENSION postgis; CREATE EXTENSION postgis_topology;") || return 1 |
|
|
|
dcmd /bin/bash -c "psql -d '$dbname' -f /usr/share/postgresql/*/contrib/postgis-2.1/legacy.sql" || return 1 |
|
|
|
info "Installed postgis extensions on database '$dbname'." |
|
|
|
fi |
|
|
|
if [ "$UNACCENT" ]; then |
|
|
|
ddb -d "$dbname" < <(echo "CREATE EXTENSION IF NOT EXISTS unaccent;") || return 1 |
|
|
|
info "Installed unaccent extension on database '$dbname'." |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
db_install_extensions() { |
|
|
|
local dbname="$1" |
|
|
|
shift |
|
|
|
while [ "$#" != 0 ]; do |
|
|
|
case "$1" in |
|
|
|
postgis) |
|
|
|
ddb -d "$dbname" < <(echo "CREATE EXTENSION postgis; CREATE EXTENSION postgis_topology;") || return 1 |
|
|
|
dcmd /bin/bash -c "psql -d '$dbname' -f /usr/share/postgresql/*/contrib/postgis-2.1/legacy.sql" || return 1 |
|
|
|
info "Installed postgis extensions on database '$dbname'." |
|
|
|
;; |
|
|
|
*) |
|
|
|
ddb -d "$dbname" < <(echo "CREATE EXTENSION IF NOT EXISTS $1;") || return 1 |
|
|
|
info "Installed $1 extension on database '$dbname'." |
|
|
|
;; |
|
|
|
esac |
|
|
|
shift |
|
|
|
done |
|
|
|
} |
|
|
|
|
|
|
|
## XXXvlab: if launched first, it'll fail handling correctly the open/close of docker |
|
|
|
db_has_database() { |
|
|
|