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.
This commit is contained in:
Marc-André Bombeck committed 2026-10-04 08:31:11 +02:00
1 parent 43a53255c9
commit c7a2eec078
1 file changed
+5 -36
+5 -36
View File
@@ -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<Record<string, unknown>> = [
{ ...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