Fix some issues of migrate script