Go · 12754 bytes Raw Blame History
1 // Code generated by sqlc. DO NOT EDIT.
2 // versions:
3 // sqlc v1.31.1
4
5 package reposdb
6
7 import (
8 "context"
9
10 "github.com/jackc/pgx/v5/pgtype"
11 )
12
13 type Querier interface {
14 AcceptTransferRequest(ctx context.Context, db DBTX, id int64) error
15 // Bypasses the soft-delete grace window (admin only — S34): set
16 // deleted_at to a year ago so the next lifecycle sweep hard-deletes
17 // without waiting. Replaces the inline UPDATE in admin/repos.go
18 // (SR2 M2).
19 AdminForceDeleteRepo(ctx context.Context, db DBTX, id int64) error
20 ArchiveRepo(ctx context.Context, db DBTX, id int64) error
21 CancelTransferRequest(ctx context.Context, db DBTX, id int64) error
22 CountForksOfRepo(ctx context.Context, db DBTX, forkOfRepoID pgtype.Int8) (int64, error)
23 // ─── rename rate limit support ─────────────────────────────────────────
24 // Used to enforce the 5-per-30-days rename rate limit. The redirect
25 // row is the audit trail for renames; counting them per repo gives a
26 // reliable cap.
27 CountRecentRedirectsForRepo(ctx context.Context, db DBTX, repoID int64) (int32, error)
28 CountReposForOwnerUser(ctx context.Context, db DBTX, ownerUserID pgtype.Int8) (int64, error)
29 // ─── S27 forks ─────────────────────────────────────────────────────
30 // Insert a fork shell. Distinct from CreateRepo because forks set
31 // `fork_of_repo_id` (which fires the fork_count trigger) and start
32 // at init_status='init_pending' so the worker job can flip them to
33 // 'initialized' once `git clone --bare --shared` finishes.
34 CreateForkRepo(ctx context.Context, db DBTX, arg CreateForkRepoParams) (Repo, error)
35 // SPDX-License-Identifier: AGPL-3.0-or-later
36 CreateRepo(ctx context.Context, db DBTX, arg CreateRepoParams) (Repo, error)
37 DeclineTransferRequest(ctx context.Context, db DBTX, id int64) error
38 DeleteBranchProtectionRule(ctx context.Context, db DBTX, id int64) error
39 DeleteProfilePinsForSet(ctx context.Context, db DBTX, setID int64) error
40 // Used by the rename compensator: drop a single redirect row when
41 // the rename has to be rolled back due to a filesystem failure. We
42 // avoided raw SQL here at the audit's request (S00-S25, M).
43 DeleteRedirectByUserOwnerOldName(ctx context.Context, db DBTX, arg DeleteRedirectByUserOwnerOldNameParams) error
44 // Used by hard-delete: drop the redirect rows pointing at this repo
45 // (they would dangle once the repos row is gone; the FK ON DELETE
46 // CASCADE would handle it, but explicit is auditable).
47 DeleteRedirectsForRepo(ctx context.Context, db DBTX, repoID int64) error
48 ExistsRepoForOwnerOrg(ctx context.Context, db DBTX, arg ExistsRepoForOwnerOrgParams) (bool, error)
49 ExistsRepoForOwnerUser(ctx context.Context, db DBTX, arg ExistsRepoForOwnerUserParams) (bool, error)
50 // Called by the periodic worker (transfers:expire) — flips pending
51 // offers past their expires_at to the expired terminal state.
52 ExpirePendingTransfers(ctx context.Context, db DBTX) (int64, error)
53 GetBranchProtectionRule(ctx context.Context, db DBTX, id int64) (BranchProtectionRule, error)
54 GetProfilePinSetForOrg(ctx context.Context, db DBTX, ownerOrgID pgtype.Int8) (int64, error)
55 // ─── profile/org pinned repositories ───────────────────────────────
56 GetProfilePinSetForUser(ctx context.Context, db DBTX, ownerUserID pgtype.Int8) (int64, error)
57 GetRepoByID(ctx context.Context, db DBTX, id int64) (Repo, error)
58 // S30: org-owner mirror of GetRepoByOwnerUserAndName. The (owner_org_id,
59 // name) partial unique index from 0017 backs this lookup with the same
60 // O(1) cost the user-side path enjoys.
61 GetRepoByOwnerOrgAndName(ctx context.Context, db DBTX, arg GetRepoByOwnerOrgAndNameParams) (Repo, error)
62 GetRepoByOwnerUserAndName(ctx context.Context, db DBTX, arg GetRepoByOwnerUserAndNameParams) (Repo, error)
63 // Returns the owner_username for a repo. Used by size-recalc and other
64 // jobs that need to derive the bare-repo on-disk path without round-
65 // tripping through the full user row.
66 GetRepoOwnerUsernameByID(ctx context.Context, db DBTX, id int64) (GetRepoOwnerUsernameByIDRow, error)
67 GetTransferRequest(ctx context.Context, db DBTX, id int64) (RepoTransferRequest, error)
68 HardDeleteRepo(ctx context.Context, db DBTX, id int64) error
69 InsertProfilePin(ctx context.Context, db DBTX, arg InsertProfilePinParams) error
70 // ─── redirects ─────────────────────────────────────────────────────────
71 // Both old-owner FKs are nullable; pass exactly one. The CHECK
72 // constraint on the table enforces the xor shape.
73 InsertRepoRedirect(ctx context.Context, db DBTX, arg InsertRepoRedirectParams) error
74 InsertRepoTopic(ctx context.Context, db DBTX, arg InsertRepoTopicParams) error
75 // ─── transfer requests ─────────────────────────────────────────────────
76 InsertTransferRequest(ctx context.Context, db DBTX, arg InsertTransferRequestParams) (RepoTransferRequest, error)
77 // Used by `shithubd hooks reinstall --all` to enumerate every active
78 // bare repo on disk and re-link its hooks.
79 ListAllRepoFullNames(ctx context.Context, db DBTX) ([]ListAllRepoFullNamesRow, error)
80 // SPDX-License-Identifier: AGPL-3.0-or-later
81 ListBranchProtectionRules(ctx context.Context, db DBTX, repoID int64) ([]BranchProtectionRule, error)
82 // Forks of a given source repo, paginated, recency-sorted. Joined
83 // with users for the owner display name. Excludes soft-deleted.
84 ListForksOfRepo(ctx context.Context, db DBTX, arg ListForksOfRepoParams) ([]ListForksOfRepoRow, error)
85 // Used by S16's hard-delete cascade (S27 amendment): before deleting
86 // a source repo, every fork must `git repack -a -d --no-shared` so
87 // it has its own copy of the objects. Returns just enough to locate
88 // the bare repo on disk.
89 ListForksOfRepoForRepack(ctx context.Context, db DBTX, forkOfRepoID pgtype.Int8) ([]ListForksOfRepoForRepackRow, error)
90 // Inbox view: pending offers a user can act on.
91 ListPendingTransfersForUser(ctx context.Context, db DBTX, toPrincipalID int64) ([]RepoTransferRequest, error)
92 ListProfilePinsForSet(ctx context.Context, db DBTX, setID int64) ([]ListProfilePinsForSetRow, error)
93 // ─── soft-delete sweep query ───────────────────────────────────────────
94 // The repo:hard_delete enqueuer queries this to find rows ready for
95 // destruction. The 7-day grace is hard-coded here; if we add a config
96 // knob later, change this to a parameter.
97 ListRepoIDsPastSoftDeleteGrace(ctx context.Context, db DBTX) ([]int64, error)
98 // ─── repo_topics (S32) ─────────────────────────────────────────────
99 ListRepoTopics(ctx context.Context, db DBTX, repoID int64) ([]string, error)
100 ListReposForOwnerOrg(ctx context.Context, db DBTX, ownerOrgID pgtype.Int8) ([]Repo, error)
101 ListReposForOwnerUser(ctx context.Context, db DBTX, ownerUserID pgtype.Int8) ([]Repo, error)
102 // S28 code-search reconciler: returns repos whose default_branch_oid
103 // has advanced past last_indexed_oid (or last_indexed_oid is NULL
104 // and a default exists). Limited so a single tick of the cron
105 // doesn't try to re-index the whole world.
106 ListReposNeedingReindex(ctx context.Context, db DBTX, limit int32) ([]ListReposNeedingReindexRow, error)
107 // /settings/repositories/restore page lists these.
108 ListSoftDeletedReposForOwner(ctx context.Context, db DBTX, ownerUserID pgtype.Int8) ([]ListSoftDeletedReposForOwnerRow, error)
109 // Sender / repo-settings view.
110 ListTransfersForRepo(ctx context.Context, db DBTX, repoID int64) ([]RepoTransferRequest, error)
111 // Returns the current repo_id when (old_owner_user_id, old_name) hits
112 // a redirect row.
113 LookupRedirectByUserOwner(ctx context.Context, db DBTX, arg LookupRedirectByUserOwnerParams) (int64, error)
114 // ─── fork-anchor cleanup on hard delete ────────────────────────────────
115 // Children pointing at this repo lose their fork-of pointer. Mirrors
116 // GitHub's behavior when an upstream is deleted.
117 OrphanForksOf(ctx context.Context, db DBTX, forkOfRepoID pgtype.Int8) (int64, error)
118 // SPDX-License-Identifier: AGPL-3.0-or-later
119 //
120 // S16 lifecycle queries. Kept in a separate file from repos.sql so the
121 // mainline CRUD stays easy to read.
122 // ─── repo mutations ────────────────────────────────────────────────────
123 // Same-owner rename. The handler validates the new name shape and the
124 // redirect row is INSERTed in the same tx.
125 RenameRepo(ctx context.Context, db DBTX, arg RenameRepoParams) error
126 // Atomic full-replace: callers compose the new topic set in Go,
127 // then replace the existing rows in one tx (DELETE + INSERT). The
128 // caller's tx wraps both calls for atomicity.
129 ReplaceRepoTopics(ctx context.Context, db DBTX, repoID int64) error
130 RestoreRepo(ctx context.Context, db DBTX, id int64) error
131 // S28 code-search: the worker writes the OID it finished indexing
132 // so the reconciler can detect drift (default_branch_oid moved but
133 // last_indexed_oid lagged).
134 SetLastIndexedOID(ctx context.Context, db DBTX, arg SetLastIndexedOIDParams) error
135 // Promotes a fork from init_pending to initialized (or init_failed).
136 // The DB row is created up-front so the URL resolves immediately and
137 // the user sees a "preparing your fork" placeholder while the worker
138 // runs `git clone --bare --shared`.
139 SetRepoInitStatus(ctx context.Context, db DBTX, arg SetRepoInitStatusParams) error
140 SetRepoVisibility(ctx context.Context, db DBTX, arg SetRepoVisibilityParams) error
141 SoftDeleteRepo(ctx context.Context, db DBTX, id int64) error
142 // Distinct name from S11's SoftDeleteRepo so future code that wants to
143 // preserve the lifecycle audit-emission shape can find this one.
144 SoftDeleteRepoLifecycle(ctx context.Context, db DBTX, id int64) error
145 // Sets owner_user_id (or owner_org_id post-S31) on accept. The xor
146 // check on the table enforces the shape. Also clears the other side
147 // so a user→org transfer flips both columns atomically.
148 TransferRepoOwner(ctx context.Context, db DBTX, arg TransferRepoOwnerParams) error
149 UnarchiveRepo(ctx context.Context, db DBTX, id int64) error
150 // S24 surface for the required-status-check knobs. Branch-protection
151 // edit handler calls this alongside UpdateBranchProtectionRule.
152 UpdateBranchProtectionCheckSettings(ctx context.Context, db DBTX, arg UpdateBranchProtectionCheckSettingsParams) error
153 // S23 surface for the review-related knobs. Branch-protection edit
154 // handler calls this alongside UpdateBranchProtectionRule.
155 UpdateBranchProtectionReviewSettings(ctx context.Context, db DBTX, arg UpdateBranchProtectionReviewSettingsParams) error
156 UpdateBranchProtectionRule(ctx context.Context, db DBTX, arg UpdateBranchProtectionRuleParams) error
157 // Used by the default-branch settings handler. The on-disk HEAD update
158 // is a separate step done via `git symbolic-ref` from the orchestrator.
159 UpdateRepoDefaultBranch(ctx context.Context, db DBTX, arg UpdateRepoDefaultBranchParams) error
160 // Set when push:process detects a commit on the repo's default branch.
161 // Pass NULL to clear (e.g. when the branch is force-deleted in a future
162 // sprint). The repo home view reads this to decide between empty and
163 // populated layouts.
164 UpdateRepoDefaultBranchOID(ctx context.Context, db DBTX, arg UpdateRepoDefaultBranchOIDParams) error
165 UpdateRepoDiskUsed(ctx context.Context, db DBTX, arg UpdateRepoDiskUsedParams) error
166 // S32: General-tab settings persist via this single query so each
167 // form post is one round-trip. The merge-method toggles are kept
168 // separate from the repo create flow because they're admin-only.
169 UpdateRepoGeneralSettings(ctx context.Context, db DBTX, arg UpdateRepoGeneralSettingsParams) error
170 UpdateRepoMergeSettings(ctx context.Context, db DBTX, arg UpdateRepoMergeSettingsParams) error
171 UpsertBranchProtectionRule(ctx context.Context, db DBTX, arg UpsertBranchProtectionRuleParams) (int64, error)
172 UpsertProfilePinSetForOrg(ctx context.Context, db DBTX, ownerOrgID pgtype.Int8) (int64, error)
173 UpsertProfilePinSetForUser(ctx context.Context, db DBTX, ownerUserID pgtype.Int8) (int64, error)
174 }
175
176 var _ Querier = (*Queries)(nil)
177