pub const TABLE_SQL: &str = "CREATE TABLE alerts (
id INTEGER PRIMARY KEY,
reason TEXT NOT NULL,
dedup_key TEXT,
detail TEXT,
status TEXT NOT NULL CHECK (status IN ('sent', 'deduped', 'overflow', 'digested', 'unsent', 'failed')),
created_at INTEGER NOT NULL
);
CREATE INDEX index_alerts_on_reason_and_dedup_key ON alerts (reason, dedup_key, created_at);
CREATE INDEX index_alerts_on_status_and_created_at ON alerts (status, created_at);
";Expand description
The alerts table, created by the migration of ocre g alerts.
status is the alert’s fate: sent, deduped, overflow (waiting for
the digest), digested, unsent (no ALERT_EMAIL) or failed (the
email could not be sent). Times are Unix seconds.