<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def perform(self):
 """Perform the version upgrade on the database. """

        db_versions = self.table.versions()

        version = self.version
        if (version.is_processed(db_versions) and
                not self.config.force_version == self.version.number):
            self.log(
                u'version {} is already installed'.format(version.number)
            )
            return

        self.start()
        try:
            self._perform_version(version)
        except Exception:
            if sys.version_info < (3, 4):
                msg = traceback.format_exc().decode('utf8', errors='ignore')
            else:
                msg = traceback.format_exc()
            error = u'\n'.join(self.logs + [u'\n', msg])
            self.table.record_log(version.number, error)
            raise
        self.finish()