mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Add scripts to save and restore baseline data
This commit is contained in:
25
script/ci/restore-staging-baseline.sh
Executable file
25
script/ci/restore-staging-baseline.sh
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Restore baseline data for staging in case a pull request messed with
|
||||
# the database.
|
||||
|
||||
set -e
|
||||
|
||||
: ${DB_USER='ofn_user'}
|
||||
: ${DB_DATABASE='openfoodnetwork'}
|
||||
|
||||
srcdir="$HOME/apps/openfoodnetwork/shared"
|
||||
srcfile="$srcdir/staging-baseline.sql.gz"
|
||||
|
||||
if [ -f "$srcfile" ]; then
|
||||
echo "Restoring data from: $srcfile"
|
||||
else
|
||||
>&2 echo "[Error] No baseline data available at: $srcfile"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dropdb -h localhost -U "$DB_USER" "$DB_DATABASE" --if-exists
|
||||
createdb -h localhost -U "$DB_USER" "$DB_DATABASE"
|
||||
|
||||
gunzip -c "$srcfile" | psql -h localhost -U "$DB_USER" "$DB_DATABASE"
|
||||
echo "Staging baseline data restored."
|
||||
16
script/ci/save-staging-baseline.sh
Executable file
16
script/ci/save-staging-baseline.sh
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Save baseline data for staging which can be restored in case a pull request
|
||||
# messes with the database.
|
||||
|
||||
set -e
|
||||
|
||||
: ${DB_USER='ofn_user'}
|
||||
: ${DB_DATABASE='openfoodnetwork'}
|
||||
|
||||
dstdir="$HOME/apps/openfoodnetwork/shared"
|
||||
dstfile="$dstdir/staging-baseline.sql.gz"
|
||||
|
||||
mkdir -p "$dstdir"
|
||||
pg_dump -h localhost -U "$DB_USER" "$DB_DATABASE" | gzip > "$dstfile"
|
||||
echo "Staging baseline data saved."
|
||||
Reference in New Issue
Block a user