Fix database upgrade