Go · 37509 bytes Raw Blame History
1 // Code generated by sqlc. DO NOT EDIT.
2 // versions:
3 // sqlc v1.31.1
4 // source: repos.sql
5
6 package reposdb
7
8 import (
9 "context"
10
11 "github.com/jackc/pgx/v5/pgtype"
12 )
13
14 const adminForceDeleteRepo = `-- name: AdminForceDeleteRepo :exec
15 UPDATE repos SET deleted_at = now() - interval '1 year' WHERE id = $1
16 `
17
18 // Bypasses the soft-delete grace window (admin only — S34): set
19 // deleted_at to a year ago so the next lifecycle sweep hard-deletes
20 // without waiting. Replaces the inline UPDATE in admin/repos.go
21 // (SR2 M2).
22 func (q *Queries) AdminForceDeleteRepo(ctx context.Context, db DBTX, id int64) error {
23 _, err := db.Exec(ctx, adminForceDeleteRepo, id)
24 return err
25 }
26
27 const countForksOfRepo = `-- name: CountForksOfRepo :one
28 SELECT count(*) FROM repos
29 WHERE fork_of_repo_id = $1 AND deleted_at IS NULL
30 `
31
32 func (q *Queries) CountForksOfRepo(ctx context.Context, db DBTX, forkOfRepoID pgtype.Int8) (int64, error) {
33 row := db.QueryRow(ctx, countForksOfRepo, forkOfRepoID)
34 var count int64
35 err := row.Scan(&count)
36 return count, err
37 }
38
39 const countReposForOwnerUser = `-- name: CountReposForOwnerUser :one
40 SELECT count(*) FROM repos
41 WHERE owner_user_id = $1 AND deleted_at IS NULL
42 `
43
44 func (q *Queries) CountReposForOwnerUser(ctx context.Context, db DBTX, ownerUserID pgtype.Int8) (int64, error) {
45 row := db.QueryRow(ctx, countReposForOwnerUser, ownerUserID)
46 var count int64
47 err := row.Scan(&count)
48 return count, err
49 }
50
51 const createForkRepo = `-- name: CreateForkRepo :one
52
53 INSERT INTO repos (
54 owner_user_id, owner_org_id, name, description, visibility,
55 default_branch, fork_of_repo_id, init_status
56 ) VALUES (
57 $1, $2, $3, $4, $5, $6, $7, 'init_pending'
58 )
59 RETURNING id, owner_user_id, owner_org_id, name, description, visibility,
60 default_branch, is_archived, archived_at, deleted_at,
61 disk_used_bytes, fork_of_repo_id, license_key, primary_language,
62 has_issues, has_pulls, created_at, updated_at, default_branch_oid,
63 allow_squash_merge, allow_rebase_merge, allow_merge_commit, default_merge_method,
64 star_count, watcher_count, fork_count, init_status,
65 last_indexed_oid
66 `
67
68 type CreateForkRepoParams struct {
69 OwnerUserID pgtype.Int8
70 OwnerOrgID pgtype.Int8
71 Name string
72 Description string
73 Visibility RepoVisibility
74 DefaultBranch string
75 ForkOfRepoID pgtype.Int8
76 }
77
78 // ─── S27 forks ─────────────────────────────────────────────────────
79 // Insert a fork shell. Distinct from CreateRepo because forks set
80 // `fork_of_repo_id` (which fires the fork_count trigger) and start
81 // at init_status='init_pending' so the worker job can flip them to
82 // 'initialized' once `git clone --bare --shared` finishes.
83 func (q *Queries) CreateForkRepo(ctx context.Context, db DBTX, arg CreateForkRepoParams) (Repo, error) {
84 row := db.QueryRow(ctx, createForkRepo,
85 arg.OwnerUserID,
86 arg.OwnerOrgID,
87 arg.Name,
88 arg.Description,
89 arg.Visibility,
90 arg.DefaultBranch,
91 arg.ForkOfRepoID,
92 )
93 var i Repo
94 err := row.Scan(
95 &i.ID,
96 &i.OwnerUserID,
97 &i.OwnerOrgID,
98 &i.Name,
99 &i.Description,
100 &i.Visibility,
101 &i.DefaultBranch,
102 &i.IsArchived,
103 &i.ArchivedAt,
104 &i.DeletedAt,
105 &i.DiskUsedBytes,
106 &i.ForkOfRepoID,
107 &i.LicenseKey,
108 &i.PrimaryLanguage,
109 &i.HasIssues,
110 &i.HasPulls,
111 &i.CreatedAt,
112 &i.UpdatedAt,
113 &i.DefaultBranchOid,
114 &i.AllowSquashMerge,
115 &i.AllowRebaseMerge,
116 &i.AllowMergeCommit,
117 &i.DefaultMergeMethod,
118 &i.StarCount,
119 &i.WatcherCount,
120 &i.ForkCount,
121 &i.InitStatus,
122 &i.LastIndexedOid,
123 )
124 return i, err
125 }
126
127 const createRepo = `-- name: CreateRepo :one
128
129 INSERT INTO repos (
130 owner_user_id, owner_org_id, name, description, visibility,
131 default_branch, license_key, primary_language
132 ) VALUES (
133 $1, $2, $3, $4, $5, $6, $7, $8
134 )
135 RETURNING id, owner_user_id, owner_org_id, name, description, visibility,
136 default_branch, is_archived, archived_at, deleted_at,
137 disk_used_bytes, fork_of_repo_id, license_key, primary_language,
138 has_issues, has_pulls, created_at, updated_at, default_branch_oid,
139 allow_squash_merge, allow_rebase_merge, allow_merge_commit, default_merge_method,
140 star_count, watcher_count, fork_count, init_status,
141 last_indexed_oid
142 `
143
144 type CreateRepoParams struct {
145 OwnerUserID pgtype.Int8
146 OwnerOrgID pgtype.Int8
147 Name string
148 Description string
149 Visibility RepoVisibility
150 DefaultBranch string
151 LicenseKey pgtype.Text
152 PrimaryLanguage pgtype.Text
153 }
154
155 // SPDX-License-Identifier: AGPL-3.0-or-later
156 func (q *Queries) CreateRepo(ctx context.Context, db DBTX, arg CreateRepoParams) (Repo, error) {
157 row := db.QueryRow(ctx, createRepo,
158 arg.OwnerUserID,
159 arg.OwnerOrgID,
160 arg.Name,
161 arg.Description,
162 arg.Visibility,
163 arg.DefaultBranch,
164 arg.LicenseKey,
165 arg.PrimaryLanguage,
166 )
167 var i Repo
168 err := row.Scan(
169 &i.ID,
170 &i.OwnerUserID,
171 &i.OwnerOrgID,
172 &i.Name,
173 &i.Description,
174 &i.Visibility,
175 &i.DefaultBranch,
176 &i.IsArchived,
177 &i.ArchivedAt,
178 &i.DeletedAt,
179 &i.DiskUsedBytes,
180 &i.ForkOfRepoID,
181 &i.LicenseKey,
182 &i.PrimaryLanguage,
183 &i.HasIssues,
184 &i.HasPulls,
185 &i.CreatedAt,
186 &i.UpdatedAt,
187 &i.DefaultBranchOid,
188 &i.AllowSquashMerge,
189 &i.AllowRebaseMerge,
190 &i.AllowMergeCommit,
191 &i.DefaultMergeMethod,
192 &i.StarCount,
193 &i.WatcherCount,
194 &i.ForkCount,
195 &i.InitStatus,
196 &i.LastIndexedOid,
197 )
198 return i, err
199 }
200
201 const deleteProfilePinsForSet = `-- name: DeleteProfilePinsForSet :exec
202 DELETE FROM profile_pins WHERE set_id = $1
203 `
204
205 func (q *Queries) DeleteProfilePinsForSet(ctx context.Context, db DBTX, setID int64) error {
206 _, err := db.Exec(ctx, deleteProfilePinsForSet, setID)
207 return err
208 }
209
210 const existsRepoForOwnerOrg = `-- name: ExistsRepoForOwnerOrg :one
211 SELECT EXISTS(
212 SELECT 1 FROM repos
213 WHERE owner_org_id = $1 AND name = $2 AND deleted_at IS NULL
214 )
215 `
216
217 type ExistsRepoForOwnerOrgParams struct {
218 OwnerOrgID pgtype.Int8
219 Name string
220 }
221
222 func (q *Queries) ExistsRepoForOwnerOrg(ctx context.Context, db DBTX, arg ExistsRepoForOwnerOrgParams) (bool, error) {
223 row := db.QueryRow(ctx, existsRepoForOwnerOrg, arg.OwnerOrgID, arg.Name)
224 var exists bool
225 err := row.Scan(&exists)
226 return exists, err
227 }
228
229 const existsRepoForOwnerUser = `-- name: ExistsRepoForOwnerUser :one
230 SELECT EXISTS(
231 SELECT 1 FROM repos
232 WHERE owner_user_id = $1 AND name = $2 AND deleted_at IS NULL
233 )
234 `
235
236 type ExistsRepoForOwnerUserParams struct {
237 OwnerUserID pgtype.Int8
238 Name string
239 }
240
241 func (q *Queries) ExistsRepoForOwnerUser(ctx context.Context, db DBTX, arg ExistsRepoForOwnerUserParams) (bool, error) {
242 row := db.QueryRow(ctx, existsRepoForOwnerUser, arg.OwnerUserID, arg.Name)
243 var exists bool
244 err := row.Scan(&exists)
245 return exists, err
246 }
247
248 const getProfilePinSetForOrg = `-- name: GetProfilePinSetForOrg :one
249 SELECT id FROM profile_pin_sets WHERE owner_org_id = $1
250 `
251
252 func (q *Queries) GetProfilePinSetForOrg(ctx context.Context, db DBTX, ownerOrgID pgtype.Int8) (int64, error) {
253 row := db.QueryRow(ctx, getProfilePinSetForOrg, ownerOrgID)
254 var id int64
255 err := row.Scan(&id)
256 return id, err
257 }
258
259 const getProfilePinSetForUser = `-- name: GetProfilePinSetForUser :one
260
261 SELECT id FROM profile_pin_sets WHERE owner_user_id = $1
262 `
263
264 // ─── profile/org pinned repositories ───────────────────────────────
265 func (q *Queries) GetProfilePinSetForUser(ctx context.Context, db DBTX, ownerUserID pgtype.Int8) (int64, error) {
266 row := db.QueryRow(ctx, getProfilePinSetForUser, ownerUserID)
267 var id int64
268 err := row.Scan(&id)
269 return id, err
270 }
271
272 const getRepoByID = `-- name: GetRepoByID :one
273 SELECT id, owner_user_id, owner_org_id, name, description, visibility,
274 default_branch, is_archived, archived_at, deleted_at,
275 disk_used_bytes, fork_of_repo_id, license_key, primary_language,
276 has_issues, has_pulls, created_at, updated_at, default_branch_oid,
277 allow_squash_merge, allow_rebase_merge, allow_merge_commit, default_merge_method,
278 star_count, watcher_count, fork_count, init_status,
279 last_indexed_oid
280 FROM repos
281 WHERE id = $1
282 `
283
284 func (q *Queries) GetRepoByID(ctx context.Context, db DBTX, id int64) (Repo, error) {
285 row := db.QueryRow(ctx, getRepoByID, id)
286 var i Repo
287 err := row.Scan(
288 &i.ID,
289 &i.OwnerUserID,
290 &i.OwnerOrgID,
291 &i.Name,
292 &i.Description,
293 &i.Visibility,
294 &i.DefaultBranch,
295 &i.IsArchived,
296 &i.ArchivedAt,
297 &i.DeletedAt,
298 &i.DiskUsedBytes,
299 &i.ForkOfRepoID,
300 &i.LicenseKey,
301 &i.PrimaryLanguage,
302 &i.HasIssues,
303 &i.HasPulls,
304 &i.CreatedAt,
305 &i.UpdatedAt,
306 &i.DefaultBranchOid,
307 &i.AllowSquashMerge,
308 &i.AllowRebaseMerge,
309 &i.AllowMergeCommit,
310 &i.DefaultMergeMethod,
311 &i.StarCount,
312 &i.WatcherCount,
313 &i.ForkCount,
314 &i.InitStatus,
315 &i.LastIndexedOid,
316 )
317 return i, err
318 }
319
320 const getRepoByOwnerOrgAndName = `-- name: GetRepoByOwnerOrgAndName :one
321 SELECT id, owner_user_id, owner_org_id, name, description, visibility,
322 default_branch, is_archived, archived_at, deleted_at,
323 disk_used_bytes, fork_of_repo_id, license_key, primary_language,
324 has_issues, has_pulls, created_at, updated_at, default_branch_oid,
325 allow_squash_merge, allow_rebase_merge, allow_merge_commit, default_merge_method,
326 star_count, watcher_count, fork_count, init_status,
327 last_indexed_oid
328 FROM repos
329 WHERE owner_org_id = $1 AND name = $2 AND deleted_at IS NULL
330 `
331
332 type GetRepoByOwnerOrgAndNameParams struct {
333 OwnerOrgID pgtype.Int8
334 Name string
335 }
336
337 // S30: org-owner mirror of GetRepoByOwnerUserAndName. The (owner_org_id,
338 // name) partial unique index from 0017 backs this lookup with the same
339 // O(1) cost the user-side path enjoys.
340 func (q *Queries) GetRepoByOwnerOrgAndName(ctx context.Context, db DBTX, arg GetRepoByOwnerOrgAndNameParams) (Repo, error) {
341 row := db.QueryRow(ctx, getRepoByOwnerOrgAndName, arg.OwnerOrgID, arg.Name)
342 var i Repo
343 err := row.Scan(
344 &i.ID,
345 &i.OwnerUserID,
346 &i.OwnerOrgID,
347 &i.Name,
348 &i.Description,
349 &i.Visibility,
350 &i.DefaultBranch,
351 &i.IsArchived,
352 &i.ArchivedAt,
353 &i.DeletedAt,
354 &i.DiskUsedBytes,
355 &i.ForkOfRepoID,
356 &i.LicenseKey,
357 &i.PrimaryLanguage,
358 &i.HasIssues,
359 &i.HasPulls,
360 &i.CreatedAt,
361 &i.UpdatedAt,
362 &i.DefaultBranchOid,
363 &i.AllowSquashMerge,
364 &i.AllowRebaseMerge,
365 &i.AllowMergeCommit,
366 &i.DefaultMergeMethod,
367 &i.StarCount,
368 &i.WatcherCount,
369 &i.ForkCount,
370 &i.InitStatus,
371 &i.LastIndexedOid,
372 )
373 return i, err
374 }
375
376 const getRepoByOwnerUserAndName = `-- name: GetRepoByOwnerUserAndName :one
377 SELECT id, owner_user_id, owner_org_id, name, description, visibility,
378 default_branch, is_archived, archived_at, deleted_at,
379 disk_used_bytes, fork_of_repo_id, license_key, primary_language,
380 has_issues, has_pulls, created_at, updated_at, default_branch_oid,
381 allow_squash_merge, allow_rebase_merge, allow_merge_commit, default_merge_method,
382 star_count, watcher_count, fork_count, init_status,
383 last_indexed_oid
384 FROM repos
385 WHERE owner_user_id = $1 AND name = $2 AND deleted_at IS NULL
386 `
387
388 type GetRepoByOwnerUserAndNameParams struct {
389 OwnerUserID pgtype.Int8
390 Name string
391 }
392
393 func (q *Queries) GetRepoByOwnerUserAndName(ctx context.Context, db DBTX, arg GetRepoByOwnerUserAndNameParams) (Repo, error) {
394 row := db.QueryRow(ctx, getRepoByOwnerUserAndName, arg.OwnerUserID, arg.Name)
395 var i Repo
396 err := row.Scan(
397 &i.ID,
398 &i.OwnerUserID,
399 &i.OwnerOrgID,
400 &i.Name,
401 &i.Description,
402 &i.Visibility,
403 &i.DefaultBranch,
404 &i.IsArchived,
405 &i.ArchivedAt,
406 &i.DeletedAt,
407 &i.DiskUsedBytes,
408 &i.ForkOfRepoID,
409 &i.LicenseKey,
410 &i.PrimaryLanguage,
411 &i.HasIssues,
412 &i.HasPulls,
413 &i.CreatedAt,
414 &i.UpdatedAt,
415 &i.DefaultBranchOid,
416 &i.AllowSquashMerge,
417 &i.AllowRebaseMerge,
418 &i.AllowMergeCommit,
419 &i.DefaultMergeMethod,
420 &i.StarCount,
421 &i.WatcherCount,
422 &i.ForkCount,
423 &i.InitStatus,
424 &i.LastIndexedOid,
425 )
426 return i, err
427 }
428
429 const getRepoOwnerUsernameByID = `-- name: GetRepoOwnerUsernameByID :one
430 SELECT COALESCE(u.username::varchar, o.slug::varchar) AS owner_username, r.name AS repo_name
431 FROM repos r
432 LEFT JOIN users u ON u.id = r.owner_user_id
433 LEFT JOIN orgs o ON o.id = r.owner_org_id
434 WHERE r.id = $1
435 `
436
437 type GetRepoOwnerUsernameByIDRow struct {
438 OwnerUsername interface{}
439 RepoName string
440 }
441
442 // Returns the owner slug for a repo. Used by size-recalc, indexing, and
443 // other jobs that need the bare-repo on-disk path. Org-owned repos use the
444 // org slug in the same path position as user-owned repos.
445 func (q *Queries) GetRepoOwnerUsernameByID(ctx context.Context, db DBTX, id int64) (GetRepoOwnerUsernameByIDRow, error) {
446 row := db.QueryRow(ctx, getRepoOwnerUsernameByID, id)
447 var i GetRepoOwnerUsernameByIDRow
448 err := row.Scan(&i.OwnerUsername, &i.RepoName)
449 return i, err
450 }
451
452 const getSoftDeletedRepoByOwnerOrgAndName = `-- name: GetSoftDeletedRepoByOwnerOrgAndName :one
453 SELECT id, owner_user_id, owner_org_id, name, description, visibility,
454 default_branch, is_archived, archived_at, deleted_at,
455 disk_used_bytes, fork_of_repo_id, license_key, primary_language,
456 has_issues, has_pulls, created_at, updated_at, default_branch_oid,
457 allow_squash_merge, allow_rebase_merge, allow_merge_commit, default_merge_method,
458 star_count, watcher_count, fork_count, init_status,
459 last_indexed_oid
460 FROM repos
461 WHERE owner_org_id = $1 AND name = $2 AND deleted_at IS NOT NULL
462 ORDER BY deleted_at DESC, id DESC
463 LIMIT 1
464 `
465
466 type GetSoftDeletedRepoByOwnerOrgAndNameParams struct {
467 OwnerOrgID pgtype.Int8
468 Name string
469 }
470
471 func (q *Queries) GetSoftDeletedRepoByOwnerOrgAndName(ctx context.Context, db DBTX, arg GetSoftDeletedRepoByOwnerOrgAndNameParams) (Repo, error) {
472 row := db.QueryRow(ctx, getSoftDeletedRepoByOwnerOrgAndName, arg.OwnerOrgID, arg.Name)
473 var i Repo
474 err := row.Scan(
475 &i.ID,
476 &i.OwnerUserID,
477 &i.OwnerOrgID,
478 &i.Name,
479 &i.Description,
480 &i.Visibility,
481 &i.DefaultBranch,
482 &i.IsArchived,
483 &i.ArchivedAt,
484 &i.DeletedAt,
485 &i.DiskUsedBytes,
486 &i.ForkOfRepoID,
487 &i.LicenseKey,
488 &i.PrimaryLanguage,
489 &i.HasIssues,
490 &i.HasPulls,
491 &i.CreatedAt,
492 &i.UpdatedAt,
493 &i.DefaultBranchOid,
494 &i.AllowSquashMerge,
495 &i.AllowRebaseMerge,
496 &i.AllowMergeCommit,
497 &i.DefaultMergeMethod,
498 &i.StarCount,
499 &i.WatcherCount,
500 &i.ForkCount,
501 &i.InitStatus,
502 &i.LastIndexedOid,
503 )
504 return i, err
505 }
506
507 const getSoftDeletedRepoByOwnerUserAndName = `-- name: GetSoftDeletedRepoByOwnerUserAndName :one
508 SELECT id, owner_user_id, owner_org_id, name, description, visibility,
509 default_branch, is_archived, archived_at, deleted_at,
510 disk_used_bytes, fork_of_repo_id, license_key, primary_language,
511 has_issues, has_pulls, created_at, updated_at, default_branch_oid,
512 allow_squash_merge, allow_rebase_merge, allow_merge_commit, default_merge_method,
513 star_count, watcher_count, fork_count, init_status,
514 last_indexed_oid
515 FROM repos
516 WHERE owner_user_id = $1 AND name = $2 AND deleted_at IS NOT NULL
517 ORDER BY deleted_at DESC, id DESC
518 LIMIT 1
519 `
520
521 type GetSoftDeletedRepoByOwnerUserAndNameParams struct {
522 OwnerUserID pgtype.Int8
523 Name string
524 }
525
526 func (q *Queries) GetSoftDeletedRepoByOwnerUserAndName(ctx context.Context, db DBTX, arg GetSoftDeletedRepoByOwnerUserAndNameParams) (Repo, error) {
527 row := db.QueryRow(ctx, getSoftDeletedRepoByOwnerUserAndName, arg.OwnerUserID, arg.Name)
528 var i Repo
529 err := row.Scan(
530 &i.ID,
531 &i.OwnerUserID,
532 &i.OwnerOrgID,
533 &i.Name,
534 &i.Description,
535 &i.Visibility,
536 &i.DefaultBranch,
537 &i.IsArchived,
538 &i.ArchivedAt,
539 &i.DeletedAt,
540 &i.DiskUsedBytes,
541 &i.ForkOfRepoID,
542 &i.LicenseKey,
543 &i.PrimaryLanguage,
544 &i.HasIssues,
545 &i.HasPulls,
546 &i.CreatedAt,
547 &i.UpdatedAt,
548 &i.DefaultBranchOid,
549 &i.AllowSquashMerge,
550 &i.AllowRebaseMerge,
551 &i.AllowMergeCommit,
552 &i.DefaultMergeMethod,
553 &i.StarCount,
554 &i.WatcherCount,
555 &i.ForkCount,
556 &i.InitStatus,
557 &i.LastIndexedOid,
558 )
559 return i, err
560 }
561
562 const insertProfilePin = `-- name: InsertProfilePin :exec
563 INSERT INTO profile_pins (set_id, repo_id, position)
564 VALUES ($1, $2, $3)
565 `
566
567 type InsertProfilePinParams struct {
568 SetID int64
569 RepoID int64
570 Position int32
571 }
572
573 func (q *Queries) InsertProfilePin(ctx context.Context, db DBTX, arg InsertProfilePinParams) error {
574 _, err := db.Exec(ctx, insertProfilePin, arg.SetID, arg.RepoID, arg.Position)
575 return err
576 }
577
578 const insertRepoTopic = `-- name: InsertRepoTopic :exec
579 INSERT INTO repo_topics (repo_id, topic)
580 VALUES ($1, $2)
581 ON CONFLICT DO NOTHING
582 `
583
584 type InsertRepoTopicParams struct {
585 RepoID int64
586 Topic string
587 }
588
589 func (q *Queries) InsertRepoTopic(ctx context.Context, db DBTX, arg InsertRepoTopicParams) error {
590 _, err := db.Exec(ctx, insertRepoTopic, arg.RepoID, arg.Topic)
591 return err
592 }
593
594 const listAllRepoFullNames = `-- name: ListAllRepoFullNames :many
595 SELECT
596 r.id,
597 r.name,
598 u.username AS owner_username
599 FROM repos r
600 JOIN users u ON u.id = r.owner_user_id
601 WHERE r.deleted_at IS NULL
602 ORDER BY r.id
603 `
604
605 type ListAllRepoFullNamesRow struct {
606 ID int64
607 Name string
608 OwnerUsername string
609 }
610
611 // Used by `shithubd hooks reinstall --all` to enumerate every active
612 // bare repo on disk and re-link its hooks.
613 func (q *Queries) ListAllRepoFullNames(ctx context.Context, db DBTX) ([]ListAllRepoFullNamesRow, error) {
614 rows, err := db.Query(ctx, listAllRepoFullNames)
615 if err != nil {
616 return nil, err
617 }
618 defer rows.Close()
619 items := []ListAllRepoFullNamesRow{}
620 for rows.Next() {
621 var i ListAllRepoFullNamesRow
622 if err := rows.Scan(&i.ID, &i.Name, &i.OwnerUsername); err != nil {
623 return nil, err
624 }
625 items = append(items, i)
626 }
627 if err := rows.Err(); err != nil {
628 return nil, err
629 }
630 return items, nil
631 }
632
633 const listForksOfRepo = `-- name: ListForksOfRepo :many
634 SELECT r.id, r.name, r.description, r.visibility, r.created_at,
635 r.star_count, r.fork_count, r.init_status,
636 u.username AS owner_username, u.display_name AS owner_display_name
637 FROM repos r
638 JOIN users u ON u.id = r.owner_user_id
639 WHERE r.fork_of_repo_id = $1
640 AND r.deleted_at IS NULL
641 ORDER BY r.created_at DESC
642 LIMIT $2 OFFSET $3
643 `
644
645 type ListForksOfRepoParams struct {
646 ForkOfRepoID pgtype.Int8
647 Limit int32
648 Offset int32
649 }
650
651 type ListForksOfRepoRow struct {
652 ID int64
653 Name string
654 Description string
655 Visibility RepoVisibility
656 CreatedAt pgtype.Timestamptz
657 StarCount int64
658 ForkCount int64
659 InitStatus RepoInitStatus
660 OwnerUsername string
661 OwnerDisplayName string
662 }
663
664 // Forks of a given source repo, paginated, recency-sorted. Joined
665 // with users for the owner display name. Excludes soft-deleted.
666 func (q *Queries) ListForksOfRepo(ctx context.Context, db DBTX, arg ListForksOfRepoParams) ([]ListForksOfRepoRow, error) {
667 rows, err := db.Query(ctx, listForksOfRepo, arg.ForkOfRepoID, arg.Limit, arg.Offset)
668 if err != nil {
669 return nil, err
670 }
671 defer rows.Close()
672 items := []ListForksOfRepoRow{}
673 for rows.Next() {
674 var i ListForksOfRepoRow
675 if err := rows.Scan(
676 &i.ID,
677 &i.Name,
678 &i.Description,
679 &i.Visibility,
680 &i.CreatedAt,
681 &i.StarCount,
682 &i.ForkCount,
683 &i.InitStatus,
684 &i.OwnerUsername,
685 &i.OwnerDisplayName,
686 ); err != nil {
687 return nil, err
688 }
689 items = append(items, i)
690 }
691 if err := rows.Err(); err != nil {
692 return nil, err
693 }
694 return items, nil
695 }
696
697 const listForksOfRepoForRepack = `-- name: ListForksOfRepoForRepack :many
698 SELECT r.id, r.name, u.username AS owner_username
699 FROM repos r
700 JOIN users u ON u.id = r.owner_user_id
701 WHERE r.fork_of_repo_id = $1
702 AND r.deleted_at IS NULL
703 `
704
705 type ListForksOfRepoForRepackRow struct {
706 ID int64
707 Name string
708 OwnerUsername string
709 }
710
711 // Used by S16's hard-delete cascade (S27 amendment): before deleting
712 // a source repo, every fork must `git repack -a -d --no-shared` so
713 // it has its own copy of the objects. Returns just enough to locate
714 // the bare repo on disk.
715 func (q *Queries) ListForksOfRepoForRepack(ctx context.Context, db DBTX, forkOfRepoID pgtype.Int8) ([]ListForksOfRepoForRepackRow, error) {
716 rows, err := db.Query(ctx, listForksOfRepoForRepack, forkOfRepoID)
717 if err != nil {
718 return nil, err
719 }
720 defer rows.Close()
721 items := []ListForksOfRepoForRepackRow{}
722 for rows.Next() {
723 var i ListForksOfRepoForRepackRow
724 if err := rows.Scan(&i.ID, &i.Name, &i.OwnerUsername); err != nil {
725 return nil, err
726 }
727 items = append(items, i)
728 }
729 if err := rows.Err(); err != nil {
730 return nil, err
731 }
732 return items, nil
733 }
734
735 const listProfilePinCandidateReposForUser = `-- name: ListProfilePinCandidateReposForUser :many
736 SELECT r.id, r.owner_user_id, r.owner_org_id, r.name, r.description, r.visibility, r.default_branch, r.is_archived, r.archived_at, r.deleted_at, r.disk_used_bytes, r.fork_of_repo_id, r.license_key, r.primary_language, r.has_issues, r.has_pulls, r.created_at, r.updated_at, r.default_branch_oid, r.allow_squash_merge, r.allow_rebase_merge, r.allow_merge_commit, r.default_merge_method, r.star_count, r.watcher_count, r.fork_count, r.init_status, r.last_indexed_oid, COALESCE(owner_user.username, owner_org.slug)::text AS owner_slug
737 FROM repos r
738 LEFT JOIN users owner_user ON owner_user.id = r.owner_user_id
739 LEFT JOIN orgs owner_org ON owner_org.id = r.owner_org_id
740 WHERE r.deleted_at IS NULL
741 AND r.visibility = 'public'
742 AND (
743 (r.owner_user_id IS NOT NULL AND owner_user.deleted_at IS NULL AND owner_user.suspended_at IS NULL)
744 OR (r.owner_org_id IS NOT NULL AND owner_org.deleted_at IS NULL)
745 )
746 AND (
747 r.owner_user_id = $1
748 OR EXISTS (
749 SELECT 1
750 FROM org_members m
751 WHERE m.org_id = r.owner_org_id
752 AND m.user_id = $1
753 )
754 OR EXISTS (
755 SELECT 1
756 FROM repo_collaborators c
757 WHERE c.repo_id = r.id
758 AND c.user_id = $1
759 )
760 )
761 ORDER BY lower(COALESCE(owner_user.username::text, owner_org.slug::text, '')), lower(r.name::text), r.id
762 `
763
764 type ListProfilePinCandidateReposForUserRow struct {
765 Repo Repo
766 OwnerSlug string
767 }
768
769 func (q *Queries) ListProfilePinCandidateReposForUser(ctx context.Context, db DBTX, ownerUserID pgtype.Int8) ([]ListProfilePinCandidateReposForUserRow, error) {
770 rows, err := db.Query(ctx, listProfilePinCandidateReposForUser, ownerUserID)
771 if err != nil {
772 return nil, err
773 }
774 defer rows.Close()
775 items := []ListProfilePinCandidateReposForUserRow{}
776 for rows.Next() {
777 var i ListProfilePinCandidateReposForUserRow
778 if err := rows.Scan(
779 &i.Repo.ID,
780 &i.Repo.OwnerUserID,
781 &i.Repo.OwnerOrgID,
782 &i.Repo.Name,
783 &i.Repo.Description,
784 &i.Repo.Visibility,
785 &i.Repo.DefaultBranch,
786 &i.Repo.IsArchived,
787 &i.Repo.ArchivedAt,
788 &i.Repo.DeletedAt,
789 &i.Repo.DiskUsedBytes,
790 &i.Repo.ForkOfRepoID,
791 &i.Repo.LicenseKey,
792 &i.Repo.PrimaryLanguage,
793 &i.Repo.HasIssues,
794 &i.Repo.HasPulls,
795 &i.Repo.CreatedAt,
796 &i.Repo.UpdatedAt,
797 &i.Repo.DefaultBranchOid,
798 &i.Repo.AllowSquashMerge,
799 &i.Repo.AllowRebaseMerge,
800 &i.Repo.AllowMergeCommit,
801 &i.Repo.DefaultMergeMethod,
802 &i.Repo.StarCount,
803 &i.Repo.WatcherCount,
804 &i.Repo.ForkCount,
805 &i.Repo.InitStatus,
806 &i.Repo.LastIndexedOid,
807 &i.OwnerSlug,
808 ); err != nil {
809 return nil, err
810 }
811 items = append(items, i)
812 }
813 if err := rows.Err(); err != nil {
814 return nil, err
815 }
816 return items, nil
817 }
818
819 const listProfilePinsForSet = `-- name: ListProfilePinsForSet :many
820 SELECT repo_id, position
821 FROM profile_pins
822 WHERE set_id = $1
823 ORDER BY position ASC
824 `
825
826 type ListProfilePinsForSetRow struct {
827 RepoID int64
828 Position int32
829 }
830
831 func (q *Queries) ListProfilePinsForSet(ctx context.Context, db DBTX, setID int64) ([]ListProfilePinsForSetRow, error) {
832 rows, err := db.Query(ctx, listProfilePinsForSet, setID)
833 if err != nil {
834 return nil, err
835 }
836 defer rows.Close()
837 items := []ListProfilePinsForSetRow{}
838 for rows.Next() {
839 var i ListProfilePinsForSetRow
840 if err := rows.Scan(&i.RepoID, &i.Position); err != nil {
841 return nil, err
842 }
843 items = append(items, i)
844 }
845 if err := rows.Err(); err != nil {
846 return nil, err
847 }
848 return items, nil
849 }
850
851 const listPublicContributionRepos = `-- name: ListPublicContributionRepos :many
852 SELECT r.id, r.owner_user_id, r.owner_org_id, r.name, r.description, r.visibility, r.default_branch, r.is_archived, r.archived_at, r.deleted_at, r.disk_used_bytes, r.fork_of_repo_id, r.license_key, r.primary_language, r.has_issues, r.has_pulls, r.created_at, r.updated_at, r.default_branch_oid, r.allow_squash_merge, r.allow_rebase_merge, r.allow_merge_commit, r.default_merge_method, r.star_count, r.watcher_count, r.fork_count, r.init_status, r.last_indexed_oid, COALESCE(u.username, o.slug)::text AS owner_slug
853 FROM repos r
854 LEFT JOIN users u ON u.id = r.owner_user_id
855 LEFT JOIN orgs o ON o.id = r.owner_org_id
856 WHERE r.deleted_at IS NULL
857 AND r.visibility = 'public'
858 AND (
859 (r.owner_user_id IS NOT NULL AND u.deleted_at IS NULL AND u.suspended_at IS NULL)
860 OR (r.owner_org_id IS NOT NULL AND o.deleted_at IS NULL)
861 )
862 ORDER BY r.updated_at DESC, r.id DESC
863 LIMIT $1
864 `
865
866 type ListPublicContributionReposRow struct {
867 Repo Repo
868 OwnerSlug string
869 }
870
871 func (q *Queries) ListPublicContributionRepos(ctx context.Context, db DBTX, limit int32) ([]ListPublicContributionReposRow, error) {
872 rows, err := db.Query(ctx, listPublicContributionRepos, limit)
873 if err != nil {
874 return nil, err
875 }
876 defer rows.Close()
877 items := []ListPublicContributionReposRow{}
878 for rows.Next() {
879 var i ListPublicContributionReposRow
880 if err := rows.Scan(
881 &i.Repo.ID,
882 &i.Repo.OwnerUserID,
883 &i.Repo.OwnerOrgID,
884 &i.Repo.Name,
885 &i.Repo.Description,
886 &i.Repo.Visibility,
887 &i.Repo.DefaultBranch,
888 &i.Repo.IsArchived,
889 &i.Repo.ArchivedAt,
890 &i.Repo.DeletedAt,
891 &i.Repo.DiskUsedBytes,
892 &i.Repo.ForkOfRepoID,
893 &i.Repo.LicenseKey,
894 &i.Repo.PrimaryLanguage,
895 &i.Repo.HasIssues,
896 &i.Repo.HasPulls,
897 &i.Repo.CreatedAt,
898 &i.Repo.UpdatedAt,
899 &i.Repo.DefaultBranchOid,
900 &i.Repo.AllowSquashMerge,
901 &i.Repo.AllowRebaseMerge,
902 &i.Repo.AllowMergeCommit,
903 &i.Repo.DefaultMergeMethod,
904 &i.Repo.StarCount,
905 &i.Repo.WatcherCount,
906 &i.Repo.ForkCount,
907 &i.Repo.InitStatus,
908 &i.Repo.LastIndexedOid,
909 &i.OwnerSlug,
910 ); err != nil {
911 return nil, err
912 }
913 items = append(items, i)
914 }
915 if err := rows.Err(); err != nil {
916 return nil, err
917 }
918 return items, nil
919 }
920
921 const listRepoTopics = `-- name: ListRepoTopics :many
922
923 SELECT topic FROM repo_topics WHERE repo_id = $1 ORDER BY topic ASC
924 `
925
926 // ─── repo_topics (S32) ─────────────────────────────────────────────
927 func (q *Queries) ListRepoTopics(ctx context.Context, db DBTX, repoID int64) ([]string, error) {
928 rows, err := db.Query(ctx, listRepoTopics, repoID)
929 if err != nil {
930 return nil, err
931 }
932 defer rows.Close()
933 items := []string{}
934 for rows.Next() {
935 var topic string
936 if err := rows.Scan(&topic); err != nil {
937 return nil, err
938 }
939 items = append(items, topic)
940 }
941 if err := rows.Err(); err != nil {
942 return nil, err
943 }
944 return items, nil
945 }
946
947 const listReposForOwnerOrg = `-- name: ListReposForOwnerOrg :many
948 SELECT id, owner_user_id, owner_org_id, name, description, visibility,
949 default_branch, is_archived, archived_at, deleted_at,
950 disk_used_bytes, fork_of_repo_id, license_key, primary_language,
951 has_issues, has_pulls, created_at, updated_at, default_branch_oid,
952 allow_squash_merge, allow_rebase_merge, allow_merge_commit, default_merge_method,
953 star_count, watcher_count, fork_count, init_status,
954 last_indexed_oid
955 FROM repos
956 WHERE owner_org_id = $1 AND deleted_at IS NULL
957 ORDER BY updated_at DESC
958 `
959
960 func (q *Queries) ListReposForOwnerOrg(ctx context.Context, db DBTX, ownerOrgID pgtype.Int8) ([]Repo, error) {
961 rows, err := db.Query(ctx, listReposForOwnerOrg, ownerOrgID)
962 if err != nil {
963 return nil, err
964 }
965 defer rows.Close()
966 items := []Repo{}
967 for rows.Next() {
968 var i Repo
969 if err := rows.Scan(
970 &i.ID,
971 &i.OwnerUserID,
972 &i.OwnerOrgID,
973 &i.Name,
974 &i.Description,
975 &i.Visibility,
976 &i.DefaultBranch,
977 &i.IsArchived,
978 &i.ArchivedAt,
979 &i.DeletedAt,
980 &i.DiskUsedBytes,
981 &i.ForkOfRepoID,
982 &i.LicenseKey,
983 &i.PrimaryLanguage,
984 &i.HasIssues,
985 &i.HasPulls,
986 &i.CreatedAt,
987 &i.UpdatedAt,
988 &i.DefaultBranchOid,
989 &i.AllowSquashMerge,
990 &i.AllowRebaseMerge,
991 &i.AllowMergeCommit,
992 &i.DefaultMergeMethod,
993 &i.StarCount,
994 &i.WatcherCount,
995 &i.ForkCount,
996 &i.InitStatus,
997 &i.LastIndexedOid,
998 ); err != nil {
999 return nil, err
1000 }
1001 items = append(items, i)
1002 }
1003 if err := rows.Err(); err != nil {
1004 return nil, err
1005 }
1006 return items, nil
1007 }
1008
1009 const listReposForOwnerUser = `-- name: ListReposForOwnerUser :many
1010 SELECT id, owner_user_id, owner_org_id, name, description, visibility,
1011 default_branch, is_archived, archived_at, deleted_at,
1012 disk_used_bytes, fork_of_repo_id, license_key, primary_language,
1013 has_issues, has_pulls, created_at, updated_at, default_branch_oid,
1014 allow_squash_merge, allow_rebase_merge, allow_merge_commit, default_merge_method,
1015 star_count, watcher_count, fork_count, init_status,
1016 last_indexed_oid
1017 FROM repos
1018 WHERE owner_user_id = $1 AND deleted_at IS NULL
1019 ORDER BY updated_at DESC
1020 `
1021
1022 func (q *Queries) ListReposForOwnerUser(ctx context.Context, db DBTX, ownerUserID pgtype.Int8) ([]Repo, error) {
1023 rows, err := db.Query(ctx, listReposForOwnerUser, ownerUserID)
1024 if err != nil {
1025 return nil, err
1026 }
1027 defer rows.Close()
1028 items := []Repo{}
1029 for rows.Next() {
1030 var i Repo
1031 if err := rows.Scan(
1032 &i.ID,
1033 &i.OwnerUserID,
1034 &i.OwnerOrgID,
1035 &i.Name,
1036 &i.Description,
1037 &i.Visibility,
1038 &i.DefaultBranch,
1039 &i.IsArchived,
1040 &i.ArchivedAt,
1041 &i.DeletedAt,
1042 &i.DiskUsedBytes,
1043 &i.ForkOfRepoID,
1044 &i.LicenseKey,
1045 &i.PrimaryLanguage,
1046 &i.HasIssues,
1047 &i.HasPulls,
1048 &i.CreatedAt,
1049 &i.UpdatedAt,
1050 &i.DefaultBranchOid,
1051 &i.AllowSquashMerge,
1052 &i.AllowRebaseMerge,
1053 &i.AllowMergeCommit,
1054 &i.DefaultMergeMethod,
1055 &i.StarCount,
1056 &i.WatcherCount,
1057 &i.ForkCount,
1058 &i.InitStatus,
1059 &i.LastIndexedOid,
1060 ); err != nil {
1061 return nil, err
1062 }
1063 items = append(items, i)
1064 }
1065 if err := rows.Err(); err != nil {
1066 return nil, err
1067 }
1068 return items, nil
1069 }
1070
1071 const listReposNeedingReindex = `-- name: ListReposNeedingReindex :many
1072 SELECT id, name, default_branch, default_branch_oid
1073 FROM repos
1074 WHERE deleted_at IS NULL
1075 AND default_branch_oid IS NOT NULL
1076 AND (last_indexed_oid IS NULL OR last_indexed_oid <> default_branch_oid)
1077 ORDER BY id
1078 LIMIT $1
1079 `
1080
1081 type ListReposNeedingReindexRow struct {
1082 ID int64
1083 Name string
1084 DefaultBranch string
1085 DefaultBranchOid pgtype.Text
1086 }
1087
1088 // S28 code-search reconciler: returns repos whose default_branch_oid
1089 // has advanced past last_indexed_oid (or last_indexed_oid is NULL
1090 // and a default exists). Limited so a single tick of the cron
1091 // doesn't try to re-index the whole world.
1092 func (q *Queries) ListReposNeedingReindex(ctx context.Context, db DBTX, limit int32) ([]ListReposNeedingReindexRow, error) {
1093 rows, err := db.Query(ctx, listReposNeedingReindex, limit)
1094 if err != nil {
1095 return nil, err
1096 }
1097 defer rows.Close()
1098 items := []ListReposNeedingReindexRow{}
1099 for rows.Next() {
1100 var i ListReposNeedingReindexRow
1101 if err := rows.Scan(
1102 &i.ID,
1103 &i.Name,
1104 &i.DefaultBranch,
1105 &i.DefaultBranchOid,
1106 ); err != nil {
1107 return nil, err
1108 }
1109 items = append(items, i)
1110 }
1111 if err := rows.Err(); err != nil {
1112 return nil, err
1113 }
1114 return items, nil
1115 }
1116
1117 const lockRepoOwnerName = `-- name: LockRepoOwnerName :exec
1118 SELECT pg_advisory_xact_lock(hashtextextended($1, 0))
1119 `
1120
1121 // Serializes DB + filesystem operations for one logical owner/name
1122 // pair. Create, soft-delete, restore, and hard-delete all touch the
1123 // canonical bare path; a transaction-scoped advisory lock keeps those
1124 // cross-resource moves from racing.
1125 func (q *Queries) LockRepoOwnerName(ctx context.Context, db DBTX, hashtextextended string) error {
1126 _, err := db.Exec(ctx, lockRepoOwnerName, hashtextextended)
1127 return err
1128 }
1129
1130 const replaceRepoTopics = `-- name: ReplaceRepoTopics :exec
1131 DELETE FROM repo_topics WHERE repo_id = $1
1132 `
1133
1134 // Atomic full-replace: callers compose the new topic set in Go,
1135 // then replace the existing rows in one tx (DELETE + INSERT). The
1136 // caller's tx wraps both calls for atomicity.
1137 func (q *Queries) ReplaceRepoTopics(ctx context.Context, db DBTX, repoID int64) error {
1138 _, err := db.Exec(ctx, replaceRepoTopics, repoID)
1139 return err
1140 }
1141
1142 const setLastIndexedOID = `-- name: SetLastIndexedOID :exec
1143 UPDATE repos SET last_indexed_oid = $2::text WHERE id = $1
1144 `
1145
1146 type SetLastIndexedOIDParams struct {
1147 ID int64
1148 LastIndexedOid pgtype.Text
1149 }
1150
1151 // S28 code-search: the worker writes the OID it finished indexing
1152 // so the reconciler can detect drift (default_branch_oid moved but
1153 // last_indexed_oid lagged).
1154 func (q *Queries) SetLastIndexedOID(ctx context.Context, db DBTX, arg SetLastIndexedOIDParams) error {
1155 _, err := db.Exec(ctx, setLastIndexedOID, arg.ID, arg.LastIndexedOid)
1156 return err
1157 }
1158
1159 const setRepoInitStatus = `-- name: SetRepoInitStatus :exec
1160 UPDATE repos SET init_status = $2 WHERE id = $1
1161 `
1162
1163 type SetRepoInitStatusParams struct {
1164 ID int64
1165 InitStatus RepoInitStatus
1166 }
1167
1168 // Promotes a fork from init_pending to initialized (or init_failed).
1169 // The DB row is created up-front so the URL resolves immediately and
1170 // the user sees a "preparing your fork" placeholder while the worker
1171 // runs `git clone --bare --shared`.
1172 func (q *Queries) SetRepoInitStatus(ctx context.Context, db DBTX, arg SetRepoInitStatusParams) error {
1173 _, err := db.Exec(ctx, setRepoInitStatus, arg.ID, arg.InitStatus)
1174 return err
1175 }
1176
1177 const softDeleteRepo = `-- name: SoftDeleteRepo :exec
1178 UPDATE repos SET deleted_at = now() WHERE id = $1
1179 `
1180
1181 func (q *Queries) SoftDeleteRepo(ctx context.Context, db DBTX, id int64) error {
1182 _, err := db.Exec(ctx, softDeleteRepo, id)
1183 return err
1184 }
1185
1186 const updateRepoDefaultBranchOID = `-- name: UpdateRepoDefaultBranchOID :exec
1187 UPDATE repos SET default_branch_oid = $2::text WHERE id = $1
1188 `
1189
1190 type UpdateRepoDefaultBranchOIDParams struct {
1191 ID int64
1192 DefaultBranchOid pgtype.Text
1193 }
1194
1195 // Set when push:process detects a commit on the repo's default branch.
1196 // Pass NULL to clear (e.g. when the branch is force-deleted in a future
1197 // sprint). The repo home view reads this to decide between empty and
1198 // populated layouts.
1199 func (q *Queries) UpdateRepoDefaultBranchOID(ctx context.Context, db DBTX, arg UpdateRepoDefaultBranchOIDParams) error {
1200 _, err := db.Exec(ctx, updateRepoDefaultBranchOID, arg.ID, arg.DefaultBranchOid)
1201 return err
1202 }
1203
1204 const updateRepoDiskUsed = `-- name: UpdateRepoDiskUsed :exec
1205 UPDATE repos SET disk_used_bytes = $2 WHERE id = $1
1206 `
1207
1208 type UpdateRepoDiskUsedParams struct {
1209 ID int64
1210 DiskUsedBytes int64
1211 }
1212
1213 func (q *Queries) UpdateRepoDiskUsed(ctx context.Context, db DBTX, arg UpdateRepoDiskUsedParams) error {
1214 _, err := db.Exec(ctx, updateRepoDiskUsed, arg.ID, arg.DiskUsedBytes)
1215 return err
1216 }
1217
1218 const updateRepoGeneralSettings = `-- name: UpdateRepoGeneralSettings :exec
1219 UPDATE repos
1220 SET description = $2,
1221 has_issues = $3,
1222 has_pulls = $4,
1223 updated_at = now()
1224 WHERE id = $1
1225 `
1226
1227 type UpdateRepoGeneralSettingsParams struct {
1228 ID int64
1229 Description string
1230 HasIssues bool
1231 HasPulls bool
1232 }
1233
1234 // S32: General-tab settings persist via this single query so each
1235 // form post is one round-trip. The merge-method toggles are kept
1236 // separate from the repo create flow because they're admin-only.
1237 func (q *Queries) UpdateRepoGeneralSettings(ctx context.Context, db DBTX, arg UpdateRepoGeneralSettingsParams) error {
1238 _, err := db.Exec(ctx, updateRepoGeneralSettings,
1239 arg.ID,
1240 arg.Description,
1241 arg.HasIssues,
1242 arg.HasPulls,
1243 )
1244 return err
1245 }
1246
1247 const updateRepoMergeSettings = `-- name: UpdateRepoMergeSettings :exec
1248 UPDATE repos
1249 SET allow_merge_commit = $2,
1250 allow_squash_merge = $3,
1251 allow_rebase_merge = $4,
1252 default_merge_method = $5,
1253 updated_at = now()
1254 WHERE id = $1
1255 `
1256
1257 type UpdateRepoMergeSettingsParams struct {
1258 ID int64
1259 AllowMergeCommit bool
1260 AllowSquashMerge bool
1261 AllowRebaseMerge bool
1262 DefaultMergeMethod PrMergeMethod
1263 }
1264
1265 func (q *Queries) UpdateRepoMergeSettings(ctx context.Context, db DBTX, arg UpdateRepoMergeSettingsParams) error {
1266 _, err := db.Exec(ctx, updateRepoMergeSettings,
1267 arg.ID,
1268 arg.AllowMergeCommit,
1269 arg.AllowSquashMerge,
1270 arg.AllowRebaseMerge,
1271 arg.DefaultMergeMethod,
1272 )
1273 return err
1274 }
1275
1276 const upsertProfilePinSetForOrg = `-- name: UpsertProfilePinSetForOrg :one
1277 INSERT INTO profile_pin_sets (owner_org_id)
1278 VALUES ($1)
1279 ON CONFLICT (owner_org_id) WHERE owner_org_id IS NOT NULL
1280 DO UPDATE SET updated_at = now()
1281 RETURNING id
1282 `
1283
1284 func (q *Queries) UpsertProfilePinSetForOrg(ctx context.Context, db DBTX, ownerOrgID pgtype.Int8) (int64, error) {
1285 row := db.QueryRow(ctx, upsertProfilePinSetForOrg, ownerOrgID)
1286 var id int64
1287 err := row.Scan(&id)
1288 return id, err
1289 }
1290
1291 const upsertProfilePinSetForUser = `-- name: UpsertProfilePinSetForUser :one
1292 INSERT INTO profile_pin_sets (owner_user_id)
1293 VALUES ($1)
1294 ON CONFLICT (owner_user_id) WHERE owner_user_id IS NOT NULL
1295 DO UPDATE SET updated_at = now()
1296 RETURNING id
1297 `
1298
1299 func (q *Queries) UpsertProfilePinSetForUser(ctx context.Context, db DBTX, ownerUserID pgtype.Int8) (int64, error) {
1300 row := db.QueryRow(ctx, upsertProfilePinSetForUser, ownerUserID)
1301 var id int64
1302 err := row.Scan(&id)
1303 return id, err
1304 }
1305