Trait pallet_contracts::migration::MigrateSequence
source · pub trait MigrateSequence: Sealed {
const VERSION_RANGE: (u16, u16);
// Required methods
fn new(version: StorageVersion) -> Cursor;
fn steps(
version: StorageVersion,
cursor: &[u8],
weight_left: &mut Weight
) -> StepResult;
fn integrity_test(max_block_weight: Weight);
// Provided method
fn is_upgrade_supported(
in_storage: StorageVersion,
target: StorageVersion
) -> bool { ... }
}
Expand description
Defines a sequence of migrations.
The sequence must be defined by a tuple of migrations, each of which must implement the
MigrationStep
trait. Migrations must be ordered by their versions with no gaps.
Required Associated Constants§
sourceconst VERSION_RANGE: (u16, u16)
const VERSION_RANGE: (u16, u16)
Returns the range of versions that this migrations sequence can handle. Migrations must be ordered by their versions with no gaps.
The following code will fail to compile:
ⓘ
let _ = <(NoopMigration<1>, NoopMigration<3>)>::VERSION_RANGE;
The following code will compile:
let _ = <(NoopMigration<1>, NoopMigration<2>)>::VERSION_RANGE;
Required Methods§
sourcefn steps(
version: StorageVersion,
cursor: &[u8],
weight_left: &mut Weight
) -> StepResult
fn steps( version: StorageVersion, cursor: &[u8], weight_left: &mut Weight ) -> StepResult
Execute the migration step until the weight limit is reached.
sourcefn integrity_test(max_block_weight: Weight)
fn integrity_test(max_block_weight: Weight)
Verify that the migration step fits into Cursor
, and that max_step_weight
is not greater
than max_block_weight
.
Provided Methods§
sourcefn is_upgrade_supported(
in_storage: StorageVersion,
target: StorageVersion
) -> bool
fn is_upgrade_supported( in_storage: StorageVersion, target: StorageVersion ) -> bool
Returns whether migrating from in_storage
to target
is supported.
A migration is supported if VERSION_RANGE
is (in_storage + 1, target).