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


Python op.rename_table方法代码示例

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


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

示例1: upgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import rename_table [as 别名]
def upgrade():
    op.rename_table('use_of_force_incidents', 'use_of_force_incidents_impd')
    op.execute('ALTER SEQUENCE use_of_force_incidents_id_seq RENAME TO use_of_force_incidents_impd_id_seq')
    op.execute('ALTER INDEX use_of_force_incidents_pkey RENAME TO use_of_force_incidents_impd_pkey')
    op.execute('ALTER TABLE use_of_force_incidents_impd RENAME CONSTRAINT "use_of_force_incidents_department_id_fkey" TO "use_of_force_incidents_impd_department_id_fkey"')

    op.rename_table('citizen_complaints', 'citizen_complaints_impd')
    op.execute('ALTER SEQUENCE citizen_complaints_id_seq RENAME TO citizen_complaints_impd_id_seq')
    op.execute('ALTER INDEX citizen_complaints_pkey RENAME TO citizen_complaints_impd_pkey')
    op.execute('ALTER TABLE citizen_complaints_impd RENAME CONSTRAINT "citizen_complaints_department_id_fkey" TO "citizen_complaints_impd_department_id_fkey"')

    op.rename_table('assaults_on_officers', 'assaults_on_officers_impd')
    op.execute('ALTER SEQUENCE assaults_on_officers_id_seq RENAME TO assaults_on_officers_impd_id_seq')
    op.execute('ALTER INDEX assaults_on_officers_pkey RENAME TO assaults_on_officers_impd_pkey')
    op.execute('ALTER TABLE assaults_on_officers_impd RENAME CONSTRAINT "assaults_on_officers_department_id_fkey" TO "assaults_on_officers_impd_department_id_fkey"')

    op.rename_table('officer_involved_shootings', 'officer_involved_shootings_impd')
    op.execute('ALTER SEQUENCE officer_involved_shootings_id_seq RENAME TO officer_involved_shootings_impd_id_seq')
    op.execute('ALTER INDEX officer_involved_shootings_pkey RENAME TO officer_involved_shootings_impd_pkey')
    op.execute('ALTER TABLE officer_involved_shootings_impd RENAME CONSTRAINT "officer_involved_shootings_department_id_fkey" TO "officer_involved_shootings_impd_department_id_fkey"') 
开发者ID:codeforamerica,项目名称:comport,代码行数:22,代码来源:d4db9d4eff92_.py

示例2: downgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import rename_table [as 别名]
def downgrade():
    op.rename_table('use_of_force_incidents_impd', 'use_of_force_incidents')
    op.execute('ALTER SEQUENCE use_of_force_incidents_impd_id_seq RENAME TO use_of_force_incidents_id_seq')
    op.execute('ALTER INDEX use_of_force_incidents_impd_pkey RENAME TO use_of_force_incidents_pkey')
    op.execute('ALTER TABLE use_of_force_incidents RENAME CONSTRAINT "use_of_force_incidents_impd_department_id_fkey" TO "use_of_force_incidents_department_id_fkey"')

    op.rename_table('citizen_complaints_impd', 'citizen_complaints')
    op.execute('ALTER SEQUENCE citizen_complaints_impd_id_seq RENAME TO citizen_complaints_id_seq')
    op.execute('ALTER INDEX citizen_complaints_impd_pkey RENAME TO citizen_complaints_pkey')
    op.execute('ALTER TABLE citizen_complaints RENAME CONSTRAINT "citizen_complaints_impd_department_id_fkey" TO "citizen_complaints_department_id_fkey"')

    op.rename_table('assaults_on_officers_impd', 'assaults_on_officers')
    op.execute('ALTER SEQUENCE assaults_on_officers_impd_id_seq RENAME TO assaults_on_officers_id_seq')
    op.execute('ALTER INDEX assaults_on_officers_impd_pkey RENAME TO assaults_on_officers_pkey')
    op.execute('ALTER TABLE assaults_on_officers RENAME CONSTRAINT "assaults_on_officers_impd_department_id_fkey" TO "assaults_on_officers_department_id_fkey"')

    op.rename_table('officer_involved_shootings_impd', 'officer_involved_shootings')
    op.execute('ALTER SEQUENCE officer_involved_shootings_impd_id_seq RENAME TO officer_involved_shootings_id_seq')
    op.execute('ALTER INDEX officer_involved_shootings_impd_pkey RENAME TO officer_involved_shootings_pkey')
    op.execute('ALTER TABLE officer_involved_shootings RENAME CONSTRAINT "officer_involved_shootings_impd_department_id_fkey" TO "officer_involved_shootings_department_id_fkey"') 
