How to use the alembic.op.create_index 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 openstack / neutron / neutron / db / migration / alembic_migrations / versions / mitaka / expand / 15e43b934f81_rbac_qos_policy.py View on Github external
sa.Column('tenant_id',
                              sa.String(length=255),
                              nullable=True),
                    sa.Column('target_tenant',
                              sa.String(length=255),
                              nullable=False),
                    sa.Column('action', sa.String(length=255), nullable=False),
                    sa.Column('object_id', sa.String(length=36),
                              nullable=False),
                    sa.ForeignKeyConstraint(['object_id'],
                                            ['qos_policies.id'],
                                            ondelete='CASCADE'),
                    sa.PrimaryKeyConstraint('id'),
                    sa.UniqueConstraint('target_tenant',
                                        'object_id', 'action'))
    op.create_index(op.f('ix_qospolicyrbacs_tenant_id'), 'qospolicyrbacs',
                    ['tenant_id'], unique=False)
github Nukesor / gitalizer / migrations / versions / 5a8fbf49bbb9_create_commit_repositories_many_to_many.py View on Github external
# Drop all constraints and indices of the new table
    op.drop_constraint(None, 'commit_repositories', type_='foreignkey')
    op.drop_constraint(None, 'commit_repositories', type_='foreignkey')
    op.drop_constraint(None, 'commit_repositories', type_='unique')
    op.drop_index(op.f('ix_commit_repositories_repository_url'), table_name='commit_repositories')
    op.drop_index(op.f('ix_commit_repositories_commit_sha'), table_name='commit_repositories')
    op.drop_constraint(None, 'commit', type_='unique')

    # Do stuff:
    op.drop_table('commit_repositories')

    # Create old columns
    op.add_column('commit', sa.Column('repository_url', sa.VARCHAR(length=240), autoincrement=False, nullable=False))

    # Create old constraints and indices
    op.create_index('ix_commit_repository_url', 'commit', ['repository_url'], unique=False)
    op.create_unique_constraint('commit_sha_repository_url_key', 'commit', ['sha', 'repository_url'])
    op.create_foreign_key('commit_repository_url_fkey', 'commit', 'repository', ['repository_url'], ['clone_url'], ondelete='CASCADE')
github klokantech / jekylledit / app / migrations / versions / b04e0f09ebca_.py View on Github external
'site',
        sa.Column('id', sa.Unicode(), nullable=False),
        sa.Column('mtime', sa.Integer(), nullable=False),
        sa.Column('gitkit_options', JSON(), nullable=True),
        sa.PrimaryKeyConstraint('id', name=op.f('site_pkey')),
    )
    op.create_table(
        'roles',
        sa.Column('email', sa.Unicode(), nullable=False),
        sa.Column('site_id', sa.Unicode(), nullable=False),
        sa.Column('roles', JSON(), nullable=False),
        sa.ForeignKeyConstraint(['email'], ['account.email'], name=op.f('roles_email_fkey')),
        sa.ForeignKeyConstraint(['site_id'], ['site.id'], name=op.f('roles_site_id_fkey')),
        sa.PrimaryKeyConstraint('email', 'site_id', name=op.f('roles_pkey')),
    )
    op.create_index(op.f('roles_site_id_idx'), 'roles', ['site_id'], unique=False)
github nyaadevs / nyaa / migrations / versions / ecb0b3b88142_flags2columns.py View on Github external
def downgrade():
    #op.add_column('nyaa_torrents', sa.Column('flags', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False))

    op.execute('UPDATE nyaa_torrents SET flags = flags | 1 WHERE anonymous;')
    op.execute('UPDATE nyaa_torrents SET flags = flags | 2 WHERE hidden;')
    op.execute('UPDATE nyaa_torrents SET flags = flags | 4 WHERE trusted;')
    op.execute('UPDATE nyaa_torrents SET flags = flags | 8 WHERE remake;')
    op.execute('UPDATE nyaa_torrents SET flags = flags | 16 WHERE complete;')
    op.execute('UPDATE nyaa_torrents SET flags = flags | 32 WHERE deleted;')
    op.execute('UPDATE nyaa_torrents SET flags = flags | 64 WHERE banned;')
    op.execute('UPDATE nyaa_torrents SET flags = flags | 128 WHERE comment_locked;')

    op.create_index('nyaa_uploader_flag_idx', 'nyaa_torrents', ['uploader_id', 'flags'], unique=False)
    op.create_index('ix_nyaa_torrents_flags', 'nyaa_torrents', ['flags'], unique=False)

