Migration logic and logging