gisaf-backend/database-container-entrypoint-postgis.sh

30 lines
714 B
Bash
Raw Normal View History

#!/bin/bash
set -e
# Perform all actions as $POSTGRES_USER
export PGUSER="$POSTGRES_USER"
# Create the 'template_postgis' template db
"${psql[@]}" <<-'EOSQL'
CREATE DATABASE template_postgis IS_TEMPLATE true;
EOSQL
# Load PostGIS into both template_database and $POSTGRES_DB
for DB in template_postgis "$POSTGRES_DB"; do
echo "Loading PostGIS extensions into $DB"
"${psql[@]}" --dbname="$DB" <<-'EOSQL'
CREATE EXTENSION IF NOT EXISTS postgis;
EOSQL
done
"${psql[@]}" --dbname="$DB" <<-'EOSQL'
CREATE EXTENSION IF NOT EXISTS hstore;
CREATE SCHEMA gisaf;
CREATE SCHEMA gisaf_admin;
CREATE SCHEMA gisaf_map;
CREATE SCHEMA gisaf_survey;
CREATE SCHEMA raw_survey;
CREATE SCHEMA survey;
EOSQL