From 7ba3c502ce4f34ff73a97470246c046f76de3db3 Mon Sep 17 00:00:00 2001 From: niladic Date: Mon, 10 Feb 2025 15:56:41 +0100 Subject: [PATCH] fix --- Procfile | 1 - app.json | 2 +- scripts/copy-scalingo-review-app-db.sh | 8 ++++---- 3 files changed, 5 insertions(+), 6 deletions(-) delete mode 100644 Procfile diff --git a/Procfile b/Procfile deleted file mode 100644 index c2cbbf28..00000000 --- a/Procfile +++ /dev/null @@ -1 +0,0 @@ -postdeploy: bash scripts/copy-scalingo-review-app-db.sh diff --git a/app.json b/app.json index 1921eff4..161e9758 100644 --- a/app.json +++ b/app.json @@ -25,6 +25,6 @@ } ], "scripts": { - "first-deploy": "bash scripts/copy-scalingo-review-app-db.sh" + "postdeploy": "bash scripts/copy-scalingo-review-app-db.sh" } } diff --git a/scripts/copy-scalingo-review-app-db.sh b/scripts/copy-scalingo-review-app-db.sh index 918b2629..bc502bf3 100644 --- a/scripts/copy-scalingo-review-app-db.sh +++ b/scripts/copy-scalingo-review-app-db.sh @@ -11,13 +11,13 @@ if [ "$IS_REVIEW_APP" = "true" ]; then USER_COUNT=$(/app/bin/psql "${SCALINGO_POSTGRESQL_URL}" -A -t -c 'SELECT COUNT(*) FROM "user";') - if [ "$USER_COUNT" = "0" ]; then + if [ "$USER_COUNT" -gt 0 ] 2>/dev/null; then + echo "Table 'user' has $USER_COUNT rows. Doing nothing." + else echo "Table 'user' has $USER_COUNT rows. Copying parent app db to review app db." /app/bin/pg_dump --clean --if-exists --format c --dbname "${PARENT_APP_DATABASE_URL}" --no-owner --no-privileges --no-comments --exclude-schema 'information_schema' --exclude-schema '^pg_*' | /app/bin/pg_restore --clean --if-exists --no-owner --no-privileges --no-comments --dbname "${SCALINGO_POSTGRESQL_URL}" - - else - echo "Table 'user' has $USER_COUNT rows. Doing nothing." + fi else