Files
member-console/internal/billing/queries/subscription_items.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

22 lines
757 B
SQL

-- name: CreateSubscriptionItem :one
INSERT INTO core.subscription_items (subscription_id, product_id, price_id, quantity)
VALUES ($1, $2, $3, $4)
RETURNING *;
-- name: GetSubscriptionItemsBySubscriptionID :many
SELECT * FROM core.subscription_items
WHERE subscription_id = $1
ORDER BY created_at ASC;
-- name: GetSubscriptionItemByID :one
SELECT * FROM core.subscription_items
WHERE subscription_item_id = $1;
-- name: UpdateSubscriptionItemPriceProduct :one
-- Converge a core item row after an in-place Stripe price modification (paid->paid
-- switch): the Stripe item id is unchanged but it now carries a new price/product.
UPDATE core.subscription_items
SET product_id = $2, price_id = $3, quantity = $4
WHERE subscription_item_id = $1
RETURNING *;