pub struct RemovePallet<P: Get<&'static str>, DbWeight: Get<RuntimeDbWeight>>(/* private fields */);
Expand description
RemovePallet
is a utility struct used to remove all storage items associated with a specific
pallet.
This struct is generic over two parameters:
P
is a type that implements theGet
trait for a static string, representing the pallet’s name.DbWeight
is a type that implements theGet
trait forRuntimeDbWeight
, providing the weight for database operations.
On runtime upgrade, the on_runtime_upgrade
function will clear all storage items associated
with the specified pallet, logging the number of keys removed. If the try-runtime
feature is
enabled, the pre_upgrade
and post_upgrade
functions can be used to verify the storage
removal before and after the upgrade.
§Examples:
construct_runtime! {
pub enum Runtime
{
System: frame_system = 0,
SomePalletToRemove: pallet_something = 1,
AnotherPalletToRemove: pallet_something_else = 2,
YourOtherPallets...
}
};
parameter_types! {
pub const SomePalletToRemoveStr: &'static str = "SomePalletToRemove";
pub const AnotherPalletToRemoveStr: &'static str = "AnotherPalletToRemove";
}
pub type Migrations = (
RemovePallet<SomePalletToRemoveStr, RocksDbWeight>,
RemovePallet<AnotherPalletToRemoveStr, RocksDbWeight>,
AnyOtherMigrations...
);
pub type Executive = frame_executive::Executive<
Runtime,
Block,
frame_system::ChainContext<Runtime>,
Runtime,
Migrations
>;
WARNING: RemovePallet
has no guard rails preventing it from bricking the chain if the
operation of removing storage for the given pallet would exceed the block weight limit.
If your pallet has too many keys to be removed in a single block, it is advised to wait for a multi-block scheduler currently under development which will allow for removal of storage items (and performing other heavy migrations) over multiple blocks (see https://github.com/paritytech/substrate/issues/13690).
Trait Implementations§
Source§impl<P: Get<&'static str>, DbWeight: Get<RuntimeDbWeight>> OnRuntimeUpgrade for RemovePallet<P, DbWeight>
impl<P: Get<&'static str>, DbWeight: Get<RuntimeDbWeight>> OnRuntimeUpgrade for RemovePallet<P, DbWeight>
Source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Auto Trait Implementations§
impl<P, DbWeight> Freeze for RemovePallet<P, DbWeight>
impl<P, DbWeight> RefUnwindSafe for RemovePallet<P, DbWeight>where
P: RefUnwindSafe,
DbWeight: RefUnwindSafe,
impl<P, DbWeight> Send for RemovePallet<P, DbWeight>
impl<P, DbWeight> Sync for RemovePallet<P, DbWeight>
impl<P, DbWeight> Unpin for RemovePallet<P, DbWeight>
impl<P, DbWeight> UnwindSafe for RemovePallet<P, DbWeight>where
P: UnwindSafe,
DbWeight: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
Source§impl<T, U> DefensiveTruncateInto<U> for Twhere
U: DefensiveTruncateFrom<T>,
impl<T, U> DefensiveTruncateInto<U> for Twhere
U: DefensiveTruncateFrom<T>,
Source§fn defensive_truncate_into(self) -> U
fn defensive_truncate_into(self) -> U
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<Src, Dest> IntoTuple<Dest> for Srcwhere
Dest: FromTuple<Src>,
impl<Src, Dest> IntoTuple<Dest> for Srcwhere
Dest: FromTuple<Src>,
fn into_tuple(self) -> Dest
Source§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
Source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
Source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
Source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T
. Read moreSource§impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
type Error = <U as TryFromKey<T>>::Error
fn try_into_key(self) -> Result<U, <U as TryFromKey<T>>::Error>
Source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
Source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.Source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
Source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.