Schema additions for the new digest-style reminder system: paliad.users - reminder_warning_offset_days INT NOT NULL DEFAULT 7, range 1..30 Per-user customisation of how many days before each deadline the heads-up email fires. 7 matches the prior Monday-weekly behaviour. - escalation_contact_id UUID NULL FK paliad.users(id) ON DELETE SET NULL Optional override of the escalation channel for overdue / DRINGEND mail. NULL means "fall back to global_admins". UI dropdown deferred to a follow-up task per m's 2026-04-28 decision; column ships now to avoid a second migration. Self-reference forbidden by CHECK constraint. paliad.reminder_log - slot TEXT NULL, slot_date DATE NULL — digest dedup keys. - reminder_type CHECK widened to admit 'morning_digest' / 'evening_digest' alongside the legacy 'overdue' / 'tomorrow' / 'weekly' values. - Partial UNIQUE INDEX (user_id, slot, slot_date) WHERE slot IS NOT NULL enforces "one digest per user per slot per local-date". Legacy rows with slot IS NULL are unaffected. CLAUDE.md updated with a §Phase status note pointing to the design doc and explaining the deferred Settings-UI dropdown for escalation_contact_id. Migration is fully additive and idempotent (IF NOT EXISTS / DROP-then-ADD on named constraints). Down migration reverses the schema cleanly; any 'morning_digest' / 'evening_digest' rows must be deleted before downgrading.
32 lines
1.2 KiB
SQL
32 lines
1.2 KiB
SQL
-- Roll back t-paliad-064 reminder redesign schema.
|
|
--
|
|
-- Drops the partial dedup index, the new columns on paliad.users and
|
|
-- paliad.reminder_log, and restores the previous reminder_type CHECK
|
|
-- constraint. Reversible.
|
|
|
|
DROP INDEX IF EXISTS paliad.reminder_log_slot_dedup_idx;
|
|
|
|
ALTER TABLE paliad.reminder_log
|
|
DROP CONSTRAINT IF EXISTS reminder_log_slot_check;
|
|
|
|
-- Narrow the reminder_type CHECK back to the original three values. Any
|
|
-- 'morning_digest' / 'evening_digest' rows must be deleted before this
|
|
-- runs, or the ALTER fails.
|
|
ALTER TABLE paliad.reminder_log
|
|
DROP CONSTRAINT IF EXISTS reminder_log_reminder_type_check;
|
|
ALTER TABLE paliad.reminder_log
|
|
ADD CONSTRAINT reminder_log_reminder_type_check
|
|
CHECK (reminder_type IN ('overdue', 'tomorrow', 'weekly'));
|
|
|
|
ALTER TABLE paliad.reminder_log
|
|
DROP COLUMN IF EXISTS slot,
|
|
DROP COLUMN IF EXISTS slot_date;
|
|
|
|
ALTER TABLE paliad.users
|
|
DROP CONSTRAINT IF EXISTS users_escalation_contact_self_check,
|
|
DROP CONSTRAINT IF EXISTS users_reminder_warning_offset_check;
|
|
|
|
ALTER TABLE paliad.users
|
|
DROP COLUMN IF EXISTS escalation_contact_id,
|
|
DROP COLUMN IF EXISTS reminder_warning_offset_days;
|