Use environment variables for DB connection if possible

This commit is contained in:
D. Berge
2020-08-12 18:18:47 +02:00
parent 3dcb55393a
commit f2373a0454
2 changed files with 14 additions and 8 deletions

View File

@@ -4,10 +4,14 @@
#
# The template schema is used by bin/create_survey.sh to initialise a new set of tables for a prospect.
PGUSER=${PGUSER:-postgres}
PGHOST=${PGHOST:-localhost}
PGDATABASE=${PGDATABASE:-dougal}
SCHEMA_NAME=${SCHEMA_NAME:-survey_1}
EPSG_CODE=${EPSG_CODE:-23031}
DEST=${DEST:-"$(dirname "$0")/../etc/db/schema-template.sql"}
pg_dump -U postgres --schema="$SCHEMA_NAME" --schema-only --host=localhost dougal |
pg_dump -U $PGUSER --schema="$SCHEMA_NAME" --schema-only --host=$PGHOST $PGDATABASE |
sed -r "s/$SCHEMA_NAME/_SURVEY__TEMPLATE_/g;s/$EPSG_CODE/_EPSG__CODE_/g" >"$DEST" &&
echo "Schema $SCHEMA_NAME dumped to $DEST"