db: fix dangling peers on db upgrade.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2019-02-21 14:22:41 +10:30
committed by Christian Decker
parent 594f260de7
commit 6ed54dd34e
2 changed files with 2 additions and 3 deletions

View File

@@ -1,9 +1,6 @@
from fixtures import * # noqa: F401,F403
import pytest
@pytest.mark.xfail(strict=True)
def test_db_dangling_peer_fix(node_factory):
# This was taken from test_fail_unconfirmed() node.
l1 = node_factory.get_node(dbfile='dangling-peer.sqlite3.xz')

View File

@@ -356,6 +356,8 @@ char *dbmigrations[] = {
");",
/* Add a direction for failed payments. */
"ALTER TABLE payments ADD faildirection INTEGER;", /* erring_direction */
/* Fix dangling peers with no channels. */
"DELETE FROM peers WHERE id NOT IN (SELECT peer_id FROM channels);",
NULL,
};