creatorupdatordeprecate

This commit is contained in:
Michael McGuinness
2025-01-03 13:41:07 +00:00
parent 0ac156f0e1
commit 788b21594c
36 changed files with 545 additions and 226 deletions
+33
View File
@@ -11,6 +11,15 @@ import (
"github.com/jackc/pgx/v5/pgtype"
)
const deprecateQuery = `-- name: DeprecateQuery :exec
INSERT INTO queryDeprecations (queryId) VALUES ($1) RETURNING id
`
func (q *Queries) DeprecateQuery(ctx context.Context, queryid pgtype.UUID) error {
_, err := q.db.Exec(ctx, deprecateQuery, queryid)
return err
}
const getQuery = `-- name: GetQuery :one
SELECT q.id, q.type, q.activeVersion, c.config, ARRAY_AGG(r.requiredQueryId) AS requiredIds
FROM queries AS q
@@ -65,3 +74,27 @@ func (q *Queries) GetQueryConfig(ctx context.Context, arg GetQueryConfigParams)
err := row.Scan(&i.ID, &i.Config)
return i, err
}
const getQueryType = `-- name: GetQueryType :one
SELECT type FROM queries where id = $1
`
func (q *Queries) GetQueryType(ctx context.Context, id pgtype.UUID) (Querytype, error) {
row := q.db.QueryRow(ctx, getQueryType, id)
var type_ Querytype
err := row.Scan(&type_)
return type_, err
}
const isQueryDeprecated = `-- name: IsQueryDeprecated :one
SELECT EXISTS (
SELECT 1 FROM queryDeprecations where queryId = $1 and removedAt is not null
)
`
func (q *Queries) IsQueryDeprecated(ctx context.Context, queryid pgtype.UUID) (bool, error) {
row := q.db.QueryRow(ctx, isQueryDeprecated, queryid)
var exists bool
err := row.Scan(&exists)
return exists, err
}