示例#1
0
    def setup_migration_version_control(self):
        self.reset_alembic_output()
        alembic_config = AlembicConfig()
        alembic_config.set_main_option(
            "script_location", self.migrate_repository
        )
        alembic_config.set_main_option(
            "sqlalchemy.url", str(self.metadata.bind.url)
        )
        try:
            sqlalchemy_migrate_version = self.metadata.bind.execute(
                u'select version from migrate_version'
            ).scalar()
        except ProgrammingError:
            sqlalchemy_migrate_version = 0

        # this value is used for graceful upgrade from
        # sqlalchemy-migrate to alembic
        alembic_config.set_main_option(
            "sqlalchemy_migrate_version", str(sqlalchemy_migrate_version)
        )
        # This is an interceptor for alembic output. Otherwise,
        # everything will be printed to stdout
        alembic_config.print_stdout = self.add_alembic_output

        self.alembic_config = alembic_config
示例#2
0
    def setup_migration_version_control(self):
        self.reset_alembic_output()
        alembic_config = AlembicConfig()
        alembic_config.set_main_option(
            "script_location", self.migrate_repository
        )
        alembic_config.set_main_option(
            "sqlalchemy.url", str(self.metadata.bind.url)
        )
        try:
            sqlalchemy_migrate_version = self.metadata.bind.execute(
                u'select version from migrate_version'
            ).scalar()
        except ProgrammingError:
            sqlalchemy_migrate_version = 0

        # this value is used for graceful upgrade from
        # sqlalchemy-migrate to alembic
        alembic_config.set_main_option(
            "sqlalchemy_migrate_version", str(sqlalchemy_migrate_version)
        )
        # This is an interceptor for alembic output. Otherwise,
        # everything will be printed to stdout
        alembic_config.print_stdout = self.add_alembic_output

        self.alembic_config = alembic_config
示例#3
0
文件: __init__.py 项目: frafra/ckan
    def setup_migration_version_control(self) -> None:
        assert isinstance(self.metadata.bind, Engine)
        self.reset_alembic_output()
        alembic_config = AlembicConfig(self._alembic_ini)
        alembic_config.set_main_option("sqlalchemy.url",
                                       config.get_value("sqlalchemy.url"))
        try:
            sqlalchemy_migrate_version = self.metadata.bind.execute(
                u'select version from migrate_version').scalar()
        except ProgrammingError:
            sqlalchemy_migrate_version = 0

        # this value is used for graceful upgrade from
        # sqlalchemy-migrate to alembic
        alembic_config.set_main_option("sqlalchemy_migrate_version",
                                       str(sqlalchemy_migrate_version))
        # This is an interceptor for alembic output. Otherwise,
        # everything will be printed to stdout
        alembic_config.print_stdout = self.add_alembic_output

        self.alembic_config = alembic_config