| 1 | -- Dependencies between issues/PRs: `issue_id` is blocked by `depends_on_id`. |
| 2 | -- The reverse direction ("blocks") is read by querying depends_on_id. Works |
| 3 | -- across issues and PRs uniformly (both live in `issues`), so PRs can be stacked. |
| 4 | CREATE TABLE issue_dependencies ( |
| 5 | issue_id TEXT NOT NULL REFERENCES issues(id) ON DELETE CASCADE, |
| 6 | depends_on_id TEXT NOT NULL REFERENCES issues(id) ON DELETE CASCADE, |
| 7 | created_at BIGINT NOT NULL, |
| 8 | PRIMARY KEY (issue_id, depends_on_id) |
| 9 | ); |
| 10 | CREATE INDEX idx_issue_deps_depends_on ON issue_dependencies (depends_on_id); |