Files
member-console/internal/billing/queries/payment_methods.sql
T
cgalo5758 b0072d8971 Consolidate domain tables into core schema
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.
2026-07-05 20:10:23 -05:00

33 lines
847 B
SQL

-- 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 *;
-- name: GetPaymentMethodByID :one
SELECT * FROM core.payment_methods
WHERE payment_method_id = $1;
-- name: GetPaymentMethodsByBillingAccountID :many
SELECT * FROM core.payment_methods
WHERE billing_account_id = $1
ORDER BY created_at DESC;
-- 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 *;
-- name: MarkPaymentMethodDetached :exec
UPDATE core.payment_methods
SET detached_at = NOW()
WHERE payment_method_id = $1;