4

I have one storagemap which stores u32 values, now I need to migrate this to Vec<T::AccountId> How to do this?

2 Answers 2

4

You can check how Substrate migrates the account references.

https://github.com/paritytech/substrate/pull/8221/files#diff-68096a50d12854e07693a4828590517bb81fea37a9253640278ecdc5b93b6992

The link shows you how to migrate.

And for your case:

YourMap::<T>::translate(|_key, old_u32_value|
    // This is just an example, put your `u32 -> Vec<AccountId>` logic here
    Some(vec![AccountId::from_u32(old_u32_value)])
);
2

You can check Substrate tutorial on storage migrations

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.