fix: script
This commit is contained in:
parent
c9995b30f8
commit
1f7404a91f
@ -1,21 +0,0 @@
|
||||
#! /usr/bin/bash
|
||||
|
||||
$rev=${1:-HEAD}
|
||||
|
||||
if [ "$rev" = "HEAD" ]; then
|
||||
$port = 5432
|
||||
else
|
||||
$port = 5433
|
||||
fi
|
||||
|
||||
while read line; do export $line; done < ./.env
|
||||
|
||||
psql \
|
||||
--echo-all \
|
||||
postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:$port/$POSTGRES_DB \
|
||||
--command="drop schema public cascade; create schema public;"
|
||||
|
||||
ls ./migrations/ | xargs -I{} psql \
|
||||
--echo-all \
|
||||
postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5433/$POSTGRES_DB \
|
||||
--file=./migrations/{}
|
29
scripts/build.sh
Executable file
29
scripts/build.sh
Executable file
@ -0,0 +1,29 @@
|
||||
#! /usr/bin/bash
|
||||
|
||||
rev=${1:-HEAD}
|
||||
|
||||
if [[ -n $(git status --porcelain) ]]; then
|
||||
echo "git working tree dirty";
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
if [[ "$rev" = "HEAD" ]]; then
|
||||
head=""
|
||||
port=5432
|
||||
else
|
||||
head=$(git show --format=format:%h -q)
|
||||
git reset "$rev"
|
||||
port=5433
|
||||
fi
|
||||
|
||||
while read line; do export $line; done < ./.env
|
||||
|
||||
url=postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:$port/$POSTGRES_DB
|
||||
|
||||
psql --echo-all $url --command="drop schema public cascade; create schema public;"
|
||||
|
||||
ls ./migrations/ | xargs -I{} psql --echo-all $url --file=./migrations/{}
|
||||
|
||||
if [[ -n "$head" ]]; then
|
||||
git reset "$head"
|
||||
fi
|
Loading…
Reference in New Issue
Block a user