# 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
#    License for the specific language governing permissions and limitations
#    under the License.





LOG = logging.getLogger(__name__)


class MigrateExtension(ext_base.MigrationExtensionBase):
    """Extension to provide sqlalchemy-migrate features.

    :param migration_config: Stores specific configuration for migrations
    :type migration_config: dict
    """

    order = 1

    def __init__(self, engine, migration_config):
        self.engine = engine
        self.repository = migration_config.get('migration_repo_path', '')
        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

# 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

#    License for the specific language governing permissions and limitations
#    under the License.





LOG = logging.getLogger(__name__)


class MigrateExtension(ext_base.MigrationExtensionBase):
    """Extension to provide sqlalchemy-migrate features.

    :param migration_config: Stores specific configuration for migrations
    :type migration_config: dict
    """

    order = 1

    def __init__(self, engine, migration_config):
        self.engine = engine
        self.repository = migration_config.get('migration_repo_path', '')
        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(