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