fix: gen-migrations workflow
Some checks failed
gen-migrations / gen-migrations (push) Failing after 10s

This commit is contained in:
Orion Kindel 2023-07-19 19:03:48 -05:00
parent 309bbd5fdb
commit 0eb9b42ad1
Signed by untrusted user who does not match committer: orion
GPG Key ID: 6D4165AE4C928719
2 changed files with 12 additions and 11 deletions

View File

@ -17,12 +17,13 @@ fi
docker compose stop "$base_or_head" 1>/dev/null
docker compose rm -f "$base_or_head" 1>/dev/null
pg_host=${PG_HOST:-localhost}
url="postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$pg_host:$port"
db() {
echo -n "postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD/$1?port=$port"
}
isready() {
local waited=0
until pg_isready -h "$pg_host" -p "$port" 1>/dev/null; do
until pg_isready -p "$port" 1>/dev/null; do
if [[ "$waited" = "10" ]]; then
pwd
cat docker-compose.yml
@ -38,8 +39,8 @@ isready() {
initdb() {
dropdb=$(mktemp)
echo "drop database dnim with (force);" > "$dropdb"
psql --quiet "$url/postgres" -f "$dropdb" || true
psql --quiet "$url/postgres" -c "create database dnim"
psql --quiet $(db postgres) -f "$dropdb" || true
psql --quiet $(db postgres) -c "create database dnim"
}
if [[ "$rev" = "empty" ]]; then
@ -61,4 +62,4 @@ docker compose up -d "$base_or_head" 1>/dev/null
isready
initdb
ls ./schema/ | xargs -I{} bash -c "set -e; $(declare -f query_file); query_file \"$url/dnim\" ./schema/{}"
ls ./schema/ | xargs -I{} bash -c "set -e; $(declare -f query_file); query_file $(db dnim) ./schema/{}"

View File

@ -14,9 +14,9 @@ fi;
migration="./migrations/${base}_to_${head}.sql"
pg_host=${PG_HOST:-localhost}
base_url="postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$pg_host:5432/dnim"
head_url="postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$pg_host:5433/dnim"
db() {
echo -n "postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD/dnim?port=$1"
}
if [[ -z "$base" ]] || [[ -z "$head" ]]; then
echo "revisions to diff are required ex. ./scripts/diff.sh abc bcd" 1>&2;
@ -27,9 +27,9 @@ if [[ ! -f "$migration" ]]; then
./scripts/build.sh base "$base" 1>&2 || (echo "base failed to build" && exit 1)
./scripts/build.sh head "$head" 1>&2 || (echo "head failed to build" && exit 1)
until pg_isready -h "$pg_host" -p 5432 1>/dev/null && pg_isready -h "$pg_host" -p 5433 1>/dev/null; do true; done;
until pg_isready -p 5432 1>/dev/null && pg_isready -p 5433 1>/dev/null; do true; done;
migra --unsafe "$base_url" "$head_url" || echo "migra exited with code $?. this is /probably/ fine" 1>&2
migra --unsafe $(db 5432) $(db 5433) || echo "migra exited with code $?. this is /probably/ fine" 1>&2
else
cat "$migration"
fi