How to use the alembic.op.alter_column function in alembic

To help you get started, we’ve selected a few alembic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github crflynn / pypistats.org / migrations / versions / c81b3715b9e5_.py View on Github external
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column("recent", "downloads", existing_type=sa.BigInteger(), type_=sa.INTEGER(), existing_nullable=False)
    # ### end Alembic commands ###
github indico / indico / indico / migrations / versions / 201503051056_49ac5164a65b_make_agreement_email_nullable.py View on Github external
def downgrade():
    op.alter_column('agreements', 'person_email', nullable=False, schema='events')
github getsentry / freight / migrations / versions / 4435f9f6c1da_task_status_is_not_nullable.py View on Github external
def upgrade():
    op.alter_column("task", "status", existing_type=sa.INTEGER(), nullable=False)
github asterisk / asterisk / contrib / ast-db-manage / config / versions / e96a0b8071c_increase_pjsip_column_size.py View on Github external
def downgrade():
    op.alter_column('ps_globals', 'user_agent', type_=sa.String(40))

    if op.get_context().bind.dialect.name != 'mssql':
        op.alter_column('ps_contacts', 'id', type_=sa.String(40))
    else:
        op.drop_constraint('uq_ps_contacts_id', 'ps_contacts')
        op.drop_index('ps_contacts_id', 'ps_contacts')
        op.alter_column('ps_contacts', 'id', type_=sa.String(40))
        op.create_index('ps_contacts_id', 'ps_contacts', ['id'])
    op.alter_column('ps_contacts', 'uri', type_=sa.String(40))
    op.alter_column('ps_contacts', 'user_agent', type_=sa.String(40))

    op.alter_column('ps_registrations', 'client_uri', type_=sa.String(40))
    op.alter_column('ps_registrations', 'server_uri', type_=sa.String(40))
github fedspendingtransparency / data-act-broker-backend / dataactcore / migrations / versions / cdb714f6f374_addoriginalfilenames.py View on Github external
op.alter_column('error_metadata', 'first_row',
               existing_type=sa.INTEGER(),
               nullable=True)
    op.alter_column('error_metadata', 'job_id',
               existing_type=sa.INTEGER(),
               nullable=True)
    op.alter_column('error_metadata', 'occurrences',
               existing_type=sa.INTEGER(),
               nullable=True)
    op.alter_column('error_type', 'description',
               existing_type=sa.TEXT(),
               nullable=True)
    op.alter_column('error_type', 'name',
               existing_type=sa.TEXT(),
               nullable=True)
    op.alter_column('file', 'file_status_id',
               existing_type=sa.INTEGER(),
               nullable=True)
    op.alter_column('file_status', 'description',
               existing_type=sa.TEXT(),
               nullable=True)
    op.alter_column('file_status', 'name',
               existing_type=sa.TEXT(),
               nullable=True)
    ### end Alembic commands ###
github hypothesis / lms / lms / migrations / versions / db0e29272784_make_module_item_configurations_columns_.py View on Github external
def upgrade():
    op.alter_column("module_item_configurations", "resource_link_id", nullable=False)
    op.alter_column(
        "module_item_configurations", "tool_consumer_instance_guid", nullable=False
    )
    op.alter_column("module_item_configurations", "document_url", nullable=False)
