From 9b43bdab9998ec7225c24b1009a3d58b6478dfe6 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 10 Mar 2026 12:52:04 -0500 Subject: [PATCH] fix(db): add vet_name, result, next_due to healthMigrations ALTER TABLE guards Existing databases were missing these 3 columns because they were defined in the CREATE TABLE but not in the healthMigrations array used for ALTER TABLE on pre-existing DBs. This caused the 'table health_records has no column named vet_name' error in the Add Health Record modal. --- server/db/init.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/db/init.js b/server/db/init.js index 44685f4..4fd9d2c 100644 --- a/server/db/init.js +++ b/server/db/init.js @@ -128,7 +128,7 @@ function initDatabase() { ) `); - // migrate: add OFA-specific columns if missing + // migrate: add OFA-specific columns if missing (covers existing DBs) const healthMigrations = [ ['test_type', 'TEXT'], ['ofa_result', 'TEXT'], @@ -136,6 +136,9 @@ function initDatabase() { ['performed_by', 'TEXT'], ['expires_at', 'TEXT'], ['document_url', 'TEXT'], + ['result', 'TEXT'], + ['vet_name', 'TEXT'], + ['next_due', 'TEXT'], ]; for (const [col, def] of healthMigrations) { try { db.exec(`ALTER TABLE health_records ADD COLUMN ${col} ${def}`); } catch (_) { /* already exists */ }