diff --git a/docker-compose.yml b/docker-compose.yml index d2e65ff..847e763 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,7 +12,7 @@ services: test: [ "CMD-SHELL", "pg_isready" ] interval: 1s timeout: 1s - retries: 10 + retries: 30 head: container_name: 'head' network_mode: 'host' @@ -22,7 +22,7 @@ services: volumes: ['/var/run/postgresql:/var/run/postgresql'] command: '-p 5433' healthcheck: - test: [ "CMD-SHELL", "pg_isready" ] + test: [ "CMD-SHELL", "pg_isready -p 5433" ] interval: 1s timeout: 1s - retries: 10 + retries: 30 diff --git a/migrations b/migrations index b574033..359aa9b 160000 --- a/migrations +++ b/migrations @@ -1 +1 @@ -Subproject commit b5740338f3a2b64c480fdf2416d44346bcfc3b27 +Subproject commit 359aa9bf7cf72ae7dbe473072bab0f0ecd449813 diff --git a/scripts/build.sh b/scripts/build.sh index ca35b61..9b2a508 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -8,6 +8,9 @@ source ./scripts/env.sh ./.env.schema base_or_head="$1" rev="$2" +docker compose kill "$base_or_head" +docker compose rm -vf "$base_or_head" + if [[ "$base_or_head" = "head" ]]; then port=5433 else diff --git a/scripts/diff.sh b/scripts/diff.sh index 2761d2f..cc5587d 100755 --- a/scripts/diff.sh +++ b/scripts/diff.sh @@ -23,11 +23,18 @@ if [[ -z "$base" ]] || [[ -z "$head" ]]; then exit 1; fi +if ! (git diff --quiet "$base..$head" -- ./schema); then + echo "" + exit 0; +fi; + if [[ ! -f "$migration" ]]; then docker compose down -v ./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) + until pg_isready --quiet -p 5432 && pg_isready --quiet -p 5433; do true; done; + migra --unsafe "$(db 5432)" "$(db 5433)" || echo "migra exited with code $?. this is /probably/ fine" 1>&2 else cat "$migration"