mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-02 20:54:23 +01:00
db: Switch to new DB asbtraction for DB migrations
These do not require the ability to iterate over the result, hence they can be migrated already. Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
committed by
Rusty Russell
parent
50a1af8908
commit
093f5bfbec
20
wallet/db.c
20
wallet/db.c
@@ -878,8 +878,12 @@ static void db_migrate(struct lightningd *ld, struct db *db, struct log *log)
|
||||
|
||||
while (current < available) {
|
||||
current++;
|
||||
if (dbmigrations[current].sql)
|
||||
db_exec(__func__, db, "%s", dbmigrations[current].sql);
|
||||
if (dbmigrations[current].sql) {
|
||||
struct db_stmt *stmt =
|
||||
db_prepare_v2(db, dbmigrations[current].sql);
|
||||
db_exec_prepared_v2(stmt);
|
||||
db_stmt_free(stmt);
|
||||
}
|
||||
if (dbmigrations[current].func)
|
||||
dbmigrations[current].func(ld, db);
|
||||
}
|
||||
@@ -1270,10 +1274,14 @@ void sqlite3_bind_amount_sat(sqlite3_stmt *stmt, int col,
|
||||
/* Will apply the current config fee settings to all channels */
|
||||
void migrate_pr2342_feerate_per_channel(struct lightningd *ld, struct db *db)
|
||||
{
|
||||
db_exec(__func__, db,
|
||||
"UPDATE channels SET feerate_base = %u, feerate_ppm = %u;",
|
||||
ld->config.fee_base,
|
||||
ld->config.fee_per_satoshi);
|
||||
struct db_stmt *stmt = db_prepare_v2(
|
||||
db, SQL("UPDATE channels SET feerate_base = ?, feerate_ppm = ?;"));
|
||||
|
||||
db_bind_int(stmt, 0, ld->config.fee_base);
|
||||
db_bind_int(stmt, 1, ld->config.fee_per_satoshi);
|
||||
|
||||
db_exec_prepared_v2(stmt);
|
||||
db_stmt_free(stmt);
|
||||
}
|
||||
|
||||
void sqlite3_bind_timeabs(sqlite3_stmt *stmt, int col, struct timeabs t)
|
||||
|
||||
Reference in New Issue
Block a user