'Upgrade the current database.
Typically this is only called if .upgrade_info() returns
UPGRADE_NECESSARY.'

def upgrade(self):

    self.acquire_lock()
    try:
        curr_ver = self.version
        while (curr_ver != self.VERSION):
            try:
                (result_ver, upgrader, upgrader_arg) = self._result_ver_and_upgrader_and_arg_from_curr_ver[curr_ver]
            except KeyError:
                raise DatabaseError(('cannot    upgrade    from    db    v%s:    no    upgrader    for    this    version' % curr_ver))
            log.info('upgrading    from    db    v%s    to    db    v%s    ...', curr_ver, result_ver)
            if (upgrader_arg is not None):
                upgrader(self, curr_ver, result_ver, upgrader_arg)
            else:
                upgrader(self, curr_ver, result_ver)
            curr_ver = result_ver
    finally:
        self.release_lock()
