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.
91 lines
2.7 KiB
Go
91 lines
2.7 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.29.0
|
|
// source: numeric_entitlement_contributions.sql
|
|
|
|
package entitlements
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const createNumericEntitlementContribution = `-- name: CreateNumericEntitlementContribution :one
|
|
INSERT INTO core.numeric_entitlement_contributions (entitlement_id, provision_id, contributed_value, stacking_policy)
|
|
VALUES ($1, $2, $3, $4)
|
|
RETURNING contribution_id, entitlement_id, provision_id, contributed_value, stacking_policy, created_at, updated_at
|
|
`
|
|
|
|
type CreateNumericEntitlementContributionParams struct {
|
|
EntitlementID string `json:"entitlement_id"`
|
|
ProvisionID string `json:"provision_id"`
|
|
ContributedValue int64 `json:"contributed_value"`
|
|
StackingPolicy string `json:"stacking_policy"`
|
|
}
|
|
|
|
func (q *Queries) CreateNumericEntitlementContribution(ctx context.Context, arg CreateNumericEntitlementContributionParams) (NumericEntitlementContribution, error) {
|
|
row := q.db.QueryRowContext(ctx, createNumericEntitlementContribution,
|
|
arg.EntitlementID,
|
|
arg.ProvisionID,
|
|
arg.ContributedValue,
|
|
arg.StackingPolicy,
|
|
)
|
|
var i NumericEntitlementContribution
|
|
err := row.Scan(
|
|
&i.ContributionID,
|
|
&i.EntitlementID,
|
|
&i.ProvisionID,
|
|
&i.ContributedValue,
|
|
&i.StackingPolicy,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const deleteContributionsByProvisionID = `-- name: DeleteContributionsByProvisionID :exec
|
|
DELETE FROM core.numeric_entitlement_contributions
|
|
WHERE provision_id = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteContributionsByProvisionID(ctx context.Context, provisionID string) error {
|
|
_, err := q.db.ExecContext(ctx, deleteContributionsByProvisionID, provisionID)
|
|
return err
|
|
}
|
|
|
|
const listContributionsByEntitlementID = `-- name: ListContributionsByEntitlementID :many
|
|
SELECT contribution_id, entitlement_id, provision_id, contributed_value, stacking_policy, created_at, updated_at FROM core.numeric_entitlement_contributions
|
|
WHERE entitlement_id = $1
|
|
ORDER BY created_at ASC
|
|
`
|
|
|
|
func (q *Queries) ListContributionsByEntitlementID(ctx context.Context, entitlementID string) ([]NumericEntitlementContribution, error) {
|
|
rows, err := q.db.QueryContext(ctx, listContributionsByEntitlementID, entitlementID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []NumericEntitlementContribution{}
|
|
for rows.Next() {
|
|
var i NumericEntitlementContribution
|
|
if err := rows.Scan(
|
|
&i.ContributionID,
|
|
&i.EntitlementID,
|
|
&i.ProvisionID,
|
|
&i.ContributedValue,
|
|
&i.StackingPolicy,
|
|
&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
|
|
}
|