Exemplo n.º 1
0
    def upgrade(self, dbname, db):
        """Upgrade all schemas in single db."""

        curs = db.cursor()
        ignore = {}
        for schema, ver, fn, recheck_func in version_list:
            # skip schema?
            if schema in ignore:
                continue
            if not skytools.exists_schema(curs, schema):
                ignore[schema] = 1
                continue

            # new enough?
            ok, oldver = check_version(curs, schema, ver, recheck_func, self.options.force)
            if ok:
                continue

            # too old schema, no way to upgrade
            if fn is None:
                self.log.info('%s: Cannot upgrade %s, too old version', dbname, schema)
                ignore[schema] = 1
                continue

            if self.options.not_really:
                self.log.info ("%s: Would upgrade '%s' version %s to %s", dbname, schema, oldver, ver)
                continue

            curs = db.cursor()
            curs.execute('begin')
            self.log.info("%s: Upgrading '%s' version %s to %s", dbname, schema, oldver, ver)
            skytools.installer_apply_file(db, fn, self.log)
            curs.execute('commit')
Exemplo n.º 2
0
    def upgrade(self, dbname, db):
        """Upgrade all schemas in single db."""

        curs = db.cursor()
        ignore = {}
        for schema, ver, fn, recheck_func in version_list:
            # skip schema?
            if schema in ignore:
                continue
            if not skytools.exists_schema(curs, schema):
                ignore[schema] = 1
                continue

            # new enough?
            if check_version(curs, schema, ver, recheck_func):
                continue

            # too old schema, no way to upgrade
            if fn is None:
                self.log.info('%s: Cannot upgrade %s, too old version', dbname, schema)
                ignore[schema] = 1
                continue

            curs = db.cursor()
            curs.execute('begin')
            skytools.installer_apply_file(db, fn, self.log)
            curs.execute('commit')
Exemplo n.º 3
0
    def upgrade(self, db):
        curs = db.cursor()
        for schema, ver, sql, recheck_fn in version_list:
            if not skytools.exists_schema(curs, schema):
                continue

            if check_version(curs, schema, ver, recheck_fn):
                continue

            fn = "upgrade/final/%s" % sql
            skytools.installer_apply_file(db, fn, self.log)
Exemplo n.º 4
0
    def upgrade(self, db):
        curs = db.cursor()
        for schema, ver, sql, recheck_fn in version_list:
            if not skytools.exists_schema(curs, schema):
                continue

            if check_version(curs, schema, ver, recheck_fn):
                continue

            fn = "upgrade/final/%s" % sql
            skytools.installer_apply_file(db, fn, self.log)
Exemplo n.º 5
0
    def upgrade(self, dbname, db):
        """Upgrade all schemas in single db."""

        curs = db.cursor()
        ignore = {}
        for schema, ver, fn, recheck_func in version_list:
            # skip schema?
            if schema in ignore:
                continue
            if not skytools.exists_schema(curs, schema):
                ignore[schema] = 1
                continue

            # new enough?
            ok, oldver = check_version(curs, schema, ver, recheck_func)
            if ok:
                continue

            # too old schema, no way to upgrade
            if fn is None:
                self.log.info('%s: Cannot upgrade %s, too old version', dbname,
                              schema)
                ignore[schema] = 1
                continue

            if self.options.not_really:
                self.log.info("%s: Would upgrade '%s' version %s to %s",
                              dbname, schema, oldver, ver)
                continue

            curs = db.cursor()
            curs.execute('begin')
            self.log.info("%s: Upgrading '%s' version %s to %s", dbname,
                          schema, oldver, ver)
            skytools.installer_apply_file(db, fn, self.log)
            curs.execute('commit')