From b65c279557c4438d13b223a160299a0ad516a5dd Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sun, 24 Feb 2019 15:37:43 +1030 Subject: [PATCH] db: don't enter into db_upgrades table on every startup. Below this code appears: if (current != orig) db_exec(__func__, db, "INSERT INTO db_upgrades VALUES (%i, '%s');", orig, version()); But since the loop pre-increments current, this is always true. I wondered why there were so many duplicates in my db_upgrades table! Signed-off-by: Rusty Russell --- wallet/db.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wallet/db.c b/wallet/db.c index b9addde3e..ac10fb4a6 100644 --- a/wallet/db.c +++ b/wallet/db.c @@ -636,8 +636,8 @@ static void db_migrate(struct db *db, struct log *log) log_info(log, "Updating database from version %u to %u", current, available); - while (++current <= available) - db_exec(__func__, db, "%s", dbmigrations[current]); + while (current < available) + db_exec(__func__, db, "%s", dbmigrations[++current]); /* Finally update the version number in the version table */ db_exec(__func__, db, "UPDATE version SET version=%d;", available);