Refactor migration tasks