So the question is quite simple. Let's say I have an original definition of nested enums like so:
#[derive(MaxEncodedLen, Debug, Encode, Decode, Copy, Clone, Eq, PartialEq, TypeInfo)]
pub enum MyNestedEnum {
Thing1(A),
Thing2(B),
}
#[derive(MaxEncodedLen, Debug, Encode, Decode, Copy, Clone, Eq, PartialEq, TypeInfo)]
pub enum A {
AThing1,
AThing2,
AThing3,
}
#[derive(MaxEncodedLen, Debug, Encode, Decode, Copy, Clone, Eq, PartialEq, TypeInfo)]
pub enum B {
BThing1,
}
And this enum is referenced for used in storage:
#[pallet::storage]
#[pallet::getter(fn account_enum_unit)]
pub type AccountEnumUnit<T: Config> = StorageDoubleMap<
_,
Blake2_128Concat, T::AccountId,
Blake2_128Concat, MyNestedEnum,
SomeUnit,
>;
Now, assume that the chain has been in operation and some data has been stored, using for example one of the paths to the element:
MyNestedEnum::Thing2(B::BThing1)
But now I want to upgrade my chain so that enum B
is enhanced with another new element changing it to:
pub enum B {
BThing1,
BThing2,
}
...and in future I should be able to store some new data using the new element, MyNestedEnum::Thing2(B::BThing2)
As the structure of enum B
has changed, must I perform a storage migration during the upgrade or is it sufficient to simply add the new element at the end in the enum? In other words will adding this new element corrupt storage even if it has not been used yet?
As a general remark I am assuming that as long as elements are not removed, no migration would need to happen, and also no migration would need to happen if you can be sure that an element nested or otherwise has never been used/stored at any time.
There are many other possibilities for change that could happen, but I wondered what the experience was for others.