atst/alembic/versions/903d7c66ff1d_remove_workspaces_name_unique_constraint.py
dandds 156ea02c90 remove migration that adds role permissions
script/seed_roles.py is idempotent, updates roles and perms, and we
should rely on that instead
2018-12-13 09:40:12 -05:00

43 lines
1.7 KiB
Python

"""remove workspaces.name unique constraint
Revision ID: 903d7c66ff1d
Revises: 875841fac207
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 = '875841fac207'
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 ###