#    op.drop_index(op.f('ix_nyaa_torrents_uploader_id'), table_name='nyaa_torrents')
#    op.drop_index(op.f('ix_nyaa_torrents_trusted'), table_name='nyaa_torrents')
#    op.drop_index(op.f('ix_nyaa_torrents_remake'), table_name='nyaa_torrents')
#    op.drop_index(op.f('ix_nyaa_torrents_hidden'), table_name='nyaa_torrents')
#    op.drop_index(op.f('ix_nyaa_torrents_deleted'), table_name='nyaa_torrents')
#    op.drop_index(op.f('ix_nyaa_torrents_complete'), table_name='nyaa_torrents')
#    op.drop_index(op.f('ix_nyaa_torrents_comment_locked'), table_name='nyaa_torrents')
#    op.drop_index(op.f('ix_nyaa_torrents_banned'), table_name='nyaa_torrents')
#    op.drop_index(op.f('ix_nyaa_torrents_anonymous'), table_name='nyaa_torrents')
#    op.drop_index('ix_nyaa_super', table_name='nyaa_torrents')
#
#    op.execute(
#        "ALTER TABLE nyaa_torrents "
#        "DROP COLUMN anonymous BOOL NOT NULL, "
github cloudify-cosmo / cloudify-manager / resources / rest-service / cloudify / migrations / versions / a6d00b128933_4_4_to_4_5.py View on Github external
unique=False)

    op.create_index('ix_events_id', 'events', ['id'], unique=False)
    op.create_index('ix_logs_id', 'logs', ['id'], unique=False)

    op.create_index('ix_deployments_id', 'deployments', ['id'], unique=False)
    op.create_index(
        'ix_deployments_created_at',
        'deployments', ['created_at'],
        unique=False)

    op.create_index(
        'ix_plugins_uploaded_at', 'plugins', ['uploaded_at'], unique=False)
    op.create_index(
        'ix_plugins_package_name', 'plugins', ['package_name'], unique=False)
    op.create_index('ix_plugins_id', 'plugins', ['id'], unique=False)
    op.create_index(
        'ix_plugins_archive_name', 'plugins', ['archive_name'], unique=False)

    op.create_index('ix_nodes_type', 'nodes', ['type'], unique=False)
    op.create_index('ix_nodes_id', 'nodes', ['id'], unique=False)
    op.create_index(
        'ix_node_instances_id', 'node_instances', ['id'], unique=False)

    op.create_index('ix_users_username', 'users', ['username'], unique=True)
    op.create_index('ix_tenants_name', 'tenants', ['name'], unique=True)
    op.create_index('ix_roles_name', 'roles', ['name'], unique=True)

    op.create_index('ix_snapshots_id', 'snapshots', ['id'], unique=False)
    op.create_index(
        'ix_snapshots_created_at', 'snapshots', ['created_at'], unique=False)
