Fix database upgrade script