@@ -88,6 +88,8 @@ static void insert_addrtype_to_addresses(struct lightningd *ld,
8888 struct db * db );
8989static void migrate_convert_old_channel_keyidx (struct lightningd * ld ,
9090 struct db * db );
91+ static void migrate_initialize_channel_htlcs_wait_indexes (struct lightningd * ld ,
92+ struct db * db );
9193
9294/* Do not reorder or remove elements from this array, it is used to
9395 * migrate existing databases from a previous state, based on the
@@ -1035,6 +1037,9 @@ static struct migration dbmigrations[] = {
10351037 {NULL , migrate_convert_old_channel_keyidx },
10361038 {SQL ("INSERT INTO vars(name, intval)"
10371039 " VALUES('needs_p2wpkh_close_rescan', 1)" ), NULL },
1040+ {SQL ("ALTER TABLE channel_htlcs ADD updated_index BIGINT DEFAULT 0" ), NULL },
1041+ {SQL ("CREATE INDEX channel_htlcs_updated_idx ON channel_htlcs (updated_index)" ), NULL },
1042+ {NULL , migrate_initialize_channel_htlcs_wait_indexes },
10381043};
10391044
10401045/**
@@ -1850,6 +1855,16 @@ static void migrate_initialize_forwards_wait_indexes(struct lightningd *ld,
18501855 "MAX(rowid)" );
18511856}
18521857
1858+ static void migrate_initialize_channel_htlcs_wait_indexes (struct lightningd * ld ,
1859+ struct db * db )
1860+ {
1861+ migrate_initialize_wait_indexes (db ,
1862+ WAIT_SUBSYSTEM_FORWARD ,
1863+ WAIT_INDEX_CREATED ,
1864+ SQL ("SELECT MAX(id) FROM channel_htlcs;" ),
1865+ "MAX(id)" );
1866+ }
1867+
18531868static void complain_unfixed (struct lightningd * ld ,
18541869 enum channel_state state ,
18551870 u64 id ,
0 commit comments