Add clear function for the accounts table.

This commit is contained in:
Kevin Gorham 2021-04-30 21:55:18 -04:00
parent 74434f370c
commit 08a5cfa80b
No known key found for this signature in database
GPG Key ID: CCA55602DF49FC38
1 changed files with 11 additions and 0 deletions

View File

@ -209,6 +209,17 @@ pub fn init_accounts_table<P: consensus::Parameters>(
Ok(())
}
pub fn clear_accounts_table<P: consensus::Parameters>(
wdb: &WalletDb<P>,
) -> Result<(), SqliteClientError> {
wdb.conn.execute("PRAGMA foreign_keys = OFF;", NO_PARAMS)?;
wdb.conn.execute( "DELETE FROM accounts;", NO_PARAMS, )?;
wdb.conn.execute("PRAGMA foreign_keys = ON;", NO_PARAMS)?;
Ok(())
}
/// Initialises the data database with the given block.
///
/// This enables a newly-created database to be immediately-usable, without needing to