From 1b2f1dbc3465133ae88d7b381b8e12b5c0ff9cea Mon Sep 17 00:00:00 2001 From: MaM Web user Date: Tue, 20 Oct 2020 22:39:42 +0200 Subject: [PATCH] =?UTF-8?q?Makefile:=20P=C5=99id=C3=A1na=20agresivn=C3=AD?= =?UTF-8?q?=20varianta=20pro=20sync=5Ftest=5Fdb?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Vyrobil Pavel --- Makefile | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a9d2e082..3b97c63a 100644 --- a/Makefile +++ b/Makefile @@ -117,12 +117,24 @@ sync_test_db: @if [ ${USER} != "mam-web" ]; then echo "Only possible by user mam-web"; exit 1; fi pg_dump mam_test > dump-test-`date +"%Y%m%d_%H%M"`.sql pg_dump -Fc mam_prod > dump-prod.sql - pg_restore -c -d mam_test dump-prod.sql + pg_restore -c --if-exists -d mam_test dump-prod.sql + rm dump-prod.sql + @echo Done. + +# Aggresive variant: destroy original mam_test db with 'DROP OWNED BY "mam-web";' +sync_test_db_aggressive: + @if [ ${USER} != "mam-web" ]; then echo "Only possible by user mam-web"; exit 1; fi + pg_dump mam_test > dump-test-`date +"%Y%m%d_%H%M"`.sql + pg_dump -Fc mam_prod > dump-prod.sql + @# I am not sure which shell is used, so I am calling bash to make sure + bash -c "psql mam_test <<< 'DROP OWNED BY \"mam-web\";'" + pg_restore -c --if-exists -d mam_test dump-prod.sql rm dump-prod.sql @echo Done. # Sync test with production -sync_test: sync_test_media sync_test_db +# HACK ALERT: using aggressive variant, due to the schemas being too different. +sync_test: sync_test_media sync_test_db_aggressive # Sync media directory with atrey. Useful for local development with production database