Changed the way db is upgraded