当前位置: 首页>>代码示例>>Python>>正文


Python command.downgrade方法代码示例

本文整理汇总了Python中alembic.command.downgrade方法的典型用法代码示例。如果您正苦于以下问题:Python command.downgrade方法的具体用法?Python command.downgrade怎么用?Python command.downgrade使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在alembic.command的用法示例。


在下文中一共展示了command.downgrade方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_upgrade_and_downgrade

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import downgrade [as 别名]
def test_upgrade_and_downgrade(uri_left, alembic_config_left):
    """Test all migrations up and down.

    Tests that we can apply all migrations from a brand new empty
    database, and also that we can remove them all.
    """
    ah.load_premigration_sql(uri_left)
    engine, script = prepare_schema_from_migrations(
        uri_left, alembic_config_left
    )

    head = get_head_revision(alembic_config_left, engine, script)
    current = get_current_revision(alembic_config_left, engine, script)

    assert head == current

    while current is not None:
        command.downgrade(alembic_config_left, '-1')
        current = get_current_revision(alembic_config_left, engine, script) 
开发者ID:jantman,项目名称:biweeklybudget,代码行数:21,代码来源:test_alembic_verify.py

示例2: test_err_correctly_raised_on_dupe_rows_no_pk

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import downgrade [as 别名]
def test_err_correctly_raised_on_dupe_rows_no_pk(self):
        self._env_fixture(version_table_pk=False)
        command.revision(self.cfg)
        r2 = command.revision(self.cfg)
        db = _sqlite_file_db()
        command.upgrade(self.cfg, "head")
        with db.connect() as conn:
            conn.execute(
                text("insert into alembic_version values ('%s')" % r2.revision)
            )
        assert_raises_message(
            util.CommandError,
            "Online migration expected to match one row when "
            "updating .* in 'alembic_version'; 2 found",
            command.downgrade,
            self.cfg,
            "-1",
        ) 
开发者ID:sqlalchemy,项目名称:alembic,代码行数:20,代码来源:test_command.py

示例3: _inline_enum_script

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import downgrade [as 别名]
def _inline_enum_script(self):
        write_script(
            self.script,
            self.rid,
            """
revision = '%s'
down_revision = None

from alembic import op
from sqlalchemy.dialects.postgresql import ENUM
from sqlalchemy import Column


def upgrade():
    op.create_table("sometable",
        Column("data", ENUM("one", "two", "three", name="pgenum"))
    )


def downgrade():
    op.drop_table("sometable")
"""
            % self.rid,
        ) 
开发者ID:sqlalchemy,项目名称:alembic,代码行数:26,代码来源:test_postgresql.py

示例4: test_data_migrations

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import downgrade [as 别名]
def test_data_migrations(
    alembic_config, postgres_engine, rev_base: str, rev_head: str,
    on_init: Callable, on_upgrade: Callable, on_downgrade: Callable
):
    # Upgrade to previous migration before target and add some data,
    # that would be changed by tested migration.
    upgrade(alembic_config, rev_base)
    on_init(engine=postgres_engine)

    # Perform upgrade in tested migration.
    # Check that data is migrated correctly in on_upgrade callback
    upgrade(alembic_config, rev_head)
    on_upgrade(engine=postgres_engine)

    # Perform downgrade in tested migration.
    # Check that changes are reverted back using on_downgrade callback
    downgrade(alembic_config, rev_base)
    on_downgrade(engine=postgres_engine) 
开发者ID:alvassin,项目名称:alembic-quickstart,代码行数:20,代码来源:test_data_migrations.py

示例5: downgrade

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import downgrade [as 别名]
def downgrade(directory=None, revision='-1', sql=False, tag=None, x_arg=None):
    """Revert to a previous version"""
    config = current_app.extensions['migrate'].migrate.get_config(directory,
                                                                  x_arg=x_arg)
    if sql and revision == '-1':
        revision = 'head:-1'
    command.downgrade(config, revision, sql=sql, tag=tag) 
开发者ID:jpush,项目名称:jbox,代码行数:9,代码来源:__init__.py

