// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.31.1 // source: actions_variables.sql package actionsdb import ( "context" "github.com/jackc/pgx/v5/pgtype" ) const deleteOrgVariable = `-- name: DeleteOrgVariable :exec DELETE FROM actions_variables WHERE org_id = $1 AND name = $2 ` type DeleteOrgVariableParams struct { OrgID pgtype.Int8 Name string } func (q *Queries) DeleteOrgVariable(ctx context.Context, db DBTX, arg DeleteOrgVariableParams) error { _, err := db.Exec(ctx, deleteOrgVariable, arg.OrgID, arg.Name) return err } const deleteRepoVariable = `-- name: DeleteRepoVariable :exec DELETE FROM actions_variables WHERE repo_id = $1 AND name = $2 ` type DeleteRepoVariableParams struct { RepoID pgtype.Int8 Name string } func (q *Queries) DeleteRepoVariable(ctx context.Context, db DBTX, arg DeleteRepoVariableParams) error { _, err := db.Exec(ctx, deleteRepoVariable, arg.RepoID, arg.Name) return err } const listOrgVariables = `-- name: ListOrgVariables :many SELECT id, name, value, created_at, updated_at FROM actions_variables WHERE org_id = $1 ORDER BY name ASC ` type ListOrgVariablesRow struct { ID int64 Name string Value string CreatedAt pgtype.Timestamptz UpdatedAt pgtype.Timestamptz } func (q *Queries) ListOrgVariables(ctx context.Context, db DBTX, orgID pgtype.Int8) ([]ListOrgVariablesRow, error) { rows, err := db.Query(ctx, listOrgVariables, orgID) if err != nil { return nil, err } defer rows.Close() items := []ListOrgVariablesRow{} for rows.Next() { var i ListOrgVariablesRow if err := rows.Scan( &i.ID, &i.Name, &i.Value, &i.CreatedAt, &i.UpdatedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const listRepoVariables = `-- name: ListRepoVariables :many SELECT id, name, value, created_at, updated_at FROM actions_variables WHERE repo_id = $1 ORDER BY name ASC ` type ListRepoVariablesRow struct { ID int64 Name string Value string CreatedAt pgtype.Timestamptz UpdatedAt pgtype.Timestamptz } func (q *Queries) ListRepoVariables(ctx context.Context, db DBTX, repoID pgtype.Int8) ([]ListRepoVariablesRow, error) { rows, err := db.Query(ctx, listRepoVariables, repoID) if err != nil { return nil, err } defer rows.Close() items := []ListRepoVariablesRow{} for rows.Next() { var i ListRepoVariablesRow if err := rows.Scan( &i.ID, &i.Name, &i.Value, &i.CreatedAt, &i.UpdatedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const upsertOrgVariable = `-- name: UpsertOrgVariable :one INSERT INTO actions_variables (org_id, name, value, created_by_user_id) VALUES ($1, $2, $3, $4) ON CONFLICT (org_id, name) WHERE org_id IS NOT NULL DO UPDATE SET value = EXCLUDED.value, updated_at = now() RETURNING id, repo_id, org_id, name, value, created_by_user_id, created_at, updated_at ` type UpsertOrgVariableParams struct { OrgID pgtype.Int8 Name string Value string CreatedByUserID pgtype.Int8 } func (q *Queries) UpsertOrgVariable(ctx context.Context, db DBTX, arg UpsertOrgVariableParams) (ActionsVariable, error) { row := db.QueryRow(ctx, upsertOrgVariable, arg.OrgID, arg.Name, arg.Value, arg.CreatedByUserID, ) var i ActionsVariable err := row.Scan( &i.ID, &i.RepoID, &i.OrgID, &i.Name, &i.Value, &i.CreatedByUserID, &i.CreatedAt, &i.UpdatedAt, ) return i, err } const upsertRepoVariable = `-- name: UpsertRepoVariable :one INSERT INTO actions_variables (repo_id, name, value, created_by_user_id) VALUES ($1, $2, $3, $4) ON CONFLICT (repo_id, name) WHERE repo_id IS NOT NULL DO UPDATE SET value = EXCLUDED.value, updated_at = now() RETURNING id, repo_id, org_id, name, value, created_by_user_id, created_at, updated_at ` type UpsertRepoVariableParams struct { RepoID pgtype.Int8 Name string Value string CreatedByUserID pgtype.Int8 } // SPDX-License-Identifier: AGPL-3.0-or-later func (q *Queries) UpsertRepoVariable(ctx context.Context, db DBTX, arg UpsertRepoVariableParams) (ActionsVariable, error) { row := db.QueryRow(ctx, upsertRepoVariable, arg.RepoID, arg.Name, arg.Value, arg.CreatedByUserID, ) var i ActionsVariable err := row.Scan( &i.ID, &i.RepoID, &i.OrgID, &i.Name, &i.Value, &i.CreatedByUserID, &i.CreatedAt, &i.UpdatedAt, ) return i, err }