From 2345c61b8c36ed4eaf73dd7e522c5ccce5d1e306 Mon Sep 17 00:00:00 2001 From: Orion Kindel Date: Sat, 15 Jul 2023 18:42:20 -0400 Subject: [PATCH] fix: psql should exit nonzero on failure --- scripts/diff.sh | 6 ------ scripts/migrate.sh | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/scripts/diff.sh b/scripts/diff.sh index 196402e..7c48aa7 100755 --- a/scripts/diff.sh +++ b/scripts/diff.sh @@ -28,14 +28,8 @@ if [[ ! -f "$migration" ]]; then echo "migrate from $rev => HEAD" 1>&2 - echo "do language plpgsql \$migration\$" >> "$migration" - echo "begin" >> "$migration" - echo >> "$migration" migra --unsafe $base_url $head_url >> "$migration" \ || echo "migra exited with code $?. this is /probably/ fine" 1>&2 - echo >> "$migration" - echo "end;" >> "$migration" - echo '$migration$;' >> "$migration" fi echo "$migration" diff --git a/scripts/migrate.sh b/scripts/migrate.sh index e0f9106..0655323 100755 --- a/scripts/migrate.sh +++ b/scripts/migrate.sh @@ -26,7 +26,7 @@ else migration_file=$(./scripts/diff.sh "$last_revision") if [[ "$2" = "--greenlight" ]]; then - psql "$POSTGRES_URI/dnim" -f "$migration_file" + psql "$POSTGRES_URI/dnim" -v ON_ERROR_STOP=1 --single-transaction -f "$migration_file" else echo "migration available at $migration_file" echo "review and rerun with --greenlight to apply"