-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ajoute un script qui copie la BDD de demo dans les review apps (#2183)
- Loading branch information
Showing
3 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/sh | ||
|
||
echo "Running Scalingo review app DB copy script" | ||
|
||
if [ "$IS_REVIEW_APP" = "true" ]; then | ||
dbclient-fetcher pgsql 15 | ||
|
||
echo "Copying review app db" | ||
|
||
echo "Checking number of rows in 'user' table" | ||
|
||
USER_COUNT=$(/app/bin/psql "${SCALINGO_POSTGRESQL_URL}" -A -t -c 'SELECT COUNT(*) FROM "user";') | ||
|
||
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}" | ||
|
||
fi | ||
|
||
else | ||
echo "Not a review app - skipping database copy" | ||
fi |