Go · 13269 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 DeleteRepoSourceRemote(ctx context.Context, db DBTX, repoID int64) error
49 ExistsRepoForOwnerOrg(ctx context.Context, db DBTX, arg ExistsRepoForOwnerOrgParams) (bool, error)
50 ExistsRepoForOwnerUser(ctx context.Context, db DBTX, arg ExistsRepoForOwnerUserParams) (bool, error)
51 // Called by the periodic worker (transfers:expire) — flips pending
52 // offers past their expires_at to the expired terminal state.
53 ExpirePendingTransfers(ctx context.Context, db DBTX) (int64, error)
54 GetBranchProtectionRule(ctx context.Context, db DBTX, id int64) (BranchProtectionRule, error)
55 GetProfilePinSetForOrg(ctx context.Context, db DBTX, ownerOrgID pgtype.Int8) (int64, error)
56 // ─── profile/org pinned repositories ───────────────────────────────
57 GetProfilePinSetForUser(ctx context.Context, db DBTX, ownerUserID pgtype.Int8) (int64, error)
58 GetRepoByID(ctx context.Context, db DBTX, id int64) (Repo, error)
59 // S30: org-owner mirror of GetRepoByOwnerUserAndName. The (owner_org_id,
60 // name) partial unique index from 0017 backs this lookup with the same
61 // O(1) cost the user-side path enjoys.
62 GetRepoByOwnerOrgAndName(ctx context.Context, db DBTX, arg GetRepoByOwnerOrgAndNameParams) (Repo, error)
63 GetRepoByOwnerUserAndName(ctx context.Context, db DBTX, arg GetRepoByOwnerUserAndNameParams) (Repo, error)
64 // Returns the owner_username for a repo. Used by size-recalc and other
65 // jobs that need to derive the bare-repo on-disk path without round-
66 // tripping through the full user row.
67 GetRepoOwnerUsernameByID(ctx context.Context, db DBTX, id int64) (GetRepoOwnerUsernameByIDRow, error)
68 // SPDX-License-Identifier: AGPL-3.0-or-later
69 GetRepoSourceRemote(ctx context.Context, db DBTX, repoID int64) (RepoSourceRemote, error)
70 GetTransferRequest(ctx context.Context, db DBTX, id int64) (RepoTransferRequest, error)
71 HardDeleteRepo(ctx context.Context, db DBTX, id int64) error
72 InsertProfilePin(ctx context.Context, db DBTX, arg InsertProfilePinParams) error
73 // ─── redirects ─────────────────────────────────────────────────────────
74 // Both old-owner FKs are nullable; pass exactly one. The CHECK
75 // constraint on the table enforces the xor shape.
76 InsertRepoRedirect(ctx context.Context, db DBTX, arg InsertRepoRedirectParams) error
77 InsertRepoTopic(ctx context.Context, db DBTX, arg InsertRepoTopicParams) error
78 // ─── transfer requests ─────────────────────────────────────────────────
79 InsertTransferRequest(ctx context.Context, db DBTX, arg InsertTransferRequestParams) (RepoTransferRequest, error)
80 // Used by `shithubd hooks reinstall --all` to enumerate every active
81 // bare repo on disk and re-link its hooks.
82 ListAllRepoFullNames(ctx context.Context, db DBTX) ([]ListAllRepoFullNamesRow, error)
83 // SPDX-License-Identifier: AGPL-3.0-or-later
84 ListBranchProtectionRules(ctx context.Context, db DBTX, repoID int64) ([]BranchProtectionRule, error)
85 // Forks of a given source repo, paginated, recency-sorted. Joined
86 // with users for the owner display name. Excludes soft-deleted.
87 ListForksOfRepo(ctx context.Context, db DBTX, arg ListForksOfRepoParams) ([]ListForksOfRepoRow, error)
88 // Used by S16's hard-delete cascade (S27 amendment): before deleting
89 // a source repo, every fork must `git repack -a -d --no-shared` so
90 // it has its own copy of the objects. Returns just enough to locate
91 // the bare repo on disk.
92 ListForksOfRepoForRepack(ctx context.Context, db DBTX, forkOfRepoID pgtype.Int8) ([]ListForksOfRepoForRepackRow, error)
93 // Inbox view: pending offers a user can act on.
94 ListPendingTransfersForUser(ctx context.Context, db DBTX, toPrincipalID int64) ([]RepoTransferRequest, error)
95 ListProfilePinsForSet(ctx context.Context, db DBTX, setID int64) ([]ListProfilePinsForSetRow, error)
96 // ─── soft-delete sweep query ───────────────────────────────────────────
97 // The repo:hard_delete enqueuer queries this to find rows ready for
98 // destruction. The 7-day grace is hard-coded here; if we add a config
99 // knob later, change this to a parameter.
100 ListRepoIDsPastSoftDeleteGrace(ctx context.Context, db DBTX) ([]int64, error)
101 // ─── repo_topics (S32) ─────────────────────────────────────────────
102 ListRepoTopics(ctx context.Context, db DBTX, repoID int64) ([]string, error)
103 ListReposForOwnerOrg(ctx context.Context, db DBTX, ownerOrgID pgtype.Int8) ([]Repo, error)
104 ListReposForOwnerUser(ctx context.Context, db DBTX, ownerUserID pgtype.Int8) ([]Repo, error)
105 // S28 code-search reconciler: returns repos whose default_branch_oid
106 // has advanced past last_indexed_oid (or last_indexed_oid is NULL
107 // and a default exists). Limited so a single tick of the cron
108 // doesn't try to re-index the whole world.
109 ListReposNeedingReindex(ctx context.Context, db DBTX, limit int32) ([]ListReposNeedingReindexRow, error)
110 // /settings/repositories/restore page lists these.
111 ListSoftDeletedReposForOwner(ctx context.Context, db DBTX, ownerUserID pgtype.Int8) ([]ListSoftDeletedReposForOwnerRow, error)
112 // Sender / repo-settings view.
113 ListTransfersForRepo(ctx context.Context, db DBTX, repoID int64) ([]RepoTransferRequest, error)
114 // Returns the current repo_id when (old_owner_user_id, old_name) hits
115 // a redirect row.
116 LookupRedirectByUserOwner(ctx context.Context, db DBTX, arg LookupRedirectByUserOwnerParams) (int64, error)
117 MarkRepoSourceRemoteFetchError(ctx context.Context, db DBTX, arg MarkRepoSourceRemoteFetchErrorParams) error
118 MarkRepoSourceRemoteFetched(ctx context.Context, db DBTX, repoID int64) error
119 // ─── fork-anchor cleanup on hard delete ────────────────────────────────
120 // Children pointing at this repo lose their fork-of pointer. Mirrors
121 // GitHub's behavior when an upstream is deleted.
122 OrphanForksOf(ctx context.Context, db DBTX, forkOfRepoID pgtype.Int8) (int64, error)
123 // SPDX-License-Identifier: AGPL-3.0-or-later
124 //
125 // S16 lifecycle queries. Kept in a separate file from repos.sql so the
126 // mainline CRUD stays easy to read.
127 // ─── repo mutations ────────────────────────────────────────────────────
128 // Same-owner rename. The handler validates the new name shape and the
129 // redirect row is INSERTed in the same tx.
130 RenameRepo(ctx context.Context, db DBTX, arg RenameRepoParams) error
131 // Atomic full-replace: callers compose the new topic set in Go,
132 // then replace the existing rows in one tx (DELETE + INSERT). The
133 // caller's tx wraps both calls for atomicity.
134 ReplaceRepoTopics(ctx context.Context, db DBTX, repoID int64) error
135 RestoreRepo(ctx context.Context, db DBTX, id int64) error
136 // S28 code-search: the worker writes the OID it finished indexing
137 // so the reconciler can detect drift (default_branch_oid moved but
138 // last_indexed_oid lagged).
139 SetLastIndexedOID(ctx context.Context, db DBTX, arg SetLastIndexedOIDParams) error
140 // Promotes a fork from init_pending to initialized (or init_failed).
141 // The DB row is created up-front so the URL resolves immediately and
142 // the user sees a "preparing your fork" placeholder while the worker
143 // runs `git clone --bare --shared`.
144 SetRepoInitStatus(ctx context.Context, db DBTX, arg SetRepoInitStatusParams) error
145 SetRepoVisibility(ctx context.Context, db DBTX, arg SetRepoVisibilityParams) error
146 SoftDeleteRepo(ctx context.Context, db DBTX, id int64) error
147 // Distinct name from S11's SoftDeleteRepo so future code that wants to
148 // preserve the lifecycle audit-emission shape can find this one.
149 SoftDeleteRepoLifecycle(ctx context.Context, db DBTX, id int64) error
150 // Sets owner_user_id (or owner_org_id post-S31) on accept. The xor
151 // check on the table enforces the shape. Also clears the other side
152 // so a user→org transfer flips both columns atomically.
153 TransferRepoOwner(ctx context.Context, db DBTX, arg TransferRepoOwnerParams) error
154 UnarchiveRepo(ctx context.Context, db DBTX, id int64) error
155 // S24 surface for the required-status-check knobs. Branch-protection
156 // edit handler calls this alongside UpdateBranchProtectionRule.
157 UpdateBranchProtectionCheckSettings(ctx context.Context, db DBTX, arg UpdateBranchProtectionCheckSettingsParams) error
158 // S23 surface for the review-related knobs. Branch-protection edit
159 // handler calls this alongside UpdateBranchProtectionRule.
160 UpdateBranchProtectionReviewSettings(ctx context.Context, db DBTX, arg UpdateBranchProtectionReviewSettingsParams) error
161 UpdateBranchProtectionRule(ctx context.Context, db DBTX, arg UpdateBranchProtectionRuleParams) error
162 // Used by the default-branch settings handler. The on-disk HEAD update
163 // is a separate step done via `git symbolic-ref` from the orchestrator.
164 UpdateRepoDefaultBranch(ctx context.Context, db DBTX, arg UpdateRepoDefaultBranchParams) error
165 // Set when push:process detects a commit on the repo's default branch.
166 // Pass NULL to clear (e.g. when the branch is force-deleted in a future
167 // sprint). The repo home view reads this to decide between empty and
168 // populated layouts.
169 UpdateRepoDefaultBranchOID(ctx context.Context, db DBTX, arg UpdateRepoDefaultBranchOIDParams) error
170 UpdateRepoDiskUsed(ctx context.Context, db DBTX, arg UpdateRepoDiskUsedParams) error
171 // S32: General-tab settings persist via this single query so each
172 // form post is one round-trip. The merge-method toggles are kept
173 // separate from the repo create flow because they're admin-only.
174 UpdateRepoGeneralSettings(ctx context.Context, db DBTX, arg UpdateRepoGeneralSettingsParams) error
175 UpdateRepoMergeSettings(ctx context.Context, db DBTX, arg UpdateRepoMergeSettingsParams) error
176 UpsertBranchProtectionRule(ctx context.Context, db DBTX, arg UpsertBranchProtectionRuleParams) (int64, error)
177 UpsertProfilePinSetForOrg(ctx context.Context, db DBTX, ownerOrgID pgtype.Int8) (int64, error)
178 UpsertProfilePinSetForUser(ctx context.Context, db DBTX, ownerUserID pgtype.Int8) (int64, error)
179 UpsertRepoSourceRemote(ctx context.Context, db DBTX, arg UpsertRepoSourceRemoteParams) (RepoSourceRemote, error)
180 }
181
182 var _ Querier = (*Queries)(nil)
183