From 9540ade3698a82f065088e47bf85d2dd7fae87de Mon Sep 17 00:00:00 2001 From: kadewu Date: Wed, 16 Oct 2024 19:59:47 +0200 Subject: [PATCH] review fixes: add comments and make script name more accurate --- run-automation.sh => setup-e2e-db.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) rename run-automation.sh => setup-e2e-db.sh (58%) diff --git a/run-automation.sh b/setup-e2e-db.sh similarity index 58% rename from run-automation.sh rename to setup-e2e-db.sh index dde9be2f2..ee98c76f9 100755 --- a/run-automation.sh +++ b/setup-e2e-db.sh @@ -1,13 +1,28 @@ #!/bin/bash +# Script to load update-automation-snapshot into our database (to public schema) +# It needs the docker compose from saleor platform repository: https://github.com/saleor/saleor-platform +# Tested only on MacOs + DIR="$( cd "$( dirname "$0" )" && pwd )" SNAPSHOT=$DIR"/update-automation-snapshot.sql" +# make sure to use `public` schema sed -i '' 's/update_automation_snapshot_staging_saleor_cloud/public/' $SNAPSHOT sed -i '' 's/update_automation_snapshot_staging_saleor_cloud/public/' $SNAPSHOT + # please note that you should not use this password on production services DB_URL="postgresql://saleor:saleor@localhost:5432/" +# use different database for testing purpose FULL_DB_URL=$DB_URL"e2e" + +# drop previous database psql $DB_URL -c 'DROP DATABASE IF EXISTS e2e WITH(FORCE);' + +# create new database and make sure to install needed extensions psql $DB_URL -c 'CREATE DATABASE e2e;' psql $FULL_DB_URL -c 'CREATE EXTENSION IF NOT EXISTS btree_gin; CREATE EXTENSION IF NOT EXISTS pg_trgm;' + +# load the snapshot psql $FULL_DB_URL -f $SNAPSHOT + +# make sure to run migrations in case snapshot is not up to date with `core` migrations docker compose exec api python manage.py migrate