Skip to content

g1t/services/identity/migrations/0027_teams.sql

40 lines1,637 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: groups of a workspace's members, given roles on repositories
2-- together, mentioned and asked to review together. See src/teams.rs and
3-- crates/contracts/src/teams.rs. Every timestamp is RFC 3339 UTC. The
4-- statements say IF NOT EXISTS, so running them again changes nothing.
5
6CREATE TABLE IF NOT EXISTS teams (
7 id TEXT PRIMARY KEY,
8 workspace_id TEXT NOT NULL,
9 -- Its name in URLs and mentions, unique in the workspace.
10 slug TEXT NOT NULL,
11 name TEXT NOT NULL,
12 description TEXT,
13 -- 'visible' (every member sees it) or 'secret' (its people and owners).
14 visibility TEXT NOT NULL DEFAULT 'visible',
15 -- Its parent team, whose roles on repositories it inherits.
16 parent_id TEXT,
17 -- Whether its people are notified when it is mentioned.
18 notify INTEGER NOT NULL DEFAULT 1,
19 -- How review requests for it are assigned (JSON, ReviewAssignment).
20 review_assignment TEXT,
21 created_by TEXT,
22 created_at TEXT NOT NULL,
23 updated_at TEXT NOT NULL
24);
25CREATE UNIQUE INDEX IF NOT EXISTS teams_slug ON teams (workspace_id, slug);
26CREATE INDEX IF NOT EXISTS teams_parent ON teams (parent_id);
27
28-- Who is in a team: 'maintainer' or 'member'. Only members of the
29-- workspace; removing someone from it removes these rows too.
30CREATE TABLE IF NOT EXISTS team_members (
31 team_id TEXT NOT NULL,
32 user_id TEXT NOT NULL,
33 role TEXT NOT NULL DEFAULT 'member',
34 created_at TEXT NOT NULL,
35 PRIMARY KEY (team_id, user_id)
36);
37CREATE INDEX IF NOT EXISTS team_members_user ON team_members (user_id);
38
39-- A team's role on a repository is a row of repo_grants (0020) with
40-- principal_kind 'team' and principal_id the team's id.