diff --git a/sqldb/sqlc/graph.sql.go b/sqldb/sqlc/graph.sql.go index cdf15a90b..2c26eb5d2 100644 --- a/sqldb/sqlc/graph.sql.go +++ b/sqldb/sqlc/graph.sql.go @@ -3537,6 +3537,27 @@ func (q *Queries) ListNodesPaginated(ctx context.Context, arg ListNodesPaginated return items, nil } +const nodeExists = `-- name: NodeExists :one +SELECT EXISTS ( + SELECT 1 + FROM graph_nodes + WHERE pub_key = $1 + AND version = $2 +) AS node_exists +` + +type NodeExistsParams struct { + PubKey []byte + Version int16 +} + +func (q *Queries) NodeExists(ctx context.Context, arg NodeExistsParams) (bool, error) { + row := q.db.QueryRowContext(ctx, nodeExists, arg.PubKey, arg.Version) + var node_exists bool + err := row.Scan(&node_exists) + return node_exists, err +} + const upsertChanPolicyExtraType = `-- name: UpsertChanPolicyExtraType :exec /* ───────────────────────────────────────────── graph_channel_policy_extra_types table queries diff --git a/sqldb/sqlc/querier.go b/sqldb/sqlc/querier.go index 7b7b06495..aa8ab2ecf 100644 --- a/sqldb/sqlc/querier.go +++ b/sqldb/sqlc/querier.go @@ -125,6 +125,7 @@ type Querier interface { ListNodeIDsAndPubKeys(ctx context.Context, arg ListNodeIDsAndPubKeysParams) ([]ListNodeIDsAndPubKeysRow, error) ListNodesPaginated(ctx context.Context, arg ListNodesPaginatedParams) ([]GraphNode, error) NextInvoiceSettleIndex(ctx context.Context) (int64, error) + NodeExists(ctx context.Context, arg NodeExistsParams) (bool, error) OnAMPSubInvoiceCanceled(ctx context.Context, arg OnAMPSubInvoiceCanceledParams) error OnAMPSubInvoiceCreated(ctx context.Context, arg OnAMPSubInvoiceCreatedParams) error OnAMPSubInvoiceSettled(ctx context.Context, arg OnAMPSubInvoiceSettledParams) error diff --git a/sqldb/sqlc/queries/graph.sql b/sqldb/sqlc/queries/graph.sql index 480437655..2df865d9b 100644 --- a/sqldb/sqlc/queries/graph.sql +++ b/sqldb/sqlc/queries/graph.sql @@ -59,6 +59,14 @@ FROM graph_nodes WHERE pub_key = $1 AND version = $2; +-- name: NodeExists :one +SELECT EXISTS ( + SELECT 1 + FROM graph_nodes + WHERE pub_key = $1 + AND version = $2 +) AS node_exists; + -- name: GetNodeIDByPubKey :one SELECT id FROM graph_nodes