fix: gen-migrations workflow
Some checks failed
gen-migrations / gen-migrations (push) Failing after 10s
Some checks failed
gen-migrations / gen-migrations (push) Failing after 10s
This commit is contained in:
parent
309bbd5fdb
commit
0eb9b42ad1
@ -17,12 +17,13 @@ fi
|
|||||||
docker compose stop "$base_or_head" 1>/dev/null
|
docker compose stop "$base_or_head" 1>/dev/null
|
||||||
docker compose rm -f "$base_or_head" 1>/dev/null
|
docker compose rm -f "$base_or_head" 1>/dev/null
|
||||||
|
|
||||||
pg_host=${PG_HOST:-localhost}
|
db() {
|
||||||
url="postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$pg_host:$port"
|
echo -n "postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD/$1?port=$port"
|
||||||
|
}
|
||||||
|
|
||||||
isready() {
|
isready() {
|
||||||
local waited=0
|
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
|
if [[ "$waited" = "10" ]]; then
|
||||||
pwd
|
pwd
|
||||||
cat docker-compose.yml
|
cat docker-compose.yml
|
||||||
@ -38,8 +39,8 @@ isready() {
|
|||||||
initdb() {
|
initdb() {
|
||||||
dropdb=$(mktemp)
|
dropdb=$(mktemp)
|
||||||
echo "drop database dnim with (force);" > "$dropdb"
|
echo "drop database dnim with (force);" > "$dropdb"
|
||||||
psql --quiet "$url/postgres" -f "$dropdb" || true
|
psql --quiet $(db postgres) -f "$dropdb" || true
|
||||||
psql --quiet "$url/postgres" -c "create database dnim"
|
psql --quiet $(db postgres) -c "create database dnim"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ "$rev" = "empty" ]]; then
|
if [[ "$rev" = "empty" ]]; then
|
||||||
@ -61,4 +62,4 @@ docker compose up -d "$base_or_head" 1>/dev/null
|
|||||||
|
|
||||||
isready
|
isready
|
||||||
initdb
|
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/{}"
|
||||||
|
@ -14,9 +14,9 @@ fi;
|
|||||||
|
|
||||||
migration="./migrations/${base}_to_${head}.sql"
|
migration="./migrations/${base}_to_${head}.sql"
|
||||||
|
|
||||||
pg_host=${PG_HOST:-localhost}
|
db() {
|
||||||
base_url="postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$pg_host:5432/dnim"
|
echo -n "postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD/dnim?port=$1"
|
||||||
head_url="postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$pg_host:5433/dnim"
|
}
|
||||||
|
|
||||||
if [[ -z "$base" ]] || [[ -z "$head" ]]; then
|
if [[ -z "$base" ]] || [[ -z "$head" ]]; then
|
||||||
echo "revisions to diff are required ex. ./scripts/diff.sh abc bcd" 1>&2;
|
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 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)
|
./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
|
else
|
||||||
cat "$migration"
|
cat "$migration"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user