fix: idempotent migrations (ADD COLUMN IF NOT EXISTS), stale doc, safety note

This commit is contained in:
atlas 2026-07-10 16:25:02 +02:00 committed by mara
commit c47faf0af9
5 changed files with 80 additions and 26 deletions

View file

@ -30,14 +30,15 @@ CREATE INDEX IF NOT EXISTS idx_approvals_pending
/// all known migrations. New columns go here as v5, v6, …
const MIGRATIONS: &[&str] = &[
// v1: `kind` (pre-Phase-8 dbs): legacy rows default to `apply_commit`.
"ALTER TABLE approvals ADD COLUMN kind TEXT NOT NULL DEFAULT 'apply_commit'",
"ALTER TABLE approvals ADD COLUMN IF NOT EXISTS \
kind TEXT NOT NULL DEFAULT 'apply_commit'",
// v2: `description`: manager-supplied note on the dashboard card.
"ALTER TABLE approvals ADD COLUMN description TEXT",
"ALTER TABLE approvals ADD COLUMN IF NOT EXISTS description TEXT",
// v3: `fetched_sha`: canonical sha hive-c0re resolved at submit time.
"ALTER TABLE approvals ADD COLUMN fetched_sha TEXT",
"ALTER TABLE approvals ADD COLUMN IF NOT EXISTS fetched_sha TEXT",
// v4: `submitter`: authenticated agent that submitted the approval.
// Legacy rows are NULL → callers fall back to the root agent.
"ALTER TABLE approvals ADD COLUMN submitter TEXT",
"ALTER TABLE approvals ADD COLUMN IF NOT EXISTS submitter TEXT",
];
pub struct Approvals {