| 1 | -- Notifications: an actor did something (mention, assignment) that a user should |
| 2 | -- see. Rendered by resolving the linked actor/repo/issue at display time. |
| 3 | CREATE TABLE notifications ( |
| 4 | id TEXT PRIMARY KEY, |
| 5 | user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE, |
| 6 | actor_id TEXT REFERENCES users(id) ON DELETE SET NULL, |
| 7 | kind TEXT NOT NULL, |
| 8 | repo_id TEXT REFERENCES repos(id) ON DELETE CASCADE, |
| 9 | issue_id TEXT REFERENCES issues(id) ON DELETE CASCADE, |
| 10 | read_at BIGINT, |
| 11 | created_at BIGINT NOT NULL |
| 12 | ); |
| 13 | CREATE INDEX idx_notifications_user ON notifications (user_id, read_at); |