db: Add a cleanup migration to clear any dangling utxoset entries

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker 2018-04-02 16:42:37 +02:00
parent eb531e6da7
commit 1133820ad6

View file

@ -270,6 +270,12 @@ char *dbmigrations[] = {
/* Record the msatoshi actually sent in a payment. */
"ALTER TABLE payments ADD msatoshi_sent INTEGER;",
"UPDATE payments SET msatoshi_sent = msatoshi;",
/* Delete dangling utxoset entries due to Issue #1280 */
"DELETE FROM utxoset WHERE blockheight IN ("
" SELECT DISTINCT(blockheight)"
" FROM utxoset LEFT OUTER JOIN blocks on (blockheight == blocks.height) "
" WHERE blocks.hash IS NULL"
");",
NULL,
};