fix(migrations): backfill missing hwmon columns on existing DBs

cpu_load_percent + memory/disk columns were silently added inline to the
hwmon migration entry, but PRAGMA user_version had already passed that
index for existing deploys → ALTER never ran → replaceKioskKey and
heartbeat hit "no such column: cpu_load_percent" on upgrade. Append a
tail migration that addColumnIfNotExists for each. Lesson: never mutate
an existing migration entry; always append a new one.
This commit is contained in:
Mitchell R 2026-05-21 10:14:52 +02:00
parent 5d225f7b49
commit 6b959755e7
No known key found for this signature in database

View file

@ -867,4 +867,17 @@ export const MIGRATIONS: readonly MigrationEntry[] = [
addColumnIfNotExists(db, "displays", "actual_power_state_at", "TEXT"); addColumnIfNotExists(db, "displays", "actual_power_state_at", "TEXT");
}, },
// Backfill hwmon/telemetry columns. They were originally added inline to
// an earlier migration entry; existing deploys had already passed that
// index via PRAGMA user_version, so the new columns silently never landed.
// Re-add idempotently here so replaceKioskKey / heartbeat stop hitting
// "no such column" on upgrade.
(db: DatabaseSync) => {
addColumnIfNotExists(db, "kiosks", "cpu_load_percent", "REAL");
addColumnIfNotExists(db, "kiosks", "memory_total_mb", "INTEGER");
addColumnIfNotExists(db, "kiosks", "memory_used_mb", "INTEGER");
addColumnIfNotExists(db, "kiosks", "disk_total_mb", "INTEGER");
addColumnIfNotExists(db, "kiosks", "disk_free_mb", "INTEGER");
addColumnIfNotExists(db, "kiosks", "disk_used_percent", "REAL");
},
]; ];