| 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 getOrgVariable = `-- name: GetOrgVariable :one |
| 43 | SELECT id, name, value, created_by_user_id, created_at, updated_at |
| 44 | FROM actions_variables |
| 45 | WHERE org_id = $1 AND name = $2 |
| 46 | ` |
| 47 | |
| 48 | type GetOrgVariableParams struct { |
| 49 | OrgID pgtype.Int8 |
| 50 | Name string |
| 51 | } |
| 52 | |
| 53 | type GetOrgVariableRow struct { |
| 54 | ID int64 |
| 55 | Name string |
| 56 | Value string |
| 57 | CreatedByUserID pgtype.Int8 |
| 58 | CreatedAt pgtype.Timestamptz |
| 59 | UpdatedAt pgtype.Timestamptz |
| 60 | } |
| 61 | |
| 62 | func (q *Queries) GetOrgVariable(ctx context.Context, db DBTX, arg GetOrgVariableParams) (GetOrgVariableRow, error) { |
| 63 | row := db.QueryRow(ctx, getOrgVariable, arg.OrgID, arg.Name) |
| 64 | var i GetOrgVariableRow |
| 65 | err := row.Scan( |
| 66 | &i.ID, |
| 67 | &i.Name, |
| 68 | &i.Value, |
| 69 | &i.CreatedByUserID, |
| 70 | &i.CreatedAt, |
| 71 | &i.UpdatedAt, |
| 72 | ) |
| 73 | return i, err |
| 74 | } |
| 75 | |
| 76 | const getRepoVariable = `-- name: GetRepoVariable :one |
| 77 | SELECT id, name, value, created_by_user_id, created_at, updated_at |
| 78 | FROM actions_variables |
| 79 | WHERE repo_id = $1 AND name = $2 |
| 80 | ` |
| 81 | |
| 82 | type GetRepoVariableParams struct { |
| 83 | RepoID pgtype.Int8 |
| 84 | Name string |
| 85 | } |
| 86 | |
| 87 | type GetRepoVariableRow struct { |
| 88 | ID int64 |
| 89 | Name string |
| 90 | Value string |
| 91 | CreatedByUserID pgtype.Int8 |
| 92 | CreatedAt pgtype.Timestamptz |
| 93 | UpdatedAt pgtype.Timestamptz |
| 94 | } |
| 95 | |
| 96 | func (q *Queries) GetRepoVariable(ctx context.Context, db DBTX, arg GetRepoVariableParams) (GetRepoVariableRow, error) { |
| 97 | row := db.QueryRow(ctx, getRepoVariable, arg.RepoID, arg.Name) |
| 98 | var i GetRepoVariableRow |
| 99 | err := row.Scan( |
| 100 | &i.ID, |
| 101 | &i.Name, |
| 102 | &i.Value, |
| 103 | &i.CreatedByUserID, |
| 104 | &i.CreatedAt, |
| 105 | &i.UpdatedAt, |
| 106 | ) |
| 107 | return i, err |
| 108 | } |
| 109 | |
| 110 | const listOrgVariables = `-- name: ListOrgVariables :many |
| 111 | SELECT id, name, value, created_by_user_id, created_at, updated_at |
| 112 | FROM actions_variables |
| 113 | WHERE org_id = $1 |
| 114 | ORDER BY name ASC |
| 115 | ` |
| 116 | |
| 117 | type ListOrgVariablesRow struct { |
| 118 | ID int64 |
| 119 | Name string |
| 120 | Value string |
| 121 | CreatedByUserID pgtype.Int8 |
| 122 | CreatedAt pgtype.Timestamptz |
| 123 | UpdatedAt pgtype.Timestamptz |
| 124 | } |
| 125 | |
| 126 | func (q *Queries) ListOrgVariables(ctx context.Context, db DBTX, orgID pgtype.Int8) ([]ListOrgVariablesRow, error) { |
| 127 | rows, err := db.Query(ctx, listOrgVariables, orgID) |
| 128 | if err != nil { |
| 129 | return nil, err |
| 130 | } |
| 131 | defer rows.Close() |
| 132 | items := []ListOrgVariablesRow{} |
| 133 | for rows.Next() { |
| 134 | var i ListOrgVariablesRow |
| 135 | if err := rows.Scan( |
| 136 | &i.ID, |
| 137 | &i.Name, |
| 138 | &i.Value, |
| 139 | &i.CreatedByUserID, |
| 140 | &i.CreatedAt, |
| 141 | &i.UpdatedAt, |
| 142 | ); err != nil { |
| 143 | return nil, err |
| 144 | } |
| 145 | items = append(items, i) |
| 146 | } |
| 147 | if err := rows.Err(); err != nil { |
| 148 | return nil, err |
| 149 | } |
| 150 | return items, nil |
| 151 | } |
| 152 | |
| 153 | const listRepoVariables = `-- name: ListRepoVariables :many |
| 154 | SELECT id, name, value, created_by_user_id, created_at, updated_at |
| 155 | FROM actions_variables |
| 156 | WHERE repo_id = $1 |
| 157 | ORDER BY name ASC |
| 158 | ` |
| 159 | |
| 160 | type ListRepoVariablesRow struct { |
| 161 | ID int64 |
| 162 | Name string |
| 163 | Value string |
| 164 | CreatedByUserID pgtype.Int8 |
| 165 | CreatedAt pgtype.Timestamptz |
| 166 | UpdatedAt pgtype.Timestamptz |
| 167 | } |
| 168 | |
| 169 | func (q *Queries) ListRepoVariables(ctx context.Context, db DBTX, repoID pgtype.Int8) ([]ListRepoVariablesRow, error) { |
| 170 | rows, err := db.Query(ctx, listRepoVariables, repoID) |
| 171 | if err != nil { |
| 172 | return nil, err |
| 173 | } |
| 174 | defer rows.Close() |
| 175 | items := []ListRepoVariablesRow{} |
| 176 | for rows.Next() { |
| 177 | var i ListRepoVariablesRow |
| 178 | if err := rows.Scan( |
| 179 | &i.ID, |
| 180 | &i.Name, |
| 181 | &i.Value, |
| 182 | &i.CreatedByUserID, |
| 183 | &i.CreatedAt, |
| 184 | &i.UpdatedAt, |
| 185 | ); err != nil { |
| 186 | return nil, err |
| 187 | } |
| 188 | items = append(items, i) |
| 189 | } |
| 190 | if err := rows.Err(); err != nil { |
| 191 | return nil, err |
| 192 | } |
| 193 | return items, nil |
| 194 | } |
| 195 | |
| 196 | const upsertOrgVariable = `-- name: UpsertOrgVariable :one |
| 197 | INSERT INTO actions_variables (org_id, name, value, created_by_user_id) |
| 198 | VALUES ($1, $2, $3, $4) |
| 199 | ON CONFLICT (org_id, name) WHERE org_id IS NOT NULL DO UPDATE |
| 200 | SET value = EXCLUDED.value, updated_at = now() |
| 201 | RETURNING id, repo_id, org_id, name, value, created_by_user_id, |
| 202 | created_at, updated_at |
| 203 | ` |
| 204 | |
| 205 | type UpsertOrgVariableParams struct { |
| 206 | OrgID pgtype.Int8 |
| 207 | Name string |
| 208 | Value string |
| 209 | CreatedByUserID pgtype.Int8 |
| 210 | } |
| 211 | |
| 212 | func (q *Queries) UpsertOrgVariable(ctx context.Context, db DBTX, arg UpsertOrgVariableParams) (ActionsVariable, error) { |
| 213 | row := db.QueryRow(ctx, upsertOrgVariable, |
| 214 | arg.OrgID, |
| 215 | arg.Name, |
| 216 | arg.Value, |
| 217 | arg.CreatedByUserID, |
| 218 | ) |
| 219 | var i ActionsVariable |
| 220 | err := row.Scan( |
| 221 | &i.ID, |
| 222 | &i.RepoID, |
| 223 | &i.OrgID, |
| 224 | &i.Name, |
| 225 | &i.Value, |
| 226 | &i.CreatedByUserID, |
| 227 | &i.CreatedAt, |
| 228 | &i.UpdatedAt, |
| 229 | ) |
| 230 | return i, err |
| 231 | } |
| 232 | |
| 233 | const upsertRepoVariable = `-- name: UpsertRepoVariable :one |
| 234 | |
| 235 | INSERT INTO actions_variables (repo_id, name, value, created_by_user_id) |
| 236 | VALUES ($1, $2, $3, $4) |
| 237 | ON CONFLICT (repo_id, name) WHERE repo_id IS NOT NULL DO UPDATE |
| 238 | SET value = EXCLUDED.value, updated_at = now() |
| 239 | RETURNING id, repo_id, org_id, name, value, created_by_user_id, |
| 240 | created_at, updated_at |
| 241 | ` |
| 242 | |
| 243 | type UpsertRepoVariableParams struct { |
| 244 | RepoID pgtype.Int8 |
| 245 | Name string |
| 246 | Value string |
| 247 | CreatedByUserID pgtype.Int8 |
| 248 | } |
| 249 | |
| 250 | // SPDX-License-Identifier: AGPL-3.0-or-later |
| 251 | func (q *Queries) UpsertRepoVariable(ctx context.Context, db DBTX, arg UpsertRepoVariableParams) (ActionsVariable, error) { |
| 252 | row := db.QueryRow(ctx, upsertRepoVariable, |
| 253 | arg.RepoID, |
| 254 | arg.Name, |
| 255 | arg.Value, |
| 256 | arg.CreatedByUserID, |
| 257 | ) |
| 258 | var i ActionsVariable |
| 259 | err := row.Scan( |
| 260 | &i.ID, |
| 261 | &i.RepoID, |
| 262 | &i.OrgID, |
| 263 | &i.Name, |
| 264 | &i.Value, |
| 265 | &i.CreatedByUserID, |
| 266 | &i.CreatedAt, |
| 267 | &i.UpdatedAt, |
| 268 | ) |
| 269 | return i, err |
| 270 | } |
| 271 |