From 42d00dd1c0bf0d555a6c1226fee56bcb2f4fc484 Mon Sep 17 00:00:00 2001 From: Daniel Volz Date: Sun, 18 Jan 2026 08:23:35 +0100 Subject: [PATCH] fix: add stock_calculation_mode ALTER migration for backward compatibility (#39) Older production databases were missing the stock_calculation_mode column, causing 500 errors on /export endpoint. Added migration to add column with default value 'automatic'. --- backend/src/db/client.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/src/db/client.ts b/backend/src/db/client.ts index 251f23f..c030acd 100644 --- a/backend/src/db/client.ts +++ b/backend/src/db/client.ts @@ -73,6 +73,8 @@ export async function runAlterMigrations(client: Client): Promise<{ success: boo `ALTER TABLE user_settings ADD COLUMN max_nagging_reminders integer NOT NULL DEFAULT 5`, // Added in v1.2.3 - dismiss missed doses without deducting stock `ALTER TABLE dose_tracking ADD COLUMN dismissed integer NOT NULL DEFAULT 0`, + // Added in v1.3.x - stock calculation mode (automatic/manual) + `ALTER TABLE user_settings ADD COLUMN stock_calculation_mode text NOT NULL DEFAULT 'automatic'`, ]; for (const sql of alterMigrations) {