# Path: oslo_db/exception.py
# class DBError(CausedByException):
# class DBDuplicateEntry(DBError):
# class DBConstraintError(DBError):
# class DBReferenceError(DBError):
# class DBNonExistentConstraint(DBError):
# class DBNonExistentTable(DBError):
# class DBNonExistentDatabase(DBError):
# class DBDeadlock(DBError):
# class DBInvalidUnicodeParameter(Exception):
# class DBMigrationError(DBError):
# class DBConnectionError(DBError):
# class DBDataError(DBError):
# class DBNotSupportedError(DBError):
# class InvalidSortKey(Exception):
# class ColumnError(Exception):
# class BackendNotAvailable(Exception):
# class RetryRequest(Exception):
# class NoEngineContextEstablished(AttributeError):
# class ContextNotRequestedError(AttributeError):
# class CantStartEngineError(Exception):
#     def __init__(self, inner_exception=None, cause=None):
#     def __init__(self, columns=None, inner_exception=None, value=None):
#     def __init__(self, table, check_name, inner_exception=None):
#     def __init__(self, table, constraint, key, key_table,
#                  inner_exception=None):
#     def __init__(self, table, constraint, inner_exception=None):
#     def __init__(self, table, inner_exception=None):
#     def __init__(self, database, inner_exception=None):
#     def __init__(self, inner_exception=None):
#     def __init__(self):
#     def __init__(self, message):
#     def __init__(self, key=None):
#     def __init__(self, inner_exc):


from debtcollector import removals
from stevedore import enabled
from oslo_db import exception
import sqlalchemy

    @property
    def _plugins(self):
        return sorted(ext.obj for ext in self._manager.extensions)

    def upgrade(self, revision):
        """Upgrade database with all available backends."""
        # a revision exists only in a single plugin. Until we reached it, we
        # should upgrade to the plugins' heads.
        # revision=None is a special case meaning latest revision.
        rev_in_plugins = [p.has_revision(revision) for p in self._plugins]
        if not any(rev_in_plugins) and revision is not None:
            raise exception.DBMigrationError('Revision does not exist')

        results = []
        for plugin, has_revision in zip(self._plugins, rev_in_plugins):
            if not has_revision or revision is None:
                results.append(plugin.upgrade(None))
            else:
                results.append(plugin.upgrade(revision))
                break
        return results

    def downgrade(self, revision):
        """Downgrade database with available backends."""
        # a revision exists only in a single plugin. Until we reached it, we
        # should upgrade to the plugins' first revision.
        # revision=None is a special case meaning initial revision.
        rev_in_plugins = [p.has_revision(revision) for p in self._plugins]
        if not any(rev_in_plugins) and revision is not None:

# Path: oslo_db/exception.py
# class DBError(CausedByException):
# class DBDuplicateEntry(DBError):
# class DBConstraintError(DBError):
# class DBReferenceError(DBError):
# class DBNonExistentConstraint(DBError):
# class DBNonExistentTable(DBError):
# class DBNonExistentDatabase(DBError):
# class DBDeadlock(DBError):
# class DBInvalidUnicodeParameter(Exception):
# class DBMigrationError(DBError):
# class DBConnectionError(DBError):
# class DBDataError(DBError):
# class DBNotSupportedError(DBError):
# class InvalidSortKey(Exception):
# class ColumnError(Exception):
# class BackendNotAvailable(Exception):
# class RetryRequest(Exception):
# class NoEngineContextEstablished(AttributeError):
# class ContextNotRequestedError(AttributeError):
# class CantStartEngineError(Exception):
#     def __init__(self, inner_exception=None, cause=None):
#     def __init__(self, columns=None, inner_exception=None, value=None):
#     def __init__(self, table, check_name, inner_exception=None):
#     def __init__(self, table, constraint, key, key_table,
#                  inner_exception=None):
#     def __init__(self, table, constraint, inner_exception=None):
#     def __init__(self, table, inner_exception=None):
#     def __init__(self, database, inner_exception=None):
#     def __init__(self, inner_exception=None):
#     def __init__(self):
#     def __init__(self, message):
#     def __init__(self, key=None):
#     def __init__(self, inner_exc):


# Path: oslo_db/sqlalchemy/migration_cli/manager.py
from debtcollector import removals
from stevedore import enabled
from oslo_db import exception
import sqlalchemy


    @property
    def _plugins(self):
        return sorted(ext.obj for ext in self._manager.extensions)

    def upgrade(self, revision):
        """Upgrade database with all available backends."""
        # a revision exists only in a single plugin. Until we reached it, we
        # should upgrade to the plugins' heads.
        # revision=None is a special case meaning latest revision.
        rev_in_plugins = [p.has_revision(revision) for p in self._plugins]
        if not any(rev_in_plugins) and revision is not None:
            raise exception.DBMigrationError('Revision does not exist')

        results = []
        for plugin, has_revision in zip(self._plugins, rev_in_plugins):
            if not has_revision or revision is None:
                results.append(plugin.upgrade(None))
            else:
                results.append(plugin.upgrade(revision))
                break
        return results

    def downgrade(self, revision):
        """Downgrade database with available backends."""
        # a revision exists only in a single plugin. Until we reached it, we
        # should upgrade to the plugins' first revision.
        # revision=None is a special case meaning initial revision.
        rev_in_plugins = [p.has_revision(revision) for p in self._plugins]
        if not any(rev_in_plugins) and revision is not None:

            raise exception.DBMigrationError('Revision does not exist')