atst/alembic/versions/903d7c66ff1d_remove_workspaces_name_unique_constraint.py
richard-dds 885b2da308 Remove workspaces.name unique constraint
- Added some random indexes
- Fixed audit_events.request_id foreign key constraint
2018-09-26 10:23:54 -04:00

43 lines
1.7 KiB
Python

"""remove workspaces.name unique constraint
Revision ID: 903d7c66ff1d
Revises: 7958cca588a1
Create Date: 2018-09-26 10:19:13.230064
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = '903d7c66ff1d'
down_revision = '7958cca588a1'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_index(op.f('ix_audit_events_request_id'), 'audit_events', ['request_id'], unique=False)
op.create_index(op.f('ix_audit_events_workspace_id'), 'audit_events', ['workspace_id'], unique=False)
op.create_foreign_key(None, 'audit_events', 'requests', ['request_id'], ['id'])
op.alter_column('request_status_events', 'time_created',
existing_type=postgresql.TIMESTAMP(timezone=True),
nullable=False,
existing_server_default=sa.text('now()'))
op.drop_constraint('workspaces_name_key', 'workspaces', type_='unique')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_unique_constraint('workspaces_name_key', 'workspaces', ['name'])
op.alter_column('request_status_events', 'time_created',
existing_type=postgresql.TIMESTAMP(timezone=True),
nullable=True,
existing_server_default=sa.text('now()'))
op.drop_constraint(None, 'audit_events', type_='foreignkey')
op.drop_index(op.f('ix_audit_events_workspace_id'), table_name='audit_events')
op.drop_index(op.f('ix_audit_events_request_id'), table_name='audit_events')
# ### end Alembic commands ###