开发者ID:codeforamerica,项目名称:comport,代码行数:22,代码来源:d4db9d4eff92_.py

示例3: upgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import rename_table [as 别名]
def upgrade():
    conn = op.get_bind()

    temp_log_table = op.create_table(
        'temp_log',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('result_id', sa.Integer(), nullable=True),
        sa.Column('data', sa.LargeBinary(length=2048), nullable=True),
        sa.ForeignKeyConstraint(['result_id'], ['result.id'], ),
        sa.PrimaryKeyConstraint('id'))
    res = conn.execute('SELECT id, result_id, data FROM log')
    results = res.fetchall()
    if len(results) > 0:
        modified_logs = [{
            'id': r[0],
            'result_id': r[1],
            'data': msgpack.packb(json.loads(r[2]), use_bin_type=True)}
            for r in results]
        op.bulk_insert(temp_log_table, modified_logs)
    op.drop_table('log')
    op.rename_table('temp_log', 'log') 
开发者ID:chainer,项目名称:chainerui,代码行数:23,代码来源:e3db52a480f8_alter_log_data_type.py

示例4: downgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import rename_table [as 别名]
def downgrade():
    conn = op.get_bind()

    temp_log_table = op.create_table(
        'temp_log',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('result_id', sa.Integer(), nullable=True),
        sa.Column('data', sa.String(length=1024), nullable=True),
        sa.ForeignKeyConstraint(['result_id'], ['result.id'], ),
        sa.PrimaryKeyConstraint('id'))
    res = conn.execute('SELECT id, result_id, data FROM log')
    results = res.fetchall()
    if len(results) > 0:
        modified_logs = [{
            'id': r[0],
            'result_id': r[1],
            'data': json.dumps(msgpack.unpackb(r[2], raw=False))}
            for r in results]
        op.bulk_insert(temp_log_table, modified_logs)
    op.drop_table('log')
    op.rename_table('temp_log', 'log') 
开发者ID:chainer,项目名称:chainerui,代码行数:23,代码来源:e3db52a480f8_alter_log_data_type.py

示例5: upgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import rename_table [as 别名]
def upgrade():
    # Step 1: Schema migration
    # rename table
    op.rename_table("fetch_new_events_task", "sync_event_database_task")

    # Step 2: Data migration
    # Change task type to new sync_task_name
    engine = op.get_bind()
    meta = sa.MetaData(bind=engine)
    task = sa.Table("task", meta, autoload=True)
    stmt = (
        task.update()
        .where(task.c.type == "fetch_new_events")
        .values(type="sync_event_database")
    )
    engine.execute(stmt) 
开发者ID:busy-beaver-dev,项目名称:busy-beaver,代码行数:18,代码来源:20190609_20-09-41__rename_sync_event_task_table_and_update_.py

示例6: upgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import rename_table [as 别名]
def upgrade(active_plugins=None, options=None):
    # commands auto generated by Alembic - please adjust! #
    op.rename_table('devicetemplates', 'vnfd')
    op.rename_table('devicetemplateattributes', 'vnfd_attribute')
    op.rename_table('devices', 'vnf')
    op.rename_table('deviceattributes', 'vnf_attribute')
    migration.modify_foreign_keys_constraint_with_col_change(
        'vnfd_attribute', 'template_id', 'vnfd_id',
        sa.String(length=36))
    migration.modify_foreign_keys_constraint_with_col_change(
        'servicetypes', 'template_id', 'vnfd_id',
        sa.String(length=36))
    migration.modify_foreign_keys_constraint_with_col_change(
        'vnf', 'template_id', 'vnfd_id',
        sa.String(length=36))
    migration.modify_foreign_keys_constraint_with_col_change(
        'vnf_attribute', 'device_id', 'vnf_id',
        sa.String(length=36))
    # end Alembic commands # 
开发者ID:openstack,项目名称:tacker,代码行数:21,代码来源:22f5385a3d50_rename_devicedb.py

