wallet: fix migration of existing invoices's id variable.
Rusty can't type. Rusty can't test. Bad Rusty. Bad. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
909bed6a30
commit
435a4623ad
|
@ -913,7 +913,6 @@ def test_listinvoices_index(node_factory, executor):
|
|||
assert only_one(l2.rpc.listinvoices(index='updated', start=i, limit=1)['invoices'])['label'] == str(70 + 1 - i)
|
||||
|
||||
|
||||
@pytest.mark.xfail(strict=True)
|
||||
@unittest.skipIf(TEST_NETWORK != 'regtest', "The DB migration is network specific due to the chain var.")
|
||||
def test_invoices_wait_db_migration(node_factory, bitcoind):
|
||||
"""Canned db is from v23.02.2's test_invoice_routeboost_private l2"""
|
||||
|
|
16
wallet/db.c
16
wallet/db.c
|
@ -70,6 +70,9 @@ static void migrate_normalize_invstr(struct lightningd *ld,
|
|||
static void migrate_initialize_wait_indexes(struct lightningd *ld,
|
||||
struct db *db);
|
||||
|
||||
static void migrate_invoice_created_index_var(struct lightningd *ld,
|
||||
struct db *db);
|
||||
|
||||
/* Do not reorder or remove elements from this array, it is used to
|
||||
* migrate existing databases from a previous state, based on the
|
||||
* string indices */
|
||||
|
@ -966,6 +969,7 @@ static struct migration dbmigrations[] = {
|
|||
{SQL("ALTER TABLE invoices ADD updated_index BIGINT DEFAULT 0"), NULL},
|
||||
{SQL("CREATE INDEX invoice_update_idx ON invoices (updated_index)"), NULL},
|
||||
{NULL, migrate_datastore_commando_runes},
|
||||
{NULL, migrate_invoice_created_index_var},
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1672,6 +1676,18 @@ static void migrate_initialize_wait_indexes(struct lightningd *ld,
|
|||
tal_free(stmt);
|
||||
}
|
||||
|
||||
static void migrate_invoice_created_index_var(struct lightningd *ld, struct db *db)
|
||||
{
|
||||
struct db_stmt *stmt;
|
||||
|
||||
/* Prior migration had a typo! */
|
||||
stmt = db_prepare_v2(db, SQL("UPDATE vars"
|
||||
" SET name = 'last_invoices_created_index'"
|
||||
" WHERE name = 'last_invoice_created_index'"));
|
||||
db_exec_prepared_v2(stmt);
|
||||
tal_free(stmt);
|
||||
}
|
||||
|
||||
static void complain_unfixed(struct lightningd *ld,
|
||||
enum channel_state state,
|
||||
u64 id,
|
||||
|
|
Loading…
Reference in New Issue