#!/usr/bin/env bash set -euo pipefail root="$(cd "$(dirname "$0")/.." && pwd)" # Operator-created NOLOGIN group role granted to the region runtime login (ADR-0060). runtime_role="${EVO_PG_RUNTIME_ROLE:?set EVO_PG_RUNTIME_ROLE to the runtime group role}" if [ -n "${EVO_PGPASS_SOURCE:-}" ]; then umask 077 export PGPASSFILE PGPASSFILE="$(mktemp /tmp/evo-pgpass.XXXXXXXX)" trap 'rm -f -- "$PGPASSFILE"' EXIT cat "$EVO_PGPASS_SOURCE" > "$PGPASSFILE" fi # Connection comes from PG* environment / mounted service and password files. # Never print the connection or enable shell tracing here. digest="$(sha256sum "$root/migrations/0001_region_bootstrap.sql")" digest="${digest%% *}" digest_2="$(sha256sum "$root/migrations/0002_region_fencing.sql")" digest_2="${digest_2%% *}" psql -X --no-password --set=ON_ERROR_STOP=1 --set="migration_sha=$digest" \ --set="migration_sha_2=$digest_2" --set="runtime_role=$runtime_role" \ --file="$root/migrations/apply.sql"