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.
106 lines
2.8 KiB
Go
106 lines
2.8 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.29.0
|
|
// source: provider_operations.sql
|
|
|
|
package integration
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/lib/pq"
|
|
)
|
|
|
|
const addProviderOperation = `-- name: AddProviderOperation :exec
|
|
INSERT INTO core.provider_operations (provider, operation)
|
|
VALUES ($1, $2)
|
|
ON CONFLICT (provider, operation) DO NOTHING
|
|
`
|
|
|
|
type AddProviderOperationParams struct {
|
|
Provider string `json:"provider"`
|
|
Operation string `json:"operation"`
|
|
}
|
|
|
|
func (q *Queries) AddProviderOperation(ctx context.Context, arg AddProviderOperationParams) error {
|
|
_, err := q.db.ExecContext(ctx, addProviderOperation, arg.Provider, arg.Operation)
|
|
return err
|
|
}
|
|
|
|
const deleteProviderOperationsNotIn = `-- name: DeleteProviderOperationsNotIn :exec
|
|
DELETE FROM core.provider_operations
|
|
WHERE provider = $1 AND operation <> ALL($2::text[])
|
|
`
|
|
|
|
type DeleteProviderOperationsNotInParams struct {
|
|
Provider string `json:"provider"`
|
|
Operations []string `json:"operations"`
|
|
}
|
|
|
|
// Boot reconciliation: drop operations a provider no longer declares.
|
|
func (q *Queries) DeleteProviderOperationsNotIn(ctx context.Context, arg DeleteProviderOperationsNotInParams) error {
|
|
_, err := q.db.ExecContext(ctx, deleteProviderOperationsNotIn, arg.Provider, pq.Array(arg.Operations))
|
|
return err
|
|
}
|
|
|
|
const listAllProviderOperations = `-- name: ListAllProviderOperations :many
|
|
SELECT provider, operation FROM core.provider_operations
|
|
ORDER BY provider, operation
|
|
`
|
|
|
|
type ListAllProviderOperationsRow struct {
|
|
Provider string `json:"provider"`
|
|
Operation string `json:"operation"`
|
|
}
|
|
|
|
func (q *Queries) ListAllProviderOperations(ctx context.Context) ([]ListAllProviderOperationsRow, error) {
|
|
rows, err := q.db.QueryContext(ctx, listAllProviderOperations)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []ListAllProviderOperationsRow{}
|
|
for rows.Next() {
|
|
var i ListAllProviderOperationsRow
|
|
if err := rows.Scan(&i.Provider, &i.Operation); 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 listProviderOperations = `-- name: ListProviderOperations :many
|
|
SELECT operation FROM core.provider_operations
|
|
WHERE provider = $1 ORDER BY operation
|
|
`
|
|
|
|
func (q *Queries) ListProviderOperations(ctx context.Context, provider string) ([]string, error) {
|
|
rows, err := q.db.QueryContext(ctx, listProviderOperations, provider)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []string{}
|
|
for rows.Next() {
|
|
var operation string
|
|
if err := rows.Scan(&operation); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, operation)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|