Added database upgrade function