Skip to content

g1t/services/work/migrations/0026_code_owners.sql

39 lines1,723 bytesCodeBlame

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar1-- Teams asked to review, code owners, and the protection rule that waits
2-- for them. See src/codeowners.rs and src/team_reviews.rs. Every
3-- timestamp is RFC 3339 UTC. The ALTERs must run once, as in 0007; the
4-- tables and indexes say IF NOT EXISTS.
5
6-- The teams asked to review a pull request, as a JSON array of
7-- `workspace/slug`. People review assignment picks from a team are in
8-- `reviewers` beside it.
9ALTER TABLE pulls ADD COLUMN team_reviewers TEXT NOT NULL DEFAULT '[]';
10
11-- Branch protection: merging waits for the code owners' approval.
12ALTER TABLE repo_settings ADD COLUMN require_code_owner_review INTEGER NOT NULL DEFAULT 0;
13
14-- Who owns what a pull request changes, as last worked out from the
15-- CODEOWNERS file of the branch it merges into: its path, the reviews it
16-- needs (JSON, codeowners::Requirement), who answers for each owner (JSON
17-- object of owner to usernames), how many errors the file has, and which
18-- owners g1t already asked to review, so that a request someone withdrew
19-- is not made again on the next push.
20CREATE TABLE IF NOT EXISTS pull_code_owners (
21 pull_id TEXT PRIMARY KEY,
22 path TEXT NOT NULL,
23 requirements TEXT NOT NULL,
24 members TEXT NOT NULL,
25 errors INTEGER NOT NULL DEFAULT 0,
26 requested TEXT NOT NULL DEFAULT '[]',
27 updated_at TEXT NOT NULL
28);
29
30-- Each person review assignment picked from a team, for round robin
31-- (who was asked least recently goes first).
32CREATE TABLE IF NOT EXISTS team_review_requests (
33 team_id TEXT NOT NULL,
34 username TEXT NOT NULL,
35 repo_id TEXT NOT NULL,
36 number INTEGER NOT NULL,
37 requested_at TEXT NOT NULL
38);
39CREATE INDEX IF NOT EXISTS team_review_requests_team ON team_review_requests (team_id, username, requested_at);