From ab4b8e0bd3f6065e2a75ed19441e997a7fa40965 Mon Sep 17 00:00:00 2001 From: Orion Kindel Date: Thu, 20 Jul 2023 00:41:55 -0500 Subject: [PATCH] chore: improve gen_migrations logging --- docker-compose.yml | 12 ++++++------ scripts/gen_migrations.sh | 13 +++++++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 8261fd0..d2e65ff 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 diff --git a/scripts/gen_migrations.sh b/scripts/gen_migrations.sh index 376e685..bde8d07 100755 --- a/scripts/gen_migrations.sh +++ b/scripts/gen_migrations.sh @@ -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