Files
blake 17ca2f9dfb feat: enhance reminder functionality with version tracking for shifts
Introduced a new column `version_at` in the shifts table to track the last change time of a shift's version. Updated reminder logic to skip reminders that are due before the shift's version change or the signup time. Modified related functions and tests to ensure correct behavior when managing reminders for shifts and signups, including scenarios for late signups and shift changes.
2026-11-02 12:00:42 -06:00

15 lines
485 B
SQL

-- version_at is when this shift's version last changed.
-- A reminder due before that time, or before the signup, is not sent.
ALTER TABLE shifts ADD COLUMN version_at TEXT NULL CHECK (
version_at IS NULL
OR version_at GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]Z'
);
UPDATE shifts
SET version_at = (
SELECT MAX(created_at)
FROM outbox
WHERE outbox.shift_id = shifts.id AND outbox.kind = 'changed'
)
WHERE version > 1;