Implemented migration logic.