Squash the pre-production migration history into fresh core, fedwiki, and stripe baselines and reduce the canonical source list to those three streams. Update sqlc configs, generated queries, raw SQL, tests, and docs while keeping provider tables schema-qualified. BREAKING: existing local database volumes must be wiped because goose version history restarts from the new baselines.
137 lines
3.9 KiB
Go
137 lines
3.9 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.29.0
|
|
// source: numeric_entitlements.sql
|
|
|
|
package entitlements
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const createNumericEntitlement = `-- name: CreateNumericEntitlement :one
|
|
INSERT INTO core.numeric_entitlements (pool_id, resource_key, entitlement_type, resource_limit)
|
|
VALUES ($1, $2, $3, $4)
|
|
RETURNING entitlement_id, pool_id, resource_key, entitlement_type, resource_limit, reset_period, created_at, updated_at
|
|
`
|
|
|
|
type CreateNumericEntitlementParams struct {
|
|
PoolID string `json:"pool_id"`
|
|
ResourceKey string `json:"resource_key"`
|
|
EntitlementType string `json:"entitlement_type"`
|
|
ResourceLimit int64 `json:"resource_limit"`
|
|
}
|
|
|
|
func (q *Queries) CreateNumericEntitlement(ctx context.Context, arg CreateNumericEntitlementParams) (NumericEntitlement, error) {
|
|
row := q.db.QueryRowContext(ctx, createNumericEntitlement,
|
|
arg.PoolID,
|
|
arg.ResourceKey,
|
|
arg.EntitlementType,
|
|
arg.ResourceLimit,
|
|
)
|
|
var i NumericEntitlement
|
|
err := row.Scan(
|
|
&i.EntitlementID,
|
|
&i.PoolID,
|
|
&i.ResourceKey,
|
|
&i.EntitlementType,
|
|
&i.ResourceLimit,
|
|
&i.ResetPeriod,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getNumericEntitlementByPoolAndResource = `-- name: GetNumericEntitlementByPoolAndResource :one
|
|
SELECT entitlement_id, pool_id, resource_key, entitlement_type, resource_limit, reset_period, created_at, updated_at FROM core.numeric_entitlements
|
|
WHERE pool_id = $1 AND resource_key = $2
|
|
`
|
|
|
|
type GetNumericEntitlementByPoolAndResourceParams struct {
|
|
PoolID string `json:"pool_id"`
|
|
ResourceKey string `json:"resource_key"`
|
|
}
|
|
|
|
func (q *Queries) GetNumericEntitlementByPoolAndResource(ctx context.Context, arg GetNumericEntitlementByPoolAndResourceParams) (NumericEntitlement, error) {
|
|
row := q.db.QueryRowContext(ctx, getNumericEntitlementByPoolAndResource, arg.PoolID, arg.ResourceKey)
|
|
var i NumericEntitlement
|
|
err := row.Scan(
|
|
&i.EntitlementID,
|
|
&i.PoolID,
|
|
&i.ResourceKey,
|
|
&i.EntitlementType,
|
|
&i.ResourceLimit,
|
|
&i.ResetPeriod,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listNumericEntitlementsByPoolID = `-- name: ListNumericEntitlementsByPoolID :many
|
|
SELECT entitlement_id, pool_id, resource_key, entitlement_type, resource_limit, reset_period, created_at, updated_at FROM core.numeric_entitlements
|
|
WHERE pool_id = $1
|
|
ORDER BY resource_key ASC
|
|
`
|
|
|
|
func (q *Queries) ListNumericEntitlementsByPoolID(ctx context.Context, poolID string) ([]NumericEntitlement, error) {
|
|
rows, err := q.db.QueryContext(ctx, listNumericEntitlementsByPoolID, poolID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []NumericEntitlement{}
|
|
for rows.Next() {
|
|
var i NumericEntitlement
|
|
if err := rows.Scan(
|
|
&i.EntitlementID,
|
|
&i.PoolID,
|
|
&i.ResourceKey,
|
|
&i.EntitlementType,
|
|
&i.ResourceLimit,
|
|
&i.ResetPeriod,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const updateNumericEntitlementLimit = `-- name: UpdateNumericEntitlementLimit :one
|
|
UPDATE core.numeric_entitlements
|
|
SET resource_limit = $2
|
|
WHERE entitlement_id = $1
|
|
RETURNING entitlement_id, pool_id, resource_key, entitlement_type, resource_limit, reset_period, created_at, updated_at
|
|
`
|
|
|
|
type UpdateNumericEntitlementLimitParams struct {
|
|
EntitlementID string `json:"entitlement_id"`
|
|
ResourceLimit int64 `json:"resource_limit"`
|
|
}
|
|
|
|
func (q *Queries) UpdateNumericEntitlementLimit(ctx context.Context, arg UpdateNumericEntitlementLimitParams) (NumericEntitlement, error) {
|
|
row := q.db.QueryRowContext(ctx, updateNumericEntitlementLimit, arg.EntitlementID, arg.ResourceLimit)
|
|
var i NumericEntitlement
|
|
err := row.Scan(
|
|
&i.EntitlementID,
|
|
&i.PoolID,
|
|
&i.ResourceKey,
|
|
&i.EntitlementType,
|
|
&i.ResourceLimit,
|
|
&i.ResetPeriod,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|