Fix potential issue in DB migrate code.