github pypa / warehouse / warehouse / migrations / versions / 283c68f2ab2_initial_migration.py View on Github external
"openid_sessions",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("url", sa.Text(), nullable=True),
        sa.Column("assoc_handle", sa.Text(), nullable=True),
        sa.Column("expires", sa.DateTime(), nullable=True),
        sa.Column("mac_key", sa.Text(), nullable=True),
        sa.PrimaryKeyConstraint("id"),
    )

    op.create_table(
        "openid_nonces",
        sa.Column("created", sa.DateTime(), nullable=True),
        sa.Column("nonce", sa.Text(), nullable=True),
    )

    op.create_index("openid_nonces_created", "openid_nonces", ["created"], unique=False)

    op.create_index("openid_nonces_nonce", "openid_nonces", ["nonce"], unique=False)

    op.create_table(
        "file_registry",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("filename", sa.Text(), nullable=False),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("filename", name="file_registry_filename_key"),
    )

    op.create_table(
        "openid_whitelist",
        sa.Column("name", sa.Text(), nullable=False),
        sa.Column("trust_root", sa.Text(), nullable=False),
        sa.Column("created", sa.DateTime(), nullable=True),
github cloudify-cosmo / cloudify-manager / resources / rest-service / cloudify / migrations / versions / a6d00b128933_4_4_to_4_5.py View on Github external
ondelete='CASCADE')

    # adding tenant_id indexes
    op.create_index(
        op.f('blueprints__tenant_id_idx'),
        'blueprints', ['_tenant_id'],
        unique=False)
    op.create_index(
        op.f('deployment_modifications__tenant_id_idx'),
        'deployment_modifications', ['_tenant_id'],
        unique=False)
    op.create_index(
        op.f('deployment_update_steps__tenant_id_idx'),
        'deployment_update_steps', ['_tenant_id'],
        unique=False)
    op.create_index(
        op.f('deployment_updates__tenant_id_idx'),
        'deployment_updates', ['_tenant_id'],
        unique=False)
    op.create_index(
        op.f('deployments__tenant_id_idx'),
        'deployments', ['_tenant_id'],
        unique=False)
    op.create_index(
        op.f('events__tenant_id_idx'), 'events', ['_tenant_id'], unique=False)
    op.create_index(
        op.f('executions__tenant_id_idx'),
        'executions', ['_tenant_id'],
        unique=False)
    op.create_index(
        op.f('logs__tenant_id_idx'), 'logs', ['_tenant_id'], unique=False)
    op.create_index(
github indico / indico / indico / migrations / versions / 201509111039_699b4e79992_add_unique_constraints_to_principals.py View on Github external
def upgrade():
    op.create_index('ix_uq_attachment_principals_local_group', 'attachment_principals',
                    ['local_group_id', 'attachment_id'], unique=True, schema='attachments',
                    postgresql_where=sa.text('type = 2'))
    op.create_index('ix_uq_attachment_principals_mp_group', 'attachment_principals',
                    ['mp_group_provider', 'mp_group_name', 'attachment_id'], unique=True, schema='attachments',
                    postgresql_where=sa.text('type = 3'))
    op.create_index('ix_uq_attachment_principals_user', 'attachment_principals',
                    ['user_id', 'attachment_id'], unique=True, schema='attachments',
                    postgresql_where=sa.text('type = 1'))
    op.create_index('ix_uq_folder_principals_local_group', 'folder_principals',
                    ['local_group_id', 'folder_id'], unique=True, schema='attachments',
                    postgresql_where=sa.text('type = 2'))
    op.create_index('ix_uq_folder_principals_mp_group', 'folder_principals',
                    ['mp_group_provider', 'mp_group_name', 'folder_id'], unique=True, schema='attachments',
                    postgresql_where=sa.text('type = 3'))
    op.create_index('ix_uq_folder_principals_user', 'folder_principals',
                    ['user_id', 'folder_id'], unique=True, schema='attachments',
github TwilioDevEd / authy2fa-flask / migrations / versions / f2733ec8543e_create_user_table.py View on Github external
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('email', sa.String(length=64), nullable=True),
    sa.Column('password_hash', sa.String(length=128), nullable=True),
    sa.Column('full_name', sa.String(length=256), nullable=True),
    sa.Column('country_code', sa.Integer(), nullable=True),
    sa.Column('phone', sa.String(length=30), nullable=True),
    sa.Column('authy_id', sa.Integer(), nullable=True),
    sa.Column('authy_status', sa.Enum('unverified', 'onetouch', 'sms', 'token', 'approved', 'denied', name='authy_statuses'), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True)
    # ### end Alembic commands ###
github gateway4labs / labmanager / alembic / versions / 1b8856078bd3_integrating_embed_tables.py View on Github external
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('SiWaySAMLUsers',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('email', sa.Unicode(length=255), nullable=False),
    sa.Column('uid', sa.Integer(), nullable=False),
    sa.Column('employee_type', sa.Unicode(length=255), nullable=False),
    sa.Column('full_name', sa.Unicode(length=255), nullable=False),
    sa.Column('short_name', sa.Unicode(length=255), nullable=False),
    sa.Column('school_name', sa.Unicode(length=255), nullable=False),
    sa.Column('group', sa.Unicode(length=255), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(u'ix_SiWaySAMLUsers_email', 'SiWaySAMLUsers', ['email'], unique=True)
    op.create_table('EmbedApplications',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('url', sa.Unicode(length=255), nullable=False),
    sa.Column('name', sa.Unicode(length=100), nullable=False),
    sa.Column('owner_id', sa.Integer(), nullable=True),
    sa.Column('height', sa.Integer(), nullable=True),
    sa.Column('scale', sa.Integer(), nullable=True),
    sa.Column('identifier', sa.Unicode(length=36), nullable=False),
    sa.Column('creation', sa.DateTime(), nullable=False),
    sa.Column('last_update', sa.DateTime(), nullable=False),
    sa.ForeignKeyConstraint(['owner_id'], ['lt_users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(u'ix_EmbedApplications_creation', 'EmbedApplications', ['creation'], unique=False)
    op.create_index(u'ix_EmbedApplications_identifier', 'EmbedApplications', ['identifier'], unique=True)
    op.create_index(u'ix_EmbedApplications_last_update', 'EmbedApplications', ['last_update'], unique=False)