How to use the alembic.op.add_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 Weasyl / weasyl / libweasyl / libweasyl / alembic / versions / eff79a07a88d_use_timestamp_column_for_latest_.py View on Github external
def upgrade():
    op.alter_column(
        'profile',
        'latest_submission_time',
        new_column_name='latest_submission_time_old',
    )
    op.add_column(
        'profile',
        sa.Column('latest_submission_time', libweasyl.models.helpers.ArrowColumn(), nullable=False, server_default='epoch'),
    )
    op.execute(
        "UPDATE profile SET latest_submission_time = TIMESTAMP WITHOUT TIME ZONE 'epoch' + "
        "(latest_submission_time_old - %d) * INTERVAL '1 second'" % (UNIXTIME_OFFSET,))
    op.drop_column('profile', 'latest_submission_time_old')
github holmes-app / holmes-api / holmes / migrations / versions / 4d45dd3d8ce5_add_a_flag_for_review_active.py View on Github external
def upgrade():
    op.add_column(
        'violations',
        sa.Column('review_is_active', sa.Integer, nullable=False, server_default='1')
    )

    connection = op.get_bind()
    connection.execute('''UPDATE violations
        SET review_is_active = 0
        WHERE review_id IN (SELECT id FROM reviews WHERE is_active = 0)''')

    op.create_index(
        'idx_key_domain_review_active',
        'violations',
        ['key_id', 'domain_id', 'review_is_active'])
github asterisk / asterisk / contrib / ast-db-manage / config / versions / 461d7d691209_add_pjsip_qualify_timeout.py View on Github external
def upgrade():
    op.add_column('ps_aors', sa.Column('qualify_timeout', sa.Integer))
    op.add_column('ps_contacts', sa.Column('qualify_timeout', sa.Integer))
github Pagure / pagure / alembic / versions / 58e60d869326_add_notification_bool_to_pr.py View on Github external
def upgrade():
    ''' Add the column notification to the table pull_request_comments.
    '''
    op.add_column(
        'pull_request_comments',
        sa.Column('notification', sa.Boolean, default=False, nullable=True)
    )
    op.execute('''UPDATE "pull_request_comments" SET notification=False;''')
    op.alter_column(
        'pull_request_comments', 'notification',
        nullable=False, existing_nullable=True)
github all-of-us / raw-data-repository / rdr_service / alembic / versions / b0520bacfbd0_genomics_cohort_2_pilot.py View on Github external
op.create_table('participant_cohort_pilot',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('modified', sa.DateTime(), nullable=True),
    sa.Column('participant_id', sa.Integer(), nullable=True),
    sa.Column('consent_date', sa.Date(), nullable=True),
    sa.Column('enrollment_status_core_stored_sample_date', sa.Date(), nullable=True),
    sa.Column('cluster', sa.SmallInteger(), nullable=True),
    sa.Column('participant_cohort', rdr_service.model.utils.Enum(ParticipantCohort), nullable=True),
    sa.Column('participant_cohort_pilot', rdr_service.model.utils.Enum(ParticipantCohortPilotFlag), nullable=True),
    sa.ForeignKeyConstraint(['participant_id'], ['participant.participant_id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_participant_cohort_pilot_created'), 'participant_cohort_pilot', ['created'], unique=False)
    op.create_index('participant_cohort_participantId', 'participant_cohort_pilot', ['participant_id'], unique=False)
    op.add_column('participant_summary', sa.Column('cohort_2_pilot_flag', rdr_service.model.utils.Enum(ParticipantCohortPilotFlag), nullable=True))
    # ### end Alembic commands ###
github spiral-project / ihatemoney / ihatemoney / migrations / versions / 26d6a218c329_.py View on Github external
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column("person", sa.Column("weight", sa.Float(), nullable=True))
    ### end Alembic commands ###
github openstack / sahara / sahara / db / migration / alembic_migrations / versions / 018_volume_local_to_instance.py View on Github external
def upgrade():
    op.add_column('node_group_templates',
                  sa.Column('volume_local_to_instance', sa.Boolean()))
    op.add_column('node_groups',
                  sa.Column('volume_local_to_instance', sa.Boolean()))
    op.add_column('templates_relations',
                  sa.Column('volume_local_to_instance', sa.Boolean()))
github openstack / manila / manila / db / migrations / alembic / versions / 3e7d62517afa_add_create_share_from_snapshot_support.py View on Github external
snapshot_support_extra_spec else 'False')

        # Copy the snapshot_support value to create_share_from_snapshot_support
        extra_specs.append({
            'spec_key':
            constants.ExtraSpecs.CREATE_SHARE_FROM_SNAPSHOT_SUPPORT,
            'spec_value': spec_value,
            'deleted': 0,
            'created_at': now,
            'share_type_id': share_type.id,
        })
    if extra_specs:
        op.bulk_insert(extra_specs_table, extra_specs)

    # Add create_share_from_snapshot_support attribute to shares table
    op.add_column('shares',
                  sa.Column('create_share_from_snapshot_support',
                            sa.Boolean, default=True))

    # Copy snapshot_support to create_share_from_snapshot_support on each share
    shares_table = sa.Table(
        'shares',
        sa.MetaData(),
        sa.Column('id', sa.String(length=36)),
        sa.Column('deleted', sa.String(length=36)),
        sa.Column('snapshot_support', sa.Boolean),
        sa.Column('create_share_from_snapshot_support', sa.Boolean),
    )
    # pylint: disable=no-value-for-parameter
    update = shares_table.update().where(
        shares_table.c.deleted == 'False').values(
        create_share_from_snapshot_support=shares_table.c.snapshot_support)
github pajbot / pajbot / alembic / versions / 406575186b81_added_a_last_edited_by_column_to_the_.py View on Github external
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column("tb_stream_chunk_highlight", sa.Column("last_edited_by", sa.Integer(), nullable=True))
    op.create_foreign_key(None, "tb_stream_chunk_highlight", "tb_user", ["last_edited_by"], ["id"])
    ### end Alembic commands ###
github gateway4labs / labmanager / alembic / versions / 1c131a5ca91f_add_publicly_available_to_rlms.py View on Github external
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('rlmss', sa.Column('public_identifier', sa.Unicode(length=50), nullable=False))
    op.add_column('rlmss', sa.Column('publicly_available', sa.Boolean(), nullable=False))
    op.create_index('ix_rlmss_publicly_available', 'rlmss', ['publicly_available'], unique=False)
    ### end Alembic commands ###