mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +00:00
Pushing to staging first loads staging baseline data
This commit is contained in:
26
script/load_staging_baseline.sh
Normal file
26
script/load_staging_baseline.sh
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Every time staging is deployed, we load a baseline data set before running the new code's
|
||||
# migrations. This script loads the baseline data set, after first taking a backup of the
|
||||
# current database.
|
||||
|
||||
set -e
|
||||
|
||||
cd /home/openfoodweb/apps/openfoodweb/current
|
||||
|
||||
echo "Stopping unicorn..."
|
||||
service unicorn_openfoodweb stop
|
||||
|
||||
echo "Backing up current data..."
|
||||
mkdir -p db/backup
|
||||
pg_dump -h localhost -U openfoodweb openfoodweb_production |gzip > db/backup/staging-`date +%Y%m%d%H%M%S`.sql.gz
|
||||
|
||||
echo "Loading baseline data..."
|
||||
dropdb -U openfoodweb -w openfoodweb_production
|
||||
createdb -U openfoodweb -w openfoodweb_production
|
||||
gunzip -c db/backup/staging-baseline.sql.gz |psql -h localhost -U openfoodweb openfoodweb_production
|
||||
|
||||
echo "Restarting unicorn..."
|
||||
service unicorn_openfoodweb start
|
||||
|
||||
echo "Done!"
|
||||
@@ -2,9 +2,14 @@
|
||||
|
||||
set -e
|
||||
|
||||
# Add staging git remote if required
|
||||
ST2_TEST=`git remote | grep -s 'staging2' || true`
|
||||
if [[ "$ST2_TEST" != *staging2* ]]; then
|
||||
git remote add staging2 openfoodweb@ofn-staging2:apps/openfoodweb/current
|
||||
fi
|
||||
|
||||
echo "--- Loading baseline data"
|
||||
ssh ofn-staging2 "/home/openfoodweb/apps/openfoodweb/current/script/load_staging_baseline.sh"
|
||||
|
||||
echo "--- Pushing to staging"
|
||||
[[ $(git push staging2 $BUILDKITE_COMMIT:master --force 2>&1) =~ "Done" ]]
|
||||
|
||||
Reference in New Issue
Block a user