# Path: oslo_db/sqlalchemy/migration.py
# def db_sync(engine, abs_path, version=None, init_version=0, sanity_check=True):
# def _db_schema_sanity_check(engine):
# def db_version(engine, abs_path, init_version):
# def db_version_control(engine, abs_path, version=None):
# def _find_migrate_repo(abs_path):
#         EXCLUDED_TABLES = ['migrate_version', 'alembic_version']
# 
# Path: oslo_db/sqlalchemy/migration_cli/ext_base.py
# class MigrationExtensionBase(object, metaclass=abc.ABCMeta):
#     def enabled(self):
#     def upgrade(self, version):
#     def downgrade(self, version):
#     def version(self):
#     def revision(self, *args, **kwargs):
#     def stamp(self, *args, **kwargs):
#     def has_revision(self, rev_id):
#     def __cmp__(self, other):


import logging
import os
from migrate.versioning import version as migrate_version
from oslo_db.sqlalchemy import migration
from oslo_db.sqlalchemy.migration_cli import ext_base
        self.init_version = migration_config.get('init_version', 0)

    @property
    def enabled(self):
        return os.path.exists(self.repository)

    def upgrade(self, version):
        version = None if version == 'head' else version
        return migration.db_sync(
            self.engine, self.repository, version,
            init_version=self.init_version)

    def downgrade(self, version):
        try:
            # version for migrate should be valid int - else skip
            if version in ('base', None):
                version = self.init_version
            version = int(version)
            return migration.db_sync(
                self.engine, self.repository, version,
                init_version=self.init_version)
        except ValueError:
            LOG.error(
                'Migration number for migrate plugin must be valid '
                'integer or empty, if you want to downgrade '
                'to initial state'
            )
            raise

    def version(self):

# Path: oslo_db/sqlalchemy/migration.py
# def db_sync(engine, abs_path, version=None, init_version=0, sanity_check=True):
# def _db_schema_sanity_check(engine):
# def db_version(engine, abs_path, init_version):
# def db_version_control(engine, abs_path, version=None):
# def _find_migrate_repo(abs_path):
#         EXCLUDED_TABLES = ['migrate_version', 'alembic_version']
# 
# Path: oslo_db/sqlalchemy/migration_cli/ext_base.py
# class MigrationExtensionBase(object, metaclass=abc.ABCMeta):
#     def enabled(self):
#     def upgrade(self, version):
#     def downgrade(self, version):
#     def version(self):
#     def revision(self, *args, **kwargs):
#     def stamp(self, *args, **kwargs):
#     def has_revision(self, rev_id):
#     def __cmp__(self, other):


# Path: oslo_db/sqlalchemy/migration_cli/ext_migrate.py
import logging
import os
from migrate.versioning import version as migrate_version
from oslo_db.sqlalchemy import migration
from oslo_db.sqlalchemy.migration_cli import ext_base

        self.init_version = migration_config.get('init_version', 0)

    @property
    def enabled(self):
        return os.path.exists(self.repository)

    def upgrade(self, version):
        version = None if version == 'head' else version
        return migration.db_sync(
            self.engine, self.repository, version,
            init_version=self.init_version)

    def downgrade(self, version):
        try:
            # version for migrate should be valid int - else skip
            if version in ('base', None):
                version = self.init_version
            version = int(version)
            return migration.db_sync(
                self.engine, self.repository, version,
                init_version=self.init_version)
        except ValueError:
            LOG.error(
                'Migration number for migrate plugin must be valid '
                'integer or empty, if you want to downgrade '
                'to initial state'
            )
            raise

    def version(self):

        return migration.db_version(