-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make migrations are reflected to schema-upstream.sql
- Loading branch information
1 parent
78451fc
commit 2d23d44
Showing
3 changed files
with
770 additions
and
1 deletion.
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
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,30 @@ | ||
#!/usr/bin/env bash | ||
set -ex; | ||
|
||
export NODE_ENV="test" | ||
DATABASE="codechain-indexer-test" | ||
|
||
function mktemp2 { | ||
PREFIX="$1" | ||
POSTFIX="$2" | ||
python -c "import tempfile; print(tempfile.NamedTemporaryFile(prefix='$PREFIX', suffix='$SUFFIX', delete=False).name)" | ||
} | ||
|
||
UPSTREAM=schema-upstream.sql | ||
MIGRATE=$(mktemp2 "${DATABASE}." ".schema.migrate.sql") | ||
|
||
yarn sequelize db:migrate | ||
pg_dump -s -d "${DATABASE}" > "${MIGRATE}" | ||
|
||
# brew install pgFormatter | ||
# apt install pgformatter | ||
pg_format --nocomment -w 120 -o "${MIGRATE}" "${MIGRATE}" | ||
|
||
case $1 in | ||
diff-only) | ||
diff "${UPSTREAM}" "${MIGRATE}" | ||
;; | ||
*) | ||
mv "${MIGRATE}" "${UPSTREAM}" | ||
;; | ||
esac |
Oops, something went wrong.