From ee92ef45ab38c06bcbd39cf8baf843181e8a12e3 Mon Sep 17 00:00:00 2001 From: mptyl Date: Sun, 12 Jul 2026 07:49:58 +0200 Subject: [PATCH] fix(vector): track packaged migrations in restore smoke --- scripts/local-vector-smoke.sh | 8 +++++--- scripts/test-vector-backup-restore-safety.sh | 10 ++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/scripts/local-vector-smoke.sh b/scripts/local-vector-smoke.sh index b9169a4c..3ec07fcc 100755 --- a/scripts/local-vector-smoke.sh +++ b/scripts/local-vector-smoke.sh @@ -390,10 +390,12 @@ PY -XAt -U "$THT_VECTOR_BOOTSTRAP_USER" -d thoth --command \ "SELECT content_hash <> 'mutated-after-backup' FROM vectors.memory WHERE record_key = '$marker'") test "$restored" = t - pending=$(docker exec -e PGPASSWORD="$new_bootstrap_password" "$restore_container" psql \ + expected_migrations=$(find harness/tht/migrations/vector -type f -name '[0-9][0-9][0-9]_*.sql' \ + -exec basename {} \; | sed 's/_.*//' | sort | paste -sd, -) + applied_migrations=$(docker exec -e PGPASSWORD="$new_bootstrap_password" "$restore_container" psql \ -XAt -U "$THT_VECTOR_BOOTSTRAP_USER" -d thoth --command \ - "SELECT count(*) = 3 FROM public.tht_vector_migrations") - test "$pending" = t + "SELECT string_agg(version, ',' ORDER BY version) FROM public.tht_vector_migrations") + test "$applied_migrations" = "$expected_migrations" dimensions=$(docker exec -e PGPASSWORD="$new_bootstrap_password" "$restore_container" psql \ -XAt -U "$THT_VECTOR_BOOTSTRAP_USER" -d thoth --command \ "SELECT count(*) = 3 FROM pg_attribute a JOIN pg_class c ON c.oid=a.attrelid diff --git a/scripts/test-vector-backup-restore-safety.sh b/scripts/test-vector-backup-restore-safety.sh index bf0cf0e0..68188fd6 100755 --- a/scripts/test-vector-backup-restore-safety.sh +++ b/scripts/test-vector-backup-restore-safety.sh @@ -86,4 +86,14 @@ PATH="$fakebin:$PATH" RESTORE_LOG="$tmp/restore.log" ./scripts/vector-restore.sh grep -q -- '--single-transaction' "$tmp/restore.log" grep -q -- '--exit-on-error' "$tmp/restore.log" +# The live restore smoke must follow the packaged migration set instead of a stale +# hard-coded count when a new migration is added. +if grep -Fq 'SELECT count(*) = 3 FROM public.tht_vector_migrations' \ + scripts/local-vector-smoke.sh; then + echo "local vector smoke hard-codes the pre-004 migration count" >&2 + exit 1 +fi +grep -Fq 'expected_migrations=' scripts/local-vector-smoke.sh +grep -Fq 'applied_migrations=' scripts/local-vector-smoke.sh + echo "vector backup/restore filesystem, identity, and transaction contracts passed."