示例6: drop_tables

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import downgrade [as 别名]
def drop_tables(ctx):
    """ Alias for 'alembic downgrade base'.
    Downgrade to no database tables
    """
    current_session = get_current_session()
    command.downgrade(setup_alembic_config(url=current_session.url),
                      revision='base', sql=False, tag=None) 
开发者ID:analyseether,项目名称:ether_sql,代码行数:9,代码来源:sql.py

示例7: downgrade

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import downgrade [as 别名]
def downgrade(config, revision: str, sql: bool, tag: str):
    """Revert to a previous version."""

    bot = Bot(config)

    directory = os.path.join('yui', 'migrations')
    c = Config(os.path.join(directory, 'alembic.ini'))
    c.set_main_option('script_location', directory)
    c.set_main_option('sqlalchemy.url', bot.config.DATABASE_URL)
    c.attributes['Base'] = bot.orm_base

    command.downgrade(c, revision, sql=sql, tag=tag) 
开发者ID:item4,项目名称:yui,代码行数:14,代码来源:cli.py

示例8: downgrade

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import downgrade [as 别名]
def downgrade(self, revision):
        alembic_command.downgrade(self.config(), revision) 
开发者ID:a10networks,项目名称:a10-neutron-lbaas,代码行数:4,代码来源:test_migrations.py

示例9: test_upgrade_heads_downgrade_base

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import downgrade [as 别名]
def test_upgrade_heads_downgrade_base(self):
        self.upgrade('heads')
        self.downgrade('base') 
开发者ID:a10networks,项目名称:a10-neutron-lbaas,代码行数:5,代码来源:test_migrations.py

示例10: test_upgrade_heads_downgrade_base_upgrade_heads

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import downgrade [as 别名]
def test_upgrade_heads_downgrade_base_upgrade_heads(self):
        self.upgrade('heads')
        self.downgrade('base')
        self.upgrade('heads') 
开发者ID:a10networks,项目名称:a10-neutron-lbaas,代码行数:6,代码来源:test_migrations.py

示例11: downgrade

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import downgrade [as 别名]
def downgrade(self):
        downgrade(self.alembic_config, 'base') 
开发者ID:chainer,项目名称:chainerui,代码行数:4,代码来源:database.py

示例12: run

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import downgrade [as 别名]
def run(parser, options, args):
        if len(args) not in (1, 2):
            parser.error('Bad number of parameters')

        # Read the configuration of the application
        try:
            application = args[1]
        except IndexError:
            application = 'kansha'

        cfg = _build_alembic_config()
        _set_sqlalchemy_uri(cfg, application, parser.error)

        command.downgrade(cfg, args[0]) 
开发者ID:Net-ng,项目名称:kansha,代码行数:16,代码来源:admin.py

示例13: downgrade

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import downgrade [as 别名]
def downgrade(context, directory='migrations', revision='-1', sql=False, tag=None, x_arg=None):
    """Revert to a previous version"""
    config = _get_config(directory, x_arg=x_arg)
    if sql and revision == '-1':
        revision = 'head:-1'
    command.downgrade(config, revision, sql=sql, tag=tag) 
开发者ID:frol,项目名称:flask-restplus-server-example,代码行数:8,代码来源:db.py

示例14: test_not_requires_connection

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import downgrade [as 别名]
def test_not_requires_connection(self):
        env_file_fixture(
            """
assert not context.requires_connection()
"""
        )
        command.upgrade(self.cfg, a, sql=True)
        command.downgrade(self.cfg, "%s:%s" % (b, a), sql=True) 
开发者ID:sqlalchemy,项目名称:alembic,代码行数:10,代码来源:test_offline_environment.py

示例15: test_requires_connection

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import downgrade [as 别名]
def test_requires_connection(self):
        env_file_fixture(
            """
assert context.requires_connection()
"""
        )
        command.upgrade(self.cfg, a)
        command.downgrade(self.cfg, a) 
开发者ID:sqlalchemy,项目名称:alembic,代码行数:10,代码来源:test_offline_environment.py


注:本文中的alembic.command.downgrade方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。