Refactor migration