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