Skip to content

Commit

Permalink
db: don't enter into db_upgrades table on every startup.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
rustyrussell committed Mar 4, 2019
1 parent 9aaf2fe commit b65c279
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions wallet/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b65c279

Please sign in to comment.