diff --git a/substrate/frame/balances/src/migration.rs b/substrate/frame/balances/src/migration.rs index 920c6eea56241..c75300dee0ca4 100644 --- a/substrate/frame/balances/src/migration.rs +++ b/substrate/frame/balances/src/migration.rs @@ -101,3 +101,24 @@ impl, I: 'static> OnRuntimeUpgrade for ResetInactive { } } } + +pub struct SimpleStorageUpdate(PhantomData<(T, I)>); +impl, I: 'static> OnRuntimeUpgrade for SimpleStorageUpdate { + fn on_runtime_upgrade() -> Weight { + let current_storage_version = >::current_storage_version(); + let on_chain_version = Pallet::::on_chain_storage_version(); + + if onchain_storage_version == 0 && current_storage_version != 0 { + current_storage_version.put::>(); + + log::info!(target: LOG_TARGET, "Storage to version {current_storage_version}"); + T::DbWeight::get().reads_writes(2 + accounts.len() as u64, 3) + } else { + log::info!( + target: LOG_TARGET, + "Migration did not execute. This probably should be removed" + ); + T::DbWeight::get().reads(1) + } + } +}