How to use the alembic.op 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 rr- / szurubooru / server / szurubooru / migrations / versions / 9ef1a1643c2a_update_user_table_for_hardened_passwords.py View on Github external
)

    session = sa.orm.session.Session(bind=op.get_bind())
    if session.query(User).count() >= 0:
        for user in session.query(User).all():
            password_hash_length = len(user.password_hash)
            if password_hash_length == 40:
                user.password_revision = 1
            elif password_hash_length == 64:
                user.password_revision = 2
            else:
                user.password_revision = 0
        session.flush()
    session.commit()

    op.alter_column(
        "user", "password_revision", existing_nullable=True, nullable=False
    )
github openstack / neutron-fwaas / neutron_fwaas / db / migration / alembic_migrations / versions / pike / contract / fd38cd995cc0_shared_attribute_for_firewall_resources.py View on Github external
def upgrade():
    op.alter_column('firewall_rules_v2', 'public', new_column_name='shared',
                    existing_type=sa.Boolean)
    op.alter_column('firewall_groups_v2', 'public', new_column_name='shared',
                    existing_type=sa.Boolean)
    op.alter_column('firewall_policies_v2', 'public', new_column_name='shared',
                    existing_type=sa.Boolean)
github CSCfi / pebbles / migrations / versions / c0732331a3c8_.py View on Github external
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('locks',
    sa.Column('lock_id', sa.String(length=64), nullable=False),
    sa.Column('acquired_at', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('lock_id', name=op.f('pk_locks')),
    sa.UniqueConstraint('lock_id', name=op.f('uq_locks_lock_id'))
    )
    op.create_table('notifications',
    sa.Column('id', sa.String(length=32), nullable=False),
    sa.Column('broadcasted', sa.DateTime(), nullable=True),
    sa.Column('subject', sa.String(length=255), nullable=True),
    sa.Column('message', sa.Text(), nullable=True),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_notifications'))
    )
    op.create_table('plugins',
    sa.Column('id', sa.String(length=32), nullable=False),
    sa.Column('name', sa.String(length=32), nullable=True),
    sa.Column('schema', sa.Text(), nullable=True),
github rafalp / Misago / misago / migrations / f99b40a61441_users.py View on Github external
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "misago_users",
        sa.Column("id", sa.BigInteger(), nullable=False),
        sa.Column("name", sa.String(length=50), nullable=False),
        sa.Column("slug", sa.String(length=50), nullable=False),
        sa.Column("email", sa.String(length=255), nullable=False),
        sa.Column("email_hash", sa.String(length=255), nullable=False),
        sa.Column("password", sa.String(length=255), nullable=True),
        sa.Column("is_deactivated", sa.Boolean(), nullable=False),
        sa.Column("is_moderator", sa.Boolean(), nullable=False),
        sa.Column("is_admin", sa.Boolean(), nullable=False),
        sa.Column("joined_at", sa.DateTime(), nullable=False),
        sa.Column("extra", sa.JSON(), nullable=False),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("email"),
        sa.UniqueConstraint("email_hash"),
        sa.UniqueConstraint("slug"),
github timelesslounge / timelessis / migrations / versions / 2019-01-28T150634.py View on Github external
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('scheme_types',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('description', sa.String(), nullable=False),
    sa.Column('default_value', sa.String(), nullable=False),
    sa.Column('value_type', sa.String(), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('description')
    )
    op.add_column('scheme_conditions', sa.Column('scheme_type_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'scheme_conditions', 'scheme_types', ['scheme_type_id'], ['id'])
    # ### end Alembic commands ###
github mitmedialab / CivilServant / alembic / versions / e566e8e209d1_added_query_index_to_experimentthing.py View on Github external
def upgrade_production():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('experiment_things', sa.Column('query_index', sa.String(length=256), nullable=True))
    op.create_index(op.f('ix_experiment_things_object_created'), 'experiment_things', ['object_created'], unique=False)
    op.create_index(op.f('ix_experiment_things_query_index'), 'experiment_things', ['query_index'], unique=False)
    ### end Alembic commands ###
github openstack / octavia / octavia / db / migration / alembic_migrations / versions / 4c094013699a_update_load_balancer_amphora.py View on Github external
def upgrade():
    op.add_column(
        u'amphora',
        sa.Column(u'load_balancer_id', sa.String(36),
                  sa.ForeignKey(u'load_balancer.id',
                                name=u'fk_amphora_load_balancer_id'),
                  nullable=True)
    )
    op.drop_table(u'load_balancer_amphora')
    op.drop_constraint(
        u'fk_container_provisioning_status_name', u'amphora',
        type_=u'foreignkey'
    )
    op.create_foreign_key(
        u'fk_amphora_provisioning_status_name', u'amphora',
        u'provisioning_status', [u'status'], [u'name']
    )
github asterisk / asterisk / contrib / ast-db-manage / config / versions / a6ef36f1309_ps_globals_add_ignore_uri_user_options.py View on Github external
def upgrade():
    ############################# Enums ##############################

    # yesno_values have already been created, so use postgres enum object
    # type to get around "already created" issue - works okay with mysql
    yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False)

    op.add_column('ps_globals', sa.Column('ignore_uri_user_options', yesno_values))
github lucyparsons / OpenOversight / OpenOversight / migrations / versions / f01cb1bc6293_add_last_employment_info.py View on Github external
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('officers', sa.Column('last_employment_date', sa.Date(), nullable=True))
    op.add_column('officers', sa.Column('last_employment_details', sa.String(length=120), nullable=True))
    # ### end Alembic commands ###