From: Bill Erickson Date: Tue, 26 Oct 2021 15:09:30 +0000 (-0400) Subject: LP1901932 database rebuild script X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=3982173fd2df95f1666536998065c853e53370fd;p=working%2FEvergreen.git LP1901932 database rebuild script Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/sql/Pg/create-test-database.sh b/Open-ILS/src/sql/Pg/create-test-database.sh new file mode 100644 index 0000000000..bee9f32ff0 --- /dev/null +++ b/Open-ILS/src/sql/Pg/create-test-database.sh @@ -0,0 +1,25 @@ +#!/usr/bin/bash + +PGUSER=evergreen +PGPASS=evergreen +DB_STAMP=1305; +STOCK_DB=evergreen; +DATA_SOURCE_STAMP=1305; +DATA_DB="eg_$DB_STAMP"; +SCHEMA_EXPORT="/tmp/eg-$DB_STAMP.schema.sql" + +# Extract the stock schema +pg_dump -U $PGUSER --schema-only --format custom --file $SCHEMA_EXPORT $STOCK_DB + +# Extract the data from our data-full database +# pg_dump -U $PGUSER --data-only --format custom --file Open-ILS/src/sql/Pg/data-snapshots/eg-$DATA_SOURCE_STAMP.data.sql $STOCK_DB + +# Create a new database from the stock schema. +# This will have no schema or data +sudo perl Open-ILS/src/support-scripts/eg_db_config --create-database --user $PGUSER --password $PGPASS --hostname localhost --database $DATA_DB + +# Apply the stock schema to the new database (without data) +pg_restore -U $PGUSER --dbname $DATA_DB $SCHEMA_EXPORT + +# Load the full sample data into our new schema-only database +pg_restore -U evergreen --dbname $DATA_DB --disable-triggers Open-ILS/src/sql/Pg/data-snapshots/eg-$DATA_SOURCE_STAMP.data.sql