From c7a2eec078d48084e39b876aa37e7297299a961b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sun, 4 Oct 2026 08:31:11 +0200 Subject: [PATCH] Drop the column fallback around the medication update The update retried without pausedAt and notificationsEnabled for a database that lacked the columns. Migrations guarantee both, and inside the transaction a failed statement aborts it, so the retry could not work anyway. --- src/app/api/medications/[id]/route.ts | 41 ++++----------------------- 1 file changed, 5 insertions(+), 36 deletions(-) diff --git a/src/app/api/medications/[id]/route.ts b/src/app/api/medications/[id]/route.ts index f7e62e198..3587a4dda 100644 --- a/src/app/api/medications/[id]/route.ts +++ b/src/app/api/medications/[id]/route.ts @@ -969,42 +969,11 @@ export const PUT = apiHandler( }), }; - const withoutNotifications = { ...baseUpdateData } as Record< - string, - unknown - >; - delete withoutNotifications.notificationsEnabled; - const hasPausedAtPatch = Object.keys(pausedAtPatch).length > 0; - const hasNotificationsPatch = notificationsEnabled !== undefined; - - const updateCandidates: Array> = [ - { ...baseUpdateData, ...pausedAtPatch }, - ]; - if (hasPausedAtPatch) { - updateCandidates.push(baseUpdateData); - } - if (hasNotificationsPatch) { - updateCandidates.push({ ...withoutNotifications, ...pausedAtPatch }); - if (hasPausedAtPatch) { - updateCandidates.push(withoutNotifications); - } - } - - let updated; - let lastUpdateErr: unknown; - for (const candidate of updateCandidates) { - try { - updated = await tx.medication.update({ - where: { id }, - data: candidate, - include: { schedules: true }, - }); - break; - } catch (updateErr) { - lastUpdateErr = updateErr; - } - } - if (!updated) throw lastUpdateErr; + const updated = await tx.medication.update({ + where: { id }, + data: { ...baseUpdateData, ...pausedAtPatch }, + include: { schedules: true }, + }); // v1.25 H-MED1 — durable pause intervals. The `pausedAt` column is a // single live marker that resume clears, so the paused window is