Skip to content

Commit

Permalink
add storage migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
Roznovjak committed Nov 6, 2023
1 parent a36f7d1 commit d3edf0c
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions runtime/basilisk/src/migrations.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::Runtime;
use frame_support::{traits::OnRuntimeUpgrade, weights::Weight};
#[cfg(feature = "try-runtime")]
use sp_std::prelude::*;
Expand All @@ -6,15 +7,32 @@ pub struct OnRuntimeUpgradeMigration;
impl OnRuntimeUpgrade for OnRuntimeUpgradeMigration {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::DispatchError> {
Ok(vec![])
log::info!("PreMigrate Collator Selection Pallet start");
let number_of_invulnerables = pallet_collator_selection::migration::v1::MigrateToV1::<Runtime>::pre_upgrade()?;
log::info!("PreMigrate Collator Selection Pallet end");
Ok(number_of_invulnerables)
}

fn on_runtime_upgrade() -> Weight {
Weight::zero()
let mut weight: Weight = Weight::zero();

log::info!("Migrate Collator Selection Pallet to v1 start");
weight = weight.saturating_add(pallet_collator_selection::migration::v1::MigrateToV1::<Runtime>::on_runtime_upgrade());
log::info!("Migrate Collator Selection Pallet to v1 end");

log::info!("Migrate Unknown Tokens Pallet to v2 start");
weight = weight.saturating_add(orml_unknown_tokens::Migration::<Runtime>::on_runtime_upgrade());
log::info!("Migrate Unknown Tokens Pallet to v2 end");

weight
}

#[cfg(feature = "try-runtime")]
fn post_upgrade(_state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
Ok(())
fn post_upgrade(state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
log::info!("PostMigrate Collator Selection Pallet start");
let migration_result = pallet_collator_selection::migration::v1::MigrateToV1::<Runtime>::post_upgrade(state);
log::info!("PostMigrate Collator Selection Pallet end");

migration_result
}
}

0 comments on commit d3edf0c

Please sign in to comment.