Files
member-console/internal/stripe/queries/customer_mappings.sql

22 lines
716 B
SQL

-- name: UpsertCustomerMapping :one
INSERT INTO stripe.customer_mappings (billing_account_id, stripe_customer_id, sync_status)
VALUES ($1, $2, $3)
ON CONFLICT (billing_account_id) DO UPDATE
SET stripe_customer_id = EXCLUDED.stripe_customer_id,
sync_status = EXCLUDED.sync_status,
updated_at = NOW()
RETURNING *;
-- name: GetCustomerMappingByBillingAccountID :one
SELECT * FROM stripe.customer_mappings
WHERE billing_account_id = $1;
-- name: GetCustomerMappingByStripeCustomerID :one
SELECT * FROM stripe.customer_mappings
WHERE stripe_customer_id = $1;
-- name: UpdateCustomerMappingSyncStatus :exec
UPDATE stripe.customer_mappings
SET sync_status = $2, updated_at = NOW()
WHERE billing_account_id = $1;