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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2019-02-24 15:37:43 +10:30
parent 9aaf2fe8d4
commit b65c279557
1 changed files with 2 additions and 2 deletions

View File

@ -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);