Skip to content

Commit c648c7a

Browse files
committed
sqldb/sqlc: add zombie index table
Note that this table will only contain entries for channels that we have deleted from the `channels` table which is why we cannot use foreign keys. Similarly, we may no longer have node entries for the nodes in the table.
1 parent cee872a commit c648c7a

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

sqldb/sqlc/migrations/000007_graph.down.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ DROP TABLE IF EXISTS source_nodes;
2525
DROP TABLE IF EXISTS node_addresses;
2626
DROP TABLE IF EXISTS node_features;
2727
DROP TABLE IF EXISTS node_extra_types;
28-
DROP TABLE IF EXISTS nodes;
28+
DROP TABLE IF EXISTS nodes;
29+
DROP TABLE IF EXISTS channel_policy_extra_types;
30+
DROP TABLE IF EXISTS zombie_channels;

sqldb/sqlc/migrations/000007_graph.up.sql

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,3 +292,31 @@ CREATE TABLE IF NOT EXISTS channel_policy_extra_types (
292292
CREATE UNIQUE INDEX IF NOT EXISTS channel_policy_extra_types_unique ON channel_policy_extra_types (
293293
type, channel_policy_id
294294
);
295+
296+
/* ─────────────────────────────────────────────
297+
Other graph related tables
298+
─────────────────────────────────────────────
299+
*/
300+
301+
CREATE TABLE IF NOT EXISTS zombie_channels (
302+
-- The channel id (short channel id) of the channel.
303+
-- NOTE: we don't use a foreign key here to the `channels`
304+
-- table since we may delete the channel record once it
305+
-- is marked as a zombie.
306+
scid BLOB NOT NULL,
307+
308+
-- The protocol version that this node was gossiped on.
309+
version SMALLINT NOT NULL,
310+
311+
-- The public key of the node 1 node of the channel. If
312+
-- this is not null, it means an update from this node
313+
-- will be able to resurrect the channel.
314+
node_key_1 BLOB,
315+
316+
-- The public key of the node 2 node of the channel. If
317+
-- this is not null, it means an update from this node
318+
-- will be able to resurrect the channel.
319+
node_key_2 BLOB
320+
);
321+
CREATE UNIQUE INDEX IF NOT EXISTS zombie_channels_channel_id_version_idx
322+
ON zombie_channels(scid, version);

sqldb/sqlc/models.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)