chore: improve gen_migrations logging
All checks were successful
gen-migrations / gen-migrations (push) Has been skipped

This commit is contained in:
Orion Kindel 2023-07-20 00:41:55 -05:00
parent d0526f0426
commit ab4b8e0bd3
Signed by untrusted user who does not match committer: orion
GPG Key ID: 6D4165AE4C928719
2 changed files with 15 additions and 10 deletions

View File

@ -10,9 +10,9 @@ services:
command: '-p 5432' command: '-p 5432'
healthcheck: healthcheck:
test: [ "CMD-SHELL", "pg_isready" ] test: [ "CMD-SHELL", "pg_isready" ]
interval: 5s interval: 1s
timeout: 5s timeout: 1s
retries: 5 retries: 10
head: head:
container_name: 'head' container_name: 'head'
network_mode: 'host' network_mode: 'host'
@ -23,6 +23,6 @@ services:
command: '-p 5433' command: '-p 5433'
healthcheck: healthcheck:
test: [ "CMD-SHELL", "pg_isready" ] test: [ "CMD-SHELL", "pg_isready" ]
interval: 5s interval: 1s
timeout: 5s timeout: 1s
retries: 5 retries: 10

View File

@ -13,14 +13,19 @@ revs_ct=$(echo "$revs" | wc -l)
do_i() { do_i() {
base=$(echo "$revs" | tail --lines "+$1" | head -n 1) base=$(echo "$revs" | tail --lines "+$1" | head -n 1)
if [[ -f "./migrations/${base}_skipped.sql" ]]; then if [[ -f "./migrations/${base}_skipped.sql" ]]; then
echo "skip $base" echo "[$base]: skipped previously"
return return
fi fi
for j in $(seq "$(($1 + 1))" "$revs_ct"); do for j in $(seq "$(($1 + 1))" "$revs_ct"); do
head=$(echo "$revs" | tail --lines "+$j" | head -n 1) head=$(echo "$revs" | tail --lines "+$j" | head -n 1)
migration="./migrations/${base}_to_${head}.sql" migration="./migrations/${base}_to_${head}.sql"
echo "building $migration..."
if [[ -f "$migration" ]]; then
echo "[$migration]: exists"
else
echo "[$migration]: building..."
fi
set +e set +e
out=$(./scripts/diff.sh "$base" "$head") out=$(./scripts/diff.sh "$base" "$head")
@ -29,14 +34,14 @@ do_i() {
if [[ "$status" = "1" && "$out" = *"head failed to build"* ]]; then if [[ "$status" = "1" && "$out" = *"head failed to build"* ]]; then
echo "" > "./migrations/${head}_skipped.sql" echo "" > "./migrations/${head}_skipped.sql"
echo "wrote ./migrations/${head}_skipped.sql" echo "[$migration]: skipped, $head bad"
continue continue
elif [[ "$status" = "1" ]]; then elif [[ "$status" = "1" ]]; then
echo "$out" echo "$out"
exit 1 exit 1
else else
echo "$out" > "$migration" echo "$out" > "$migration"
echo "wrote $migration" echo "[$migration]: wrote"
break break
fi fi
done done