refactor(hive-c0re): shared additive-migration helper in db
db::apply_migrations runs ALTER lists and ignores duplicate-column errors (turn_stats' pattern); approvals, operator_questions, broker reminders, and scheduled_prompts drop their hand-rolled pragma_table_info guards. broker's acked_at migration stays bespoke — its backfill must only run when the column was just created
This commit is contained in:
parent
34b21b8038
commit
d190420946
7 changed files with 71 additions and 132 deletions
|
|
@ -186,12 +186,11 @@ impl ScheduledPrompts {
|
|||
conn.execute_batch(SCHEMA)
|
||||
.context("apply scheduled_prompts schema")?;
|
||||
// Migration: add paused_at_unix to existing databases.
|
||||
// Silently ignores "duplicate column name" errors so this is
|
||||
// idempotent across daemon restarts on already-migrated DBs.
|
||||
let _ = conn.execute(
|
||||
"ALTER TABLE scheduled_prompts ADD COLUMN paused_at_unix INTEGER",
|
||||
[],
|
||||
);
|
||||
crate::db::apply_migrations(
|
||||
&conn,
|
||||
"scheduled_prompts",
|
||||
&["ALTER TABLE scheduled_prompts ADD COLUMN paused_at_unix INTEGER"],
|
||||
)?;
|
||||
// Migration: recreate the due-rows index to also exclude paused
|
||||
// rows. `CREATE INDEX IF NOT EXISTS` won't update an existing
|
||||
// index's WHERE clause, so we drop + recreate on every open.
|
||||
|
|
|
|||
Loading…
Reference in a new issue