Skip to content

Commit 934f8f8

Browse files
committed
fix: update DB migration documentation and enhance verification script
- Added a note in `DB-MIGRATIONS.md` to clarify that `verify` should not be run before `migrate`. - Modified `verify-bootstrap-contract.sh` to check for a non-negative integer count of `management_user` instead of just existence, improving error handling for database queries.
1 parent 85ed898 commit 934f8f8

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

docs/development/DB-MIGRATIONS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ For disposable environments (e.g. alpha), reset schema via ops jobs only:
9494
5. `metaboost-db-verify-bootstrap-contract`
9595
6. `metaboost-management-superuser-create`
9696

97+
**Do not run verify before migrate.** Rebootstrap only restores roles/grants; `linear_migration_history` and application tables are created by the migrate jobs (steps 3–4). Verify before migrate fails with `linear_migration_history exists expected 't' but got 'f'`.
98+
9799
Then rollout-restart API workloads. Scale down app tiers first if you want a quiet cutover.
98100

99101
From repo root (waits for each job):

infra/k8s/base/ops/source/database/runner/verify-bootstrap-contract.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,12 @@ check_database_contract() {
111111
assert_positive_int "${label}: read linear_migration_history row count" "$ro_history_count"
112112

113113
if [[ "$label" == "management" ]]; then
114-
local can_query_management_user
115-
can_query_management_user="$(run_query "$read_write_password" "$read_write_role" "$db_name" "SELECT EXISTS (SELECT 1 FROM management_user LIMIT 1);")"
116-
assert_equals "${label}: read_write can query management_user" "$can_query_management_user" "t"
114+
local management_user_count
115+
management_user_count="$(run_query "$read_write_password" "$read_write_role" "$db_name" "SELECT count(*) FROM management_user;")"
116+
if ! [[ "$management_user_count" =~ ^[0-9]+$ ]]; then
117+
echo "ERROR: ${label}: read_write cannot query management_user (expected a non-negative integer count)." >&2
118+
exit 1
119+
fi
117120
fi
118121
}
119122

0 commit comments

Comments
 (0)