github fedspendingtransparency / data-act-broker-backend / dataactcore / migrations / versions / de141f790505_add_new_short_colnames.py View on Github external
op.alter_column('award_financial_assistance', 'legal_entity_city_code', new_column_name='legalentitycitycode')
    op.alter_column('award_financial_assistance', 'legal_entity_address_line3', new_column_name='legalentityaddressline3')
    op.alter_column('award_financial_assistance', 'legal_entity_address_line2', new_column_name='legalentityaddressline2')
    op.alter_column('award_financial_assistance', 'legal_entity_address_line1', new_column_name='legalentityaddressline1')
    op.alter_column('award_financial_assistance', 'funding_sub_tier_agency_na', new_column_name='fundingsubtieragencyname')
    op.alter_column('award_financial_assistance', 'funding_sub_tier_agency_co', new_column_name='fundingsubtieragencycode')
    op.alter_column('award_financial_assistance', 'funding_office_name', new_column_name='fundingagencyofficename')
    op.alter_column('award_financial_assistance', 'funding_office_code', new_column_name='fundingofficecode')
    op.alter_column('award_financial_assistance', 'funding_agency_name', new_column_name='fundingagencyname')
    op.alter_column('award_financial_assistance', 'funding_agency_code', new_column_name='fundingagencycode')
    op.alter_column('award_financial_assistance', 'fiscal_year_and_quarter_co', new_column_name='fiscalyearandquartercorrection')
    op.alter_column('award_financial_assistance', 'federal_action_obligation', new_column_name='federalactionobligation')
    op.alter_column('award_financial_assistance', 'face_value_loan_guarantee', new_column_name='facevalueloanguarantee')
    op.alter_column('award_financial_assistance', 'correction_late_delete_ind', new_column_name='correctionlatedeleteindicator')
    op.alter_column('award_financial_assistance', 'business_types', new_column_name='businesstypes')
    op.alter_column('award_financial_assistance', 'business_funds_indicator', new_column_name='businessfundsindicator')
    op.alter_column('award_financial_assistance', 'awarding_sub_tier_agency_n', new_column_name='awardingsubtieragencyname')
    op.alter_column('award_financial_assistance', 'awarding_sub_tier_agency_c', new_column_name='awardingsubtieragencycode')
    op.alter_column('award_financial_assistance', 'awarding_office_name', new_column_name='awardingofficename')
    op.alter_column('award_financial_assistance', 'awarding_office_code', new_column_name='awardingofficecode')
    op.alter_column('award_financial_assistance', 'awarding_agency_name', new_column_name='awardingagencyname')
    op.alter_column('award_financial_assistance', 'awarding_agency_code', new_column_name='awardingagencycode')
    op.alter_column('award_financial_assistance', 'awardee_or_recipient_uniqu', new_column_name='awardeeorrecipientuniqueidentifier')
    op.alter_column('award_financial_assistance', 'awardee_or_recipient_legal', new_column_name='awardeeorrecipientlegalentityname')
    op.alter_column('award_financial_assistance', 'award_modification_amendme', new_column_name='awardmodificationamendmentnumber')
    op.alter_column('award_financial_assistance', 'award_description', new_column_name='awarddescription')
    op.alter_column('award_financial_assistance', 'assistance_type', new_column_name='assistancetype')
    op.alter_column('award_financial_assistance', 'action_type', new_column_name='actiontype')
    op.alter_column('award_financial_assistance', 'action_date', new_column_name='actiondate')


    op.alter_column('award_financial', 'ussgl498200_upward_adjustm_cpe', new_column_name='ussgl498200_upadjsprioryrdelivordersobligpaid_cpe')
