fix bug in db migration logic