Complete M7.2 PostgreSQL adapter and migration bootstrap
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
root="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
prefix="$root/.cache/postgres/install"
|
||||
export PATH="$prefix/bin:$PATH"
|
||||
export LD_LIBRARY_PATH="$prefix/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
|
||||
test_dir="$(mktemp -d /tmp/evo-pg-test.XXXXXXXX)"
|
||||
chmod 700 "$test_dir"
|
||||
export PGHOST="$test_dir" PGPORT=55432 PGDATABASE=postgres PGUSER="$(id -un)"
|
||||
unset PGHOSTADDR PGPASSWORD PGSERVICE PGSERVICEFILE
|
||||
initdb -D "$test_dir/data" --no-locale --encoding=UTF8 --auth-local=trust --auth-host=reject > "$test_dir/init.log"
|
||||
trap 'pg_ctl -D "$test_dir/data" -m immediate stop > /dev/null || true' EXIT
|
||||
pg_ctl -D "$test_dir/data" -l "$test_dir/server.log" -o "-k $test_dir -p 55432 -c listen_addresses=''" -w start
|
||||
psql -X -v ON_ERROR_STOP=1 -c 'CREATE ROLE evo_runtime_test NOLOGIN'
|
||||
bash "$root/tools/migrate-postgres.sh"
|
||||
bash "$root/tools/migrate-postgres.sh" # exact supported upgrade/restart is a no-op
|
||||
"${1:?path to evo-postgres-tests}"
|
||||
# Migration failure must not publish a partial schema.
|
||||
createdb migration_rollback
|
||||
if (export PGDATABASE=migration_rollback; psql -X -v ON_ERROR_STOP=1 -1 \
|
||||
-v migration_sha=invalid -f "$root/migrations/0001_region_bootstrap.sql"); then
|
||||
echo 'Expected failed migration' >&2; exit 1
|
||||
fi
|
||||
test "$(PGDATABASE=migration_rollback psql -XAtc "SELECT count(*) FROM pg_namespace WHERE nspname='evolution'")" = 0
|
||||
# Unknown future versions and checksum drift must not be repaired silently.
|
||||
psql -X -v ON_ERROR_STOP=1 -c 'UPDATE evolution.schema_migrations SET version=2'
|
||||
if bash "$root/tools/migrate-postgres.sh"; then exit 1; fi
|
||||
psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET version=1,sha256=repeat('0',64)"
|
||||
if bash "$root/tools/migrate-postgres.sh"; then exit 1; fi
|
||||
echo 'postgres migrations, rollback, constraints and permissions passed'
|
||||
@@ -19,7 +19,7 @@ DOCKER_CONFIG="$(mktemp -d "$RUNNER_TEMP/aevolution-docker.XXXXXX")"
|
||||
trap 'rm -rf -- "$DOCKER_CONFIG"' EXIT
|
||||
printf '%s' "$HARBOR_PASSWORD" | docker login registry.aeternalisgames.com \
|
||||
--username "$HARBOR_USERNAME" --password-stdin
|
||||
source_image="aevolution-proof:${GITHUB_SHA}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
|
||||
source_image="${SOURCE_IMAGE:-aevolution-proof:${GITHUB_SHA}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}}"
|
||||
target_image="registry.aeternalisgames.com/${HARBOR_PROJECT}/${HARBOR_REPOSITORY}:sha-${GITHUB_SHA}-run-${GITHUB_RUN_NUMBER}-${GITHUB_RUN_ATTEMPT}"
|
||||
docker tag "$source_image" "$target_image"
|
||||
docker push "$target_image"
|
||||
|
||||
Reference in New Issue
Block a user