github Nukesor / sticker-finder / migrations / versions / 2018_11_28_e28425b95092_fuck_languages.py View on Github external
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('change', sa.Column('reviewed', sa.Boolean(), nullable=False, server_default='False'))
    op.alter_column('change', 'reviewed', server_default=None)
    op.drop_column('chat', 'choosing_language')
    op.add_column('task', sa.Column('reverted', sa.Boolean(), nullable=False, server_default='False'))
    op.alter_column('task', 'reverted', server_default=None)
    op.add_column('task', sa.Column('default_language', sa.Boolean(), nullable=True))

    op.add_column('change', sa.Column('default_language', sa.Boolean(), nullable=False, server_default='True'))
    op.add_column('sticker_set', sa.Column('default_language', sa.Boolean(), nullable=False, server_default='True'))
    op.add_column('tag', sa.Column('default_language', sa.Boolean(), nullable=False, server_default='True'))
    op.add_column('user', sa.Column('default_language', sa.Boolean(), nullable=False, server_default='True'))

    op.alter_column('change', 'default_language', server_default=None)
    op.alter_column('sticker_set', 'default_language', server_default=None)
    op.alter_column('tag', 'default_language', server_default=None)
    op.alter_column('user', 'default_language', server_default=None)

    op.drop_index('ix_change_language', table_name='change')
    op.drop_constraint('change_language_fkey', 'change', type_='foreignkey')
    op.drop_index('ix_sticker_set_language', table_name='sticker_set')
    op.drop_constraint('sticker_set_language_fkey', 'sticker_set', type_='foreignkey')
    op.drop_index('ix_tag_language', table_name='tag')
    op.drop_constraint('tag_language_fkey', 'tag', type_='foreignkey')
    op.drop_index('ix_user_language', table_name='user')
    op.drop_constraint('user_language_fkey', 'user', type_='foreignkey')

    op.drop_table('language')
    session = Session(bind=op.get_bind())

    # Set all changes to reviewed, where an task exists
github fedspendingtransparency / data-act-broker-backend / dataactcore / migrations / versions / c75b5f18b7e4_added_valid_flag_and_dropped_.py View on Github external
def downgrade_staging():
    ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('object_class_program_activity', 'ussgl498200_upadjsprioryrdelivordersobligpaid_cpe',
               existing_type=sa.NUMERIC(),
               nullable=False)
    op.alter_column('object_class_program_activity', 'ussgl498100_upadjsprioryeardeliveredordersobligunpaid_cpe',
               existing_type=sa.NUMERIC(),
               nullable=False)
    op.alter_column('object_class_program_activity', 'ussgl497200_downadjsprioryrpaiddelivordersobligrefclt_cpe',
               existing_type=sa.NUMERIC(),
               nullable=False)
    op.alter_column('object_class_program_activity', 'ussgl497100_downadjsprioryrunpaiddelivordersobligrec_cpe',
               existing_type=sa.NUMERIC(),
               nullable=False)
    op.alter_column('object_class_program_activity', 'ussgl493100_deliveredordersobligstransferredunpaid_cpe',
               existing_type=sa.NUMERIC(),
               nullable=False)
    op.alter_column('object_class_program_activity', 'ussgl490800_authorityoutlayednotyetdisbursed_fyb',
               existing_type=sa.NUMERIC(),
               nullable=False)
    op.alter_column('object_class_program_activity', 'ussgl490800_authorityoutlayednotyetdisbursed_cpe',
               existing_type=sa.NUMERIC(),
               nullable=False)
    op.alter_column('object_class_program_activity', 'ussgl490200_deliveredordersobligationspaid_cpe',
               existing_type=sa.NUMERIC(),
               nullable=False)
    op.alter_column('object_class_program_activity', 'ussgl490100_deliveredordersobligationsunpaid_fyb',
               existing_type=sa.NUMERIC(),
               nullable=False)
    op.alter_column('object_class_program_activity', 'ussgl490100_deliveredordersobligationsunpaid_cpe',
               existing_type=sa.NUMERIC(),
github apache / incubator-superset / panoramix / migrations / versions / 18e88e1cc004_making_audit_nullable.py View on Github external
op.alter_column('table_columns', 'changed_on',
                   existing_type=sa.DATETIME(),
                   nullable=True)
        op.alter_column('table_columns', 'created_on',
                   existing_type=sa.DATETIME(),
                   nullable=True)
        op.alter_column('tables', 'changed_on',
                   existing_type=sa.DATETIME(),
                   nullable=True)
        op.alter_column('tables', 'created_on',
                   existing_type=sa.DATETIME(),
                   nullable=True)
        op.alter_column('url', 'changed_on',
                   existing_type=sa.DATETIME(),
                   nullable=True)
        op.alter_column('url', 'created_on',
                   existing_type=sa.DATETIME(),
                   nullable=True)
        ### end Alembic commands ###
    except:
        pass