[gh-469] Move migration code to its own module