-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: cached dumps in CI helpers
- Loading branch information
Showing
5 changed files
with
79 additions
and
50 deletions.
There are no files selected for viewing
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,33 @@ | ||
#!/bin/bash | ||
|
||
db_restore() { | ||
DUMP=$1 | ||
DB_NAME=$2 | ||
|
||
echo "Removing database '$DB_NAME'" | ||
dropdb $DB_NAME --if-exists | ||
echo "Create database '$DB_NAME'" | ||
createdb -O $DB_USER $DB_NAME | ||
|
||
if [ -f "$DUMP" ]; then | ||
echo "๐ ๐ Database dump $DUMP found ๐ ๐" | ||
echo "Restore Database dump from $DUMP ๐ฆโฎ ๐" | ||
psql -q -o /dev/null -d $DB_NAME -f "$DUMP" | ||
psql -d $DB_NAME -P pager=off -c "SELECT name as installed_module FROM ir_module_module WHERE state = 'installed' ORDER BY name" | ||
return 1 | ||
else | ||
echo "No dump found matching" | ||
return 0 | ||
fi | ||
} | ||
|
||
db_save() { | ||
DB_NAME=$1 | ||
DUMP=$2 | ||
if [ ! -z "$DUMP" ]; then | ||
echo "Dumping $DB_NAME into $DUMP ๐โฎ ๐ฆ" | ||
mkdir -p $(dirname $DUMP) | ||
pg_dump -Fp -d $DB_NAME -O -f "$DUMP" | ||
ls $DUMP | ||
fi | ||
} |
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
File renamed without changes.
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