improve migrate script