MySQL · 1584 bytes Raw Blame History
1 -- SPDX-License-Identifier: AGPL-3.0-or-later
2
3 -- name: ListBranchProtectionRules :many
4 SELECT id, repo_id, pattern,
5 prevent_force_push, prevent_deletion, require_pr_for_push,
6 allowed_pusher_user_ids,
7 require_signed_commits, status_checks_required,
8 created_at, updated_at, created_by_user_id
9 FROM branch_protection_rules
10 WHERE repo_id = $1
11 ORDER BY pattern;
12
13 -- name: GetBranchProtectionRule :one
14 SELECT id, repo_id, pattern,
15 prevent_force_push, prevent_deletion, require_pr_for_push,
16 allowed_pusher_user_ids,
17 require_signed_commits, status_checks_required,
18 created_at, updated_at, created_by_user_id
19 FROM branch_protection_rules
20 WHERE id = $1;
21
22 -- name: UpsertBranchProtectionRule :one
23 INSERT INTO branch_protection_rules (
24 repo_id, pattern,
25 prevent_force_push, prevent_deletion, require_pr_for_push,
26 allowed_pusher_user_ids, created_by_user_id
27 ) VALUES (
28 $1, $2, $3, $4, $5, $6, sqlc.narg(created_by_user_id)::bigint
29 )
30 RETURNING id;
31
32 -- name: UpdateBranchProtectionRule :exec
33 UPDATE branch_protection_rules
34 SET pattern = $2,
35 prevent_force_push = $3,
36 prevent_deletion = $4,
37 require_pr_for_push = $5,
38 allowed_pusher_user_ids = $6
39 WHERE id = $1;
40
41 -- name: DeleteBranchProtectionRule :exec
42 DELETE FROM branch_protection_rules WHERE id = $1;
43
44 -- name: UpdateRepoDefaultBranch :exec
45 -- Used by the default-branch settings handler. The on-disk HEAD update
46 -- is a separate step done via `git symbolic-ref` from the orchestrator.
47 UPDATE repos SET default_branch = $2, updated_at = now() WHERE id = $1;
48