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.
187 lines
5.1 KiB
Go
187 lines
5.1 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.29.0
|
|
// source: payment_methods.sql
|
|
|
|
package billing
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
)
|
|
|
|
const createPaymentMethod = `-- name: CreatePaymentMethod :one
|
|
INSERT INTO core.payment_methods (
|
|
billing_account_id, pm_type,
|
|
card_brand, card_last4, card_exp_month, card_exp_year,
|
|
funding, is_default
|
|
)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
|
RETURNING payment_method_id, billing_account_id, pm_type, card_brand, card_last4, card_exp_month, card_exp_year, funding, is_default, detached_at, created_at, updated_at
|
|
`
|
|
|
|
type CreatePaymentMethodParams struct {
|
|
BillingAccountID string `json:"billing_account_id"`
|
|
PmType string `json:"pm_type"`
|
|
CardBrand sql.NullString `json:"card_brand"`
|
|
CardLast4 sql.NullString `json:"card_last4"`
|
|
CardExpMonth sql.NullInt32 `json:"card_exp_month"`
|
|
CardExpYear sql.NullInt32 `json:"card_exp_year"`
|
|
Funding sql.NullString `json:"funding"`
|
|
IsDefault bool `json:"is_default"`
|
|
}
|
|
|
|
func (q *Queries) CreatePaymentMethod(ctx context.Context, arg CreatePaymentMethodParams) (PaymentMethod, error) {
|
|
row := q.db.QueryRowContext(ctx, createPaymentMethod,
|
|
arg.BillingAccountID,
|
|
arg.PmType,
|
|
arg.CardBrand,
|
|
arg.CardLast4,
|
|
arg.CardExpMonth,
|
|
arg.CardExpYear,
|
|
arg.Funding,
|
|
arg.IsDefault,
|
|
)
|
|
var i PaymentMethod
|
|
err := row.Scan(
|
|
&i.PaymentMethodID,
|
|
&i.BillingAccountID,
|
|
&i.PmType,
|
|
&i.CardBrand,
|
|
&i.CardLast4,
|
|
&i.CardExpMonth,
|
|
&i.CardExpYear,
|
|
&i.Funding,
|
|
&i.IsDefault,
|
|
&i.DetachedAt,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getPaymentMethodByID = `-- name: GetPaymentMethodByID :one
|
|
SELECT payment_method_id, billing_account_id, pm_type, card_brand, card_last4, card_exp_month, card_exp_year, funding, is_default, detached_at, created_at, updated_at FROM core.payment_methods
|
|
WHERE payment_method_id = $1
|
|
`
|
|
|
|
func (q *Queries) GetPaymentMethodByID(ctx context.Context, paymentMethodID string) (PaymentMethod, error) {
|
|
row := q.db.QueryRowContext(ctx, getPaymentMethodByID, paymentMethodID)
|
|
var i PaymentMethod
|
|
err := row.Scan(
|
|
&i.PaymentMethodID,
|
|
&i.BillingAccountID,
|
|
&i.PmType,
|
|
&i.CardBrand,
|
|
&i.CardLast4,
|
|
&i.CardExpMonth,
|
|
&i.CardExpYear,
|
|
&i.Funding,
|
|
&i.IsDefault,
|
|
&i.DetachedAt,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getPaymentMethodsByBillingAccountID = `-- name: GetPaymentMethodsByBillingAccountID :many
|
|
SELECT payment_method_id, billing_account_id, pm_type, card_brand, card_last4, card_exp_month, card_exp_year, funding, is_default, detached_at, created_at, updated_at FROM core.payment_methods
|
|
WHERE billing_account_id = $1
|
|
ORDER BY created_at DESC
|
|
`
|
|
|
|
func (q *Queries) GetPaymentMethodsByBillingAccountID(ctx context.Context, billingAccountID string) ([]PaymentMethod, error) {
|
|
rows, err := q.db.QueryContext(ctx, getPaymentMethodsByBillingAccountID, billingAccountID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []PaymentMethod{}
|
|
for rows.Next() {
|
|
var i PaymentMethod
|
|
if err := rows.Scan(
|
|
&i.PaymentMethodID,
|
|
&i.BillingAccountID,
|
|
&i.PmType,
|
|
&i.CardBrand,
|
|
&i.CardLast4,
|
|
&i.CardExpMonth,
|
|
&i.CardExpYear,
|
|
&i.Funding,
|
|
&i.IsDefault,
|
|
&i.DetachedAt,
|
|
&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 markPaymentMethodDetached = `-- name: MarkPaymentMethodDetached :exec
|
|
UPDATE core.payment_methods
|
|
SET detached_at = NOW()
|
|
WHERE payment_method_id = $1
|
|
`
|
|
|
|
func (q *Queries) MarkPaymentMethodDetached(ctx context.Context, paymentMethodID string) error {
|
|
_, err := q.db.ExecContext(ctx, markPaymentMethodDetached, paymentMethodID)
|
|
return err
|
|
}
|
|
|
|
const updatePaymentMethodSafeFields = `-- name: UpdatePaymentMethodSafeFields :one
|
|
UPDATE core.payment_methods
|
|
SET card_brand = $2,
|
|
card_last4 = $3,
|
|
card_exp_month = $4,
|
|
card_exp_year = $5,
|
|
funding = $6
|
|
WHERE payment_method_id = $1
|
|
RETURNING payment_method_id, billing_account_id, pm_type, card_brand, card_last4, card_exp_month, card_exp_year, funding, is_default, detached_at, created_at, updated_at
|
|
`
|
|
|
|
type UpdatePaymentMethodSafeFieldsParams struct {
|
|
PaymentMethodID string `json:"payment_method_id"`
|
|
CardBrand sql.NullString `json:"card_brand"`
|
|
CardLast4 sql.NullString `json:"card_last4"`
|
|
CardExpMonth sql.NullInt32 `json:"card_exp_month"`
|
|
CardExpYear sql.NullInt32 `json:"card_exp_year"`
|
|
Funding sql.NullString `json:"funding"`
|
|
}
|
|
|
|
func (q *Queries) UpdatePaymentMethodSafeFields(ctx context.Context, arg UpdatePaymentMethodSafeFieldsParams) (PaymentMethod, error) {
|
|
row := q.db.QueryRowContext(ctx, updatePaymentMethodSafeFields,
|
|
arg.PaymentMethodID,
|
|
arg.CardBrand,
|
|
arg.CardLast4,
|
|
arg.CardExpMonth,
|
|
arg.CardExpYear,
|
|
arg.Funding,
|
|
)
|
|
var i PaymentMethod
|
|
err := row.Scan(
|
|
&i.PaymentMethodID,
|
|
&i.BillingAccountID,
|
|
&i.PmType,
|
|
&i.CardBrand,
|
|
&i.CardLast4,
|
|
&i.CardExpMonth,
|
|
&i.CardExpYear,
|
|
&i.Funding,
|
|
&i.IsDefault,
|
|
&i.DetachedAt,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|