diff --git a/rust-bins/duniter-dbex/src/migrate.rs b/rust-bins/duniter-dbex/src/migrate.rs index 591b7a81def64f765d9f7c4ecec6546ef87dc9be..2e7b671d8cd2049995edc8e33c590472c8063597 100644 --- a/rust-bins/duniter-dbex/src/migrate.rs +++ b/rust-bins/duniter-dbex/src/migrate.rs @@ -28,6 +28,10 @@ pub(crate) fn migrate(profile_path: PathBuf) -> anyhow::Result<()> { let start_time = Instant::now(); let dbs = duniter_dbs::open_dbs(Some(profile_path.as_path())); + // Clear bc_db and gva_db + dbs.bc_db.clear()?; + dbs.gva_db.clear()?; + let data_path = profile_path.join(crate::DATA_DIR); let duniter_js_db = BcV1Db::<LevelDb>::open(LevelDbConf { db_path: data_path.as_path().join("leveldb"), diff --git a/rust-libs/tools/kv_typed/src/db_schema.rs b/rust-libs/tools/kv_typed/src/db_schema.rs index 925c04d7c542a7468d931187815b142ca2291e56..3c4835031f71c0d8de856fee90ca5e1be4982dcd 100644 --- a/rust-libs/tools/kv_typed/src/db_schema.rs +++ b/rust-libs/tools/kv_typed/src/db_schema.rs @@ -141,6 +141,7 @@ macro_rules! db_schema { $(type [<$col_name ColRw>]: DbCollectionRw;)* type DbRo: Sized; + fn clear(&self) -> KvResult<()>; fn get_ro_handler(&self) -> Self::DbRo; fn open( backend_conf: <<Self as [<$db_name DbWritable>]>::Backend as kv_typed::backend::Backend>::Conf, @@ -156,6 +157,11 @@ macro_rules! db_schema { $(type [<$col_name ColRw>] = ColRw<B::Col, [<$col_name Event>]>;)* type DbRo = [<$db_name DbRo>]<B>; + #[inline(always)] + fn clear(&self) -> KvResult<()> { + $(self.collections.[<$col_name:snake>].clear()?;)* + Ok(()) + } #[inline(always)] fn get_ro_handler(&self) -> Self::DbRo { [<$db_name DbRo>] { @@ -182,11 +188,15 @@ macro_rules! db_schema { }, }) } + #[inline(always)] fn save(&self) -> KvResult<()> { $(self.collections.[<$col_name:snake>].save()?;)* Ok(()) } - $(fn [<$col_name:snake _write>](&self) -> &ColRw<B::Col, [<$col_name Event>]> { &self.collections.[<$col_name:snake>] })* + $( + #[inline(always)] + fn [<$col_name:snake _write>](&self) -> &ColRw<B::Col, [<$col_name Event>]> { &self.collections.[<$col_name:snake>] } + )* } } }