sqldb: Change payment_intent relationship to payment table

Previously a one(intent)-to-many(payment) relationship it is now
changed to a one-to-one relationship because a payment request
only can have 1 payment related to it. Looking into the future
with BOLT12 offers, the fetched invoice from the offer could be
stored here as well and the relationship would still hold.
This commit is contained in:
ziggie committed 2026-02-25 08:02:08 +01:00
1 parent f8241748a1
commit 27071acb6b
4 files changed
+53 -52

No files matched your search

+3 -3
View File
@@ -9,7 +9,7 @@ SELECT
i.intent_type AS "intent_type",
i.intent_payload AS "intent_payload"
FROM payments p
LEFT JOIN payment_intents i ON i.id = p.intent_id
LEFT JOIN payment_intents i ON i.payment_id = p.id
WHERE (
p.id > sqlc.narg('index_offset_get') OR
sqlc.narg('index_offset_get') IS NULL
@@ -37,7 +37,7 @@ SELECT
i.intent_type AS "intent_type",
i.intent_payload AS "intent_payload"
FROM payments p
LEFT JOIN payment_intents i ON i.id = p.intent_id
LEFT JOIN payment_intents i ON i.payment_id = p.id
WHERE p.payment_identifier = $1;
-- name: FetchPaymentsByIDs :many
@@ -46,7 +46,7 @@ SELECT
i.intent_type AS "intent_type",
i.intent_payload AS "intent_payload"
FROM payments p
LEFT JOIN payment_intents i ON i.id = p.intent_id
LEFT JOIN payment_intents i ON i.payment_id = p.id
WHERE p.id IN (sqlc.slice('payment_ids')/*SLICE:payment_ids*/);
-- name: CountPayments :one