Struct frame_support::migrations::RemovePallet
source · pub struct RemovePallet<P: Get<&'static str>, DbWeight: Get<RuntimeDbWeight>>(_);
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::{Pallet, Call, Storage, Config<T>, Event<T>} = 0,
SomePalletToRemove: pallet_something::{Pallet, Call, Storage, Event<T>} = 1,
AnotherPalletToRemove: pallet_something_else::{Pallet, Call, Storage, Event<T>} = 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
source§fn pre_upgrade() -> Result<Vec<u8>, TryRuntimeError>
fn pre_upgrade() -> Result<Vec<u8>, TryRuntimeError>
Hooks::pre_upgrade
.source§fn post_upgrade(_state: Vec<u8>) -> Result<(), TryRuntimeError>
fn post_upgrade(_state: Vec<u8>) -> Result<(), TryRuntimeError>
Hooks::post_upgrade
.source§fn try_on_runtime_upgrade(checks: bool) -> Result<Weight, TryRuntimeError>
fn try_on_runtime_upgrade(checks: bool) -> Result<Weight, TryRuntimeError>
pre_upgrade
->
on_runtime_upgrade
-> post_upgrade
hooks for a migration. Read moreAuto Trait Implementations§
impl<P, DbWeight> RefUnwindSafe for RemovePallet<P, DbWeight>where DbWeight: RefUnwindSafe, P: RefUnwindSafe,
impl<P, DbWeight> Send for RemovePallet<P, DbWeight>where DbWeight: Send, P: Send,
impl<P, DbWeight> Sync for RemovePallet<P, DbWeight>where DbWeight: Sync, P: Sync,
impl<P, DbWeight> Unpin for RemovePallet<P, DbWeight>where DbWeight: Unpin, P: Unpin,
impl<P, DbWeight> UnwindSafe for RemovePallet<P, DbWeight>where DbWeight: UnwindSafe, P: UnwindSafe,
Blanket Implementations§
source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
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, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for Twhere Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,
§impl<T> Pointable for T
impl<T> Pointable 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<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 Swhere
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for Swhere T: Bounded, S: TryInto<T>,
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.