mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 09:47:08 +00:00
Add script to update template schema from database
This commit is contained in:
13
sbin/dump_schema.sh
Executable file
13
sbin/dump_schema.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Use this to create a new template schema based on an existing schema in the database.
|
||||
#
|
||||
# The template schema is used by bin/create_survey.sh to initialise a new set of tables for a prospect.
|
||||
|
||||
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 |
|
||||
sed -r "s/$SCHEMA_NAME/_SURVEY__TEMPLATE_/g;s/$EPSG_CODE/_EPSG__CODE_/g" >"$DEST" &&
|
||||
echo "Schema $SCHEMA_NAME dumped to $DEST"
|
||||
Reference in New Issue
Block a user