Fix database upgrade SQL