mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-17 10:05:41 +00:00
remove old pallet migrations (#5194)
* remove old pallet migrations * remove more stuff
This commit is contained in:
@@ -16,29 +16,7 @@
|
||||
|
||||
//! A module that is responsible for migration of storage.
|
||||
|
||||
use crate::session_info::{Config, Pallet, Store};
|
||||
use frame_support::{pallet_prelude::*, traits::StorageVersion, weights::Weight};
|
||||
use frame_support::traits::StorageVersion;
|
||||
|
||||
/// The current storage version.
|
||||
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
|
||||
|
||||
/// Migrates the pallet storage to the most recent version, checking and setting the `StorageVersion`.
|
||||
pub fn migrate_to_latest<T: Config>() -> Weight {
|
||||
let mut weight = 0;
|
||||
if StorageVersion::get::<Pallet<T>>() < 1 {
|
||||
weight += migrate_to_v1::<T>();
|
||||
StorageVersion::new(1).put::<Pallet<T>>();
|
||||
}
|
||||
weight
|
||||
}
|
||||
|
||||
pub fn migrate_to_v1<T: Config>() -> Weight {
|
||||
let mut vs = 0;
|
||||
|
||||
<Pallet<T> as Store>::Sessions::translate_values(|old: primitives::v2::OldV1SessionInfo| {
|
||||
vs += 1;
|
||||
Some(primitives::v2::SessionInfo::from(old))
|
||||
});
|
||||
|
||||
T::DbWeight::get().reads_writes(vs, vs)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user