sqldb+graph/db: source nodes table, queries and CRUD

In this commit, we add the `source_nodes` table. It points to entries in
the `nodes` table. This table will store one entry per protocol version
that we are announcing a node_announcement on.

With this commit, we can run the TestSourceNode unit test against our
SQL backends.
This commit is contained in:
Elle Mouton
2025-05-19 12:11:15 +02:00
parent 86d48390ca
commit 0064d33cda
8 changed files with 184 additions and 5 deletions

View File

@ -116,3 +116,19 @@ WHERE node_id = $1;
DELETE FROM node_extra_types
WHERE node_id = $1
AND type = $2;
/* ─────────────────────────────────────────────
source_nodes table queries
─────────────────────────────────────────────
*/
-- name: AddSourceNode :exec
INSERT INTO source_nodes (node_id)
VALUES ($1)
ON CONFLICT (node_id) DO NOTHING;
-- name: GetSourceNodesByVersion :many
SELECT sn.node_id, n.pub_key
FROM source_nodes sn
JOIN nodes n ON sn.node_id = n.id
WHERE n.version = $1;