sqldb: add a temporary index to store KV invoice hash to ID mapping

This commit is contained in:
Andras Banki-Horvath
2024-09-11 14:14:25 +02:00
parent 3820497d7f
commit b7d743929d
7 changed files with 109 additions and 0 deletions

View File

@@ -179,3 +179,23 @@ INSERT INTO invoice_htlc_custom_records (
SELECT ihcr.htlc_id, key, value
FROM invoice_htlcs ih JOIN invoice_htlc_custom_records ihcr ON ih.id=ihcr.htlc_id
WHERE ih.invoice_id = $1;
-- name: InsertKVInvoiceKeyAndAddIndex :exec
INSERT INTO invoice_payment_hashes (
id, add_index
) VALUES (
$1, $2
);
-- name: SetKVInvoicePaymentHash :exec
UPDATE invoice_payment_hashes
SET hash = $2
WHERE id = $1;
-- name: GetKVInvoicePaymentHashByAddIndex :one
SELECT hash
FROM invoice_payment_hashes
WHERE add_index = $1;
-- name: ClearKVInvoiceHashIndex :exec
DELETE FROM invoice_payment_hashes;