Repository: paritytech/substrate
File: frame/support/src/migrations.rs (Rust)

Code before:
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::{
	traits::{
		GetStorageVersion, NoStorageVersionSet, OnRuntimeUpgrade, PalletInfoAccess, StorageVersion,
	},
	weights::{RuntimeDbWeight, Weight},
};
use impl_trait_for_tuples::impl_for_tuples;
use sp_core::Get;
use sp_io::{hashing::twox_128, storage::clear_prefix, KillStorageResult};
use sp_std::marker::PhantomData;

#[cfg(feature = "try-runtime")]
use sp_std::vec::Vec;

/// Make it easier to write versioned runtime upgrades.
///
/// VersionedRuntimeUpgrade allows developers to write migrations without worrying about checking
/// and setting storage versions. Instead, the developer wraps their migration in this struct which
/// takes care of version handling using best practices.
///
/// It takes 4 type parameters:
/// - `Version`: The version being upgraded *from*.
/// - `Inner`: An implementation of `OnRuntimeUpgrade`.
/// - `Pallet`: The Pallet being upgraded.
/// - `Weight`: The runtime's RuntimeDbWeight implementation.
///
/// `Version` is used to check if the migration should be run. If it is run, the pallets on-chain
/// version is incremented.
///
/// Example:
/// ```ignore
/// parameter_types! {
/// 	pub const V4ToV5: StorageVersion = StorageVersion::new(4);
/// 	pub const V5ToV6: StorageVersion = StorageVersion::new(5);
/// }
///
/// // Migrations to pass to the Executive pallet.
/// pub type Migrations = (
/// 	// ...other migrations
/// 	VersionedRuntimeUpgrade<
/// 		V4ToV5,
/// 		parachains_configuration::migration::v5::MigrateToV5<Runtime>,
/// 		Configuration,
/// 		RocksDbWeight,
/// 	>,
/// 	VersionedRuntimeUpgrade<
/// 		V5ToV6,

Review comment (suggestion):
This is a good start, but I think we need `from` and `to`.  
It should advance exactly from `from` to `to`, so we can lock it down. No more `<` or `>` squishy logic anymore.

Code after:
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::{
	traits::{GetStorageVersion, NoStorageVersionSet, PalletInfoAccess, StorageVersion},
	weights::{RuntimeDbWeight, Weight},
};
use impl_trait_for_tuples::impl_for_tuples;
use sp_core::Get;
use sp_io::{hashing::twox_128, storage::clear_prefix, KillStorageResult};
use sp_std::marker::PhantomData;

#[cfg(feature = "try-runtime")]
use sp_std::vec::Vec;

#[cfg(feature = "experimental")]
use crate::traits::OnRuntimeUpgrade;

/// Make it easier to write versioned runtime upgrades.
///
/// [`VersionedRuntimeUpgrade`] allows developers to write migrations without worrying about
/// checking and setting storage versions. Instead, the developer wraps their migration in this
/// struct which takes care of version handling using best practices.
///
/// It takes 5 type parameters:
/// - `From`: The version being upgraded from.
/// - `To`: The version being upgraded to.
/// - `Inner`: An implementation of `OnRuntimeUpgrade`.
/// - `Pallet`: The Pallet being upgraded.
/// - `Weight`: The runtime's RuntimeDbWeight implementation.
///
/// When a [`VersionedRuntimeUpgrade`] `on_runtime_upgrade`, `pre_upgrade`, or `post_upgrade`
/// method is called, the on-chain version of the pallet is compared to `From`. If they match, the
/// `Inner` equivalent is called and the pallets on-chain version is set to `To` after the
/// migration. Otherwise, a warning is logged notifying the developer that the upgrade was a noop
/// and should probably be removed.
///
/// ### Examples
/// ```ignore
/// // In file defining migrations
/// pub struct VersionUncheckedMigrateV5ToV6<T>(sp_std::marker::PhantomData<T>);
/// impl<T: Config> OnRuntimeUpgrade for VersionUncheckedMigrateV5ToV6<T> {
/// 	// OnRuntimeUpgrade implementation...
/// }
///
/// pub type VersionCheckedMigrateV5ToV6<Runtime, Pallet, DbWeight> =
/// 	VersionedRuntimeUpgrade<5, 6, VersionUncheckedMigrateV5ToV6<Runtime>, Pallet, DbWeight>;
///
/// // Migrations tuple to pass to the Executive pallet:
/// pub type Migrations = (