Makes interfaces more reusable.
Fixes #6029
Migrate command accepts a datadir and an optional user-provided transformer function that transform v2 keys to v2 keys. Migrate command then builds a v3 backend state based on the existing v2 keys and the output of the transformer function.