diff --git a/graph/db/graph_test.go b/graph/db/graph_test.go index 6984517e0..c8a5c54b2 100644 --- a/graph/db/graph_test.go +++ b/graph/db/graph_test.go @@ -3359,6 +3359,9 @@ func TestAddChannelEdgeShellNodes(t *testing.T) { // error. err = graph.AddChannelEdge(&edgeInfo) require.ErrorIs(t, err, ErrEdgeAlreadyExist) + + // Show that updating the shell node to a full node record works. + require.NoError(t, graph.AddLightningNode(node2)) } // TestNodePruningUpdateIndexDeletion tests that once a node has been removed diff --git a/sqldb/sqlc/graph.sql.go b/sqldb/sqlc/graph.sql.go index 0823132a3..2c42e535a 100644 --- a/sqldb/sqlc/graph.sql.go +++ b/sqldb/sqlc/graph.sql.go @@ -542,7 +542,8 @@ ON CONFLICT (pub_key, version) last_update = EXCLUDED.last_update, color = EXCLUDED.color, signature = EXCLUDED.signature -WHERE EXCLUDED.last_update > nodes.last_update +WHERE nodes.last_update IS NULL + OR EXCLUDED.last_update > nodes.last_update RETURNING id ` diff --git a/sqldb/sqlc/queries/graph.sql b/sqldb/sqlc/queries/graph.sql index dd96ac2f1..a11bc7d62 100644 --- a/sqldb/sqlc/queries/graph.sql +++ b/sqldb/sqlc/queries/graph.sql @@ -17,7 +17,8 @@ ON CONFLICT (pub_key, version) last_update = EXCLUDED.last_update, color = EXCLUDED.color, signature = EXCLUDED.signature -WHERE EXCLUDED.last_update > nodes.last_update +WHERE nodes.last_update IS NULL + OR EXCLUDED.last_update > nodes.last_update RETURNING id; -- name: GetNodeByPubKey :one