chore: improve gen_migrations logging
All checks were successful
gen-migrations / gen-migrations (push) Has been skipped
All checks were successful
gen-migrations / gen-migrations (push) Has been skipped
This commit is contained in:
parent
d0526f0426
commit
ab4b8e0bd3
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user