tenseleyflow/shithub / 3c7723c

Browse files

actions: sqlc config + generated CRUD types (S41a)

Adds the actions block to sqlc.yaml + the per-table .sql query files.
sqlc generate produces internal/actions/sqlc/ with one .sql.go file
per query file plus models.go (the Go structs mirroring the schema)
and querier.go (the Queries interface).

Just enough surface for S41b/c/d to read and write the rows. No
orchestration logic in this commit; the workflow package (next two
commits) layers on top.
Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
3c7723cc7642437bdf49f1a7cae5ab830690d333
Parents
e1d20b6
Tree
3f25554

20 changed files

StatusFile+-
A internal/actions/queries/actions_variables.sql 35 0
A internal/actions/queries/workflow_artifacts.sql 21 0
A internal/actions/queries/workflow_jobs.sql 29 0
A internal/actions/queries/workflow_runners.sql 50 0
A internal/actions/queries/workflow_runs.sql 41 0
A internal/actions/queries/workflow_secrets.sql 49 0
A internal/actions/queries/workflow_step_log_chunks.sql 16 0
A internal/actions/queries/workflow_steps.sql 31 0
A internal/actions/sqlc/actions_variables.sql.go 198 0
A internal/actions/sqlc/db.go 25 0
A internal/actions/sqlc/models.go 2357 0
A internal/actions/sqlc/querier.go 66 0
A internal/actions/sqlc/workflow_artifacts.sql.go 143 0
A internal/actions/sqlc/workflow_jobs.sql.go 171 0
A internal/actions/sqlc/workflow_runners.sql.go 232 0
A internal/actions/sqlc/workflow_runs.sql.go 211 0
A internal/actions/sqlc/workflow_secrets.sql.go 268 0
A internal/actions/sqlc/workflow_step_log_chunks.sql.go 94 0
A internal/actions/sqlc/workflow_steps.sql.go 177 0
M sqlc.yaml 16 0
internal/actions/queries/actions_variables.sqladded
@@ -0,0 +1,35 @@
1
+-- SPDX-License-Identifier: AGPL-3.0-or-later
2
+
3
+-- name: UpsertRepoVariable :one
4
+INSERT INTO actions_variables (repo_id, name, value, created_by_user_id)
5
+VALUES ($1, $2, $3, $4)
6
+ON CONFLICT (repo_id, name) WHERE repo_id IS NOT NULL DO UPDATE
7
+SET value = EXCLUDED.value, updated_at = now()
8
+RETURNING id, repo_id, org_id, name, value, created_by_user_id,
9
+          created_at, updated_at;
10
+
11
+-- name: UpsertOrgVariable :one
12
+INSERT INTO actions_variables (org_id, name, value, created_by_user_id)
13
+VALUES ($1, $2, $3, $4)
14
+ON CONFLICT (org_id, name) WHERE org_id IS NOT NULL DO UPDATE
15
+SET value = EXCLUDED.value, updated_at = now()
16
+RETURNING id, repo_id, org_id, name, value, created_by_user_id,
17
+          created_at, updated_at;
18
+
19
+-- name: ListRepoVariables :many
20
+SELECT id, name, value, created_at, updated_at
21
+FROM actions_variables
22
+WHERE repo_id = $1
23
+ORDER BY name ASC;
24
+
25
+-- name: ListOrgVariables :many
26
+SELECT id, name, value, created_at, updated_at
27
+FROM actions_variables
28
+WHERE org_id = $1
29
+ORDER BY name ASC;
30
+
31
+-- name: DeleteRepoVariable :exec
32
+DELETE FROM actions_variables WHERE repo_id = $1 AND name = $2;
33
+
34
+-- name: DeleteOrgVariable :exec
35
+DELETE FROM actions_variables WHERE org_id = $1 AND name = $2;
internal/actions/queries/workflow_artifacts.sqladded
@@ -0,0 +1,21 @@
1
+-- SPDX-License-Identifier: AGPL-3.0-or-later
2
+
3
+-- name: InsertArtifact :one
4
+INSERT INTO workflow_artifacts (run_id, name, object_key, byte_count, expires_at)
5
+VALUES ($1, $2, $3, $4, $5)
6
+RETURNING id, run_id, name, object_key, byte_count, expires_at, created_at;
7
+
8
+-- name: ListArtifactsForRun :many
9
+SELECT id, name, object_key, byte_count, expires_at, created_at
10
+FROM workflow_artifacts
11
+WHERE run_id = $1
12
+ORDER BY name ASC;
13
+
14
+-- name: GetArtifactByID :one
15
+SELECT id, run_id, name, object_key, byte_count, expires_at, created_at
16
+FROM workflow_artifacts
17
+WHERE id = $1;
18
+
19
+-- name: DeleteExpiredArtifacts :many
20
+DELETE FROM workflow_artifacts WHERE expires_at < now()
21
+RETURNING id, object_key;
internal/actions/queries/workflow_jobs.sqladded
@@ -0,0 +1,29 @@
1
+-- SPDX-License-Identifier: AGPL-3.0-or-later
2
+
3
+-- name: InsertWorkflowJob :one
4
+INSERT INTO workflow_jobs (
5
+    run_id, job_index, job_key, job_name,
6
+    runs_on, needs_jobs, if_expr, timeout_minutes,
7
+    permissions, job_env
8
+) VALUES (
9
+    $1, $2, $3, $4, $5, $6, $7, $8, $9, $10
10
+)
11
+RETURNING id, run_id, job_index, job_key, job_name, runs_on,
12
+          runner_id, needs_jobs, if_expr, timeout_minutes, permissions,
13
+          job_env, status, conclusion, cancel_requested,
14
+          started_at, completed_at, version, created_at, updated_at;
15
+
16
+-- name: GetWorkflowJobByID :one
17
+SELECT id, run_id, job_index, job_key, job_name, runs_on,
18
+       runner_id, needs_jobs, if_expr, timeout_minutes, permissions,
19
+       job_env, status, conclusion, cancel_requested,
20
+       started_at, completed_at, version, created_at, updated_at
21
+FROM workflow_jobs
22
+WHERE id = $1;
23
+
24
+-- name: ListJobsForRun :many
25
+SELECT id, run_id, job_index, job_key, job_name, runs_on, status,
26
+       conclusion, started_at, completed_at, created_at
27
+FROM workflow_jobs
28
+WHERE run_id = $1
29
+ORDER BY job_index ASC;
internal/actions/queries/workflow_runners.sqladded
@@ -0,0 +1,50 @@
1
+-- SPDX-License-Identifier: AGPL-3.0-or-later
2
+
3
+-- name: InsertRunner :one
4
+INSERT INTO workflow_runners (name, labels, capacity, registered_by_user_id)
5
+VALUES ($1, $2, $3, $4)
6
+RETURNING id, name, labels, capacity, status, last_heartbeat_at,
7
+          registered_by_user_id, created_at, updated_at;
8
+
9
+-- name: GetRunnerByID :one
10
+SELECT id, name, labels, capacity, status, last_heartbeat_at,
11
+       registered_by_user_id, created_at, updated_at
12
+FROM workflow_runners
13
+WHERE id = $1;
14
+
15
+-- name: GetRunnerByName :one
16
+SELECT id, name, labels, capacity, status, last_heartbeat_at,
17
+       registered_by_user_id, created_at, updated_at
18
+FROM workflow_runners
19
+WHERE name = $1;
20
+
21
+-- name: ListRunners :many
22
+SELECT id, name, labels, capacity, status, last_heartbeat_at, created_at
23
+FROM workflow_runners
24
+ORDER BY name ASC;
25
+
26
+-- name: TouchRunnerHeartbeat :exec
27
+UPDATE workflow_runners
28
+SET last_heartbeat_at = now(),
29
+    status = $2,
30
+    updated_at = now()
31
+WHERE id = $1;
32
+
33
+-- name: InsertRunnerToken :one
34
+INSERT INTO runner_tokens (runner_id, token_hash, expires_at)
35
+VALUES ($1, $2, $3)
36
+RETURNING id, runner_id, token_hash, expires_at, revoked_at, created_at;
37
+
38
+-- name: GetRunnerByTokenHash :one
39
+SELECT r.id, r.name, r.labels, r.capacity, r.status,
40
+       r.last_heartbeat_at, r.created_at
41
+FROM workflow_runners r
42
+JOIN runner_tokens t ON t.runner_id = r.id
43
+WHERE t.token_hash = $1
44
+  AND t.revoked_at IS NULL
45
+  AND (t.expires_at IS NULL OR t.expires_at > now());
46
+
47
+-- name: RevokeAllTokensForRunner :exec
48
+UPDATE runner_tokens
49
+SET revoked_at = now()
50
+WHERE runner_id = $1 AND revoked_at IS NULL;
internal/actions/queries/workflow_runs.sqladded
@@ -0,0 +1,41 @@
1
+-- SPDX-License-Identifier: AGPL-3.0-or-later
2
+
3
+-- name: InsertWorkflowRun :one
4
+INSERT INTO workflow_runs (
5
+    repo_id, run_index, workflow_file, workflow_name,
6
+    head_sha, head_ref, event, event_payload,
7
+    actor_user_id, parent_run_id, concurrency_group, need_approval
8
+) VALUES (
9
+    $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12
10
+)
11
+RETURNING id, repo_id, run_index, workflow_file, workflow_name,
12
+          head_sha, head_ref, event, event_payload,
13
+          actor_user_id, parent_run_id, concurrency_group,
14
+          status, conclusion, pinned, need_approval, approved_by_user_id,
15
+          started_at, completed_at, version, created_at, updated_at;
16
+
17
+-- name: GetWorkflowRunByID :one
18
+SELECT id, repo_id, run_index, workflow_file, workflow_name,
19
+       head_sha, head_ref, event, event_payload,
20
+       actor_user_id, parent_run_id, concurrency_group,
21
+       status, conclusion, pinned, need_approval, approved_by_user_id,
22
+       started_at, completed_at, version, created_at, updated_at
23
+FROM workflow_runs
24
+WHERE id = $1;
25
+
26
+-- name: NextRunIndexForRepo :one
27
+-- Atomic next-index emitter: take the max + 1 for this repo. Pairs
28
+-- with the (repo_id, run_index) UNIQUE so concurrent inserts that
29
+-- race here will catch a unique-violation and the caller retries.
30
+SELECT COALESCE(MAX(run_index), 0) + 1 AS next_index
31
+FROM workflow_runs
32
+WHERE repo_id = $1;
33
+
34
+-- name: ListWorkflowRunsForRepo :many
35
+SELECT id, repo_id, run_index, workflow_file, workflow_name,
36
+       head_sha, head_ref, event, status, conclusion,
37
+       actor_user_id, started_at, completed_at, created_at
38
+FROM workflow_runs
39
+WHERE repo_id = $1
40
+ORDER BY created_at DESC
41
+LIMIT $2 OFFSET $3;
internal/actions/queries/workflow_secrets.sqladded
@@ -0,0 +1,49 @@
1
+-- SPDX-License-Identifier: AGPL-3.0-or-later
2
+
3
+-- name: UpsertRepoSecret :one
4
+INSERT INTO workflow_secrets (repo_id, name, ciphertext, nonce, created_by_user_id)
5
+VALUES ($1, $2, $3, $4, $5)
6
+ON CONFLICT (repo_id, name) WHERE repo_id IS NOT NULL DO UPDATE
7
+SET ciphertext = EXCLUDED.ciphertext,
8
+    nonce      = EXCLUDED.nonce,
9
+    updated_at = now()
10
+RETURNING id, repo_id, org_id, name, ciphertext, nonce,
11
+          created_by_user_id, created_at, updated_at;
12
+
13
+-- name: UpsertOrgSecret :one
14
+INSERT INTO workflow_secrets (org_id, name, ciphertext, nonce, created_by_user_id)
15
+VALUES ($1, $2, $3, $4, $5)
16
+ON CONFLICT (org_id, name) WHERE org_id IS NOT NULL DO UPDATE
17
+SET ciphertext = EXCLUDED.ciphertext,
18
+    nonce      = EXCLUDED.nonce,
19
+    updated_at = now()
20
+RETURNING id, repo_id, org_id, name, ciphertext, nonce,
21
+          created_by_user_id, created_at, updated_at;
22
+
23
+-- name: ListRepoSecrets :many
24
+SELECT id, name, created_by_user_id, created_at, updated_at
25
+FROM workflow_secrets
26
+WHERE repo_id = $1
27
+ORDER BY name ASC;
28
+
29
+-- name: ListOrgSecrets :many
30
+SELECT id, name, created_by_user_id, created_at, updated_at
31
+FROM workflow_secrets
32
+WHERE org_id = $1
33
+ORDER BY name ASC;
34
+
35
+-- name: GetRepoSecret :one
36
+SELECT id, name, ciphertext, nonce
37
+FROM workflow_secrets
38
+WHERE repo_id = $1 AND name = $2;
39
+
40
+-- name: GetOrgSecret :one
41
+SELECT id, name, ciphertext, nonce
42
+FROM workflow_secrets
43
+WHERE org_id = $1 AND name = $2;
44
+
45
+-- name: DeleteRepoSecret :exec
46
+DELETE FROM workflow_secrets WHERE repo_id = $1 AND name = $2;
47
+
48
+-- name: DeleteOrgSecret :exec
49
+DELETE FROM workflow_secrets WHERE org_id = $1 AND name = $2;
internal/actions/queries/workflow_step_log_chunks.sqladded
@@ -0,0 +1,16 @@
1
+-- SPDX-License-Identifier: AGPL-3.0-or-later
2
+
3
+-- name: AppendStepLogChunk :one
4
+INSERT INTO workflow_step_log_chunks (step_id, seq, chunk)
5
+VALUES ($1, $2, $3)
6
+RETURNING id, step_id, seq, created_at;
7
+
8
+-- name: ListStepLogChunks :many
9
+SELECT id, step_id, seq, chunk, created_at
10
+FROM workflow_step_log_chunks
11
+WHERE step_id = $1 AND seq > $2
12
+ORDER BY seq ASC
13
+LIMIT $3;
14
+
15
+-- name: DeleteStepLogChunks :exec
16
+DELETE FROM workflow_step_log_chunks WHERE step_id = $1;
internal/actions/queries/workflow_steps.sqladded
@@ -0,0 +1,31 @@
1
+-- SPDX-License-Identifier: AGPL-3.0-or-later
2
+
3
+-- name: InsertWorkflowStep :one
4
+INSERT INTO workflow_steps (
5
+    job_id, step_index, step_id, step_name, if_expr,
6
+    run_command, uses_alias, working_directory, step_env, continue_on_error
7
+) VALUES (
8
+    $1, $2, $3, $4, $5, $6, $7, $8, $9, $10
9
+)
10
+RETURNING id, job_id, step_index, step_id, step_name, if_expr,
11
+          run_command, uses_alias, working_directory, step_env,
12
+          continue_on_error, status, conclusion, log_object_key,
13
+          log_byte_count, started_at, completed_at, version,
14
+          created_at, updated_at;
15
+
16
+-- name: GetWorkflowStepByID :one
17
+SELECT id, job_id, step_index, step_id, step_name, if_expr,
18
+       run_command, uses_alias, working_directory, step_env,
19
+       continue_on_error, status, conclusion, log_object_key,
20
+       log_byte_count, started_at, completed_at, version,
21
+       created_at, updated_at
22
+FROM workflow_steps
23
+WHERE id = $1;
24
+
25
+-- name: ListStepsForJob :many
26
+SELECT id, job_id, step_index, step_id, step_name, run_command,
27
+       uses_alias, status, conclusion, log_byte_count,
28
+       started_at, completed_at, created_at
29
+FROM workflow_steps
30
+WHERE job_id = $1
31
+ORDER BY step_index ASC;
internal/actions/sqlc/actions_variables.sql.goadded
@@ -0,0 +1,198 @@
1
+// Code generated by sqlc. DO NOT EDIT.
2
+// versions:
3
+//   sqlc v1.31.1
4
+// source: actions_variables.sql
5
+
6
+package actionsdb
7
+
8
+import (
9
+	"context"
10
+
11
+	"github.com/jackc/pgx/v5/pgtype"
12
+)
13
+
14
+const deleteOrgVariable = `-- name: DeleteOrgVariable :exec
15
+DELETE FROM actions_variables WHERE org_id = $1 AND name = $2
16
+`
17
+
18
+type DeleteOrgVariableParams struct {
19
+	OrgID pgtype.Int8
20
+	Name  string
21
+}
22
+
23
+func (q *Queries) DeleteOrgVariable(ctx context.Context, db DBTX, arg DeleteOrgVariableParams) error {
24
+	_, err := db.Exec(ctx, deleteOrgVariable, arg.OrgID, arg.Name)
25
+	return err
26
+}
27
+
28
+const deleteRepoVariable = `-- name: DeleteRepoVariable :exec
29
+DELETE FROM actions_variables WHERE repo_id = $1 AND name = $2
30
+`
31
+
32
+type DeleteRepoVariableParams struct {
33
+	RepoID pgtype.Int8
34
+	Name   string
35
+}
36
+
37
+func (q *Queries) DeleteRepoVariable(ctx context.Context, db DBTX, arg DeleteRepoVariableParams) error {
38
+	_, err := db.Exec(ctx, deleteRepoVariable, arg.RepoID, arg.Name)
39
+	return err
40
+}
41
+
42
+const listOrgVariables = `-- name: ListOrgVariables :many
43
+SELECT id, name, value, created_at, updated_at
44
+FROM actions_variables
45
+WHERE org_id = $1
46
+ORDER BY name ASC
47
+`
48
+
49
+type ListOrgVariablesRow struct {
50
+	ID        int64
51
+	Name      string
52
+	Value     string
53
+	CreatedAt pgtype.Timestamptz
54
+	UpdatedAt pgtype.Timestamptz
55
+}
56
+
57
+func (q *Queries) ListOrgVariables(ctx context.Context, db DBTX, orgID pgtype.Int8) ([]ListOrgVariablesRow, error) {
58
+	rows, err := db.Query(ctx, listOrgVariables, orgID)
59
+	if err != nil {
60
+		return nil, err
61
+	}
62
+	defer rows.Close()
63
+	items := []ListOrgVariablesRow{}
64
+	for rows.Next() {
65
+		var i ListOrgVariablesRow
66
+		if err := rows.Scan(
67
+			&i.ID,
68
+			&i.Name,
69
+			&i.Value,
70
+			&i.CreatedAt,
71
+			&i.UpdatedAt,
72
+		); err != nil {
73
+			return nil, err
74
+		}
75
+		items = append(items, i)
76
+	}
77
+	if err := rows.Err(); err != nil {
78
+		return nil, err
79
+	}
80
+	return items, nil
81
+}
82
+
83
+const listRepoVariables = `-- name: ListRepoVariables :many
84
+SELECT id, name, value, created_at, updated_at
85
+FROM actions_variables
86
+WHERE repo_id = $1
87
+ORDER BY name ASC
88
+`
89
+
90
+type ListRepoVariablesRow struct {
91
+	ID        int64
92
+	Name      string
93
+	Value     string
94
+	CreatedAt pgtype.Timestamptz
95
+	UpdatedAt pgtype.Timestamptz
96
+}
97
+
98
+func (q *Queries) ListRepoVariables(ctx context.Context, db DBTX, repoID pgtype.Int8) ([]ListRepoVariablesRow, error) {
99
+	rows, err := db.Query(ctx, listRepoVariables, repoID)
100
+	if err != nil {
101
+		return nil, err
102
+	}
103
+	defer rows.Close()
104
+	items := []ListRepoVariablesRow{}
105
+	for rows.Next() {
106
+		var i ListRepoVariablesRow
107
+		if err := rows.Scan(
108
+			&i.ID,
109
+			&i.Name,
110
+			&i.Value,
111
+			&i.CreatedAt,
112
+			&i.UpdatedAt,
113
+		); err != nil {
114
+			return nil, err
115
+		}
116
+		items = append(items, i)
117
+	}
118
+	if err := rows.Err(); err != nil {
119
+		return nil, err
120
+	}
121
+	return items, nil
122
+}
123
+
124
+const upsertOrgVariable = `-- name: UpsertOrgVariable :one
125
+INSERT INTO actions_variables (org_id, name, value, created_by_user_id)
126
+VALUES ($1, $2, $3, $4)
127
+ON CONFLICT (org_id, name) WHERE org_id IS NOT NULL DO UPDATE
128
+SET value = EXCLUDED.value, updated_at = now()
129
+RETURNING id, repo_id, org_id, name, value, created_by_user_id,
130
+          created_at, updated_at
131
+`
132
+
133
+type UpsertOrgVariableParams struct {
134
+	OrgID           pgtype.Int8
135
+	Name            string
136
+	Value           string
137
+	CreatedByUserID pgtype.Int8
138
+}
139
+
140
+func (q *Queries) UpsertOrgVariable(ctx context.Context, db DBTX, arg UpsertOrgVariableParams) (ActionsVariable, error) {
141
+	row := db.QueryRow(ctx, upsertOrgVariable,
142
+		arg.OrgID,
143
+		arg.Name,
144
+		arg.Value,
145
+		arg.CreatedByUserID,
146
+	)
147
+	var i ActionsVariable
148
+	err := row.Scan(
149
+		&i.ID,
150
+		&i.RepoID,
151
+		&i.OrgID,
152
+		&i.Name,
153
+		&i.Value,
154
+		&i.CreatedByUserID,
155
+		&i.CreatedAt,
156
+		&i.UpdatedAt,
157
+	)
158
+	return i, err
159
+}
160
+
161
+const upsertRepoVariable = `-- name: UpsertRepoVariable :one
162
+
163
+INSERT INTO actions_variables (repo_id, name, value, created_by_user_id)
164
+VALUES ($1, $2, $3, $4)
165
+ON CONFLICT (repo_id, name) WHERE repo_id IS NOT NULL DO UPDATE
166
+SET value = EXCLUDED.value, updated_at = now()
167
+RETURNING id, repo_id, org_id, name, value, created_by_user_id,
168
+          created_at, updated_at
169
+`
170
+
171
+type UpsertRepoVariableParams struct {
172
+	RepoID          pgtype.Int8
173
+	Name            string
174
+	Value           string
175
+	CreatedByUserID pgtype.Int8
176
+}
177
+
178
+// SPDX-License-Identifier: AGPL-3.0-or-later
179
+func (q *Queries) UpsertRepoVariable(ctx context.Context, db DBTX, arg UpsertRepoVariableParams) (ActionsVariable, error) {
180
+	row := db.QueryRow(ctx, upsertRepoVariable,
181
+		arg.RepoID,
182
+		arg.Name,
183
+		arg.Value,
184
+		arg.CreatedByUserID,
185
+	)
186
+	var i ActionsVariable
187
+	err := row.Scan(
188
+		&i.ID,
189
+		&i.RepoID,
190
+		&i.OrgID,
191
+		&i.Name,
192
+		&i.Value,
193
+		&i.CreatedByUserID,
194
+		&i.CreatedAt,
195
+		&i.UpdatedAt,
196
+	)
197
+	return i, err
198
+}
internal/actions/sqlc/db.goadded
@@ -0,0 +1,25 @@
1
+// Code generated by sqlc. DO NOT EDIT.
2
+// versions:
3
+//   sqlc v1.31.1
4
+
5
+package actionsdb
6
+
7
+import (
8
+	"context"
9
+
10
+	"github.com/jackc/pgx/v5"
11
+	"github.com/jackc/pgx/v5/pgconn"
12
+)
13
+
14
+type DBTX interface {
15
+	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
16
+	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
17
+	QueryRow(context.Context, string, ...interface{}) pgx.Row
18
+}
19
+
20
+func New() *Queries {
21
+	return &Queries{}
22
+}
23
+
24
+type Queries struct {
25
+}
internal/actions/sqlc/models.goadded
2357 lines changed — click to load
@@ -0,0 +1,2357 @@
1
+// Code generated by sqlc. DO NOT EDIT.
2
+// versions:
3
+//   sqlc v1.31.1
4
+
5
+package actionsdb
6
+
7
+import (
8
+	"database/sql/driver"
9
+	"fmt"
10
+	"net/netip"
11
+
12
+	"github.com/jackc/pgx/v5/pgtype"
13
+)
14
+
15
+type CheckConclusion string
16
+
17
+const (
18
+	CheckConclusionSuccess        CheckConclusion = "success"
19
+	CheckConclusionFailure        CheckConclusion = "failure"
20
+	CheckConclusionNeutral        CheckConclusion = "neutral"
21
+	CheckConclusionCancelled      CheckConclusion = "cancelled"
22
+	CheckConclusionSkipped        CheckConclusion = "skipped"
23
+	CheckConclusionTimedOut       CheckConclusion = "timed_out"
24
+	CheckConclusionActionRequired CheckConclusion = "action_required"
25
+	CheckConclusionStale          CheckConclusion = "stale"
26
+)
27
+
28
+func (e *CheckConclusion) Scan(src interface{}) error {
29
+	switch s := src.(type) {
30
+	case []byte:
31
+		*e = CheckConclusion(s)
32
+	case string:
33
+		*e = CheckConclusion(s)
34
+	default:
35
+		return fmt.Errorf("unsupported scan type for CheckConclusion: %T", src)
36
+	}
37
+	return nil
38
+}
39
+
40
+type NullCheckConclusion struct {
41
+	CheckConclusion CheckConclusion
42
+	Valid           bool // Valid is true if CheckConclusion is not NULL
43
+}
44
+
45
+// Scan implements the Scanner interface.
46
+func (ns *NullCheckConclusion) Scan(value interface{}) error {
47
+	if value == nil {
48
+		ns.CheckConclusion, ns.Valid = "", false
49
+		return nil
50
+	}
51
+	ns.Valid = true
52
+	return ns.CheckConclusion.Scan(value)
53
+}
54
+
55
+// Value implements the driver Valuer interface.
56
+func (ns NullCheckConclusion) Value() (driver.Value, error) {
57
+	if !ns.Valid {
58
+		return nil, nil
59
+	}
60
+	return string(ns.CheckConclusion), nil
61
+}
62
+
63
+type CheckStatus string
64
+
65
+const (
66
+	CheckStatusQueued     CheckStatus = "queued"
67
+	CheckStatusInProgress CheckStatus = "in_progress"
68
+	CheckStatusCompleted  CheckStatus = "completed"
69
+	CheckStatusPending    CheckStatus = "pending"
70
+)
71
+
72
+func (e *CheckStatus) Scan(src interface{}) error {
73
+	switch s := src.(type) {
74
+	case []byte:
75
+		*e = CheckStatus(s)
76
+	case string:
77
+		*e = CheckStatus(s)
78
+	default:
79
+		return fmt.Errorf("unsupported scan type for CheckStatus: %T", src)
80
+	}
81
+	return nil
82
+}
83
+
84
+type NullCheckStatus struct {
85
+	CheckStatus CheckStatus
86
+	Valid       bool // Valid is true if CheckStatus is not NULL
87
+}
88
+
89
+// Scan implements the Scanner interface.
90
+func (ns *NullCheckStatus) Scan(value interface{}) error {
91
+	if value == nil {
92
+		ns.CheckStatus, ns.Valid = "", false
93
+		return nil
94
+	}
95
+	ns.Valid = true
96
+	return ns.CheckStatus.Scan(value)
97
+}
98
+
99
+// Value implements the driver Valuer interface.
100
+func (ns NullCheckStatus) Value() (driver.Value, error) {
101
+	if !ns.Valid {
102
+		return nil, nil
103
+	}
104
+	return string(ns.CheckStatus), nil
105
+}
106
+
107
+type CollabRole string
108
+
109
+const (
110
+	CollabRoleRead     CollabRole = "read"
111
+	CollabRoleTriage   CollabRole = "triage"
112
+	CollabRoleWrite    CollabRole = "write"
113
+	CollabRoleMaintain CollabRole = "maintain"
114
+	CollabRoleAdmin    CollabRole = "admin"
115
+)
116
+
117
+func (e *CollabRole) Scan(src interface{}) error {
118
+	switch s := src.(type) {
119
+	case []byte:
120
+		*e = CollabRole(s)
121
+	case string:
122
+		*e = CollabRole(s)
123
+	default:
124
+		return fmt.Errorf("unsupported scan type for CollabRole: %T", src)
125
+	}
126
+	return nil
127
+}
128
+
129
+type NullCollabRole struct {
130
+	CollabRole CollabRole
131
+	Valid      bool // Valid is true if CollabRole is not NULL
132
+}
133
+
134
+// Scan implements the Scanner interface.
135
+func (ns *NullCollabRole) Scan(value interface{}) error {
136
+	if value == nil {
137
+		ns.CollabRole, ns.Valid = "", false
138
+		return nil
139
+	}
140
+	ns.Valid = true
141
+	return ns.CollabRole.Scan(value)
142
+}
143
+
144
+// Value implements the driver Valuer interface.
145
+func (ns NullCollabRole) Value() (driver.Value, error) {
146
+	if !ns.Valid {
147
+		return nil, nil
148
+	}
149
+	return string(ns.CollabRole), nil
150
+}
151
+
152
+type IssueKind string
153
+
154
+const (
155
+	IssueKindIssue IssueKind = "issue"
156
+	IssueKindPr    IssueKind = "pr"
157
+)
158
+
159
+func (e *IssueKind) Scan(src interface{}) error {
160
+	switch s := src.(type) {
161
+	case []byte:
162
+		*e = IssueKind(s)
163
+	case string:
164
+		*e = IssueKind(s)
165
+	default:
166
+		return fmt.Errorf("unsupported scan type for IssueKind: %T", src)
167
+	}
168
+	return nil
169
+}
170
+
171
+type NullIssueKind struct {
172
+	IssueKind IssueKind
173
+	Valid     bool // Valid is true if IssueKind is not NULL
174
+}
175
+
176
+// Scan implements the Scanner interface.
177
+func (ns *NullIssueKind) Scan(value interface{}) error {
178
+	if value == nil {
179
+		ns.IssueKind, ns.Valid = "", false
180
+		return nil
181
+	}
182
+	ns.Valid = true
183
+	return ns.IssueKind.Scan(value)
184
+}
185
+
186
+// Value implements the driver Valuer interface.
187
+func (ns NullIssueKind) Value() (driver.Value, error) {
188
+	if !ns.Valid {
189
+		return nil, nil
190
+	}
191
+	return string(ns.IssueKind), nil
192
+}
193
+
194
+type IssueRefSource string
195
+
196
+const (
197
+	IssueRefSourceCommentBody   IssueRefSource = "comment_body"
198
+	IssueRefSourceIssueBody     IssueRefSource = "issue_body"
199
+	IssueRefSourceCommitMessage IssueRefSource = "commit_message"
200
+)
201
+
202
+func (e *IssueRefSource) Scan(src interface{}) error {
203
+	switch s := src.(type) {
204
+	case []byte:
205
+		*e = IssueRefSource(s)
206
+	case string:
207
+		*e = IssueRefSource(s)
208
+	default:
209
+		return fmt.Errorf("unsupported scan type for IssueRefSource: %T", src)
210
+	}
211
+	return nil
212
+}
213
+
214
+type NullIssueRefSource struct {
215
+	IssueRefSource IssueRefSource
216
+	Valid          bool // Valid is true if IssueRefSource is not NULL
217
+}
218
+
219
+// Scan implements the Scanner interface.
220
+func (ns *NullIssueRefSource) Scan(value interface{}) error {
221
+	if value == nil {
222
+		ns.IssueRefSource, ns.Valid = "", false
223
+		return nil
224
+	}
225
+	ns.Valid = true
226
+	return ns.IssueRefSource.Scan(value)
227
+}
228
+
229
+// Value implements the driver Valuer interface.
230
+func (ns NullIssueRefSource) Value() (driver.Value, error) {
231
+	if !ns.Valid {
232
+		return nil, nil
233
+	}
234
+	return string(ns.IssueRefSource), nil
235
+}
236
+
237
+type IssueState string
238
+
239
+const (
240
+	IssueStateOpen   IssueState = "open"
241
+	IssueStateClosed IssueState = "closed"
242
+)
243
+
244
+func (e *IssueState) Scan(src interface{}) error {
245
+	switch s := src.(type) {
246
+	case []byte:
247
+		*e = IssueState(s)
248
+	case string:
249
+		*e = IssueState(s)
250
+	default:
251
+		return fmt.Errorf("unsupported scan type for IssueState: %T", src)
252
+	}
253
+	return nil
254
+}
255
+
256
+type NullIssueState struct {
257
+	IssueState IssueState
258
+	Valid      bool // Valid is true if IssueState is not NULL
259
+}
260
+
261
+// Scan implements the Scanner interface.
262
+func (ns *NullIssueState) Scan(value interface{}) error {
263
+	if value == nil {
264
+		ns.IssueState, ns.Valid = "", false
265
+		return nil
266
+	}
267
+	ns.Valid = true
268
+	return ns.IssueState.Scan(value)
269
+}
270
+
271
+// Value implements the driver Valuer interface.
272
+func (ns NullIssueState) Value() (driver.Value, error) {
273
+	if !ns.Valid {
274
+		return nil, nil
275
+	}
276
+	return string(ns.IssueState), nil
277
+}
278
+
279
+type IssueStateReason string
280
+
281
+const (
282
+	IssueStateReasonCompleted  IssueStateReason = "completed"
283
+	IssueStateReasonNotPlanned IssueStateReason = "not_planned"
284
+	IssueStateReasonReopened   IssueStateReason = "reopened"
285
+	IssueStateReasonDuplicate  IssueStateReason = "duplicate"
286
+)
287
+
288
+func (e *IssueStateReason) Scan(src interface{}) error {
289
+	switch s := src.(type) {
290
+	case []byte:
291
+		*e = IssueStateReason(s)
292
+	case string:
293
+		*e = IssueStateReason(s)
294
+	default:
295
+		return fmt.Errorf("unsupported scan type for IssueStateReason: %T", src)
296
+	}
297
+	return nil
298
+}
299
+
300
+type NullIssueStateReason struct {
301
+	IssueStateReason IssueStateReason
302
+	Valid            bool // Valid is true if IssueStateReason is not NULL
303
+}
304
+
305
+// Scan implements the Scanner interface.
306
+func (ns *NullIssueStateReason) Scan(value interface{}) error {
307
+	if value == nil {
308
+		ns.IssueStateReason, ns.Valid = "", false
309
+		return nil
310
+	}
311
+	ns.Valid = true
312
+	return ns.IssueStateReason.Scan(value)
313
+}
314
+
315
+// Value implements the driver Valuer interface.
316
+func (ns NullIssueStateReason) Value() (driver.Value, error) {
317
+	if !ns.Valid {
318
+		return nil, nil
319
+	}
320
+	return string(ns.IssueStateReason), nil
321
+}
322
+
323
+type MilestoneState string
324
+
325
+const (
326
+	MilestoneStateOpen   MilestoneState = "open"
327
+	MilestoneStateClosed MilestoneState = "closed"
328
+)
329
+
330
+func (e *MilestoneState) Scan(src interface{}) error {
331
+	switch s := src.(type) {
332
+	case []byte:
333
+		*e = MilestoneState(s)
334
+	case string:
335
+		*e = MilestoneState(s)
336
+	default:
337
+		return fmt.Errorf("unsupported scan type for MilestoneState: %T", src)
338
+	}
339
+	return nil
340
+}
341
+
342
+type NullMilestoneState struct {
343
+	MilestoneState MilestoneState
344
+	Valid          bool // Valid is true if MilestoneState is not NULL
345
+}
346
+
347
+// Scan implements the Scanner interface.
348
+func (ns *NullMilestoneState) Scan(value interface{}) error {
349
+	if value == nil {
350
+		ns.MilestoneState, ns.Valid = "", false
351
+		return nil
352
+	}
353
+	ns.Valid = true
354
+	return ns.MilestoneState.Scan(value)
355
+}
356
+
357
+// Value implements the driver Valuer interface.
358
+func (ns NullMilestoneState) Value() (driver.Value, error) {
359
+	if !ns.Valid {
360
+		return nil, nil
361
+	}
362
+	return string(ns.MilestoneState), nil
363
+}
364
+
365
+type NotificationThreadKind string
366
+
367
+const (
368
+	NotificationThreadKindIssue NotificationThreadKind = "issue"
369
+	NotificationThreadKindPr    NotificationThreadKind = "pr"
370
+)
371
+
372
+func (e *NotificationThreadKind) Scan(src interface{}) error {
373
+	switch s := src.(type) {
374
+	case []byte:
375
+		*e = NotificationThreadKind(s)
376
+	case string:
377
+		*e = NotificationThreadKind(s)
378
+	default:
379
+		return fmt.Errorf("unsupported scan type for NotificationThreadKind: %T", src)
380
+	}
381
+	return nil
382
+}
383
+
384
+type NullNotificationThreadKind struct {
385
+	NotificationThreadKind NotificationThreadKind
386
+	Valid                  bool // Valid is true if NotificationThreadKind is not NULL
387
+}
388
+
389
+// Scan implements the Scanner interface.
390
+func (ns *NullNotificationThreadKind) Scan(value interface{}) error {
391
+	if value == nil {
392
+		ns.NotificationThreadKind, ns.Valid = "", false
393
+		return nil
394
+	}
395
+	ns.Valid = true
396
+	return ns.NotificationThreadKind.Scan(value)
397
+}
398
+
399
+// Value implements the driver Valuer interface.
400
+func (ns NullNotificationThreadKind) Value() (driver.Value, error) {
401
+	if !ns.Valid {
402
+		return nil, nil
403
+	}
404
+	return string(ns.NotificationThreadKind), nil
405
+}
406
+
407
+type OrgPlan string
408
+
409
+const (
410
+	OrgPlanFree       OrgPlan = "free"
411
+	OrgPlanTeam       OrgPlan = "team"
412
+	OrgPlanEnterprise OrgPlan = "enterprise"
413
+)
414
+
415
+func (e *OrgPlan) Scan(src interface{}) error {
416
+	switch s := src.(type) {
417
+	case []byte:
418
+		*e = OrgPlan(s)
419
+	case string:
420
+		*e = OrgPlan(s)
421
+	default:
422
+		return fmt.Errorf("unsupported scan type for OrgPlan: %T", src)
423
+	}
424
+	return nil
425
+}
426
+
427
+type NullOrgPlan struct {
428
+	OrgPlan OrgPlan
429
+	Valid   bool // Valid is true if OrgPlan is not NULL
430
+}
431
+
432
+// Scan implements the Scanner interface.
433
+func (ns *NullOrgPlan) Scan(value interface{}) error {
434
+	if value == nil {
435
+		ns.OrgPlan, ns.Valid = "", false
436
+		return nil
437
+	}
438
+	ns.Valid = true
439
+	return ns.OrgPlan.Scan(value)
440
+}
441
+
442
+// Value implements the driver Valuer interface.
443
+func (ns NullOrgPlan) Value() (driver.Value, error) {
444
+	if !ns.Valid {
445
+		return nil, nil
446
+	}
447
+	return string(ns.OrgPlan), nil
448
+}
449
+
450
+type OrgRole string
451
+
452
+const (
453
+	OrgRoleOwner  OrgRole = "owner"
454
+	OrgRoleMember OrgRole = "member"
455
+)
456
+
457
+func (e *OrgRole) Scan(src interface{}) error {
458
+	switch s := src.(type) {
459
+	case []byte:
460
+		*e = OrgRole(s)
461
+	case string:
462
+		*e = OrgRole(s)
463
+	default:
464
+		return fmt.Errorf("unsupported scan type for OrgRole: %T", src)
465
+	}
466
+	return nil
467
+}
468
+
469
+type NullOrgRole struct {
470
+	OrgRole OrgRole
471
+	Valid   bool // Valid is true if OrgRole is not NULL
472
+}
473
+
474
+// Scan implements the Scanner interface.
475
+func (ns *NullOrgRole) Scan(value interface{}) error {
476
+	if value == nil {
477
+		ns.OrgRole, ns.Valid = "", false
478
+		return nil
479
+	}
480
+	ns.Valid = true
481
+	return ns.OrgRole.Scan(value)
482
+}
483
+
484
+// Value implements the driver Valuer interface.
485
+func (ns NullOrgRole) Value() (driver.Value, error) {
486
+	if !ns.Valid {
487
+		return nil, nil
488
+	}
489
+	return string(ns.OrgRole), nil
490
+}
491
+
492
+type PrFileStatus string
493
+
494
+const (
495
+	PrFileStatusAdded    PrFileStatus = "added"
496
+	PrFileStatusModified PrFileStatus = "modified"
497
+	PrFileStatusDeleted  PrFileStatus = "deleted"
498
+	PrFileStatusRenamed  PrFileStatus = "renamed"
499
+	PrFileStatusCopied   PrFileStatus = "copied"
500
+)
501
+
502
+func (e *PrFileStatus) Scan(src interface{}) error {
503
+	switch s := src.(type) {
504
+	case []byte:
505
+		*e = PrFileStatus(s)
506
+	case string:
507
+		*e = PrFileStatus(s)
508
+	default:
509
+		return fmt.Errorf("unsupported scan type for PrFileStatus: %T", src)
510
+	}
511
+	return nil
512
+}
513
+
514
+type NullPrFileStatus struct {
515
+	PrFileStatus PrFileStatus
516
+	Valid        bool // Valid is true if PrFileStatus is not NULL
517
+}
518
+
519
+// Scan implements the Scanner interface.
520
+func (ns *NullPrFileStatus) Scan(value interface{}) error {
521
+	if value == nil {
522
+		ns.PrFileStatus, ns.Valid = "", false
523
+		return nil
524
+	}
525
+	ns.Valid = true
526
+	return ns.PrFileStatus.Scan(value)
527
+}
528
+
529
+// Value implements the driver Valuer interface.
530
+func (ns NullPrFileStatus) Value() (driver.Value, error) {
531
+	if !ns.Valid {
532
+		return nil, nil
533
+	}
534
+	return string(ns.PrFileStatus), nil
535
+}
536
+
537
+type PrMergeMethod string
538
+
539
+const (
540
+	PrMergeMethodMerge  PrMergeMethod = "merge"
541
+	PrMergeMethodSquash PrMergeMethod = "squash"
542
+	PrMergeMethodRebase PrMergeMethod = "rebase"
543
+)
544
+
545
+func (e *PrMergeMethod) Scan(src interface{}) error {
546
+	switch s := src.(type) {
547
+	case []byte:
548
+		*e = PrMergeMethod(s)
549
+	case string:
550
+		*e = PrMergeMethod(s)
551
+	default:
552
+		return fmt.Errorf("unsupported scan type for PrMergeMethod: %T", src)
553
+	}
554
+	return nil
555
+}
556
+
557
+type NullPrMergeMethod struct {
558
+	PrMergeMethod PrMergeMethod
559
+	Valid         bool // Valid is true if PrMergeMethod is not NULL
560
+}
561
+
562
+// Scan implements the Scanner interface.
563
+func (ns *NullPrMergeMethod) Scan(value interface{}) error {
564
+	if value == nil {
565
+		ns.PrMergeMethod, ns.Valid = "", false
566
+		return nil
567
+	}
568
+	ns.Valid = true
569
+	return ns.PrMergeMethod.Scan(value)
570
+}
571
+
572
+// Value implements the driver Valuer interface.
573
+func (ns NullPrMergeMethod) Value() (driver.Value, error) {
574
+	if !ns.Valid {
575
+		return nil, nil
576
+	}
577
+	return string(ns.PrMergeMethod), nil
578
+}
579
+
580
+type PrMergeableState string
581
+
582
+const (
583
+	PrMergeableStateUnknown PrMergeableState = "unknown"
584
+	PrMergeableStateClean   PrMergeableState = "clean"
585
+	PrMergeableStateDirty   PrMergeableState = "dirty"
586
+	PrMergeableStateBlocked PrMergeableState = "blocked"
587
+	PrMergeableStateBehind  PrMergeableState = "behind"
588
+)
589
+
590
+func (e *PrMergeableState) Scan(src interface{}) error {
591
+	switch s := src.(type) {
592
+	case []byte:
593
+		*e = PrMergeableState(s)
594
+	case string:
595
+		*e = PrMergeableState(s)
596
+	default:
597
+		return fmt.Errorf("unsupported scan type for PrMergeableState: %T", src)
598
+	}
599
+	return nil
600
+}
601
+
602
+type NullPrMergeableState struct {
603
+	PrMergeableState PrMergeableState
604
+	Valid            bool // Valid is true if PrMergeableState is not NULL
605
+}
606
+
607
+// Scan implements the Scanner interface.
608
+func (ns *NullPrMergeableState) Scan(value interface{}) error {
609
+	if value == nil {
610
+		ns.PrMergeableState, ns.Valid = "", false
611
+		return nil
612
+	}
613
+	ns.Valid = true
614
+	return ns.PrMergeableState.Scan(value)
615
+}
616
+
617
+// Value implements the driver Valuer interface.
618
+func (ns NullPrMergeableState) Value() (driver.Value, error) {
619
+	if !ns.Valid {
620
+		return nil, nil
621
+	}
622
+	return string(ns.PrMergeableState), nil
623
+}
624
+
625
+type PrReviewSide string
626
+
627
+const (
628
+	PrReviewSideLeft  PrReviewSide = "left"
629
+	PrReviewSideRight PrReviewSide = "right"
630
+)
631
+
632
+func (e *PrReviewSide) Scan(src interface{}) error {
633
+	switch s := src.(type) {
634
+	case []byte:
635
+		*e = PrReviewSide(s)
636
+	case string:
637
+		*e = PrReviewSide(s)
638
+	default:
639
+		return fmt.Errorf("unsupported scan type for PrReviewSide: %T", src)
640
+	}
641
+	return nil
642
+}
643
+
644
+type NullPrReviewSide struct {
645
+	PrReviewSide PrReviewSide
646
+	Valid        bool // Valid is true if PrReviewSide is not NULL
647
+}
648
+
649
+// Scan implements the Scanner interface.
650
+func (ns *NullPrReviewSide) Scan(value interface{}) error {
651
+	if value == nil {
652
+		ns.PrReviewSide, ns.Valid = "", false
653
+		return nil
654
+	}
655
+	ns.Valid = true
656
+	return ns.PrReviewSide.Scan(value)
657
+}
658
+
659
+// Value implements the driver Valuer interface.
660
+func (ns NullPrReviewSide) Value() (driver.Value, error) {
661
+	if !ns.Valid {
662
+		return nil, nil
663
+	}
664
+	return string(ns.PrReviewSide), nil
665
+}
666
+
667
+type PrReviewState string
668
+
669
+const (
670
+	PrReviewStateComment        PrReviewState = "comment"
671
+	PrReviewStateApprove        PrReviewState = "approve"
672
+	PrReviewStateRequestChanges PrReviewState = "request_changes"
673
+)
674
+
675
+func (e *PrReviewState) Scan(src interface{}) error {
676
+	switch s := src.(type) {
677
+	case []byte:
678
+		*e = PrReviewState(s)
679
+	case string:
680
+		*e = PrReviewState(s)
681
+	default:
682
+		return fmt.Errorf("unsupported scan type for PrReviewState: %T", src)
683
+	}
684
+	return nil
685
+}
686
+
687
+type NullPrReviewState struct {
688
+	PrReviewState PrReviewState
689
+	Valid         bool // Valid is true if PrReviewState is not NULL
690
+}
691
+
692
+// Scan implements the Scanner interface.
693
+func (ns *NullPrReviewState) Scan(value interface{}) error {
694
+	if value == nil {
695
+		ns.PrReviewState, ns.Valid = "", false
696
+		return nil
697
+	}
698
+	ns.Valid = true
699
+	return ns.PrReviewState.Scan(value)
700
+}
701
+
702
+// Value implements the driver Valuer interface.
703
+func (ns NullPrReviewState) Value() (driver.Value, error) {
704
+	if !ns.Valid {
705
+		return nil, nil
706
+	}
707
+	return string(ns.PrReviewState), nil
708
+}
709
+
710
+type PrincipalKind string
711
+
712
+const (
713
+	PrincipalKindUser PrincipalKind = "user"
714
+	PrincipalKindOrg  PrincipalKind = "org"
715
+)
716
+
717
+func (e *PrincipalKind) Scan(src interface{}) error {
718
+	switch s := src.(type) {
719
+	case []byte:
720
+		*e = PrincipalKind(s)
721
+	case string:
722
+		*e = PrincipalKind(s)
723
+	default:
724
+		return fmt.Errorf("unsupported scan type for PrincipalKind: %T", src)
725
+	}
726
+	return nil
727
+}
728
+
729
+type NullPrincipalKind struct {
730
+	PrincipalKind PrincipalKind
731
+	Valid         bool // Valid is true if PrincipalKind is not NULL
732
+}
733
+
734
+// Scan implements the Scanner interface.
735
+func (ns *NullPrincipalKind) Scan(value interface{}) error {
736
+	if value == nil {
737
+		ns.PrincipalKind, ns.Valid = "", false
738
+		return nil
739
+	}
740
+	ns.Valid = true
741
+	return ns.PrincipalKind.Scan(value)
742
+}
743
+
744
+// Value implements the driver Valuer interface.
745
+func (ns NullPrincipalKind) Value() (driver.Value, error) {
746
+	if !ns.Valid {
747
+		return nil, nil
748
+	}
749
+	return string(ns.PrincipalKind), nil
750
+}
751
+
752
+type RepoInitStatus string
753
+
754
+const (
755
+	RepoInitStatusInitialized RepoInitStatus = "initialized"
756
+	RepoInitStatusInitPending RepoInitStatus = "init_pending"
757
+	RepoInitStatusInitFailed  RepoInitStatus = "init_failed"
758
+)
759
+
760
+func (e *RepoInitStatus) Scan(src interface{}) error {
761
+	switch s := src.(type) {
762
+	case []byte:
763
+		*e = RepoInitStatus(s)
764
+	case string:
765
+		*e = RepoInitStatus(s)
766
+	default:
767
+		return fmt.Errorf("unsupported scan type for RepoInitStatus: %T", src)
768
+	}
769
+	return nil
770
+}
771
+
772
+type NullRepoInitStatus struct {
773
+	RepoInitStatus RepoInitStatus
774
+	Valid          bool // Valid is true if RepoInitStatus is not NULL
775
+}
776
+
777
+// Scan implements the Scanner interface.
778
+func (ns *NullRepoInitStatus) Scan(value interface{}) error {
779
+	if value == nil {
780
+		ns.RepoInitStatus, ns.Valid = "", false
781
+		return nil
782
+	}
783
+	ns.Valid = true
784
+	return ns.RepoInitStatus.Scan(value)
785
+}
786
+
787
+// Value implements the driver Valuer interface.
788
+func (ns NullRepoInitStatus) Value() (driver.Value, error) {
789
+	if !ns.Valid {
790
+		return nil, nil
791
+	}
792
+	return string(ns.RepoInitStatus), nil
793
+}
794
+
795
+type RepoVisibility string
796
+
797
+const (
798
+	RepoVisibilityPublic  RepoVisibility = "public"
799
+	RepoVisibilityPrivate RepoVisibility = "private"
800
+)
801
+
802
+func (e *RepoVisibility) Scan(src interface{}) error {
803
+	switch s := src.(type) {
804
+	case []byte:
805
+		*e = RepoVisibility(s)
806
+	case string:
807
+		*e = RepoVisibility(s)
808
+	default:
809
+		return fmt.Errorf("unsupported scan type for RepoVisibility: %T", src)
810
+	}
811
+	return nil
812
+}
813
+
814
+type NullRepoVisibility struct {
815
+	RepoVisibility RepoVisibility
816
+	Valid          bool // Valid is true if RepoVisibility is not NULL
817
+}
818
+
819
+// Scan implements the Scanner interface.
820
+func (ns *NullRepoVisibility) Scan(value interface{}) error {
821
+	if value == nil {
822
+		ns.RepoVisibility, ns.Valid = "", false
823
+		return nil
824
+	}
825
+	ns.Valid = true
826
+	return ns.RepoVisibility.Scan(value)
827
+}
828
+
829
+// Value implements the driver Valuer interface.
830
+func (ns NullRepoVisibility) Value() (driver.Value, error) {
831
+	if !ns.Valid {
832
+		return nil, nil
833
+	}
834
+	return string(ns.RepoVisibility), nil
835
+}
836
+
837
+type TeamPrivacy string
838
+
839
+const (
840
+	TeamPrivacyVisible TeamPrivacy = "visible"
841
+	TeamPrivacySecret  TeamPrivacy = "secret"
842
+)
843
+
844
+func (e *TeamPrivacy) Scan(src interface{}) error {
845
+	switch s := src.(type) {
846
+	case []byte:
847
+		*e = TeamPrivacy(s)
848
+	case string:
849
+		*e = TeamPrivacy(s)
850
+	default:
851
+		return fmt.Errorf("unsupported scan type for TeamPrivacy: %T", src)
852
+	}
853
+	return nil
854
+}
855
+
856
+type NullTeamPrivacy struct {
857
+	TeamPrivacy TeamPrivacy
858
+	Valid       bool // Valid is true if TeamPrivacy is not NULL
859
+}
860
+
861
+// Scan implements the Scanner interface.
862
+func (ns *NullTeamPrivacy) Scan(value interface{}) error {
863
+	if value == nil {
864
+		ns.TeamPrivacy, ns.Valid = "", false
865
+		return nil
866
+	}
867
+	ns.Valid = true
868
+	return ns.TeamPrivacy.Scan(value)
869
+}
870
+
871
+// Value implements the driver Valuer interface.
872
+func (ns NullTeamPrivacy) Value() (driver.Value, error) {
873
+	if !ns.Valid {
874
+		return nil, nil
875
+	}
876
+	return string(ns.TeamPrivacy), nil
877
+}
878
+
879
+type TeamRepoRole string
880
+
881
+const (
882
+	TeamRepoRoleRead     TeamRepoRole = "read"
883
+	TeamRepoRoleTriage   TeamRepoRole = "triage"
884
+	TeamRepoRoleWrite    TeamRepoRole = "write"
885
+	TeamRepoRoleMaintain TeamRepoRole = "maintain"
886
+	TeamRepoRoleAdmin    TeamRepoRole = "admin"
887
+)
888
+
889
+func (e *TeamRepoRole) Scan(src interface{}) error {
890
+	switch s := src.(type) {
891
+	case []byte:
892
+		*e = TeamRepoRole(s)
893
+	case string:
894
+		*e = TeamRepoRole(s)
895
+	default:
896
+		return fmt.Errorf("unsupported scan type for TeamRepoRole: %T", src)
897
+	}
898
+	return nil
899
+}
900
+
901
+type NullTeamRepoRole struct {
902
+	TeamRepoRole TeamRepoRole
903
+	Valid        bool // Valid is true if TeamRepoRole is not NULL
904
+}
905
+
906
+// Scan implements the Scanner interface.
907
+func (ns *NullTeamRepoRole) Scan(value interface{}) error {
908
+	if value == nil {
909
+		ns.TeamRepoRole, ns.Valid = "", false
910
+		return nil
911
+	}
912
+	ns.Valid = true
913
+	return ns.TeamRepoRole.Scan(value)
914
+}
915
+
916
+// Value implements the driver Valuer interface.
917
+func (ns NullTeamRepoRole) Value() (driver.Value, error) {
918
+	if !ns.Valid {
919
+		return nil, nil
920
+	}
921
+	return string(ns.TeamRepoRole), nil
922
+}
923
+
924
+type TeamRole string
925
+
926
+const (
927
+	TeamRoleMember     TeamRole = "member"
928
+	TeamRoleMaintainer TeamRole = "maintainer"
929
+)
930
+
931
+func (e *TeamRole) Scan(src interface{}) error {
932
+	switch s := src.(type) {
933
+	case []byte:
934
+		*e = TeamRole(s)
935
+	case string:
936
+		*e = TeamRole(s)
937
+	default:
938
+		return fmt.Errorf("unsupported scan type for TeamRole: %T", src)
939
+	}
940
+	return nil
941
+}
942
+
943
+type NullTeamRole struct {
944
+	TeamRole TeamRole
945
+	Valid    bool // Valid is true if TeamRole is not NULL
946
+}
947
+
948
+// Scan implements the Scanner interface.
949
+func (ns *NullTeamRole) Scan(value interface{}) error {
950
+	if value == nil {
951
+		ns.TeamRole, ns.Valid = "", false
952
+		return nil
953
+	}
954
+	ns.Valid = true
955
+	return ns.TeamRole.Scan(value)
956
+}
957
+
958
+// Value implements the driver Valuer interface.
959
+func (ns NullTeamRole) Value() (driver.Value, error) {
960
+	if !ns.Valid {
961
+		return nil, nil
962
+	}
963
+	return string(ns.TeamRole), nil
964
+}
965
+
966
+type TransactionalEmailStatus string
967
+
968
+const (
969
+	TransactionalEmailStatusQueued      TransactionalEmailStatus = "queued"
970
+	TransactionalEmailStatusSent        TransactionalEmailStatus = "sent"
971
+	TransactionalEmailStatusSoftBounced TransactionalEmailStatus = "soft_bounced"
972
+	TransactionalEmailStatusHardBounced TransactionalEmailStatus = "hard_bounced"
973
+	TransactionalEmailStatusDropped     TransactionalEmailStatus = "dropped"
974
+)
975
+
976
+func (e *TransactionalEmailStatus) Scan(src interface{}) error {
977
+	switch s := src.(type) {
978
+	case []byte:
979
+		*e = TransactionalEmailStatus(s)
980
+	case string:
981
+		*e = TransactionalEmailStatus(s)
982
+	default:
983
+		return fmt.Errorf("unsupported scan type for TransactionalEmailStatus: %T", src)
984
+	}
985
+	return nil
986
+}
987
+
988
+type NullTransactionalEmailStatus struct {
989
+	TransactionalEmailStatus TransactionalEmailStatus
990
+	Valid                    bool // Valid is true if TransactionalEmailStatus is not NULL
991
+}
992
+
993
+// Scan implements the Scanner interface.
994
+func (ns *NullTransactionalEmailStatus) Scan(value interface{}) error {
995
+	if value == nil {
996
+		ns.TransactionalEmailStatus, ns.Valid = "", false
997
+		return nil
998
+	}
999
+	ns.Valid = true
1000
+	return ns.TransactionalEmailStatus.Scan(value)
1001
+}
1002
+
1003
+// Value implements the driver Valuer interface.
1004
+func (ns NullTransactionalEmailStatus) Value() (driver.Value, error) {
1005
+	if !ns.Valid {
1006
+		return nil, nil
1007
+	}
1008
+	return string(ns.TransactionalEmailStatus), nil
1009
+}
1010
+
1011
+type TransferPrincipalKind string
1012
+
1013
+const (
1014
+	TransferPrincipalKindUser TransferPrincipalKind = "user"
1015
+	TransferPrincipalKindOrg  TransferPrincipalKind = "org"
1016
+)
1017
+
1018
+func (e *TransferPrincipalKind) Scan(src interface{}) error {
1019
+	switch s := src.(type) {
1020
+	case []byte:
1021
+		*e = TransferPrincipalKind(s)
1022
+	case string:
1023
+		*e = TransferPrincipalKind(s)
1024
+	default:
1025
+		return fmt.Errorf("unsupported scan type for TransferPrincipalKind: %T", src)
1026
+	}
1027
+	return nil
1028
+}
1029
+
1030
+type NullTransferPrincipalKind struct {
1031
+	TransferPrincipalKind TransferPrincipalKind
1032
+	Valid                 bool // Valid is true if TransferPrincipalKind is not NULL
1033
+}
1034
+
1035
+// Scan implements the Scanner interface.
1036
+func (ns *NullTransferPrincipalKind) Scan(value interface{}) error {
1037
+	if value == nil {
1038
+		ns.TransferPrincipalKind, ns.Valid = "", false
1039
+		return nil
1040
+	}
1041
+	ns.Valid = true
1042
+	return ns.TransferPrincipalKind.Scan(value)
1043
+}
1044
+
1045
+// Value implements the driver Valuer interface.
1046
+func (ns NullTransferPrincipalKind) Value() (driver.Value, error) {
1047
+	if !ns.Valid {
1048
+		return nil, nil
1049
+	}
1050
+	return string(ns.TransferPrincipalKind), nil
1051
+}
1052
+
1053
+type TransferStatus string
1054
+
1055
+const (
1056
+	TransferStatusPending  TransferStatus = "pending"
1057
+	TransferStatusAccepted TransferStatus = "accepted"
1058
+	TransferStatusDeclined TransferStatus = "declined"
1059
+	TransferStatusCanceled TransferStatus = "canceled"
1060
+	TransferStatusExpired  TransferStatus = "expired"
1061
+)
1062
+
1063
+func (e *TransferStatus) Scan(src interface{}) error {
1064
+	switch s := src.(type) {
1065
+	case []byte:
1066
+		*e = TransferStatus(s)
1067
+	case string:
1068
+		*e = TransferStatus(s)
1069
+	default:
1070
+		return fmt.Errorf("unsupported scan type for TransferStatus: %T", src)
1071
+	}
1072
+	return nil
1073
+}
1074
+
1075
+type NullTransferStatus struct {
1076
+	TransferStatus TransferStatus
1077
+	Valid          bool // Valid is true if TransferStatus is not NULL
1078
+}
1079
+
1080
+// Scan implements the Scanner interface.
1081
+func (ns *NullTransferStatus) Scan(value interface{}) error {
1082
+	if value == nil {
1083
+		ns.TransferStatus, ns.Valid = "", false
1084
+		return nil
1085
+	}
1086
+	ns.Valid = true
1087
+	return ns.TransferStatus.Scan(value)
1088
+}
1089
+
1090
+// Value implements the driver Valuer interface.
1091
+func (ns NullTransferStatus) Value() (driver.Value, error) {
1092
+	if !ns.Valid {
1093
+		return nil, nil
1094
+	}
1095
+	return string(ns.TransferStatus), nil
1096
+}
1097
+
1098
+type WatchLevel string
1099
+
1100
+const (
1101
+	WatchLevelAll           WatchLevel = "all"
1102
+	WatchLevelParticipating WatchLevel = "participating"
1103
+	WatchLevelIgnore        WatchLevel = "ignore"
1104
+)
1105
+
1106
+func (e *WatchLevel) Scan(src interface{}) error {
1107
+	switch s := src.(type) {
1108
+	case []byte:
1109
+		*e = WatchLevel(s)
1110
+	case string:
1111
+		*e = WatchLevel(s)
1112
+	default:
1113
+		return fmt.Errorf("unsupported scan type for WatchLevel: %T", src)
1114
+	}
1115
+	return nil
1116
+}
1117
+
1118
+type NullWatchLevel struct {
1119
+	WatchLevel WatchLevel
1120
+	Valid      bool // Valid is true if WatchLevel is not NULL
1121
+}
1122
+
1123
+// Scan implements the Scanner interface.
1124
+func (ns *NullWatchLevel) Scan(value interface{}) error {
1125
+	if value == nil {
1126
+		ns.WatchLevel, ns.Valid = "", false
1127
+		return nil
1128
+	}
1129
+	ns.Valid = true
1130
+	return ns.WatchLevel.Scan(value)
1131
+}
1132
+
1133
+// Value implements the driver Valuer interface.
1134
+func (ns NullWatchLevel) Value() (driver.Value, error) {
1135
+	if !ns.Valid {
1136
+		return nil, nil
1137
+	}
1138
+	return string(ns.WatchLevel), nil
1139
+}
1140
+
1141
+type WebhookContentType string
1142
+
1143
+const (
1144
+	WebhookContentTypeJson WebhookContentType = "json"
1145
+	WebhookContentTypeForm WebhookContentType = "form"
1146
+)
1147
+
1148
+func (e *WebhookContentType) Scan(src interface{}) error {
1149
+	switch s := src.(type) {
1150
+	case []byte:
1151
+		*e = WebhookContentType(s)
1152
+	case string:
1153
+		*e = WebhookContentType(s)
1154
+	default:
1155
+		return fmt.Errorf("unsupported scan type for WebhookContentType: %T", src)
1156
+	}
1157
+	return nil
1158
+}
1159
+
1160
+type NullWebhookContentType struct {
1161
+	WebhookContentType WebhookContentType
1162
+	Valid              bool // Valid is true if WebhookContentType is not NULL
1163
+}
1164
+
1165
+// Scan implements the Scanner interface.
1166
+func (ns *NullWebhookContentType) Scan(value interface{}) error {
1167
+	if value == nil {
1168
+		ns.WebhookContentType, ns.Valid = "", false
1169
+		return nil
1170
+	}
1171
+	ns.Valid = true
1172
+	return ns.WebhookContentType.Scan(value)
1173
+}
1174
+
1175
+// Value implements the driver Valuer interface.
1176
+func (ns NullWebhookContentType) Value() (driver.Value, error) {
1177
+	if !ns.Valid {
1178
+		return nil, nil
1179
+	}
1180
+	return string(ns.WebhookContentType), nil
1181
+}
1182
+
1183
+type WebhookDeliveryStatus string
1184
+
1185
+const (
1186
+	WebhookDeliveryStatusPending         WebhookDeliveryStatus = "pending"
1187
+	WebhookDeliveryStatusSucceeded       WebhookDeliveryStatus = "succeeded"
1188
+	WebhookDeliveryStatusFailedRetry     WebhookDeliveryStatus = "failed_retry"
1189
+	WebhookDeliveryStatusFailedPermanent WebhookDeliveryStatus = "failed_permanent"
1190
+)
1191
+
1192
+func (e *WebhookDeliveryStatus) Scan(src interface{}) error {
1193
+	switch s := src.(type) {
1194
+	case []byte:
1195
+		*e = WebhookDeliveryStatus(s)
1196
+	case string:
1197
+		*e = WebhookDeliveryStatus(s)
1198
+	default:
1199
+		return fmt.Errorf("unsupported scan type for WebhookDeliveryStatus: %T", src)
1200
+	}
1201
+	return nil
1202
+}
1203
+
1204
+type NullWebhookDeliveryStatus struct {
1205
+	WebhookDeliveryStatus WebhookDeliveryStatus
1206
+	Valid                 bool // Valid is true if WebhookDeliveryStatus is not NULL
1207
+}
1208
+
1209
+// Scan implements the Scanner interface.
1210
+func (ns *NullWebhookDeliveryStatus) Scan(value interface{}) error {
1211
+	if value == nil {
1212
+		ns.WebhookDeliveryStatus, ns.Valid = "", false
1213
+		return nil
1214
+	}
1215
+	ns.Valid = true
1216
+	return ns.WebhookDeliveryStatus.Scan(value)
1217
+}
1218
+
1219
+// Value implements the driver Valuer interface.
1220
+func (ns NullWebhookDeliveryStatus) Value() (driver.Value, error) {
1221
+	if !ns.Valid {
1222
+		return nil, nil
1223
+	}
1224
+	return string(ns.WebhookDeliveryStatus), nil
1225
+}
1226
+
1227
+type WebhookOwnerKind string
1228
+
1229
+const (
1230
+	WebhookOwnerKindRepo WebhookOwnerKind = "repo"
1231
+	WebhookOwnerKindOrg  WebhookOwnerKind = "org"
1232
+)
1233
+
1234
+func (e *WebhookOwnerKind) Scan(src interface{}) error {
1235
+	switch s := src.(type) {
1236
+	case []byte:
1237
+		*e = WebhookOwnerKind(s)
1238
+	case string:
1239
+		*e = WebhookOwnerKind(s)
1240
+	default:
1241
+		return fmt.Errorf("unsupported scan type for WebhookOwnerKind: %T", src)
1242
+	}
1243
+	return nil
1244
+}
1245
+
1246
+type NullWebhookOwnerKind struct {
1247
+	WebhookOwnerKind WebhookOwnerKind
1248
+	Valid            bool // Valid is true if WebhookOwnerKind is not NULL
1249
+}
1250
+
1251
+// Scan implements the Scanner interface.
1252
+func (ns *NullWebhookOwnerKind) Scan(value interface{}) error {
1253
+	if value == nil {
1254
+		ns.WebhookOwnerKind, ns.Valid = "", false
1255
+		return nil
1256
+	}
1257
+	ns.Valid = true
1258
+	return ns.WebhookOwnerKind.Scan(value)
1259
+}
1260
+
1261
+// Value implements the driver Valuer interface.
1262
+func (ns NullWebhookOwnerKind) Value() (driver.Value, error) {
1263
+	if !ns.Valid {
1264
+		return nil, nil
1265
+	}
1266
+	return string(ns.WebhookOwnerKind), nil
1267
+}
1268
+
1269
+type WorkflowJobStatus string
1270
+
1271
+const (
1272
+	WorkflowJobStatusQueued    WorkflowJobStatus = "queued"
1273
+	WorkflowJobStatusRunning   WorkflowJobStatus = "running"
1274
+	WorkflowJobStatusCompleted WorkflowJobStatus = "completed"
1275
+	WorkflowJobStatusCancelled WorkflowJobStatus = "cancelled"
1276
+	WorkflowJobStatusSkipped   WorkflowJobStatus = "skipped"
1277
+)
1278
+
1279
+func (e *WorkflowJobStatus) Scan(src interface{}) error {
1280
+	switch s := src.(type) {
1281
+	case []byte:
1282
+		*e = WorkflowJobStatus(s)
1283
+	case string:
1284
+		*e = WorkflowJobStatus(s)
1285
+	default:
1286
+		return fmt.Errorf("unsupported scan type for WorkflowJobStatus: %T", src)
1287
+	}
1288
+	return nil
1289
+}
1290
+
1291
+type NullWorkflowJobStatus struct {
1292
+	WorkflowJobStatus WorkflowJobStatus
1293
+	Valid             bool // Valid is true if WorkflowJobStatus is not NULL
1294
+}
1295
+
1296
+// Scan implements the Scanner interface.
1297
+func (ns *NullWorkflowJobStatus) Scan(value interface{}) error {
1298
+	if value == nil {
1299
+		ns.WorkflowJobStatus, ns.Valid = "", false
1300
+		return nil
1301
+	}
1302
+	ns.Valid = true
1303
+	return ns.WorkflowJobStatus.Scan(value)
1304
+}
1305
+
1306
+// Value implements the driver Valuer interface.
1307
+func (ns NullWorkflowJobStatus) Value() (driver.Value, error) {
1308
+	if !ns.Valid {
1309
+		return nil, nil
1310
+	}
1311
+	return string(ns.WorkflowJobStatus), nil
1312
+}
1313
+
1314
+type WorkflowRunEvent string
1315
+
1316
+const (
1317
+	WorkflowRunEventPush             WorkflowRunEvent = "push"
1318
+	WorkflowRunEventPullRequest      WorkflowRunEvent = "pull_request"
1319
+	WorkflowRunEventSchedule         WorkflowRunEvent = "schedule"
1320
+	WorkflowRunEventWorkflowDispatch WorkflowRunEvent = "workflow_dispatch"
1321
+)
1322
+
1323
+func (e *WorkflowRunEvent) Scan(src interface{}) error {
1324
+	switch s := src.(type) {
1325
+	case []byte:
1326
+		*e = WorkflowRunEvent(s)
1327
+	case string:
1328
+		*e = WorkflowRunEvent(s)
1329
+	default:
1330
+		return fmt.Errorf("unsupported scan type for WorkflowRunEvent: %T", src)
1331
+	}
1332
+	return nil
1333
+}
1334
+
1335
+type NullWorkflowRunEvent struct {
1336
+	WorkflowRunEvent WorkflowRunEvent
1337
+	Valid            bool // Valid is true if WorkflowRunEvent is not NULL
1338
+}
1339
+
1340
+// Scan implements the Scanner interface.
1341
+func (ns *NullWorkflowRunEvent) Scan(value interface{}) error {
1342
+	if value == nil {
1343
+		ns.WorkflowRunEvent, ns.Valid = "", false
1344
+		return nil
1345
+	}
1346
+	ns.Valid = true
1347
+	return ns.WorkflowRunEvent.Scan(value)
1348
+}
1349
+
1350
+// Value implements the driver Valuer interface.
1351
+func (ns NullWorkflowRunEvent) Value() (driver.Value, error) {
1352
+	if !ns.Valid {
1353
+		return nil, nil
1354
+	}
1355
+	return string(ns.WorkflowRunEvent), nil
1356
+}
1357
+
1358
+type WorkflowRunStatus string
1359
+
1360
+const (
1361
+	WorkflowRunStatusQueued    WorkflowRunStatus = "queued"
1362
+	WorkflowRunStatusRunning   WorkflowRunStatus = "running"
1363
+	WorkflowRunStatusCompleted WorkflowRunStatus = "completed"
1364
+	WorkflowRunStatusCancelled WorkflowRunStatus = "cancelled"
1365
+)
1366
+
1367
+func (e *WorkflowRunStatus) Scan(src interface{}) error {
1368
+	switch s := src.(type) {
1369
+	case []byte:
1370
+		*e = WorkflowRunStatus(s)
1371
+	case string:
1372
+		*e = WorkflowRunStatus(s)
1373
+	default:
1374
+		return fmt.Errorf("unsupported scan type for WorkflowRunStatus: %T", src)
1375
+	}
1376
+	return nil
1377
+}
1378
+
1379
+type NullWorkflowRunStatus struct {
1380
+	WorkflowRunStatus WorkflowRunStatus
1381
+	Valid             bool // Valid is true if WorkflowRunStatus is not NULL
1382
+}
1383
+
1384
+// Scan implements the Scanner interface.
1385
+func (ns *NullWorkflowRunStatus) Scan(value interface{}) error {
1386
+	if value == nil {
1387
+		ns.WorkflowRunStatus, ns.Valid = "", false
1388
+		return nil
1389
+	}
1390
+	ns.Valid = true
1391
+	return ns.WorkflowRunStatus.Scan(value)
1392
+}
1393
+
1394
+// Value implements the driver Valuer interface.
1395
+func (ns NullWorkflowRunStatus) Value() (driver.Value, error) {
1396
+	if !ns.Valid {
1397
+		return nil, nil
1398
+	}
1399
+	return string(ns.WorkflowRunStatus), nil
1400
+}
1401
+
1402
+type WorkflowRunnerStatus string
1403
+
1404
+const (
1405
+	WorkflowRunnerStatusIdle    WorkflowRunnerStatus = "idle"
1406
+	WorkflowRunnerStatusBusy    WorkflowRunnerStatus = "busy"
1407
+	WorkflowRunnerStatusOffline WorkflowRunnerStatus = "offline"
1408
+)
1409
+
1410
+func (e *WorkflowRunnerStatus) Scan(src interface{}) error {
1411
+	switch s := src.(type) {
1412
+	case []byte:
1413
+		*e = WorkflowRunnerStatus(s)
1414
+	case string:
1415
+		*e = WorkflowRunnerStatus(s)
1416
+	default:
1417
+		return fmt.Errorf("unsupported scan type for WorkflowRunnerStatus: %T", src)
1418
+	}
1419
+	return nil
1420
+}
1421
+
1422
+type NullWorkflowRunnerStatus struct {
1423
+	WorkflowRunnerStatus WorkflowRunnerStatus
1424
+	Valid                bool // Valid is true if WorkflowRunnerStatus is not NULL
1425
+}
1426
+
1427
+// Scan implements the Scanner interface.
1428
+func (ns *NullWorkflowRunnerStatus) Scan(value interface{}) error {
1429
+	if value == nil {
1430
+		ns.WorkflowRunnerStatus, ns.Valid = "", false
1431
+		return nil
1432
+	}
1433
+	ns.Valid = true
1434
+	return ns.WorkflowRunnerStatus.Scan(value)
1435
+}
1436
+
1437
+// Value implements the driver Valuer interface.
1438
+func (ns NullWorkflowRunnerStatus) Value() (driver.Value, error) {
1439
+	if !ns.Valid {
1440
+		return nil, nil
1441
+	}
1442
+	return string(ns.WorkflowRunnerStatus), nil
1443
+}
1444
+
1445
+type WorkflowStepStatus string
1446
+
1447
+const (
1448
+	WorkflowStepStatusQueued    WorkflowStepStatus = "queued"
1449
+	WorkflowStepStatusRunning   WorkflowStepStatus = "running"
1450
+	WorkflowStepStatusCompleted WorkflowStepStatus = "completed"
1451
+	WorkflowStepStatusCancelled WorkflowStepStatus = "cancelled"
1452
+	WorkflowStepStatusSkipped   WorkflowStepStatus = "skipped"
1453
+)
1454
+
1455
+func (e *WorkflowStepStatus) Scan(src interface{}) error {
1456
+	switch s := src.(type) {
1457
+	case []byte:
1458
+		*e = WorkflowStepStatus(s)
1459
+	case string:
1460
+		*e = WorkflowStepStatus(s)
1461
+	default:
1462
+		return fmt.Errorf("unsupported scan type for WorkflowStepStatus: %T", src)
1463
+	}
1464
+	return nil
1465
+}
1466
+
1467
+type NullWorkflowStepStatus struct {
1468
+	WorkflowStepStatus WorkflowStepStatus
1469
+	Valid              bool // Valid is true if WorkflowStepStatus is not NULL
1470
+}
1471
+
1472
+// Scan implements the Scanner interface.
1473
+func (ns *NullWorkflowStepStatus) Scan(value interface{}) error {
1474
+	if value == nil {
1475
+		ns.WorkflowStepStatus, ns.Valid = "", false
1476
+		return nil
1477
+	}
1478
+	ns.Valid = true
1479
+	return ns.WorkflowStepStatus.Scan(value)
1480
+}
1481
+
1482
+// Value implements the driver Valuer interface.
1483
+func (ns NullWorkflowStepStatus) Value() (driver.Value, error) {
1484
+	if !ns.Valid {
1485
+		return nil, nil
1486
+	}
1487
+	return string(ns.WorkflowStepStatus), nil
1488
+}
1489
+
1490
+type ActionsVariable struct {
1491
+	ID              int64
1492
+	RepoID          pgtype.Int8
1493
+	OrgID           pgtype.Int8
1494
+	Name            string
1495
+	Value           string
1496
+	CreatedByUserID pgtype.Int8
1497
+	CreatedAt       pgtype.Timestamptz
1498
+	UpdatedAt       pgtype.Timestamptz
1499
+}
1500
+
1501
+type AuthAuditLog struct {
1502
+	ID         int64
1503
+	ActorID    pgtype.Int8
1504
+	Action     string
1505
+	TargetType string
1506
+	TargetID   pgtype.Int8
1507
+	Meta       []byte
1508
+	CreatedAt  pgtype.Timestamptz
1509
+}
1510
+
1511
+type AuthThrottle struct {
1512
+	ID              int64
1513
+	Scope           string
1514
+	Identifier      string
1515
+	Hits            int32
1516
+	WindowStartedAt pgtype.Timestamptz
1517
+}
1518
+
1519
+type BranchProtectionRule struct {
1520
+	ID                             int64
1521
+	RepoID                         int64
1522
+	Pattern                        string
1523
+	PreventForcePush               bool
1524
+	PreventDeletion                bool
1525
+	RequirePrForPush               bool
1526
+	AllowedPusherUserIds           []int64
1527
+	RequireSignedCommits           bool
1528
+	StatusChecksRequired           []string
1529
+	CreatedAt                      pgtype.Timestamptz
1530
+	UpdatedAt                      pgtype.Timestamptz
1531
+	CreatedByUserID                pgtype.Int8
1532
+	RequiredReviewCount            int32
1533
+	DismissStaleReviewsOnPush      bool
1534
+	RequireCodeOwnerReview         bool
1535
+	DismissStaleStatusChecksOnPush bool
1536
+}
1537
+
1538
+type CheckRun struct {
1539
+	ID          int64
1540
+	SuiteID     int64
1541
+	RepoID      int64
1542
+	HeadSha     string
1543
+	Name        string
1544
+	Status      CheckStatus
1545
+	Conclusion  NullCheckConclusion
1546
+	StartedAt   pgtype.Timestamptz
1547
+	CompletedAt pgtype.Timestamptz
1548
+	DetailsUrl  string
1549
+	Output      []byte
1550
+	ExternalID  pgtype.Text
1551
+	CreatedAt   pgtype.Timestamptz
1552
+	UpdatedAt   pgtype.Timestamptz
1553
+}
1554
+
1555
+type CheckSuite struct {
1556
+	ID         int64
1557
+	RepoID     int64
1558
+	HeadSha    string
1559
+	AppSlug    string
1560
+	Status     CheckStatus
1561
+	Conclusion NullCheckConclusion
1562
+	CreatedAt  pgtype.Timestamptz
1563
+	UpdatedAt  pgtype.Timestamptz
1564
+}
1565
+
1566
+type CodeSearchContent struct {
1567
+	RepoID      int64
1568
+	RefName     string
1569
+	Path        string
1570
+	ContentTsv  interface{}
1571
+	ContentTrgm string
1572
+}
1573
+
1574
+type CodeSearchPath struct {
1575
+	RepoID  int64
1576
+	RefName string
1577
+	Path    string
1578
+	Tsv     interface{}
1579
+}
1580
+
1581
+type DomainEvent struct {
1582
+	ID          int64
1583
+	ActorUserID pgtype.Int8
1584
+	Kind        string
1585
+	RepoID      pgtype.Int8
1586
+	SourceKind  string
1587
+	SourceID    int64
1588
+	Public      bool
1589
+	Payload     []byte
1590
+	CreatedAt   pgtype.Timestamptz
1591
+}
1592
+
1593
+type DomainEventsProcessed struct {
1594
+	Consumer    string
1595
+	LastEventID int64
1596
+	UpdatedAt   pgtype.Timestamptz
1597
+}
1598
+
1599
+type EmailVerification struct {
1600
+	ID          int64
1601
+	UserEmailID int64
1602
+	TokenHash   []byte
1603
+	ExpiresAt   pgtype.Timestamptz
1604
+	UsedAt      pgtype.Timestamptz
1605
+	CreatedAt   pgtype.Timestamptz
1606
+}
1607
+
1608
+type Issue struct {
1609
+	ID                int64
1610
+	RepoID            int64
1611
+	Number            int64
1612
+	Kind              IssueKind
1613
+	Title             string
1614
+	Body              string
1615
+	BodyHtmlCached    pgtype.Text
1616
+	MdPipelineVersion int32
1617
+	AuthorUserID      pgtype.Int8
1618
+	State             IssueState
1619
+	StateReason       NullIssueStateReason
1620
+	Locked            bool
1621
+	LockReason        pgtype.Text
1622
+	MilestoneID       pgtype.Int8
1623
+	CreatedAt         pgtype.Timestamptz
1624
+	UpdatedAt         pgtype.Timestamptz
1625
+	EditedAt          pgtype.Timestamptz
1626
+	ClosedAt          pgtype.Timestamptz
1627
+	ClosedByUserID    pgtype.Int8
1628
+}
1629
+
1630
+type IssueAssignee struct {
1631
+	IssueID          int64
1632
+	UserID           int64
1633
+	AssignedAt       pgtype.Timestamptz
1634
+	AssignedByUserID pgtype.Int8
1635
+}
1636
+
1637
+type IssueComment struct {
1638
+	ID                int64
1639
+	IssueID           int64
1640
+	AuthorUserID      pgtype.Int8
1641
+	Body              string
1642
+	BodyHtmlCached    pgtype.Text
1643
+	MdPipelineVersion int32
1644
+	CreatedAt         pgtype.Timestamptz
1645
+	UpdatedAt         pgtype.Timestamptz
1646
+	EditedAt          pgtype.Timestamptz
1647
+}
1648
+
1649
+type IssueEvent struct {
1650
+	ID          int64
1651
+	IssueID     int64
1652
+	ActorUserID pgtype.Int8
1653
+	Kind        string
1654
+	Meta        []byte
1655
+	RefTargetID pgtype.Int8
1656
+	CreatedAt   pgtype.Timestamptz
1657
+}
1658
+
1659
+type IssueLabel struct {
1660
+	IssueID         int64
1661
+	LabelID         int64
1662
+	AppliedAt       pgtype.Timestamptz
1663
+	AppliedByUserID pgtype.Int8
1664
+}
1665
+
1666
+type IssueReference struct {
1667
+	ID             int64
1668
+	SourceIssueID  pgtype.Int8
1669
+	TargetIssueID  int64
1670
+	SourceKind     IssueRefSource
1671
+	SourceObjectID pgtype.Int8
1672
+	CreatedAt      pgtype.Timestamptz
1673
+}
1674
+
1675
+type IssuesSearch struct {
1676
+	IssueID      int64
1677
+	RepoID       int64
1678
+	Kind         IssueKind
1679
+	State        IssueState
1680
+	AuthorUserID pgtype.Int8
1681
+	Tsv          interface{}
1682
+}
1683
+
1684
+type Job struct {
1685
+	ID          int64
1686
+	Kind        string
1687
+	Payload     []byte
1688
+	RunAt       pgtype.Timestamptz
1689
+	Attempts    int32
1690
+	MaxAttempts int32
1691
+	LastError   pgtype.Text
1692
+	LockedBy    pgtype.Text
1693
+	LockedAt    pgtype.Timestamptz
1694
+	CompletedAt pgtype.Timestamptz
1695
+	FailedAt    pgtype.Timestamptz
1696
+	CreatedAt   pgtype.Timestamptz
1697
+}
1698
+
1699
+type Label struct {
1700
+	ID          int64
1701
+	RepoID      int64
1702
+	Name        string
1703
+	Color       string
1704
+	Description string
1705
+	CreatedAt   pgtype.Timestamptz
1706
+}
1707
+
1708
+type Meta struct {
1709
+	Key       string
1710
+	Value     []byte
1711
+	UpdatedAt pgtype.Timestamptz
1712
+}
1713
+
1714
+type Milestone struct {
1715
+	ID          int64
1716
+	RepoID      int64
1717
+	Title       string
1718
+	Description string
1719
+	State       MilestoneState
1720
+	DueOn       pgtype.Timestamptz
1721
+	CreatedAt   pgtype.Timestamptz
1722
+	ClosedAt    pgtype.Timestamptz
1723
+}
1724
+
1725
+type Notification struct {
1726
+	ID              int64
1727
+	RecipientUserID int64
1728
+	Kind            string
1729
+	Reason          string
1730
+	RepoID          pgtype.Int8
1731
+	ThreadKind      NullNotificationThreadKind
1732
+	ThreadID        pgtype.Int8
1733
+	SourceEventID   pgtype.Int8
1734
+	Unread          bool
1735
+	LastEventAt     pgtype.Timestamptz
1736
+	LastActorUserID pgtype.Int8
1737
+	Summary         []byte
1738
+	CreatedAt       pgtype.Timestamptz
1739
+	UpdatedAt       pgtype.Timestamptz
1740
+}
1741
+
1742
+type NotificationEmailLog struct {
1743
+	ID              int64
1744
+	RecipientUserID int64
1745
+	NotificationID  pgtype.Int8
1746
+	ThreadKind      NullNotificationThreadKind
1747
+	ThreadID        pgtype.Int8
1748
+	SentAt          pgtype.Timestamptz
1749
+	MessageID       pgtype.Text
1750
+}
1751
+
1752
+type NotificationThread struct {
1753
+	RecipientUserID int64
1754
+	ThreadKind      NotificationThreadKind
1755
+	ThreadID        int64
1756
+	Subscribed      bool
1757
+	Reason          string
1758
+	UpdatedAt       pgtype.Timestamptz
1759
+}
1760
+
1761
+type Org struct {
1762
+	ID                    int64
1763
+	Slug                  string
1764
+	DisplayName           string
1765
+	Description           string
1766
+	AvatarObjectKey       pgtype.Text
1767
+	Location              string
1768
+	Website               string
1769
+	BillingEmail          string
1770
+	Plan                  OrgPlan
1771
+	AllowMemberRepoCreate bool
1772
+	CreatedByUserID       pgtype.Int8
1773
+	SuspendedAt           pgtype.Timestamptz
1774
+	SuspendedReason       pgtype.Text
1775
+	DeletedAt             pgtype.Timestamptz
1776
+	CreatedAt             pgtype.Timestamptz
1777
+	UpdatedAt             pgtype.Timestamptz
1778
+}
1779
+
1780
+type OrgInvitation struct {
1781
+	ID              int64
1782
+	OrgID           int64
1783
+	InvitedByUserID pgtype.Int8
1784
+	TargetUserID    pgtype.Int8
1785
+	TargetEmail     pgtype.Text
1786
+	Role            OrgRole
1787
+	TokenHash       []byte
1788
+	ExpiresAt       pgtype.Timestamptz
1789
+	AcceptedAt      pgtype.Timestamptz
1790
+	DeclinedAt      pgtype.Timestamptz
1791
+	CanceledAt      pgtype.Timestamptz
1792
+	CreatedAt       pgtype.Timestamptz
1793
+}
1794
+
1795
+type OrgMember struct {
1796
+	OrgID           int64
1797
+	UserID          int64
1798
+	Role            OrgRole
1799
+	InvitedByUserID pgtype.Int8
1800
+	JoinedAt        pgtype.Timestamptz
1801
+}
1802
+
1803
+type PasswordReset struct {
1804
+	ID        int64
1805
+	UserID    int64
1806
+	TokenHash []byte
1807
+	ExpiresAt pgtype.Timestamptz
1808
+	UsedAt    pgtype.Timestamptz
1809
+	CreatedAt pgtype.Timestamptz
1810
+}
1811
+
1812
+type PrReview struct {
1813
+	ID                int64
1814
+	PrIssueID         int64
1815
+	AuthorUserID      pgtype.Int8
1816
+	State             PrReviewState
1817
+	Body              string
1818
+	BodyHtmlCached    pgtype.Text
1819
+	SubmittedAt       pgtype.Timestamptz
1820
+	DismissedAt       pgtype.Timestamptz
1821
+	DismissedByUserID pgtype.Int8
1822
+	DismissalReason   string
1823
+}
1824
+
1825
+type PrReviewComment struct {
1826
+	ID                int64
1827
+	PrIssueID         int64
1828
+	ReviewID          pgtype.Int8
1829
+	AuthorUserID      pgtype.Int8
1830
+	FilePath          string
1831
+	Side              PrReviewSide
1832
+	OriginalCommitSha string
1833
+	OriginalLine      int32
1834
+	OriginalPosition  int32
1835
+	CurrentPosition   pgtype.Int4
1836
+	Body              string
1837
+	BodyHtmlCached    pgtype.Text
1838
+	InReplyToID       pgtype.Int8
1839
+	Pending           bool
1840
+	ResolvedAt        pgtype.Timestamptz
1841
+	ResolvedByUserID  pgtype.Int8
1842
+	CreatedAt         pgtype.Timestamptz
1843
+	UpdatedAt         pgtype.Timestamptz
1844
+	EditedAt          pgtype.Timestamptz
1845
+}
1846
+
1847
+type PrReviewRequest struct {
1848
+	ID                  int64
1849
+	PrIssueID           int64
1850
+	RequestedUserID     pgtype.Int8
1851
+	RequestedTeamID     pgtype.Int8
1852
+	RequestedByUserID   pgtype.Int8
1853
+	RequestedAt         pgtype.Timestamptz
1854
+	DismissedAt         pgtype.Timestamptz
1855
+	SatisfiedByReviewID pgtype.Int8
1856
+}
1857
+
1858
+type Principal struct {
1859
+	Slug string
1860
+	Kind PrincipalKind
1861
+	ID   int64
1862
+}
1863
+
1864
+type ProfilePin struct {
1865
+	SetID    int64
1866
+	RepoID   int64
1867
+	Position int32
1868
+	PinnedAt pgtype.Timestamptz
1869
+}
1870
+
1871
+type ProfilePinSet struct {
1872
+	ID          int64
1873
+	OwnerUserID pgtype.Int8
1874
+	OwnerOrgID  pgtype.Int8
1875
+	UpdatedAt   pgtype.Timestamptz
1876
+}
1877
+
1878
+type PullRequest struct {
1879
+	IssueID            int64
1880
+	BaseRef            string
1881
+	HeadRef            string
1882
+	HeadRepoID         int64
1883
+	BaseOid            string
1884
+	HeadOid            string
1885
+	Draft              bool
1886
+	Mergeable          pgtype.Bool
1887
+	MergeableState     PrMergeableState
1888
+	MergeCommitSha     pgtype.Text
1889
+	MergedAt           pgtype.Timestamptz
1890
+	MergedByUserID     pgtype.Int8
1891
+	MergeMethod        NullPrMergeMethod
1892
+	BaseOidAtMerge     pgtype.Text
1893
+	HeadOidAtMerge     pgtype.Text
1894
+	LastSynchronizedAt pgtype.Timestamptz
1895
+}
1896
+
1897
+type PullRequestCommit struct {
1898
+	PrID           int64
1899
+	Sha            string
1900
+	Position       int32
1901
+	AuthorName     string
1902
+	AuthorEmail    string
1903
+	CommitterName  string
1904
+	CommitterEmail string
1905
+	Subject        string
1906
+	Body           string
1907
+	AuthoredAt     pgtype.Timestamptz
1908
+	CommittedAt    pgtype.Timestamptz
1909
+}
1910
+
1911
+type PullRequestFile struct {
1912
+	PrID      int64
1913
+	Path      string
1914
+	Status    PrFileStatus
1915
+	OldPath   pgtype.Text
1916
+	Additions int32
1917
+	Deletions int32
1918
+	Changes   int32
1919
+}
1920
+
1921
+type PushEvent struct {
1922
+	ID           int64
1923
+	RepoID       int64
1924
+	PusherUserID pgtype.Int8
1925
+	BeforeSha    string
1926
+	AfterSha     string
1927
+	Ref          string
1928
+	Protocol     string
1929
+	RequestID    string
1930
+	ProcessedAt  pgtype.Timestamptz
1931
+	CreatedAt    pgtype.Timestamptz
1932
+}
1933
+
1934
+type RateLimit struct {
1935
+	Scope           string
1936
+	Key             string
1937
+	Hits            int32
1938
+	WindowStartedAt pgtype.Timestamptz
1939
+}
1940
+
1941
+type Repo struct {
1942
+	ID                 int64
1943
+	OwnerUserID        pgtype.Int8
1944
+	OwnerOrgID         pgtype.Int8
1945
+	Name               string
1946
+	Description        string
1947
+	Visibility         RepoVisibility
1948
+	DefaultBranch      string
1949
+	IsArchived         bool
1950
+	ArchivedAt         pgtype.Timestamptz
1951
+	DeletedAt          pgtype.Timestamptz
1952
+	DiskUsedBytes      int64
1953
+	ForkOfRepoID       pgtype.Int8
1954
+	LicenseKey         pgtype.Text
1955
+	PrimaryLanguage    pgtype.Text
1956
+	HasIssues          bool
1957
+	HasPulls           bool
1958
+	CreatedAt          pgtype.Timestamptz
1959
+	UpdatedAt          pgtype.Timestamptz
1960
+	DefaultBranchOid   pgtype.Text
1961
+	AllowSquashMerge   bool
1962
+	AllowRebaseMerge   bool
1963
+	AllowMergeCommit   bool
1964
+	DefaultMergeMethod PrMergeMethod
1965
+	StarCount          int64
1966
+	WatcherCount       int64
1967
+	ForkCount          int64
1968
+	InitStatus         RepoInitStatus
1969
+	LastIndexedOid     pgtype.Text
1970
+}
1971
+
1972
+type RepoCollaborator struct {
1973
+	RepoID        int64
1974
+	UserID        int64
1975
+	Role          CollabRole
1976
+	AddedAt       pgtype.Timestamptz
1977
+	AddedByUserID pgtype.Int8
1978
+}
1979
+
1980
+type RepoIssueCounter struct {
1981
+	RepoID     int64
1982
+	NextNumber int64
1983
+}
1984
+
1985
+type RepoRedirect struct {
1986
+	OldOwnerUserID pgtype.Int8
1987
+	OldOwnerOrgID  pgtype.Int8
1988
+	OldName        string
1989
+	RepoID         int64
1990
+	RedirectedAt   pgtype.Timestamptz
1991
+}
1992
+
1993
+type RepoTopic struct {
1994
+	RepoID    int64
1995
+	Topic     string
1996
+	CreatedAt pgtype.Timestamptz
1997
+}
1998
+
1999
+type RepoTransferRequest struct {
2000
+	ID              int64
2001
+	RepoID          int64
2002
+	FromUserID      int64
2003
+	ToPrincipalKind TransferPrincipalKind
2004
+	ToPrincipalID   int64
2005
+	CreatedBy       int64
2006
+	CreatedAt       pgtype.Timestamptz
2007
+	ExpiresAt       pgtype.Timestamptz
2008
+	Status          TransferStatus
2009
+	AcceptedAt      pgtype.Timestamptz
2010
+	DeclinedAt      pgtype.Timestamptz
2011
+	CanceledAt      pgtype.Timestamptz
2012
+}
2013
+
2014
+type ReposSearch struct {
2015
+	RepoID int64
2016
+	Tsv    interface{}
2017
+}
2018
+
2019
+type RunnerToken struct {
2020
+	ID        int64
2021
+	RunnerID  int64
2022
+	TokenHash []byte
2023
+	ExpiresAt pgtype.Timestamptz
2024
+	RevokedAt pgtype.Timestamptz
2025
+	CreatedAt pgtype.Timestamptz
2026
+}
2027
+
2028
+type SignupIpThrottle struct {
2029
+	Cidr            netip.Addr
2030
+	Hits            int32
2031
+	WindowStartedAt pgtype.Timestamptz
2032
+}
2033
+
2034
+type Star struct {
2035
+	UserID    int64
2036
+	RepoID    int64
2037
+	StarredAt pgtype.Timestamptz
2038
+}
2039
+
2040
+type Team struct {
2041
+	ID              int64
2042
+	OrgID           int64
2043
+	Slug            string
2044
+	DisplayName     string
2045
+	Description     string
2046
+	ParentTeamID    pgtype.Int8
2047
+	Privacy         TeamPrivacy
2048
+	CreatedByUserID pgtype.Int8
2049
+	CreatedAt       pgtype.Timestamptz
2050
+	UpdatedAt       pgtype.Timestamptz
2051
+}
2052
+
2053
+type TeamMember struct {
2054
+	TeamID        int64
2055
+	UserID        int64
2056
+	Role          TeamRole
2057
+	AddedByUserID pgtype.Int8
2058
+	AddedAt       pgtype.Timestamptz
2059
+}
2060
+
2061
+type TeamRepoAccess struct {
2062
+	TeamID        int64
2063
+	RepoID        int64
2064
+	Role          TeamRepoRole
2065
+	AddedByUserID pgtype.Int8
2066
+	AddedAt       pgtype.Timestamptz
2067
+}
2068
+
2069
+type TransactionalEmailLog struct {
2070
+	ID              int64
2071
+	RecipientUserID pgtype.Int8
2072
+	RecipientEmail  string
2073
+	Kind            string
2074
+	Subject         string
2075
+	ProviderID      string
2076
+	Status          TransactionalEmailStatus
2077
+	ErrorSummary    pgtype.Text
2078
+	SentAt          pgtype.Timestamptz
2079
+	DeliveredAt     pgtype.Timestamptz
2080
+}
2081
+
2082
+type User struct {
2083
+	ID                int64
2084
+	Username          string
2085
+	DisplayName       string
2086
+	PrimaryEmailID    pgtype.Int8
2087
+	PasswordHash      string
2088
+	PasswordAlgo      string
2089
+	PasswordUpdatedAt pgtype.Timestamptz
2090
+	EmailVerified     bool
2091
+	LastLoginAt       pgtype.Timestamptz
2092
+	SuspendedAt       pgtype.Timestamptz
2093
+	SuspendedReason   pgtype.Text
2094
+	DeletedAt         pgtype.Timestamptz
2095
+	CreatedAt         pgtype.Timestamptz
2096
+	UpdatedAt         pgtype.Timestamptz
2097
+	Bio               string
2098
+	Location          string
2099
+	Website           string
2100
+	Company           string
2101
+	Pronouns          string
2102
+	AvatarObjectKey   pgtype.Text
2103
+	Theme             string
2104
+	SessionEpoch      int32
2105
+	IsSiteAdmin       bool
2106
+}
2107
+
2108
+type UserEmail struct {
2109
+	ID                    int64
2110
+	UserID                int64
2111
+	Email                 string
2112
+	IsPrimary             bool
2113
+	Verified              bool
2114
+	VerificationTokenHash []byte
2115
+	VerificationSentAt    pgtype.Timestamptz
2116
+	VerifiedAt            pgtype.Timestamptz
2117
+	CreatedAt             pgtype.Timestamptz
2118
+}
2119
+
2120
+type UserNotificationPref struct {
2121
+	UserID    int64
2122
+	Key       string
2123
+	Value     []byte
2124
+	UpdatedAt pgtype.Timestamptz
2125
+}
2126
+
2127
+type UserRecoveryCode struct {
2128
+	ID          int64
2129
+	UserID      int64
2130
+	CodeHash    []byte
2131
+	UsedAt      pgtype.Timestamptz
2132
+	GeneratedAt pgtype.Timestamptz
2133
+	CreatedAt   pgtype.Timestamptz
2134
+}
2135
+
2136
+type UserSshKey struct {
2137
+	ID                int64
2138
+	UserID            int64
2139
+	Title             string
2140
+	FingerprintSha256 string
2141
+	KeyType           string
2142
+	KeyBits           int32
2143
+	PublicKey         string
2144
+	LastUsedAt        pgtype.Timestamptz
2145
+	LastUsedIp        *netip.Addr
2146
+	CreatedAt         pgtype.Timestamptz
2147
+}
2148
+
2149
+type UserToken struct {
2150
+	ID          int64
2151
+	UserID      int64
2152
+	Name        string
2153
+	TokenHash   []byte
2154
+	TokenPrefix string
2155
+	Scopes      []string
2156
+	ExpiresAt   pgtype.Timestamptz
2157
+	LastUsedAt  pgtype.Timestamptz
2158
+	LastUsedIp  *netip.Addr
2159
+	RevokedAt   pgtype.Timestamptz
2160
+	CreatedAt   pgtype.Timestamptz
2161
+}
2162
+
2163
+type UserTotp struct {
2164
+	ID              int64
2165
+	UserID          int64
2166
+	SecretEncrypted []byte
2167
+	SecretNonce     []byte
2168
+	ConfirmedAt     pgtype.Timestamptz
2169
+	LastUsedCounter int64
2170
+	CreatedAt       pgtype.Timestamptz
2171
+	UpdatedAt       pgtype.Timestamptz
2172
+}
2173
+
2174
+type UsernameRedirect struct {
2175
+	OldUsername string
2176
+	UserID      int64
2177
+	ChangedAt   pgtype.Timestamptz
2178
+}
2179
+
2180
+type UsersSearch struct {
2181
+	UserID int64
2182
+	Tsv    interface{}
2183
+}
2184
+
2185
+type Watch struct {
2186
+	UserID    int64
2187
+	RepoID    int64
2188
+	Level     WatchLevel
2189
+	UpdatedAt pgtype.Timestamptz
2190
+}
2191
+
2192
+type Webhook struct {
2193
+	ID                   int64
2194
+	OwnerKind            WebhookOwnerKind
2195
+	OwnerID              int64
2196
+	Url                  string
2197
+	ContentType          WebhookContentType
2198
+	Events               []string
2199
+	SecretCiphertext     []byte
2200
+	SecretNonce          []byte
2201
+	Active               bool
2202
+	SslVerification      bool
2203
+	ConsecutiveFailures  int32
2204
+	AutoDisableThreshold int32
2205
+	DisabledAt           pgtype.Timestamptz
2206
+	DisabledReason       pgtype.Text
2207
+	LastSuccessAt        pgtype.Timestamptz
2208
+	LastFailureAt        pgtype.Timestamptz
2209
+	CreatedByUserID      pgtype.Int8
2210
+	CreatedAt            pgtype.Timestamptz
2211
+	UpdatedAt            pgtype.Timestamptz
2212
+}
2213
+
2214
+type WebhookDelivery struct {
2215
+	ID                int64
2216
+	WebhookID         int64
2217
+	EventKind         string
2218
+	EventID           pgtype.Int8
2219
+	DeliveryUuid      pgtype.UUID
2220
+	Payload           []byte
2221
+	RequestHeaders    []byte
2222
+	RequestBody       []byte
2223
+	ResponseStatus    pgtype.Int4
2224
+	ResponseHeaders   []byte
2225
+	ResponseBody      []byte
2226
+	ResponseTruncated bool
2227
+	StartedAt         pgtype.Timestamptz
2228
+	CompletedAt       pgtype.Timestamptz
2229
+	Attempt           int32
2230
+	MaxAttempts       int32
2231
+	NextRetryAt       pgtype.Timestamptz
2232
+	Status            WebhookDeliveryStatus
2233
+	IdempotencyKey    string
2234
+	ErrorSummary      pgtype.Text
2235
+	RedeliverOf       pgtype.Int8
2236
+}
2237
+
2238
+type WebhookEventsPending struct {
2239
+	ID        int64
2240
+	RepoID    int64
2241
+	EventKind string
2242
+	Payload   []byte
2243
+	CreatedAt pgtype.Timestamptz
2244
+}
2245
+
2246
+type WorkflowArtifact struct {
2247
+	ID        int64
2248
+	RunID     int64
2249
+	Name      string
2250
+	ObjectKey string
2251
+	ByteCount int64
2252
+	ExpiresAt pgtype.Timestamptz
2253
+	CreatedAt pgtype.Timestamptz
2254
+}
2255
+
2256
+type WorkflowJob struct {
2257
+	ID              int64
2258
+	RunID           int64
2259
+	JobIndex        int32
2260
+	JobKey          string
2261
+	JobName         string
2262
+	RunsOn          string
2263
+	RunnerID        pgtype.Int8
2264
+	NeedsJobs       []string
2265
+	IfExpr          string
2266
+	TimeoutMinutes  int32
2267
+	Permissions     []byte
2268
+	JobEnv          []byte
2269
+	Status          WorkflowJobStatus
2270
+	Conclusion      NullCheckConclusion
2271
+	CancelRequested bool
2272
+	StartedAt       pgtype.Timestamptz
2273
+	CompletedAt     pgtype.Timestamptz
2274
+	Version         int32
2275
+	CreatedAt       pgtype.Timestamptz
2276
+	UpdatedAt       pgtype.Timestamptz
2277
+}
2278
+
2279
+type WorkflowRun struct {
2280
+	ID               int64
2281
+	RepoID           int64
2282
+	RunIndex         int64
2283
+	WorkflowFile     string
2284
+	WorkflowName     string
2285
+	HeadSha          string
2286
+	HeadRef          string
2287
+	Event            WorkflowRunEvent
2288
+	EventPayload     []byte
2289
+	ActorUserID      pgtype.Int8
2290
+	ParentRunID      pgtype.Int8
2291
+	ConcurrencyGroup string
2292
+	Status           WorkflowRunStatus
2293
+	Conclusion       NullCheckConclusion
2294
+	Pinned           bool
2295
+	NeedApproval     bool
2296
+	ApprovedByUserID pgtype.Int8
2297
+	StartedAt        pgtype.Timestamptz
2298
+	CompletedAt      pgtype.Timestamptz
2299
+	Version          int32
2300
+	CreatedAt        pgtype.Timestamptz
2301
+	UpdatedAt        pgtype.Timestamptz
2302
+}
2303
+
2304
+type WorkflowRunner struct {
2305
+	ID                 int64
2306
+	Name               string
2307
+	Labels             []string
2308
+	Capacity           int32
2309
+	Status             WorkflowRunnerStatus
2310
+	LastHeartbeatAt    pgtype.Timestamptz
2311
+	RegisteredByUserID pgtype.Int8
2312
+	CreatedAt          pgtype.Timestamptz
2313
+	UpdatedAt          pgtype.Timestamptz
2314
+}
2315
+
2316
+type WorkflowSecret struct {
2317
+	ID              int64
2318
+	RepoID          pgtype.Int8
2319
+	OrgID           pgtype.Int8
2320
+	Name            string
2321
+	Ciphertext      []byte
2322
+	Nonce           []byte
2323
+	CreatedByUserID pgtype.Int8
2324
+	CreatedAt       pgtype.Timestamptz
2325
+	UpdatedAt       pgtype.Timestamptz
2326
+}
2327
+
2328
+type WorkflowStep struct {
2329
+	ID               int64
2330
+	JobID            int64
2331
+	StepIndex        int32
2332
+	StepID           string
2333
+	StepName         string
2334
+	IfExpr           string
2335
+	RunCommand       string
2336
+	UsesAlias        string
2337
+	WorkingDirectory string
2338
+	StepEnv          []byte
2339
+	ContinueOnError  bool
2340
+	Status           WorkflowStepStatus
2341
+	Conclusion       NullCheckConclusion
2342
+	LogObjectKey     pgtype.Text
2343
+	LogByteCount     int64
2344
+	StartedAt        pgtype.Timestamptz
2345
+	CompletedAt      pgtype.Timestamptz
2346
+	Version          int32
2347
+	CreatedAt        pgtype.Timestamptz
2348
+	UpdatedAt        pgtype.Timestamptz
2349
+}
2350
+
2351
+type WorkflowStepLogChunk struct {
2352
+	ID        int64
2353
+	StepID    int64
2354
+	Seq       int32
2355
+	Chunk     []byte
2356
+	CreatedAt pgtype.Timestamptz
2357
+}
internal/actions/sqlc/querier.goadded
@@ -0,0 +1,66 @@
1
+// Code generated by sqlc. DO NOT EDIT.
2
+// versions:
3
+//   sqlc v1.31.1
4
+
5
+package actionsdb
6
+
7
+import (
8
+	"context"
9
+
10
+	"github.com/jackc/pgx/v5/pgtype"
11
+)
12
+
13
+type Querier interface {
14
+	// SPDX-License-Identifier: AGPL-3.0-or-later
15
+	AppendStepLogChunk(ctx context.Context, db DBTX, arg AppendStepLogChunkParams) (AppendStepLogChunkRow, error)
16
+	DeleteExpiredArtifacts(ctx context.Context, db DBTX) ([]DeleteExpiredArtifactsRow, error)
17
+	DeleteOrgSecret(ctx context.Context, db DBTX, arg DeleteOrgSecretParams) error
18
+	DeleteOrgVariable(ctx context.Context, db DBTX, arg DeleteOrgVariableParams) error
19
+	DeleteRepoSecret(ctx context.Context, db DBTX, arg DeleteRepoSecretParams) error
20
+	DeleteRepoVariable(ctx context.Context, db DBTX, arg DeleteRepoVariableParams) error
21
+	DeleteStepLogChunks(ctx context.Context, db DBTX, stepID int64) error
22
+	GetArtifactByID(ctx context.Context, db DBTX, id int64) (WorkflowArtifact, error)
23
+	GetOrgSecret(ctx context.Context, db DBTX, arg GetOrgSecretParams) (GetOrgSecretRow, error)
24
+	GetRepoSecret(ctx context.Context, db DBTX, arg GetRepoSecretParams) (GetRepoSecretRow, error)
25
+	GetRunnerByID(ctx context.Context, db DBTX, id int64) (WorkflowRunner, error)
26
+	GetRunnerByName(ctx context.Context, db DBTX, name string) (WorkflowRunner, error)
27
+	GetRunnerByTokenHash(ctx context.Context, db DBTX, tokenHash []byte) (GetRunnerByTokenHashRow, error)
28
+	GetWorkflowJobByID(ctx context.Context, db DBTX, id int64) (WorkflowJob, error)
29
+	GetWorkflowRunByID(ctx context.Context, db DBTX, id int64) (WorkflowRun, error)
30
+	GetWorkflowStepByID(ctx context.Context, db DBTX, id int64) (WorkflowStep, error)
31
+	// SPDX-License-Identifier: AGPL-3.0-or-later
32
+	InsertArtifact(ctx context.Context, db DBTX, arg InsertArtifactParams) (WorkflowArtifact, error)
33
+	// SPDX-License-Identifier: AGPL-3.0-or-later
34
+	InsertRunner(ctx context.Context, db DBTX, arg InsertRunnerParams) (WorkflowRunner, error)
35
+	InsertRunnerToken(ctx context.Context, db DBTX, arg InsertRunnerTokenParams) (RunnerToken, error)
36
+	// SPDX-License-Identifier: AGPL-3.0-or-later
37
+	InsertWorkflowJob(ctx context.Context, db DBTX, arg InsertWorkflowJobParams) (WorkflowJob, error)
38
+	// SPDX-License-Identifier: AGPL-3.0-or-later
39
+	InsertWorkflowRun(ctx context.Context, db DBTX, arg InsertWorkflowRunParams) (WorkflowRun, error)
40
+	// SPDX-License-Identifier: AGPL-3.0-or-later
41
+	InsertWorkflowStep(ctx context.Context, db DBTX, arg InsertWorkflowStepParams) (WorkflowStep, error)
42
+	ListArtifactsForRun(ctx context.Context, db DBTX, runID int64) ([]ListArtifactsForRunRow, error)
43
+	ListJobsForRun(ctx context.Context, db DBTX, runID int64) ([]ListJobsForRunRow, error)
44
+	ListOrgSecrets(ctx context.Context, db DBTX, orgID pgtype.Int8) ([]ListOrgSecretsRow, error)
45
+	ListOrgVariables(ctx context.Context, db DBTX, orgID pgtype.Int8) ([]ListOrgVariablesRow, error)
46
+	ListRepoSecrets(ctx context.Context, db DBTX, repoID pgtype.Int8) ([]ListRepoSecretsRow, error)
47
+	ListRepoVariables(ctx context.Context, db DBTX, repoID pgtype.Int8) ([]ListRepoVariablesRow, error)
48
+	ListRunners(ctx context.Context, db DBTX) ([]ListRunnersRow, error)
49
+	ListStepLogChunks(ctx context.Context, db DBTX, arg ListStepLogChunksParams) ([]WorkflowStepLogChunk, error)
50
+	ListStepsForJob(ctx context.Context, db DBTX, jobID int64) ([]ListStepsForJobRow, error)
51
+	ListWorkflowRunsForRepo(ctx context.Context, db DBTX, arg ListWorkflowRunsForRepoParams) ([]ListWorkflowRunsForRepoRow, error)
52
+	// Atomic next-index emitter: take the max + 1 for this repo. Pairs
53
+	// with the (repo_id, run_index) UNIQUE so concurrent inserts that
54
+	// race here will catch a unique-violation and the caller retries.
55
+	NextRunIndexForRepo(ctx context.Context, db DBTX, repoID int64) (int32, error)
56
+	RevokeAllTokensForRunner(ctx context.Context, db DBTX, runnerID int64) error
57
+	TouchRunnerHeartbeat(ctx context.Context, db DBTX, arg TouchRunnerHeartbeatParams) error
58
+	UpsertOrgSecret(ctx context.Context, db DBTX, arg UpsertOrgSecretParams) (WorkflowSecret, error)
59
+	UpsertOrgVariable(ctx context.Context, db DBTX, arg UpsertOrgVariableParams) (ActionsVariable, error)
60
+	// SPDX-License-Identifier: AGPL-3.0-or-later
61
+	UpsertRepoSecret(ctx context.Context, db DBTX, arg UpsertRepoSecretParams) (WorkflowSecret, error)
62
+	// SPDX-License-Identifier: AGPL-3.0-or-later
63
+	UpsertRepoVariable(ctx context.Context, db DBTX, arg UpsertRepoVariableParams) (ActionsVariable, error)
64
+}
65
+
66
+var _ Querier = (*Queries)(nil)
internal/actions/sqlc/workflow_artifacts.sql.goadded
@@ -0,0 +1,143 @@
1
+// Code generated by sqlc. DO NOT EDIT.
2
+// versions:
3
+//   sqlc v1.31.1
4
+// source: workflow_artifacts.sql
5
+
6
+package actionsdb
7
+
8
+import (
9
+	"context"
10
+
11
+	"github.com/jackc/pgx/v5/pgtype"
12
+)
13
+
14
+const deleteExpiredArtifacts = `-- name: DeleteExpiredArtifacts :many
15
+DELETE FROM workflow_artifacts WHERE expires_at < now()
16
+RETURNING id, object_key
17
+`
18
+
19
+type DeleteExpiredArtifactsRow struct {
20
+	ID        int64
21
+	ObjectKey string
22
+}
23
+
24
+func (q *Queries) DeleteExpiredArtifacts(ctx context.Context, db DBTX) ([]DeleteExpiredArtifactsRow, error) {
25
+	rows, err := db.Query(ctx, deleteExpiredArtifacts)
26
+	if err != nil {
27
+		return nil, err
28
+	}
29
+	defer rows.Close()
30
+	items := []DeleteExpiredArtifactsRow{}
31
+	for rows.Next() {
32
+		var i DeleteExpiredArtifactsRow
33
+		if err := rows.Scan(&i.ID, &i.ObjectKey); err != nil {
34
+			return nil, err
35
+		}
36
+		items = append(items, i)
37
+	}
38
+	if err := rows.Err(); err != nil {
39
+		return nil, err
40
+	}
41
+	return items, nil
42
+}
43
+
44
+const getArtifactByID = `-- name: GetArtifactByID :one
45
+SELECT id, run_id, name, object_key, byte_count, expires_at, created_at
46
+FROM workflow_artifacts
47
+WHERE id = $1
48
+`
49
+
50
+func (q *Queries) GetArtifactByID(ctx context.Context, db DBTX, id int64) (WorkflowArtifact, error) {
51
+	row := db.QueryRow(ctx, getArtifactByID, id)
52
+	var i WorkflowArtifact
53
+	err := row.Scan(
54
+		&i.ID,
55
+		&i.RunID,
56
+		&i.Name,
57
+		&i.ObjectKey,
58
+		&i.ByteCount,
59
+		&i.ExpiresAt,
60
+		&i.CreatedAt,
61
+	)
62
+	return i, err
63
+}
64
+
65
+const insertArtifact = `-- name: InsertArtifact :one
66
+
67
+INSERT INTO workflow_artifacts (run_id, name, object_key, byte_count, expires_at)
68
+VALUES ($1, $2, $3, $4, $5)
69
+RETURNING id, run_id, name, object_key, byte_count, expires_at, created_at
70
+`
71
+
72
+type InsertArtifactParams struct {
73
+	RunID     int64
74
+	Name      string
75
+	ObjectKey string
76
+	ByteCount int64
77
+	ExpiresAt pgtype.Timestamptz
78
+}
79
+
80
+// SPDX-License-Identifier: AGPL-3.0-or-later
81
+func (q *Queries) InsertArtifact(ctx context.Context, db DBTX, arg InsertArtifactParams) (WorkflowArtifact, error) {
82
+	row := db.QueryRow(ctx, insertArtifact,
83
+		arg.RunID,
84
+		arg.Name,
85
+		arg.ObjectKey,
86
+		arg.ByteCount,
87
+		arg.ExpiresAt,
88
+	)
89
+	var i WorkflowArtifact
90
+	err := row.Scan(
91
+		&i.ID,
92
+		&i.RunID,
93
+		&i.Name,
94
+		&i.ObjectKey,
95
+		&i.ByteCount,
96
+		&i.ExpiresAt,
97
+		&i.CreatedAt,
98
+	)
99
+	return i, err
100
+}
101
+
102
+const listArtifactsForRun = `-- name: ListArtifactsForRun :many
103
+SELECT id, name, object_key, byte_count, expires_at, created_at
104
+FROM workflow_artifacts
105
+WHERE run_id = $1
106
+ORDER BY name ASC
107
+`
108
+
109
+type ListArtifactsForRunRow struct {
110
+	ID        int64
111
+	Name      string
112
+	ObjectKey string
113
+	ByteCount int64
114
+	ExpiresAt pgtype.Timestamptz
115
+	CreatedAt pgtype.Timestamptz
116
+}
117
+
118
+func (q *Queries) ListArtifactsForRun(ctx context.Context, db DBTX, runID int64) ([]ListArtifactsForRunRow, error) {
119
+	rows, err := db.Query(ctx, listArtifactsForRun, runID)
120
+	if err != nil {
121
+		return nil, err
122
+	}
123
+	defer rows.Close()
124
+	items := []ListArtifactsForRunRow{}
125
+	for rows.Next() {
126
+		var i ListArtifactsForRunRow
127
+		if err := rows.Scan(
128
+			&i.ID,
129
+			&i.Name,
130
+			&i.ObjectKey,
131
+			&i.ByteCount,
132
+			&i.ExpiresAt,
133
+			&i.CreatedAt,
134
+		); err != nil {
135
+			return nil, err
136
+		}
137
+		items = append(items, i)
138
+	}
139
+	if err := rows.Err(); err != nil {
140
+		return nil, err
141
+	}
142
+	return items, nil
143
+}
internal/actions/sqlc/workflow_jobs.sql.goadded
@@ -0,0 +1,171 @@
1
+// Code generated by sqlc. DO NOT EDIT.
2
+// versions:
3
+//   sqlc v1.31.1
4
+// source: workflow_jobs.sql
5
+
6
+package actionsdb
7
+
8
+import (
9
+	"context"
10
+
11
+	"github.com/jackc/pgx/v5/pgtype"
12
+)
13
+
14
+const getWorkflowJobByID = `-- name: GetWorkflowJobByID :one
15
+SELECT id, run_id, job_index, job_key, job_name, runs_on,
16
+       runner_id, needs_jobs, if_expr, timeout_minutes, permissions,
17
+       job_env, status, conclusion, cancel_requested,
18
+       started_at, completed_at, version, created_at, updated_at
19
+FROM workflow_jobs
20
+WHERE id = $1
21
+`
22
+
23
+func (q *Queries) GetWorkflowJobByID(ctx context.Context, db DBTX, id int64) (WorkflowJob, error) {
24
+	row := db.QueryRow(ctx, getWorkflowJobByID, id)
25
+	var i WorkflowJob
26
+	err := row.Scan(
27
+		&i.ID,
28
+		&i.RunID,
29
+		&i.JobIndex,
30
+		&i.JobKey,
31
+		&i.JobName,
32
+		&i.RunsOn,
33
+		&i.RunnerID,
34
+		&i.NeedsJobs,
35
+		&i.IfExpr,
36
+		&i.TimeoutMinutes,
37
+		&i.Permissions,
38
+		&i.JobEnv,
39
+		&i.Status,
40
+		&i.Conclusion,
41
+		&i.CancelRequested,
42
+		&i.StartedAt,
43
+		&i.CompletedAt,
44
+		&i.Version,
45
+		&i.CreatedAt,
46
+		&i.UpdatedAt,
47
+	)
48
+	return i, err
49
+}
50
+
51
+const insertWorkflowJob = `-- name: InsertWorkflowJob :one
52
+
53
+INSERT INTO workflow_jobs (
54
+    run_id, job_index, job_key, job_name,
55
+    runs_on, needs_jobs, if_expr, timeout_minutes,
56
+    permissions, job_env
57
+) VALUES (
58
+    $1, $2, $3, $4, $5, $6, $7, $8, $9, $10
59
+)
60
+RETURNING id, run_id, job_index, job_key, job_name, runs_on,
61
+          runner_id, needs_jobs, if_expr, timeout_minutes, permissions,
62
+          job_env, status, conclusion, cancel_requested,
63
+          started_at, completed_at, version, created_at, updated_at
64
+`
65
+
66
+type InsertWorkflowJobParams struct {
67
+	RunID          int64
68
+	JobIndex       int32
69
+	JobKey         string
70
+	JobName        string
71
+	RunsOn         string
72
+	NeedsJobs      []string
73
+	IfExpr         string
74
+	TimeoutMinutes int32
75
+	Permissions    []byte
76
+	JobEnv         []byte
77
+}
78
+
79
+// SPDX-License-Identifier: AGPL-3.0-or-later
80
+func (q *Queries) InsertWorkflowJob(ctx context.Context, db DBTX, arg InsertWorkflowJobParams) (WorkflowJob, error) {
81
+	row := db.QueryRow(ctx, insertWorkflowJob,
82
+		arg.RunID,
83
+		arg.JobIndex,
84
+		arg.JobKey,
85
+		arg.JobName,
86
+		arg.RunsOn,
87
+		arg.NeedsJobs,
88
+		arg.IfExpr,
89
+		arg.TimeoutMinutes,
90
+		arg.Permissions,
91
+		arg.JobEnv,
92
+	)
93
+	var i WorkflowJob
94
+	err := row.Scan(
95
+		&i.ID,
96
+		&i.RunID,
97
+		&i.JobIndex,
98
+		&i.JobKey,
99
+		&i.JobName,
100
+		&i.RunsOn,
101
+		&i.RunnerID,
102
+		&i.NeedsJobs,
103
+		&i.IfExpr,
104
+		&i.TimeoutMinutes,
105
+		&i.Permissions,
106
+		&i.JobEnv,
107
+		&i.Status,
108
+		&i.Conclusion,
109
+		&i.CancelRequested,
110
+		&i.StartedAt,
111
+		&i.CompletedAt,
112
+		&i.Version,
113
+		&i.CreatedAt,
114
+		&i.UpdatedAt,
115
+	)
116
+	return i, err
117
+}
118
+
119
+const listJobsForRun = `-- name: ListJobsForRun :many
120
+SELECT id, run_id, job_index, job_key, job_name, runs_on, status,
121
+       conclusion, started_at, completed_at, created_at
122
+FROM workflow_jobs
123
+WHERE run_id = $1
124
+ORDER BY job_index ASC
125
+`
126
+
127
+type ListJobsForRunRow struct {
128
+	ID          int64
129
+	RunID       int64
130
+	JobIndex    int32
131
+	JobKey      string
132
+	JobName     string
133
+	RunsOn      string
134
+	Status      WorkflowJobStatus
135
+	Conclusion  NullCheckConclusion
136
+	StartedAt   pgtype.Timestamptz
137
+	CompletedAt pgtype.Timestamptz
138
+	CreatedAt   pgtype.Timestamptz
139
+}
140
+
141
+func (q *Queries) ListJobsForRun(ctx context.Context, db DBTX, runID int64) ([]ListJobsForRunRow, error) {
142
+	rows, err := db.Query(ctx, listJobsForRun, runID)
143
+	if err != nil {
144
+		return nil, err
145
+	}
146
+	defer rows.Close()
147
+	items := []ListJobsForRunRow{}
148
+	for rows.Next() {
149
+		var i ListJobsForRunRow
150
+		if err := rows.Scan(
151
+			&i.ID,
152
+			&i.RunID,
153
+			&i.JobIndex,
154
+			&i.JobKey,
155
+			&i.JobName,
156
+			&i.RunsOn,
157
+			&i.Status,
158
+			&i.Conclusion,
159
+			&i.StartedAt,
160
+			&i.CompletedAt,
161
+			&i.CreatedAt,
162
+		); err != nil {
163
+			return nil, err
164
+		}
165
+		items = append(items, i)
166
+	}
167
+	if err := rows.Err(); err != nil {
168
+		return nil, err
169
+	}
170
+	return items, nil
171
+}
internal/actions/sqlc/workflow_runners.sql.goadded
@@ -0,0 +1,232 @@
1
+// Code generated by sqlc. DO NOT EDIT.
2
+// versions:
3
+//   sqlc v1.31.1
4
+// source: workflow_runners.sql
5
+
6
+package actionsdb
7
+
8
+import (
9
+	"context"
10
+
11
+	"github.com/jackc/pgx/v5/pgtype"
12
+)
13
+
14
+const getRunnerByID = `-- name: GetRunnerByID :one
15
+SELECT id, name, labels, capacity, status, last_heartbeat_at,
16
+       registered_by_user_id, created_at, updated_at
17
+FROM workflow_runners
18
+WHERE id = $1
19
+`
20
+
21
+func (q *Queries) GetRunnerByID(ctx context.Context, db DBTX, id int64) (WorkflowRunner, error) {
22
+	row := db.QueryRow(ctx, getRunnerByID, id)
23
+	var i WorkflowRunner
24
+	err := row.Scan(
25
+		&i.ID,
26
+		&i.Name,
27
+		&i.Labels,
28
+		&i.Capacity,
29
+		&i.Status,
30
+		&i.LastHeartbeatAt,
31
+		&i.RegisteredByUserID,
32
+		&i.CreatedAt,
33
+		&i.UpdatedAt,
34
+	)
35
+	return i, err
36
+}
37
+
38
+const getRunnerByName = `-- name: GetRunnerByName :one
39
+SELECT id, name, labels, capacity, status, last_heartbeat_at,
40
+       registered_by_user_id, created_at, updated_at
41
+FROM workflow_runners
42
+WHERE name = $1
43
+`
44
+
45
+func (q *Queries) GetRunnerByName(ctx context.Context, db DBTX, name string) (WorkflowRunner, error) {
46
+	row := db.QueryRow(ctx, getRunnerByName, name)
47
+	var i WorkflowRunner
48
+	err := row.Scan(
49
+		&i.ID,
50
+		&i.Name,
51
+		&i.Labels,
52
+		&i.Capacity,
53
+		&i.Status,
54
+		&i.LastHeartbeatAt,
55
+		&i.RegisteredByUserID,
56
+		&i.CreatedAt,
57
+		&i.UpdatedAt,
58
+	)
59
+	return i, err
60
+}
61
+
62
+const getRunnerByTokenHash = `-- name: GetRunnerByTokenHash :one
63
+SELECT r.id, r.name, r.labels, r.capacity, r.status,
64
+       r.last_heartbeat_at, r.created_at
65
+FROM workflow_runners r
66
+JOIN runner_tokens t ON t.runner_id = r.id
67
+WHERE t.token_hash = $1
68
+  AND t.revoked_at IS NULL
69
+  AND (t.expires_at IS NULL OR t.expires_at > now())
70
+`
71
+
72
+type GetRunnerByTokenHashRow struct {
73
+	ID              int64
74
+	Name            string
75
+	Labels          []string
76
+	Capacity        int32
77
+	Status          WorkflowRunnerStatus
78
+	LastHeartbeatAt pgtype.Timestamptz
79
+	CreatedAt       pgtype.Timestamptz
80
+}
81
+
82
+func (q *Queries) GetRunnerByTokenHash(ctx context.Context, db DBTX, tokenHash []byte) (GetRunnerByTokenHashRow, error) {
83
+	row := db.QueryRow(ctx, getRunnerByTokenHash, tokenHash)
84
+	var i GetRunnerByTokenHashRow
85
+	err := row.Scan(
86
+		&i.ID,
87
+		&i.Name,
88
+		&i.Labels,
89
+		&i.Capacity,
90
+		&i.Status,
91
+		&i.LastHeartbeatAt,
92
+		&i.CreatedAt,
93
+	)
94
+	return i, err
95
+}
96
+
97
+const insertRunner = `-- name: InsertRunner :one
98
+
99
+INSERT INTO workflow_runners (name, labels, capacity, registered_by_user_id)
100
+VALUES ($1, $2, $3, $4)
101
+RETURNING id, name, labels, capacity, status, last_heartbeat_at,
102
+          registered_by_user_id, created_at, updated_at
103
+`
104
+
105
+type InsertRunnerParams struct {
106
+	Name               string
107
+	Labels             []string
108
+	Capacity           int32
109
+	RegisteredByUserID pgtype.Int8
110
+}
111
+
112
+// SPDX-License-Identifier: AGPL-3.0-or-later
113
+func (q *Queries) InsertRunner(ctx context.Context, db DBTX, arg InsertRunnerParams) (WorkflowRunner, error) {
114
+	row := db.QueryRow(ctx, insertRunner,
115
+		arg.Name,
116
+		arg.Labels,
117
+		arg.Capacity,
118
+		arg.RegisteredByUserID,
119
+	)
120
+	var i WorkflowRunner
121
+	err := row.Scan(
122
+		&i.ID,
123
+		&i.Name,
124
+		&i.Labels,
125
+		&i.Capacity,
126
+		&i.Status,
127
+		&i.LastHeartbeatAt,
128
+		&i.RegisteredByUserID,
129
+		&i.CreatedAt,
130
+		&i.UpdatedAt,
131
+	)
132
+	return i, err
133
+}
134
+
135
+const insertRunnerToken = `-- name: InsertRunnerToken :one
136
+INSERT INTO runner_tokens (runner_id, token_hash, expires_at)
137
+VALUES ($1, $2, $3)
138
+RETURNING id, runner_id, token_hash, expires_at, revoked_at, created_at
139
+`
140
+
141
+type InsertRunnerTokenParams struct {
142
+	RunnerID  int64
143
+	TokenHash []byte
144
+	ExpiresAt pgtype.Timestamptz
145
+}
146
+
147
+func (q *Queries) InsertRunnerToken(ctx context.Context, db DBTX, arg InsertRunnerTokenParams) (RunnerToken, error) {
148
+	row := db.QueryRow(ctx, insertRunnerToken, arg.RunnerID, arg.TokenHash, arg.ExpiresAt)
149
+	var i RunnerToken
150
+	err := row.Scan(
151
+		&i.ID,
152
+		&i.RunnerID,
153
+		&i.TokenHash,
154
+		&i.ExpiresAt,
155
+		&i.RevokedAt,
156
+		&i.CreatedAt,
157
+	)
158
+	return i, err
159
+}
160
+
161
+const listRunners = `-- name: ListRunners :many
162
+SELECT id, name, labels, capacity, status, last_heartbeat_at, created_at
163
+FROM workflow_runners
164
+ORDER BY name ASC
165
+`
166
+
167
+type ListRunnersRow struct {
168
+	ID              int64
169
+	Name            string
170
+	Labels          []string
171
+	Capacity        int32
172
+	Status          WorkflowRunnerStatus
173
+	LastHeartbeatAt pgtype.Timestamptz
174
+	CreatedAt       pgtype.Timestamptz
175
+}
176
+
177
+func (q *Queries) ListRunners(ctx context.Context, db DBTX) ([]ListRunnersRow, error) {
178
+	rows, err := db.Query(ctx, listRunners)
179
+	if err != nil {
180
+		return nil, err
181
+	}
182
+	defer rows.Close()
183
+	items := []ListRunnersRow{}
184
+	for rows.Next() {
185
+		var i ListRunnersRow
186
+		if err := rows.Scan(
187
+			&i.ID,
188
+			&i.Name,
189
+			&i.Labels,
190
+			&i.Capacity,
191
+			&i.Status,
192
+			&i.LastHeartbeatAt,
193
+			&i.CreatedAt,
194
+		); err != nil {
195
+			return nil, err
196
+		}
197
+		items = append(items, i)
198
+	}
199
+	if err := rows.Err(); err != nil {
200
+		return nil, err
201
+	}
202
+	return items, nil
203
+}
204
+
205
+const revokeAllTokensForRunner = `-- name: RevokeAllTokensForRunner :exec
206
+UPDATE runner_tokens
207
+SET revoked_at = now()
208
+WHERE runner_id = $1 AND revoked_at IS NULL
209
+`
210
+
211
+func (q *Queries) RevokeAllTokensForRunner(ctx context.Context, db DBTX, runnerID int64) error {
212
+	_, err := db.Exec(ctx, revokeAllTokensForRunner, runnerID)
213
+	return err
214
+}
215
+
216
+const touchRunnerHeartbeat = `-- name: TouchRunnerHeartbeat :exec
217
+UPDATE workflow_runners
218
+SET last_heartbeat_at = now(),
219
+    status = $2,
220
+    updated_at = now()
221
+WHERE id = $1
222
+`
223
+
224
+type TouchRunnerHeartbeatParams struct {
225
+	ID     int64
226
+	Status WorkflowRunnerStatus
227
+}
228
+
229
+func (q *Queries) TouchRunnerHeartbeat(ctx context.Context, db DBTX, arg TouchRunnerHeartbeatParams) error {
230
+	_, err := db.Exec(ctx, touchRunnerHeartbeat, arg.ID, arg.Status)
231
+	return err
232
+}
internal/actions/sqlc/workflow_runs.sql.goadded
@@ -0,0 +1,211 @@
1
+// Code generated by sqlc. DO NOT EDIT.
2
+// versions:
3
+//   sqlc v1.31.1
4
+// source: workflow_runs.sql
5
+
6
+package actionsdb
7
+
8
+import (
9
+	"context"
10
+
11
+	"github.com/jackc/pgx/v5/pgtype"
12
+)
13
+
14
+const getWorkflowRunByID = `-- name: GetWorkflowRunByID :one
15
+SELECT id, repo_id, run_index, workflow_file, workflow_name,
16
+       head_sha, head_ref, event, event_payload,
17
+       actor_user_id, parent_run_id, concurrency_group,
18
+       status, conclusion, pinned, need_approval, approved_by_user_id,
19
+       started_at, completed_at, version, created_at, updated_at
20
+FROM workflow_runs
21
+WHERE id = $1
22
+`
23
+
24
+func (q *Queries) GetWorkflowRunByID(ctx context.Context, db DBTX, id int64) (WorkflowRun, error) {
25
+	row := db.QueryRow(ctx, getWorkflowRunByID, id)
26
+	var i WorkflowRun
27
+	err := row.Scan(
28
+		&i.ID,
29
+		&i.RepoID,
30
+		&i.RunIndex,
31
+		&i.WorkflowFile,
32
+		&i.WorkflowName,
33
+		&i.HeadSha,
34
+		&i.HeadRef,
35
+		&i.Event,
36
+		&i.EventPayload,
37
+		&i.ActorUserID,
38
+		&i.ParentRunID,
39
+		&i.ConcurrencyGroup,
40
+		&i.Status,
41
+		&i.Conclusion,
42
+		&i.Pinned,
43
+		&i.NeedApproval,
44
+		&i.ApprovedByUserID,
45
+		&i.StartedAt,
46
+		&i.CompletedAt,
47
+		&i.Version,
48
+		&i.CreatedAt,
49
+		&i.UpdatedAt,
50
+	)
51
+	return i, err
52
+}
53
+
54
+const insertWorkflowRun = `-- name: InsertWorkflowRun :one
55
+
56
+INSERT INTO workflow_runs (
57
+    repo_id, run_index, workflow_file, workflow_name,
58
+    head_sha, head_ref, event, event_payload,
59
+    actor_user_id, parent_run_id, concurrency_group, need_approval
60
+) VALUES (
61
+    $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12
62
+)
63
+RETURNING id, repo_id, run_index, workflow_file, workflow_name,
64
+          head_sha, head_ref, event, event_payload,
65
+          actor_user_id, parent_run_id, concurrency_group,
66
+          status, conclusion, pinned, need_approval, approved_by_user_id,
67
+          started_at, completed_at, version, created_at, updated_at
68
+`
69
+
70
+type InsertWorkflowRunParams struct {
71
+	RepoID           int64
72
+	RunIndex         int64
73
+	WorkflowFile     string
74
+	WorkflowName     string
75
+	HeadSha          string
76
+	HeadRef          string
77
+	Event            WorkflowRunEvent
78
+	EventPayload     []byte
79
+	ActorUserID      pgtype.Int8
80
+	ParentRunID      pgtype.Int8
81
+	ConcurrencyGroup string
82
+	NeedApproval     bool
83
+}
84
+
85
+// SPDX-License-Identifier: AGPL-3.0-or-later
86
+func (q *Queries) InsertWorkflowRun(ctx context.Context, db DBTX, arg InsertWorkflowRunParams) (WorkflowRun, error) {
87
+	row := db.QueryRow(ctx, insertWorkflowRun,
88
+		arg.RepoID,
89
+		arg.RunIndex,
90
+		arg.WorkflowFile,
91
+		arg.WorkflowName,
92
+		arg.HeadSha,
93
+		arg.HeadRef,
94
+		arg.Event,
95
+		arg.EventPayload,
96
+		arg.ActorUserID,
97
+		arg.ParentRunID,
98
+		arg.ConcurrencyGroup,
99
+		arg.NeedApproval,
100
+	)
101
+	var i WorkflowRun
102
+	err := row.Scan(
103
+		&i.ID,
104
+		&i.RepoID,
105
+		&i.RunIndex,
106
+		&i.WorkflowFile,
107
+		&i.WorkflowName,
108
+		&i.HeadSha,
109
+		&i.HeadRef,
110
+		&i.Event,
111
+		&i.EventPayload,
112
+		&i.ActorUserID,
113
+		&i.ParentRunID,
114
+		&i.ConcurrencyGroup,
115
+		&i.Status,
116
+		&i.Conclusion,
117
+		&i.Pinned,
118
+		&i.NeedApproval,
119
+		&i.ApprovedByUserID,
120
+		&i.StartedAt,
121
+		&i.CompletedAt,
122
+		&i.Version,
123
+		&i.CreatedAt,
124
+		&i.UpdatedAt,
125
+	)
126
+	return i, err
127
+}
128
+
129
+const listWorkflowRunsForRepo = `-- name: ListWorkflowRunsForRepo :many
130
+SELECT id, repo_id, run_index, workflow_file, workflow_name,
131
+       head_sha, head_ref, event, status, conclusion,
132
+       actor_user_id, started_at, completed_at, created_at
133
+FROM workflow_runs
134
+WHERE repo_id = $1
135
+ORDER BY created_at DESC
136
+LIMIT $2 OFFSET $3
137
+`
138
+
139
+type ListWorkflowRunsForRepoParams struct {
140
+	RepoID int64
141
+	Limit  int32
142
+	Offset int32
143
+}
144
+
145
+type ListWorkflowRunsForRepoRow struct {
146
+	ID           int64
147
+	RepoID       int64
148
+	RunIndex     int64
149
+	WorkflowFile string
150
+	WorkflowName string
151
+	HeadSha      string
152
+	HeadRef      string
153
+	Event        WorkflowRunEvent
154
+	Status       WorkflowRunStatus
155
+	Conclusion   NullCheckConclusion
156
+	ActorUserID  pgtype.Int8
157
+	StartedAt    pgtype.Timestamptz
158
+	CompletedAt  pgtype.Timestamptz
159
+	CreatedAt    pgtype.Timestamptz
160
+}
161
+
162
+func (q *Queries) ListWorkflowRunsForRepo(ctx context.Context, db DBTX, arg ListWorkflowRunsForRepoParams) ([]ListWorkflowRunsForRepoRow, error) {
163
+	rows, err := db.Query(ctx, listWorkflowRunsForRepo, arg.RepoID, arg.Limit, arg.Offset)
164
+	if err != nil {
165
+		return nil, err
166
+	}
167
+	defer rows.Close()
168
+	items := []ListWorkflowRunsForRepoRow{}
169
+	for rows.Next() {
170
+		var i ListWorkflowRunsForRepoRow
171
+		if err := rows.Scan(
172
+			&i.ID,
173
+			&i.RepoID,
174
+			&i.RunIndex,
175
+			&i.WorkflowFile,
176
+			&i.WorkflowName,
177
+			&i.HeadSha,
178
+			&i.HeadRef,
179
+			&i.Event,
180
+			&i.Status,
181
+			&i.Conclusion,
182
+			&i.ActorUserID,
183
+			&i.StartedAt,
184
+			&i.CompletedAt,
185
+			&i.CreatedAt,
186
+		); err != nil {
187
+			return nil, err
188
+		}
189
+		items = append(items, i)
190
+	}
191
+	if err := rows.Err(); err != nil {
192
+		return nil, err
193
+	}
194
+	return items, nil
195
+}
196
+
197
+const nextRunIndexForRepo = `-- name: NextRunIndexForRepo :one
198
+SELECT COALESCE(MAX(run_index), 0) + 1 AS next_index
199
+FROM workflow_runs
200
+WHERE repo_id = $1
201
+`
202
+
203
+// Atomic next-index emitter: take the max + 1 for this repo. Pairs
204
+// with the (repo_id, run_index) UNIQUE so concurrent inserts that
205
+// race here will catch a unique-violation and the caller retries.
206
+func (q *Queries) NextRunIndexForRepo(ctx context.Context, db DBTX, repoID int64) (int32, error) {
207
+	row := db.QueryRow(ctx, nextRunIndexForRepo, repoID)
208
+	var next_index int32
209
+	err := row.Scan(&next_index)
210
+	return next_index, err
211
+}
internal/actions/sqlc/workflow_secrets.sql.goadded
@@ -0,0 +1,268 @@
1
+// Code generated by sqlc. DO NOT EDIT.
2
+// versions:
3
+//   sqlc v1.31.1
4
+// source: workflow_secrets.sql
5
+
6
+package actionsdb
7
+
8
+import (
9
+	"context"
10
+
11
+	"github.com/jackc/pgx/v5/pgtype"
12
+)
13
+
14
+const deleteOrgSecret = `-- name: DeleteOrgSecret :exec
15
+DELETE FROM workflow_secrets WHERE org_id = $1 AND name = $2
16
+`
17
+
18
+type DeleteOrgSecretParams struct {
19
+	OrgID pgtype.Int8
20
+	Name  string
21
+}
22
+
23
+func (q *Queries) DeleteOrgSecret(ctx context.Context, db DBTX, arg DeleteOrgSecretParams) error {
24
+	_, err := db.Exec(ctx, deleteOrgSecret, arg.OrgID, arg.Name)
25
+	return err
26
+}
27
+
28
+const deleteRepoSecret = `-- name: DeleteRepoSecret :exec
29
+DELETE FROM workflow_secrets WHERE repo_id = $1 AND name = $2
30
+`
31
+
32
+type DeleteRepoSecretParams struct {
33
+	RepoID pgtype.Int8
34
+	Name   string
35
+}
36
+
37
+func (q *Queries) DeleteRepoSecret(ctx context.Context, db DBTX, arg DeleteRepoSecretParams) error {
38
+	_, err := db.Exec(ctx, deleteRepoSecret, arg.RepoID, arg.Name)
39
+	return err
40
+}
41
+
42
+const getOrgSecret = `-- name: GetOrgSecret :one
43
+SELECT id, name, ciphertext, nonce
44
+FROM workflow_secrets
45
+WHERE org_id = $1 AND name = $2
46
+`
47
+
48
+type GetOrgSecretParams struct {
49
+	OrgID pgtype.Int8
50
+	Name  string
51
+}
52
+
53
+type GetOrgSecretRow struct {
54
+	ID         int64
55
+	Name       string
56
+	Ciphertext []byte
57
+	Nonce      []byte
58
+}
59
+
60
+func (q *Queries) GetOrgSecret(ctx context.Context, db DBTX, arg GetOrgSecretParams) (GetOrgSecretRow, error) {
61
+	row := db.QueryRow(ctx, getOrgSecret, arg.OrgID, arg.Name)
62
+	var i GetOrgSecretRow
63
+	err := row.Scan(
64
+		&i.ID,
65
+		&i.Name,
66
+		&i.Ciphertext,
67
+		&i.Nonce,
68
+	)
69
+	return i, err
70
+}
71
+
72
+const getRepoSecret = `-- name: GetRepoSecret :one
73
+SELECT id, name, ciphertext, nonce
74
+FROM workflow_secrets
75
+WHERE repo_id = $1 AND name = $2
76
+`
77
+
78
+type GetRepoSecretParams struct {
79
+	RepoID pgtype.Int8
80
+	Name   string
81
+}
82
+
83
+type GetRepoSecretRow struct {
84
+	ID         int64
85
+	Name       string
86
+	Ciphertext []byte
87
+	Nonce      []byte
88
+}
89
+
90
+func (q *Queries) GetRepoSecret(ctx context.Context, db DBTX, arg GetRepoSecretParams) (GetRepoSecretRow, error) {
91
+	row := db.QueryRow(ctx, getRepoSecret, arg.RepoID, arg.Name)
92
+	var i GetRepoSecretRow
93
+	err := row.Scan(
94
+		&i.ID,
95
+		&i.Name,
96
+		&i.Ciphertext,
97
+		&i.Nonce,
98
+	)
99
+	return i, err
100
+}
101
+
102
+const listOrgSecrets = `-- name: ListOrgSecrets :many
103
+SELECT id, name, created_by_user_id, created_at, updated_at
104
+FROM workflow_secrets
105
+WHERE org_id = $1
106
+ORDER BY name ASC
107
+`
108
+
109
+type ListOrgSecretsRow struct {
110
+	ID              int64
111
+	Name            string
112
+	CreatedByUserID pgtype.Int8
113
+	CreatedAt       pgtype.Timestamptz
114
+	UpdatedAt       pgtype.Timestamptz
115
+}
116
+
117
+func (q *Queries) ListOrgSecrets(ctx context.Context, db DBTX, orgID pgtype.Int8) ([]ListOrgSecretsRow, error) {
118
+	rows, err := db.Query(ctx, listOrgSecrets, orgID)
119
+	if err != nil {
120
+		return nil, err
121
+	}
122
+	defer rows.Close()
123
+	items := []ListOrgSecretsRow{}
124
+	for rows.Next() {
125
+		var i ListOrgSecretsRow
126
+		if err := rows.Scan(
127
+			&i.ID,
128
+			&i.Name,
129
+			&i.CreatedByUserID,
130
+			&i.CreatedAt,
131
+			&i.UpdatedAt,
132
+		); err != nil {
133
+			return nil, err
134
+		}
135
+		items = append(items, i)
136
+	}
137
+	if err := rows.Err(); err != nil {
138
+		return nil, err
139
+	}
140
+	return items, nil
141
+}
142
+
143
+const listRepoSecrets = `-- name: ListRepoSecrets :many
144
+SELECT id, name, created_by_user_id, created_at, updated_at
145
+FROM workflow_secrets
146
+WHERE repo_id = $1
147
+ORDER BY name ASC
148
+`
149
+
150
+type ListRepoSecretsRow struct {
151
+	ID              int64
152
+	Name            string
153
+	CreatedByUserID pgtype.Int8
154
+	CreatedAt       pgtype.Timestamptz
155
+	UpdatedAt       pgtype.Timestamptz
156
+}
157
+
158
+func (q *Queries) ListRepoSecrets(ctx context.Context, db DBTX, repoID pgtype.Int8) ([]ListRepoSecretsRow, error) {
159
+	rows, err := db.Query(ctx, listRepoSecrets, repoID)
160
+	if err != nil {
161
+		return nil, err
162
+	}
163
+	defer rows.Close()
164
+	items := []ListRepoSecretsRow{}
165
+	for rows.Next() {
166
+		var i ListRepoSecretsRow
167
+		if err := rows.Scan(
168
+			&i.ID,
169
+			&i.Name,
170
+			&i.CreatedByUserID,
171
+			&i.CreatedAt,
172
+			&i.UpdatedAt,
173
+		); err != nil {
174
+			return nil, err
175
+		}
176
+		items = append(items, i)
177
+	}
178
+	if err := rows.Err(); err != nil {
179
+		return nil, err
180
+	}
181
+	return items, nil
182
+}
183
+
184
+const upsertOrgSecret = `-- name: UpsertOrgSecret :one
185
+INSERT INTO workflow_secrets (org_id, name, ciphertext, nonce, created_by_user_id)
186
+VALUES ($1, $2, $3, $4, $5)
187
+ON CONFLICT (org_id, name) WHERE org_id IS NOT NULL DO UPDATE
188
+SET ciphertext = EXCLUDED.ciphertext,
189
+    nonce      = EXCLUDED.nonce,
190
+    updated_at = now()
191
+RETURNING id, repo_id, org_id, name, ciphertext, nonce,
192
+          created_by_user_id, created_at, updated_at
193
+`
194
+
195
+type UpsertOrgSecretParams struct {
196
+	OrgID           pgtype.Int8
197
+	Name            string
198
+	Ciphertext      []byte
199
+	Nonce           []byte
200
+	CreatedByUserID pgtype.Int8
201
+}
202
+
203
+func (q *Queries) UpsertOrgSecret(ctx context.Context, db DBTX, arg UpsertOrgSecretParams) (WorkflowSecret, error) {
204
+	row := db.QueryRow(ctx, upsertOrgSecret,
205
+		arg.OrgID,
206
+		arg.Name,
207
+		arg.Ciphertext,
208
+		arg.Nonce,
209
+		arg.CreatedByUserID,
210
+	)
211
+	var i WorkflowSecret
212
+	err := row.Scan(
213
+		&i.ID,
214
+		&i.RepoID,
215
+		&i.OrgID,
216
+		&i.Name,
217
+		&i.Ciphertext,
218
+		&i.Nonce,
219
+		&i.CreatedByUserID,
220
+		&i.CreatedAt,
221
+		&i.UpdatedAt,
222
+	)
223
+	return i, err
224
+}
225
+
226
+const upsertRepoSecret = `-- name: UpsertRepoSecret :one
227
+
228
+INSERT INTO workflow_secrets (repo_id, name, ciphertext, nonce, created_by_user_id)
229
+VALUES ($1, $2, $3, $4, $5)
230
+ON CONFLICT (repo_id, name) WHERE repo_id IS NOT NULL DO UPDATE
231
+SET ciphertext = EXCLUDED.ciphertext,
232
+    nonce      = EXCLUDED.nonce,
233
+    updated_at = now()
234
+RETURNING id, repo_id, org_id, name, ciphertext, nonce,
235
+          created_by_user_id, created_at, updated_at
236
+`
237
+
238
+type UpsertRepoSecretParams struct {
239
+	RepoID          pgtype.Int8
240
+	Name            string
241
+	Ciphertext      []byte
242
+	Nonce           []byte
243
+	CreatedByUserID pgtype.Int8
244
+}
245
+
246
+// SPDX-License-Identifier: AGPL-3.0-or-later
247
+func (q *Queries) UpsertRepoSecret(ctx context.Context, db DBTX, arg UpsertRepoSecretParams) (WorkflowSecret, error) {
248
+	row := db.QueryRow(ctx, upsertRepoSecret,
249
+		arg.RepoID,
250
+		arg.Name,
251
+		arg.Ciphertext,
252
+		arg.Nonce,
253
+		arg.CreatedByUserID,
254
+	)
255
+	var i WorkflowSecret
256
+	err := row.Scan(
257
+		&i.ID,
258
+		&i.RepoID,
259
+		&i.OrgID,
260
+		&i.Name,
261
+		&i.Ciphertext,
262
+		&i.Nonce,
263
+		&i.CreatedByUserID,
264
+		&i.CreatedAt,
265
+		&i.UpdatedAt,
266
+	)
267
+	return i, err
268
+}
internal/actions/sqlc/workflow_step_log_chunks.sql.goadded
@@ -0,0 +1,94 @@
1
+// Code generated by sqlc. DO NOT EDIT.
2
+// versions:
3
+//   sqlc v1.31.1
4
+// source: workflow_step_log_chunks.sql
5
+
6
+package actionsdb
7
+
8
+import (
9
+	"context"
10
+
11
+	"github.com/jackc/pgx/v5/pgtype"
12
+)
13
+
14
+const appendStepLogChunk = `-- name: AppendStepLogChunk :one
15
+
16
+INSERT INTO workflow_step_log_chunks (step_id, seq, chunk)
17
+VALUES ($1, $2, $3)
18
+RETURNING id, step_id, seq, created_at
19
+`
20
+
21
+type AppendStepLogChunkParams struct {
22
+	StepID int64
23
+	Seq    int32
24
+	Chunk  []byte
25
+}
26
+
27
+type AppendStepLogChunkRow struct {
28
+	ID        int64
29
+	StepID    int64
30
+	Seq       int32
31
+	CreatedAt pgtype.Timestamptz
32
+}
33
+
34
+// SPDX-License-Identifier: AGPL-3.0-or-later
35
+func (q *Queries) AppendStepLogChunk(ctx context.Context, db DBTX, arg AppendStepLogChunkParams) (AppendStepLogChunkRow, error) {
36
+	row := db.QueryRow(ctx, appendStepLogChunk, arg.StepID, arg.Seq, arg.Chunk)
37
+	var i AppendStepLogChunkRow
38
+	err := row.Scan(
39
+		&i.ID,
40
+		&i.StepID,
41
+		&i.Seq,
42
+		&i.CreatedAt,
43
+	)
44
+	return i, err
45
+}
46
+
47
+const deleteStepLogChunks = `-- name: DeleteStepLogChunks :exec
48
+DELETE FROM workflow_step_log_chunks WHERE step_id = $1
49
+`
50
+
51
+func (q *Queries) DeleteStepLogChunks(ctx context.Context, db DBTX, stepID int64) error {
52
+	_, err := db.Exec(ctx, deleteStepLogChunks, stepID)
53
+	return err
54
+}
55
+
56
+const listStepLogChunks = `-- name: ListStepLogChunks :many
57
+SELECT id, step_id, seq, chunk, created_at
58
+FROM workflow_step_log_chunks
59
+WHERE step_id = $1 AND seq > $2
60
+ORDER BY seq ASC
61
+LIMIT $3
62
+`
63
+
64
+type ListStepLogChunksParams struct {
65
+	StepID int64
66
+	Seq    int32
67
+	Limit  int32
68
+}
69
+
70
+func (q *Queries) ListStepLogChunks(ctx context.Context, db DBTX, arg ListStepLogChunksParams) ([]WorkflowStepLogChunk, error) {
71
+	rows, err := db.Query(ctx, listStepLogChunks, arg.StepID, arg.Seq, arg.Limit)
72
+	if err != nil {
73
+		return nil, err
74
+	}
75
+	defer rows.Close()
76
+	items := []WorkflowStepLogChunk{}
77
+	for rows.Next() {
78
+		var i WorkflowStepLogChunk
79
+		if err := rows.Scan(
80
+			&i.ID,
81
+			&i.StepID,
82
+			&i.Seq,
83
+			&i.Chunk,
84
+			&i.CreatedAt,
85
+		); err != nil {
86
+			return nil, err
87
+		}
88
+		items = append(items, i)
89
+	}
90
+	if err := rows.Err(); err != nil {
91
+		return nil, err
92
+	}
93
+	return items, nil
94
+}
internal/actions/sqlc/workflow_steps.sql.goadded
@@ -0,0 +1,177 @@
1
+// Code generated by sqlc. DO NOT EDIT.
2
+// versions:
3
+//   sqlc v1.31.1
4
+// source: workflow_steps.sql
5
+
6
+package actionsdb
7
+
8
+import (
9
+	"context"
10
+
11
+	"github.com/jackc/pgx/v5/pgtype"
12
+)
13
+
14
+const getWorkflowStepByID = `-- name: GetWorkflowStepByID :one
15
+SELECT id, job_id, step_index, step_id, step_name, if_expr,
16
+       run_command, uses_alias, working_directory, step_env,
17
+       continue_on_error, status, conclusion, log_object_key,
18
+       log_byte_count, started_at, completed_at, version,
19
+       created_at, updated_at
20
+FROM workflow_steps
21
+WHERE id = $1
22
+`
23
+
24
+func (q *Queries) GetWorkflowStepByID(ctx context.Context, db DBTX, id int64) (WorkflowStep, error) {
25
+	row := db.QueryRow(ctx, getWorkflowStepByID, id)
26
+	var i WorkflowStep
27
+	err := row.Scan(
28
+		&i.ID,
29
+		&i.JobID,
30
+		&i.StepIndex,
31
+		&i.StepID,
32
+		&i.StepName,
33
+		&i.IfExpr,
34
+		&i.RunCommand,
35
+		&i.UsesAlias,
36
+		&i.WorkingDirectory,
37
+		&i.StepEnv,
38
+		&i.ContinueOnError,
39
+		&i.Status,
40
+		&i.Conclusion,
41
+		&i.LogObjectKey,
42
+		&i.LogByteCount,
43
+		&i.StartedAt,
44
+		&i.CompletedAt,
45
+		&i.Version,
46
+		&i.CreatedAt,
47
+		&i.UpdatedAt,
48
+	)
49
+	return i, err
50
+}
51
+
52
+const insertWorkflowStep = `-- name: InsertWorkflowStep :one
53
+
54
+INSERT INTO workflow_steps (
55
+    job_id, step_index, step_id, step_name, if_expr,
56
+    run_command, uses_alias, working_directory, step_env, continue_on_error
57
+) VALUES (
58
+    $1, $2, $3, $4, $5, $6, $7, $8, $9, $10
59
+)
60
+RETURNING id, job_id, step_index, step_id, step_name, if_expr,
61
+          run_command, uses_alias, working_directory, step_env,
62
+          continue_on_error, status, conclusion, log_object_key,
63
+          log_byte_count, started_at, completed_at, version,
64
+          created_at, updated_at
65
+`
66
+
67
+type InsertWorkflowStepParams struct {
68
+	JobID            int64
69
+	StepIndex        int32
70
+	StepID           string
71
+	StepName         string
72
+	IfExpr           string
73
+	RunCommand       string
74
+	UsesAlias        string
75
+	WorkingDirectory string
76
+	StepEnv          []byte
77
+	ContinueOnError  bool
78
+}
79
+
80
+// SPDX-License-Identifier: AGPL-3.0-or-later
81
+func (q *Queries) InsertWorkflowStep(ctx context.Context, db DBTX, arg InsertWorkflowStepParams) (WorkflowStep, error) {
82
+	row := db.QueryRow(ctx, insertWorkflowStep,
83
+		arg.JobID,
84
+		arg.StepIndex,
85
+		arg.StepID,
86
+		arg.StepName,
87
+		arg.IfExpr,
88
+		arg.RunCommand,
89
+		arg.UsesAlias,
90
+		arg.WorkingDirectory,
91
+		arg.StepEnv,
92
+		arg.ContinueOnError,
93
+	)
94
+	var i WorkflowStep
95
+	err := row.Scan(
96
+		&i.ID,
97
+		&i.JobID,
98
+		&i.StepIndex,
99
+		&i.StepID,
100
+		&i.StepName,
101
+		&i.IfExpr,
102
+		&i.RunCommand,
103
+		&i.UsesAlias,
104
+		&i.WorkingDirectory,
105
+		&i.StepEnv,
106
+		&i.ContinueOnError,
107
+		&i.Status,
108
+		&i.Conclusion,
109
+		&i.LogObjectKey,
110
+		&i.LogByteCount,
111
+		&i.StartedAt,
112
+		&i.CompletedAt,
113
+		&i.Version,
114
+		&i.CreatedAt,
115
+		&i.UpdatedAt,
116
+	)
117
+	return i, err
118
+}
119
+
120
+const listStepsForJob = `-- name: ListStepsForJob :many
121
+SELECT id, job_id, step_index, step_id, step_name, run_command,
122
+       uses_alias, status, conclusion, log_byte_count,
123
+       started_at, completed_at, created_at
124
+FROM workflow_steps
125
+WHERE job_id = $1
126
+ORDER BY step_index ASC
127
+`
128
+
129
+type ListStepsForJobRow struct {
130
+	ID           int64
131
+	JobID        int64
132
+	StepIndex    int32
133
+	StepID       string
134
+	StepName     string
135
+	RunCommand   string
136
+	UsesAlias    string
137
+	Status       WorkflowStepStatus
138
+	Conclusion   NullCheckConclusion
139
+	LogByteCount int64
140
+	StartedAt    pgtype.Timestamptz
141
+	CompletedAt  pgtype.Timestamptz
142
+	CreatedAt    pgtype.Timestamptz
143
+}
144
+
145
+func (q *Queries) ListStepsForJob(ctx context.Context, db DBTX, jobID int64) ([]ListStepsForJobRow, error) {
146
+	rows, err := db.Query(ctx, listStepsForJob, jobID)
147
+	if err != nil {
148
+		return nil, err
149
+	}
150
+	defer rows.Close()
151
+	items := []ListStepsForJobRow{}
152
+	for rows.Next() {
153
+		var i ListStepsForJobRow
154
+		if err := rows.Scan(
155
+			&i.ID,
156
+			&i.JobID,
157
+			&i.StepIndex,
158
+			&i.StepID,
159
+			&i.StepName,
160
+			&i.RunCommand,
161
+			&i.UsesAlias,
162
+			&i.Status,
163
+			&i.Conclusion,
164
+			&i.LogByteCount,
165
+			&i.StartedAt,
166
+			&i.CompletedAt,
167
+			&i.CreatedAt,
168
+		); err != nil {
169
+			return nil, err
170
+		}
171
+		items = append(items, i)
172
+	}
173
+	if err := rows.Err(); err != nil {
174
+		return nil, err
175
+	}
176
+	return items, nil
177
+}
sqlc.yamlmodified
@@ -225,3 +225,19 @@ sql:
225225
         emit_exact_table_names: false
226226
         emit_empty_slices: true
227227
         emit_methods_with_db_argument: true
228
+
229
+  - engine: postgresql
230
+    schema: internal/migrationsfs/migrations
231
+    queries: internal/actions/queries
232
+    gen:
233
+      go:
234
+        package: actionsdb
235
+        out: internal/actions/sqlc
236
+        sql_package: pgx/v5
237
+        emit_json_tags: false
238
+        emit_pointers_for_null_types: false
239
+        emit_prepared_queries: false
240
+        emit_interface: true
241
+        emit_exact_table_names: false
242
+        emit_empty_slices: true
243
+        emit_methods_with_db_argument: true