Skip to content

Commit 7b5e4ec

Browse files
authored
Fix migrations (#2942)
* fix migrations * fix
1 parent c83043a commit 7b5e4ec

2 files changed

Lines changed: 32 additions & 8 deletions

File tree

runtime/acala/src/lib.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,13 +1999,25 @@ pub type Executive = frame_executive::Executive<
19991999
Migrations,
20002000
>;
20012001

2002-
parameter_types! {
2003-
pub const XTokensPallet: &'static str = "XTokens";
2004-
pub const MigrationStatus: &'static str = "MigrationStatus";
2002+
pub struct RemoveXTokensMigrationStatus<T>(frame_support::pallet_prelude::PhantomData<T>);
2003+
2004+
impl<T: frame_system::Config> frame_support::traits::OnRuntimeUpgrade for RemoveXTokensMigrationStatus<T> {
2005+
fn on_runtime_upgrade() -> Weight {
2006+
let key = frame_support::storage::storage_prefix(b"XTokens", b"MigrationStatus");
2007+
log::info!(
2008+
"key: {:?}, exists: {:?}",
2009+
key,
2010+
frame_support::storage::unhashed::exists(&key)
2011+
);
2012+
2013+
frame_support::storage::unhashed::kill(&key);
2014+
2015+
T::DbWeight::get().writes(1)
2016+
}
20052017
}
20062018

20072019
#[allow(unused_parens)]
2008-
type Migrations = (frame_support::migrations::RemoveStorage<XTokensPallet, MigrationStatus, RocksDbWeight>,);
2020+
type Migrations = (RemoveXTokensMigrationStatus<Runtime>);
20092021

20102022
#[cfg(feature = "runtime-benchmarks")]
20112023
#[macro_use]

runtime/karura/src/lib.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2006,13 +2006,25 @@ pub type Executive = frame_executive::Executive<
20062006
Migrations,
20072007
>;
20082008

2009-
parameter_types! {
2010-
pub const XTokensPallet: &'static str = "XTokens";
2011-
pub const MigrationStatus: &'static str = "MigrationStatus";
2009+
pub struct RemoveXTokensMigrationStatus<T>(frame_support::pallet_prelude::PhantomData<T>);
2010+
2011+
impl<T: frame_system::Config> frame_support::traits::OnRuntimeUpgrade for RemoveXTokensMigrationStatus<T> {
2012+
fn on_runtime_upgrade() -> Weight {
2013+
let key = frame_support::storage::storage_prefix(b"XTokens", b"MigrationStatus");
2014+
log::info!(
2015+
"key: {:?}, exists: {:?}",
2016+
key,
2017+
frame_support::storage::unhashed::exists(&key)
2018+
);
2019+
2020+
frame_support::storage::unhashed::kill(&key);
2021+
2022+
T::DbWeight::get().writes(1)
2023+
}
20122024
}
20132025

20142026
#[allow(unused_parens)]
2015-
type Migrations = (frame_support::migrations::RemoveStorage<XTokensPallet, MigrationStatus, RocksDbWeight>,);
2027+
type Migrations = (RemoveXTokensMigrationStatus<Runtime>);
20162028

20172029
#[cfg(feature = "runtime-benchmarks")]
20182030
#[macro_use]

0 commit comments

Comments
 (0)