Tahinli/forge
public0 watching
★ 0
| 1 | -- Discussions: a per-repo forum next to issues, opt-in per repo. Discussion numbers come from |
| 2 | -- repos.next_issue_number, the same counter as issues and pull requests, in the same transaction |
| 3 | -- as the insert (store/discussions.rs). Comments form one level of replies: a reply's parent_id is |
| 4 | -- a top-level comment of the same discussion. A deleted comment keeps its row (deleted_at is set, |
| 5 | -- the body is emptied) so its replies still make sense. answer_comment_id is only set in 'qa'. |
| 6 | |
| 7 | repos ADD COLUMN discussions_enabled INTEGER NOT NULL DEFAULT 0; |
| 8 | |
| 9 | ( |
| 10 | id TEXT PRIMARY KEY, repo_id TEXT NOT NULL REFERENCES repos(id) ON DELETE CASCADE, |
| 11 | number INTEGER NOT NULL, |
| 12 | category TEXT NOT NULL CHECK (category IN ('general','ideas','qa','announcements')), |
| 13 | title TEXT NOT NULL, body TEXT NOT NULL DEFAULT '', |
| 14 | author_id TEXT NOT NULL REFERENCES users(id), |
| 15 | answer_comment_id TEXT, |
| 16 | locked INTEGER NOT NULL DEFAULT 0, |
| 17 | comment_count INTEGER NOT NULL DEFAULT 0, |
| 18 | created_at TEXT NOT NULL, updated_at TEXT NOT NULL, |
| 19 | UNIQUE (repo_id, number)); |
| 20 | ON discussions(repo_id, category, number); |
| 21 | |
| 22 | ( |
| 23 | id TEXT PRIMARY KEY, |
| 24 | discussion_id TEXT NOT NULL REFERENCES discussions(id) ON DELETE CASCADE, |
| 25 | parent_id TEXT REFERENCES discussion_comments(id) ON DELETE CASCADE, |
| 26 | author_id TEXT NOT NULL REFERENCES users(id), |
| 27 | body TEXT NOT NULL DEFAULT '', |
| 28 | created_at TEXT NOT NULL, updated_at TEXT NOT NULL, |
| 29 | deleted_at TEXT); |
| 30 | ON discussion_comments(discussion_id, created_at); |
| 31 | |
| 32 | -- Inbox rows for @mentions in discussions. Issues use the notifications table, which points at |
| 33 | -- issues, so discussions get their own. One row per user and discussion. |
| 34 | ( |
| 35 | user_id TEXT NOT NULL REFERENCES users(id), |
| 36 | discussion_id TEXT NOT NULL REFERENCES discussions(id) ON DELETE CASCADE, |
| 37 | repo_id TEXT NOT NULL REFERENCES repos(id), |
| 38 | reason TEXT NOT NULL DEFAULT 'mention', |
| 39 | last_actor_id TEXT REFERENCES users(id), |
| 40 | unread INTEGER NOT NULL DEFAULT 1, |
| 41 | updated_at TEXT NOT NULL, |
| 42 | PRIMARY KEY (user_id, discussion_id)); |
| 43 | ON discussion_notifications(user_id, unread, updated_at); |