Skip to content

Commit

Permalink
wallet: Re-sync the payments.id sequence with postgresql
Browse files Browse the repository at this point in the history
Fixes ElementsProject#4883
Fixes ElementsProject#4879
Changelog-None: Unreleased bug being fixed.
  • Loading branch information
cdecker committed Oct 29, 2021
1 parent 26e2f4b commit 305e456
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions wallet/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,9 @@ static struct migration dbmigrations[] = {
/* We default to 50k sats */
{SQL("ALTER TABLE channel_configs ADD max_dust_htlc_exposure_msat BIGINT DEFAULT 50000000"), NULL},
{SQL("ALTER TABLE channel_htlcs ADD fail_immediate INTEGER DEFAULT 0"), NULL},

/* Issue #4887: reset the payments.id sequence after the migration above. Since this is a SELECT statement that would otherwise fail, make it an INSERT into the `vars` table.*/
{SQL("/*PSQL*/INSERT INTO vars (name, intval) VALUES ('payment_id_reset', setval(pg_get_serial_sequence('payments', 'id'), COALESCE((SELECT MAX(id)+1 FROM payments), 1)))"), NULL},
};

/* Leak tracking. */
Expand Down

0 comments on commit 305e456

Please sign in to comment.