A repository of Substrate runtime migrations.
Feel free to open PRs to include your own examples of applying Substrate migrations and/or notes.
- Storage migrations knowledgebase article on the DevHub.
- Substrate PRs including migration relevant code.
- Run custom OnRuntimeUpgrade first (before
frame_system
)
This lists PRs that include or induce storage migrations in FRAME pallets after Substrate 2.0 with some examples of how they were implemented in production chains.
Examples
- Polkadot: paritytech/polkadot#3413
Moves from using the Rust crate version to a dedicated version number for the pallet storage version.
See paritytech/substrate#9165 (comment) for how to execute the resulting storage migration.
Examples
- Polkadot: paritytech/polkadot#3526
Introduces counts for the nominators and validators.
Two potential reasons for migrations:
- The assets and proxy pallets now use
BoundedVec
, so if the storage contains entries that overshoot the configuredStringLimit
for assets orMaxProxies
for proxy they will need a migration. - The time delayed proxies migration function was removed.
Removes the contracts pallet's schedule from storage and puts it in the pallet configuration instead.
Examples
- Polkadot: paritytech/polkadot#2432
Examples
- Polkadot: paritytech/polkadot#2467
Required for: paritytech/substrate#8220
2021-02-10
Substrate v3.0.0
Using the procedural macro shifts the storage prefix from the decl_storage
macro invocation to the pallet instantiation in the construct_runtime
macro.
As a result migrations to the new macro do not inherently require a migration, but might incidentally create the necessity if care is not taken to make sure that the prefix stays the same.
PRs porting pallets to the new procedural macro that were merged in 2021 are listed here:
- paritytech/substrate#7898
- paritytech/substrate#7936
- paritytech/substrate#7984
- paritytech/substrate#8078
- paritytech/substrate#8310
- paritytech/substrate#8337
- paritytech/substrate#8365
- paritytech/substrate#8440
- paritytech/substrate#8448
- paritytech/substrate#8452
- paritytech/substrate#8465
- paritytech/substrate#8620
- paritytech/substrate#8663
- paritytech/substrate#8724
- paritytech/substrate#8741
- paritytech/substrate#8761
- paritytech/substrate#8762
- paritytech/substrate#8763
- paritytech/substrate#8769
- paritytech/substrate#8824
- paritytech/substrate#8825
- paritytech/substrate#9061
- paritytech/substrate#9083
- paritytech/substrate#9087
- paritytech/substrate#9088
- paritytech/substrate#9115
- paritytech/substrate#9197
- paritytech/substrate#9566
- paritytech/substrate#9711
- paritytech/substrate#9472
- paritytech/substrate#9796
- paritytech/substrate#9878
Examples
- Polkadot: paritytech/polkadot#1719
Should not require any manual code as the version is updated automatically on every on_runtime_upgrade
.
Note: If using the introduced migration function, you should use storage version guards to make sure it only runs once.
2020-09-22
Substrate v2.0.0
This lists PRs that include or induce storage migrations before Substrate 2.0 with some examples of how they were implemented in production chains.
Examples
- Polkadot: paritytech/polkadot#1692
Warning: This migration is missing a storage guard so it might be applied more than once if included in more than one runtime uprade. Use the extracted migration from paritytech/substrate#7205 in combination with a storage guard if running this migration.
Note: A migration function is provided, but you will need to manually trigger this migration if it applies to your runtime.
Examples
- Edgeware: hicommonwealth/substrate#15
Examples
- Edgeware: hicommonwealth/substrate#14
Introduces multisigs pallet.
Examples
- Edgeware: hicommonwealth/substrate#15
Flips the deposit order of fields.
Examples
- Edgeware: hicommonwealth/substrate#12
Examples
- Edgeware: hicommonwealth/substrate#6
Examples
- Edgeware: hicommonwealth/edgeware-node#173 and hicommonwealth/substrate#10
and democracy refactoring. No migration in Substrate, but might require one for chains using the pallet.
Examples
- Edgeware: hicommonwealth/substrate#12
Examples
- Edgeware: hicommonwealth/substrate#11 and hicommonwealth/edgeware-node#174
Examples
- Edgeware: hicommonwealth/substrate#12
NOTE: If included will influence how other migrations are run. (Pre-hasher migrations cannot iterate storage easily.)
Examples
Examples
- Edgeware: hicommonwealth/substrate#6
paritytech/substrate#5058 (includes balances migration, removed in paritytech/substrate#5224)
Examples
- Edgeware: hicommonwealth/edgeware-node#173 and hicommonwealth/substrate#10
Examples
- Edgeware: hicommonwealth/substrate#6
paritytech/substrate#4820) (includes indices migration removed in paritytech/substrate#5870)
Examples
- Edgeware: hicommonwealth/substrate#14
Examples
- Edgeware: hicommonwealth/substrate#6
This lists the PRs that removed migration code from Substrate.
Democracy, Indices, Multisigs, Staking, Transaction Payment
Democracy, Indices, Offences, Staking, Transaction Payment
Mostly account/hasher migration, epochs, opaque hashers, grandpa authorities
Balances
Uses PalletVersion
to determine that pallet was not present before to do initial migration of data to storage.
Uses PalletVersion