fix migrate function