-- Forks and pull requests. Applied by store/migrate.rs. -- A pull request is an issues row with kind = 'pull' (shared numbering); this table holds the -- branch, head and mergeability state. head_repo_id is NULL once the head repo is deleted. ALTER TABLE repos ADD COLUMN fork_of TEXT REFERENCES repos(id); CREATE TABLE pull_requests ( issue_id TEXT PRIMARY KEY REFERENCES issues(id) ON DELETE CASCADE, base_branch TEXT NOT NULL, head_repo_id TEXT REFERENCES repos(id), -- NULL if the head repo was deleted head_branch TEXT NOT NULL, head_oid TEXT NOT NULL, -- last known head commit (also refs/pull/N/head) base_oid TEXT NOT NULL, -- base branch tip when mergeability was last computed merge_base TEXT, mergeable TEXT NOT NULL DEFAULT 'unknown', -- 'unknown' | 'clean' | 'conflict' | 'merged' | 'up_to_date' conflict_files TEXT NOT NULL DEFAULT '[]', -- JSON array of paths merged_at TEXT, merged_by TEXT REFERENCES users(id), merge_commit TEXT, allow_maintainer_edits INTEGER NOT NULL DEFAULT 1); CREATE INDEX pull_requests_head ON pull_requests(head_repo_id, head_branch);