示例7: downgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import rename_table [as 别名]
def downgrade():

	op.drop_constraint('password_reset_code_email_fkey', 'password_reset_code', type_='foreignkey')

	# Drop New Index
	op.drop_index('ix_password_reset_code_email_code', 'password_reset_code')
	op.drop_index('ix_password_reset_code_email', 'password_reset_code')

	# Rename email column
	op.alter_column('password_reset_code', 'email', new_column_name='user_id', )

	# Drop date columns
	op.alter_column('password_reset_code', 'created_at', new_column_name='created', server_default=None)
	op.drop_column('password_reset_code', 'updated_at')

	op.rename_table('password_reset_code', 'password_reset') 
开发者ID:Murali-group,项目名称:GraphSpace,代码行数:18,代码来源:3ab443000c7e_update_password_reset_table.py

示例8: upgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import rename_table [as 别名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('skin')
    op.drop_table('modules')
    op.drop_column('node', 'mods')
    op.drop_column('node', 'parentid')
    op.drop_column('node', 'folderid')
    op.drop_column('node', 'image')
    op.drop_column('node', 'folder')
    op.drop_column('node', 'custom')
    op.drop_column('node', 'target')
    op.drop_column('node', 'type')
    op.drop_column('node', 'skin_id')
    op.drop_column('node', 'modules_id')
    op.rename_table('node', 'page')
    op.execute('ALTER SEQUENCE node_id_seq RENAME TO page_id_seq')
    # ### end Alembic commands ### 
开发者ID:pygame,项目名称:pygameweb,代码行数:19,代码来源:6cb6a6a151b7_removed_unused_page_tables_and_fields.py

示例9: upgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import rename_table [as 别名]
def upgrade():
    # Rename option table
    op.drop_index("ix_poll_option_poll_id", table_name="poll_option")
    op.rename_table("poll_option", "option")
    op.create_index(op.f("ix_option_poll_id"), "option", ["poll_id"], unique=False)

    # Rename vote.poll_option
    op.drop_constraint("one_vote_per_option_and_user", "vote", type_="unique")
    op.drop_index("ix_vote_poll_option_id", table_name="vote")
    op.drop_constraint("vote_poll_option_id_fkey", "vote", type_="foreignkey")

    op.alter_column("vote", "poll_option_id", new_column_name="option_id")

    op.create_index(op.f("ix_vote_option_id"), "vote", ["option_id"], unique=False)
    op.create_unique_constraint(
        "one_vote_per_option_and_user", "vote", ["user_id", "poll_id", "option_id"]
    )
    op.create_foreign_key(
        "vote_option_id_fkey",
        "vote",
        "option",
        ["option_id"],
        ["id"],
        ondelete="cascade",
    ) 
开发者ID:Nukesor,项目名称:ultimate-poll-bot,代码行数:27,代码来源:2020_04_21_4a3508ddb972_rename_polloption_to_option.py

示例10: upgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import rename_table [as 别名]
def upgrade():
    op.rename_table("forward_email", "contact") 
开发者ID:simple-login,项目名称:app,代码行数:4,代码来源:2020_031709_7744c5c16159_.py

示例11: downgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import rename_table [as 别名]
def downgrade():
    op.rename_table("contact", "forward_email") 
开发者ID:simple-login,项目名称:app,代码行数:4,代码来源:2020_031709_7744c5c16159_.py

示例12: upgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import rename_table [as 别名]
def upgrade():
    op.rename_table("forward_email_log", "email_log") 
开发者ID:simple-login,项目名称:app,代码行数:4,代码来源:2020_031711_6e061eb84167_.py

示例13: downgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import rename_table [as 别名]
def downgrade():
    op.rename_table("email_log", "forward_email_log") 
开发者ID:simple-login,项目名称:app,代码行数:4,代码来源:2020_031711_6e061eb84167_.py

示例14: upgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import rename_table [as 别名]
def upgrade():
    op.rename_table("gen_email", "alias") 
开发者ID:simple-login,项目名称:app,代码行数:4,代码来源:2020_031711_e9395fe234a4_.py

示例15: upgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import rename_table [as 别名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.rename_table('business_verification', 'kyc_application')
    # ### end Alembic commands ### 
开发者ID:teamsempo,项目名称:SempoBlockchain,代码行数:6,代码来源:1674ba61ae00_.py


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