Files
aevolution/tools/migrate-postgres.sh
T
dingoandClaude Opus 5.5 703f67834f Complete M7.9a region clones and retained-history audit
Clone a verified committed head into an isolated world and database
(ADR-0067): world re-identification with a proven byte round trip, a
schema v7 clone genesis naming the source commit and digest with digested
inherited outcomes, a read-only source session, an owner-only atomic
target transaction and the evo-world-clone tool. audit_region_history
re-verifies every retained link. Real-process tests cover trajectory
equality after the cut, source isolation, killed clones and retention.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 06:47:45 -04:00

35 lines
1.6 KiB
Bash

#!/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%% *}"
digest_3="$(sha256sum "$root/migrations/0003_region_checkpoints.sql")"
digest_3="${digest_3%% *}"
digest_4="$(sha256sum "$root/migrations/0004_lineage_profile.sql")"
digest_4="${digest_4%% *}"
digest_5="$(sha256sum "$root/migrations/0005_batch_decisions.sql")"
digest_5="${digest_5%% *}"
digest_6="$(sha256sum "$root/migrations/0006_commit_lookup.sql")"
digest_6="${digest_6%% *}"
digest_7="$(sha256sum "$root/migrations/0007_region_clones.sql")"
digest_7="${digest_7%% *}"
psql -X --no-password --set=ON_ERROR_STOP=1 --set="migration_sha=$digest" \
--set="migration_sha_2=$digest_2" --set="migration_sha_3=$digest_3" \
--set="migration_sha_4=$digest_4" --set="migration_sha_5=$digest_5" \
--set="migration_sha_6=$digest_6" --set="migration_sha_7=$digest_7" \
--set="runtime_role=$runtime_role" \
--file="$root/migrations/apply.sql"