| 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 | } |
| 199 |