コード例 #1
0
    def runchange(self, ver, change, step):
        startver = ver
        endver = ver + step
        # Current database version must be correct! Don't run if corrupt!
        if self.version != startver:
            raise exceptions.InvalidVersionError("%s is not %s" %
                                                 (self.version, startver))
        # Run the change
        #change.run(self.engine, step)
        # Yield messages out
        for message in change.run(self.engine, step):
            yield message

        # Update/refresh database version
        try:
            # Update/refresh database version
            self.update_repository_table(startver, endver)
            self.load()
        except AttributeError:
            # SQLAlchemy-migrate 0.5.4
            from sqlalchemy.sql import and_
            update = self.table.update(
                and_(self.table.c.version == int(startver),
                     self.table.c.repository_id == str(self.repository.id)))
            self.engine.execute(update, version=int(endver))
            self._load()
コード例 #2
0
ファイル: schema.py プロジェクト: wondie/stdm
    def runchange(self, ver, change, step):
        startver = ver
        endver = ver + step
        # Current database version must be correct! Don't run if corrupt!
        if self.version != startver:
            raise exceptions.InvalidVersionError("%s is not %s" % \
                                                     (self.version, startver))
        # Run the change
        change.run(self.engine, step)

        # Update/refresh database version
        self.update_repository_table(startver, endver)
        self.load()
コード例 #3
0
ファイル: schema.py プロジェクト: wondie/stdm
    def _validate_version(cls, repository, version):
        """
        Ensures this is a valid version number for this repository.

        :raises: :exc:`InvalidVersionError` if invalid
        :return: valid version number
        """
        if version is None:
            version = 0
        try:
            version = VerNum(version)  # raises valueerror
            if version < 0 or version > repository.latest:
                raise ValueError()
        except ValueError:
            raise exceptions.InvalidVersionError(version)
        return version