Python alembic.op.drop_column() Examples

The following are 30 code examples of alembic.op.drop_column(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module alembic.op , or try the search function .
Example #1
Source File: aba5a217ca9b_merge_created_in_creator.py    From gnocchi with Apache License 2.0 6 votes vote down vote up
def upgrade():
    for table_name in ("resource", "resource_history", "metric"):
        creator_col = sa.Column("creator", sa.String(255))
        created_by_user_id_col = sa.Column("created_by_user_id",
                                           sa.String(255))
        created_by_project_id_col = sa.Column("created_by_project_id",
                                              sa.String(255))
        op.add_column(table_name, creator_col)
        t = sa.sql.table(
            table_name, creator_col,
            created_by_user_id_col, created_by_project_id_col)
        op.execute(
            t.update().values(
                creator=(
                    created_by_user_id_col + ":" + created_by_project_id_col
                )).where((created_by_user_id_col is not None)
                         | (created_by_project_id_col is not None)))
        op.drop_column(table_name, "created_by_user_id")
        op.drop_column(table_name, "created_by_project_id") 
Example #2
Source File: 19e8725e0581_.py    From gitlab-tools with GNU General Public License v3.0 6 votes vote down vote up
def downgrade():
    bind = op.get_bind()
    session = Session(bind=bind)
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('pull_mirror', sa.Column('gitlab_id', sa.INTEGER(), nullable=True))

    for pull_mirror in session.query(PullMirror):
        pull_mirror.gitlab_id = pull_mirror.project.gitlab_id
        session.add(pull_mirror)
    session.commit()

    op.drop_constraint(None, 'pull_mirror', type_='foreignkey')
    op.drop_index(op.f('ix_pull_mirror_project_id'), table_name='pull_mirror')
    op.drop_column('pull_mirror', 'project_id')
    op.drop_index(op.f('ix_push_mirror_user_id'), table_name='push_mirror')
    op.drop_index(op.f('ix_push_mirror_project_id'), table_name='push_mirror')
    op.drop_table('push_mirror')
    op.drop_table('project')
    # ### end Alembic commands ### 
Example #3
Source File: d4841aeeb072_.py    From gitlab-tools with GNU General Public License v3.0 6 votes vote down vote up
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('task_result', sa.Column('traceback', sa.TEXT(), autoincrement=False, nullable=True))
    op.add_column('task_result', sa.Column('task_id', sa.VARCHAR(length=155), autoincrement=False, nullable=True))
    op.add_column('task_result', sa.Column('date_done', postgresql.TIMESTAMP(), autoincrement=False, nullable=True))
    op.add_column('task_result', sa.Column('status', sa.VARCHAR(length=50), autoincrement=False, nullable=True))
    op.add_column('task_result', sa.Column('result', postgresql.BYTEA(), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'task_result', type_='foreignkey')
    op.create_unique_constraint('task_result_task_id_key', 'task_result', ['task_id'])
    op.drop_index(op.f('ix_task_result_celery_taskmeta_id'), table_name='task_result')
    op.drop_column('task_result', 'celery_taskmeta_id')
    op.drop_table('celery_tasksetmeta')
    op.drop_table('celery_taskmeta')
    # ### end Alembic commands ### 
Example #4
Source File: 2019_122910_696e17c13b8b_.py    From app with MIT License 5 votes vote down vote up
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('custom_domain', 'spf_verified')
    # ### end Alembic commands ### 
Example #5
Source File: 4713e7ebca9_add_task_status_links.py    From drydock with Apache License 2.0 5 votes vote down vote up
def downgrade():
    for c in tables.Tasks.__add_result_links__:
        op.drop_column(tables.Tasks.__tablename__, c.name) 
Example #6
Source File: 2fe19381f386_.py    From app with MIT License 5 votes vote down vote up
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('users', 'is_developer')
    # ### end Alembic commands ### 
Example #7
Source File: 2020_050312_de1b457472e0_.py    From app with MIT License 5 votes vote down vote up
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('custom_domain', 'dmarc_verified')
    # ### end Alembic commands ### 
Example #8
Source File: 2020_052714_cfc013b6461a_.py    From app with MIT License 5 votes vote down vote up
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('alias', 'cannot_be_disabled')
    # ### end Alembic commands ### 
Example #9
Source File: 3cd10cfce8c3_.py    From app with MIT License 5 votes vote down vote up
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('oauth_token', 'scope')
    op.drop_column('oauth_token', 'redirect_uri')
    op.drop_column('authorization_code', 'scope')
    op.drop_column('authorization_code', 'redirect_uri')
    # ### end Alembic commands ### 
Example #10
Source File: 1b7d161d1012_.py    From app with MIT License 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('users', 'is_developer')
    # ### end Alembic commands ### 
Example #11
Source File: 2020_010120_d29cca963221_.py    From app with MIT License 5 votes vote down vote up
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('users', 'lifetime')
    op.drop_table('lifetime_coupon')
    # ### end Alembic commands ### 
Example #12
Source File: d4e4488a0032_.py    From app with MIT License 5 votes vote down vote up
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('users', 'otp_secret')
    op.drop_column('users', 'enable_otp')
    # ### end Alembic commands ### 
Example #13
Source File: c6e7fc37ad42_.py    From app with MIT License 5 votes vote down vote up
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('gen_email', 'custom')
    op.drop_column('client_user', 'name')
    op.drop_column('client_user', 'default_avatar')
    # ### end Alembic commands ### 
Example #14
Source File: 29579044e36c_.py    From gitlab-tools with GNU General Public License v3.0 5 votes vote down vote up
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('pull_mirror', 'is_jobs_enabled')
    # ### end Alembic commands ### 
Example #15
Source File: cad4d8aacceb_.py    From gitlab-tools with GNU General Public License v3.0 5 votes vote down vote up
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'pull_mirror', type_='foreignkey')
    op.drop_index(op.f('ix_pull_mirror_periodic_task_id'), table_name='pull_mirror')
    op.drop_column('pull_mirror', 'periodic_task_id')
    # ### end Alembic commands ### 
Example #16
Source File: 82696705e6df_.py    From gitlab-tools with GNU General Public License v3.0 5 votes vote down vote up
def downgrade():
    bind = op.get_bind()
    session = Session(bind=bind)
    op.add_column('pull_mirror', sa.Column('is_public', sa.BOOLEAN(), autoincrement=False, nullable=True))
    # Set is_public correctly
    for pull_mirror in session.query(PullMirror):
        pull_mirror.is_public = True if pull_mirror.visibility == 'public' else False
        session.add(pull_mirror)
    session.commit()
    op.drop_column('pull_mirror', 'visibility') 
Example #17
Source File: 82696705e6df_.py    From gitlab-tools with GNU General Public License v3.0 5 votes vote down vote up
def upgrade():
    bind = op.get_bind()
    session = Session(bind=bind)
    op.add_column('pull_mirror', sa.Column('visibility', sa.String(length=255), nullable=True))

    # Set visibility correctly
    for pull_mirror in session.query(PullMirror):
        pull_mirror.visibility = 'public' if pull_mirror.is_public else 'private'
        session.add(pull_mirror)
    session.commit()

    op.alter_column('pull_mirror', 'visibility', nullable=False)

    op.drop_column('pull_mirror', 'is_public') 
Example #18
Source File: d4841aeeb072_.py    From gitlab-tools with GNU General Public License v3.0 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('celery_taskmeta',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('task_id', sa.String(length=155), nullable=True),
    sa.Column('status', sa.String(length=50), nullable=True),
    sa.Column('result', sa.PickleType(), nullable=True),
    sa.Column('date_done', sa.DateTime(), nullable=True),
    sa.Column('traceback', sa.Text(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('task_id'),
    sqlite_autoincrement=True
    )
    op.create_table('celery_tasksetmeta',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('taskset_id', sa.String(length=155), nullable=True),
    sa.Column('result', sa.PickleType(), nullable=True),
    sa.Column('date_done', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('taskset_id'),
    sqlite_autoincrement=True
    )
    op.add_column('task_result', sa.Column('celery_taskmeta_id', sa.Integer(), nullable=False))
    op.create_index(op.f('ix_task_result_celery_taskmeta_id'), 'task_result', ['celery_taskmeta_id'], unique=False)
    op.drop_constraint('task_result_task_id_key', 'task_result', type_='unique')
    op.create_foreign_key(None, 'task_result', 'celery_taskmeta', ['celery_taskmeta_id'], ['id'])
    op.drop_column('task_result', 'result')
    op.drop_column('task_result', 'status')
    op.drop_column('task_result', 'date_done')
    op.drop_column('task_result', 'task_id')
    op.drop_column('task_result', 'traceback')
    # ### end Alembic commands ### 
Example #19
Source File: 33cdd98bb9b2_split_volume_mapping_table.py    From zun with Apache License 2.0 5 votes vote down vote up
def update_volume_mapping_table():
    op.drop_column('volume_mapping', 'cinder_volume_id')
    op.drop_column('volume_mapping', 'volume_provider')
    op.drop_column('volume_mapping', 'connection_info')
    op.drop_column('volume_mapping', 'contents')
    op.drop_column('volume_mapping', 'auto_remove')
    op.drop_column('volume_mapping', 'host') 
Example #20
Source File: c2052ead4f95_remove_meta_from_container.py    From zun with Apache License 2.0 5 votes vote down vote up
def upgrade():
    op.drop_column('container', 'meta') 
Example #21
Source File: f046346d1d87_add_timestamp_to_pci_device.py    From zun with Apache License 2.0 5 votes vote down vote up
def upgrade():
    op.add_column('pci_device',
                  sa.Column('created_at', sa.DateTime(), nullable=True))
    op.add_column('pci_device',
                  sa.Column('updated_at', sa.DateTime(), nullable=True))
    op.drop_column('pci_device', 'request_id')
    op.add_column('pci_device', sa.Column('request_id', sa.String(36),
                                          nullable=True)) 
Example #22
Source File: 828c16f70cce_create_resource_type_table.py    From gnocchi with Apache License 2.0 5 votes vote down vote up
def upgrade():
    resource_type = op.create_table(
        'resource_type',
        sa.Column('name', sa.String(length=255), nullable=False),
        sa.PrimaryKeyConstraint('name'),
        mysql_charset='utf8',
        mysql_engine='InnoDB'
    )

    resource = sa.Table('resource', sa.MetaData(),
                        type_string_col("type", "resource"))
    op.execute(resource_type.insert().from_select(
        ['name'], sa.select([resource.c.type]).distinct()))

    for table in ["resource", "resource_history"]:
        op.alter_column(table, "type", new_column_name="old_type",
                        existing_type=type_enum)
        op.add_column(table, type_string_col("type", table))
        sa_table = sa.Table(table, sa.MetaData(),
                            type_string_col("type", table),
                            type_enum_col('old_type'))
        op.execute(sa_table.update().values(
            {sa_table.c.type: sa_table.c.old_type}))
        op.drop_column(table, "old_type")
        op.alter_column(table, "type", nullable=False,
                        existing_type=type_string) 
Example #23
Source File: 5c4f93e5bb4_mysql_float_to_timestamp.py    From gnocchi with Apache License 2.0 5 votes vote down vote up
def upgrade():
    bind = op.get_bind()
    if bind and bind.engine.name == "mysql":
        op.execute("SET time_zone = '+00:00'")
        # NOTE(jd) So that crappy engine that is MySQL does not have "ALTER
        # TABLE … USING …". We need to copy everything and convert…
        for table_name, column_name in (("resource", "started_at"),
                                        ("resource", "ended_at"),
                                        ("resource", "revision_start"),
                                        ("resource_history", "started_at"),
                                        ("resource_history", "ended_at"),
                                        ("resource_history", "revision_start"),
                                        ("resource_history", "revision_end"),
                                        ("resource_type", "updated_at")):

            nullable = column_name == "ended_at"

            existing_type = sa.types.DECIMAL(
                precision=20, scale=6, asdecimal=True)
            existing_col = sa.Column(
                column_name,
                existing_type,
                nullable=nullable)
            temp_col = sa.Column(
                column_name + "_ts",
                sqlalchemy_types.TimestampUTC(),
                nullable=True)
            op.add_column(table_name, temp_col)
            t = sa.sql.table(table_name, existing_col, temp_col)
            op.execute(t.update().values(
                **{column_name + "_ts": func.from_unixtime(existing_col)}))
            op.drop_column(table_name, column_name)
            op.alter_column(table_name,
                            column_name + "_ts",
                            nullable=nullable,
                            type_=sqlalchemy_types.TimestampUTC(),
                            existing_nullable=nullable,
                            existing_type=existing_type,
                            new_column_name=column_name) 
Example #24
Source File: 3bc88a29a22_.py    From comport with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('citizen_complaints', 'officer_years_of_service')
    op.add_column('citizen_complaints', sa.Column('officer_years_of_service', sa.Integer(), nullable=True))
    ### end Alembic commands ### 
Example #25
Source File: 331a821cc4a_.py    From comport with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('use_of_force_incidents', 'resident_condition')
    op.drop_column('use_of_force_incidents', 'officer_condition')
    op.create_table('citizen_complaint',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('department_id', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.Column('opaque_id', sa.VARCHAR(length=255), autoincrement=False, nullable=False),
    sa.Column('occured_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('division', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('precinct', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('shift', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('beat', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('disposition', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('census_tract', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('resident_race', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('officer_race', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('resident_sex', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('officer_sex', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('officer_identifier', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('officer_years_of_service', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('category', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('officer_age', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('resident_age', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['department_id'], ['departments.id'], name='citizen_complaint_department_id_fkey'),
    sa.PrimaryKeyConstraint('id', name='citizen_complaint_pkey')
    )
    op.drop_table('citizen_complaints')
    op.drop_table('officer_involved_shootings')
    ### end Alembic commands ### 
Example #26
Source File: 2f13ffb1ce60_.py    From comport with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def downgrade():
    op.drop_column('pursuits_srpd', 'division')
    op.drop_column('pursuits_srpd', 'bureau') 
Example #27
Source File: b13e5a5233_.py    From comport with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('extractors', 'last_contact')
    ### end Alembic commands ### 
Example #28
Source File: 1d31622bbed_.py    From comport with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('departments', 'why_we_are_doing_this')
    op.drop_column('departments', 'what_this_is')
    op.drop_column('departments', 'how_you_can_use_this_data')
    op.drop_column('departments', 'contact_us')
    ### end Alembic commands ### 
Example #29
Source File: c471472f1a82_.py    From comport with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def downgrade():
    op.drop_column('use_of_force_incidents_srpd', 'officer_force_type_scale')
    op.drop_column('use_of_force_incidents_srpd', 'division')
    op.drop_column('use_of_force_incidents_srpd', 'bureau') 
Example #30
Source File: 43fd1bb4848_.py    From comport with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('use_of_force_incidents', 'citizen_weapon')
    op.drop_column('use_of_force_incidents', 'census_tract')
    ### end Alembic commands ###