-- Lanna Desk, phase 8 begins: the notifications log (docs/PLAN.md "Phase 8"). -- -- Every mail the app sends, or fails to send, is a row here: the test from -- the Notifications page first, the reminders later. A text message or a -- Matrix message gets its own channel when those come. CREATE TABLE notifications ( id BIGSERIAL PRIMARY KEY, channel TEXT NOT NULL CHECK (channel IN ('email', 'sms', 'matrix')), -- what it was for: 'test', later 'reminder' ... purpose TEXT NOT NULL CHECK (purpose <> ''), recipient TEXT NOT NULL CHECK (recipient <> ''), subject TEXT NOT NULL DEFAULT '', status TEXT NOT NULL CHECK (status IN ('sent', 'failed')), -- the mail server's answer, or why it failed detail TEXT NOT NULL DEFAULT '', actor TEXT NOT NULL, created_at TIMESTAMPTZ NOT NULL DEFAULT now() ); CREATE INDEX notifications_created ON notifications (created_at DESC);