Fix migrate bugs