A couple of us have generated migrations and these indexes are automatically added. Rather than removing them for each migration, let's make it official.
47 lines
2.4 KiB
Python
47 lines
2.4 KiB
Python
"""Add indexes
|
|
|
|
Revision ID: 3777e9e39644
|
|
Revises: fa3ba4049218
|
|
Create Date: 2019-02-20 15:57:44.531311
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '3777e9e39644'
|
|
down_revision = 'fa3ba4049218'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_index(op.f('ix_audit_events_portfolio_id'), 'audit_events', ['portfolio_id'], unique=False)
|
|
op.drop_index('ix_audit_events_workspace_id', table_name='audit_events')
|
|
op.create_index(op.f('ix_invitations_portfolio_role_id'), 'invitations', ['portfolio_role_id'], unique=False)
|
|
op.drop_index('ix_invitations_workspace_role_id', table_name='invitations')
|
|
op.create_index(op.f('ix_portfolio_roles_portfolio_id'), 'portfolio_roles', ['portfolio_id'], unique=False)
|
|
op.create_index(op.f('ix_portfolio_roles_user_id'), 'portfolio_roles', ['user_id'], unique=False)
|
|
op.create_index('portfolio_role_user_portfolio', 'portfolio_roles', ['user_id', 'portfolio_id'], unique=True)
|
|
op.drop_index('ix_workspace_roles_user_id', table_name='portfolio_roles')
|
|
op.drop_index('ix_workspace_roles_workspace_id', table_name='portfolio_roles')
|
|
op.drop_index('workspace_role_user_workspace', table_name='portfolio_roles')
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_index('workspace_role_user_workspace', 'portfolio_roles', ['user_id', 'portfolio_id'], unique=True)
|
|
op.create_index('ix_workspace_roles_workspace_id', 'portfolio_roles', ['portfolio_id'], unique=False)
|
|
op.create_index('ix_workspace_roles_user_id', 'portfolio_roles', ['user_id'], unique=False)
|
|
op.drop_index('portfolio_role_user_portfolio', table_name='portfolio_roles')
|
|
op.drop_index(op.f('ix_portfolio_roles_user_id'), table_name='portfolio_roles')
|
|
op.drop_index(op.f('ix_portfolio_roles_portfolio_id'), table_name='portfolio_roles')
|
|
op.create_index('ix_invitations_workspace_role_id', 'invitations', ['portfolio_role_id'], unique=False)
|
|
op.drop_index(op.f('ix_invitations_portfolio_role_id'), table_name='invitations')
|
|
op.create_index('ix_audit_events_workspace_id', 'audit_events', ['portfolio_id'], unique=False)
|
|
op.drop_index(op.f('ix_audit_events_portfolio_id'), table_name='audit_events')
|
|
# ### end Alembic commands ###
|