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'
healthcheck:
test: [ "CMD-SHELL", "pg_isready" ]
interval: 5s
timeout: 5s
retries: 5
interval: 1s
timeout: 1s
retries: 10
head:
container_name: 'head'
network_mode: 'host'
@ -23,6 +23,6 @@ services:
command: '-p 5433'
healthcheck:
test: [ "CMD-SHELL", "pg_isready" ]
interval: 5s
timeout: 5s
retries: 5
interval: 1s
timeout: 1s
retries: 10

View File

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