| 1 | -- The morning digest (phase 5c, mail/digest.ts): when each person who turned it on gets their next |
| 2 | -- one. Their choices (hour, time zone, weekends) live in notification_prefs; this row is only the |
| 3 | -- schedule, written whenever those settings are saved and moved on by the cron after each send. |
| 4 | CREATE TABLE IF NOT EXISTS mail_digests ( |
| 5 | account_id TEXT PRIMARY KEY REFERENCES accounts(id), |
| 6 | next_at TEXT NOT NULL, -- the next send, UTC ISO |
| 7 | last_sent_at TEXT -- the last one queued; the next digest covers what happened since |
| 8 | ); |
| 9 | CREATE INDEX IF NOT EXISTS mail_digests_next ON mail_digests(next_at); |