| 1 | -- Security alerts the way people can live with (src/inbox.rs, src/security_digest.rs): |
| 2 | -- what each person chose about them, and what waits for their next digest. |
| 3 | |
| 4 | -- Whether critical and high alerts on repositories they watch for security |
| 5 | -- reach them at once (1, the default when null), and when the rest do: |
| 6 | -- daily (the default when null), weekly, at_once or off. |
| 7 | ALTER TABLE inbox_settings ADD COLUMN security_alerts INTEGER; |
| 8 | ALTER TABLE inbox_settings ADD COLUMN security_digest TEXT; |
| 9 | |
| 10 | -- One row per person per scan summary that waits for their digest: what |
| 11 | -- the scan opened, by severity (JSON SeverityCounts), its headline and |
| 12 | -- where the alerts are. The digest reads a person's rows, writes one inbox |
| 13 | -- item per workspace, emails it, and deletes them. |
| 14 | CREATE TABLE inbox_security_digest ( |
| 15 | id TEXT PRIMARY KEY, |
| 16 | username TEXT NOT NULL, |
| 17 | workspace TEXT NOT NULL, |
| 18 | repo_id TEXT NOT NULL, |
| 19 | repo TEXT NOT NULL, |
| 20 | -- secret_scanning | code_scanning | vulnerability |
| 21 | alert_type TEXT NOT NULL, |
| 22 | event_id TEXT NOT NULL, |
| 23 | opened INTEGER NOT NULL, |
| 24 | counts TEXT NOT NULL, |
| 25 | worst TEXT, |
| 26 | title TEXT NOT NULL, |
| 27 | link TEXT NOT NULL, |
| 28 | created_at TEXT NOT NULL, |
| 29 | UNIQUE (event_id, username) |
| 30 | ); |
| 31 | CREATE INDEX inbox_security_digest_user ON inbox_security_digest (username, created_at); |