"""users to permission_sets join table, remove role rel

Revision ID: fc08d99bb7f7
Revises: a19138e386c4
Create Date: 2019-03-18 06:13:43.128905

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = 'fc08d99bb7f7'
down_revision = 'a19138e386c4'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('users_permission_sets',
    sa.Column('user_id', postgresql.UUID(as_uuid=True), nullable=True),
    sa.Column('permission_set_id', postgresql.UUID(as_uuid=True), nullable=True),
    sa.ForeignKeyConstraint(['permission_set_id'], ['permission_sets.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], )
    )
    op.drop_constraint('users_atat_role_id_fkey', 'users', type_='foreignkey')
    op.drop_column('users', 'atat_role_id')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('users', sa.Column('atat_role_id', postgresql.UUID(), autoincrement=False, nullable=True))
    op.create_foreign_key('users_atat_role_id_fkey', 'users', 'permission_sets', ['atat_role_id'], ['id'])
    op.drop_table('users_permission_sets')
    # ### end Alembic commands ###
