"""User Affiliations table

Revision ID: 62c18e9012fd
Revises: 963cad0fd72a
Create Date: 2016-12-06 23:42:07.076047

"""

# revision identifiers, used by Alembic.
revision = '62c18e9012fd'
down_revision = '963cad0fd72a'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa


def upgrade(engine_name):
    globals()["upgrade_%s" % engine_name]()


def downgrade(engine_name):
    globals()["downgrade_%s" % engine_name]()





def upgrade_data_broker():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('user_affiliation',
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('cgac_id', sa.Integer(), nullable=False),
    sa.Column('permission_type_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['cgac_id'], ['cgac.cgac_id'], name='user_affiliation_cgac_fk'),
    sa.ForeignKeyConstraint(['permission_type_id'], ['permission_type.permission_type_id'], name='user_affiliation_permission_type_fk'),
    sa.ForeignKeyConstraint(['user_id'], ['users.user_id'], name='user_affiliation_user_fk'),
    sa.PrimaryKeyConstraint('user_id', 'cgac_id')
    )
    ### end Alembic commands ###


def downgrade_data_broker():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('user_affiliation')
    ### end Alembic commands ###

