Fix escape handling in migration