Implementation of the database upgrade mechanism.