"""add workbench tables

Revision ID: f38451075acc
Revises: 2681d14b61d8
Create Date: 2019-12-04 13:44:24.237092

"""
from alembic import op
import sqlalchemy as sa
from rdr_service.model.field_types import BlobUTF8
from rdr_service.model.utils import Enum
from rdr_service.participant_enums import WorkbenchWorkspaceStatus, WorkbenchWorkspaceUserRole
# revision identifiers, used by Alembic.
revision = 'f38451075acc'
down_revision = '2681d14b61d8'
branch_labels = None
depends_on = None


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


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



def upgrade_rdr():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('workbench_researcher',
    sa.Column('user_source_id', sa.Integer(), nullable=False),
    sa.Column('creation_time', sa.DateTime(), nullable=True),
    sa.Column('modified_time', sa.DateTime(), nullable=True),
    sa.Column('given_name', sa.String(length=100), nullable=True),
    sa.Column('family_name', sa.String(length=100), nullable=True),
    sa.Column('street_address1', sa.String(length=250), nullable=True),
    sa.Column('street_address2', sa.String(length=250), nullable=True),
    sa.Column('city', sa.String(length=80), nullable=True),
    sa.Column('state', sa.String(length=80), nullable=True),
    sa.Column('zip_code', sa.String(length=80), nullable=True),
    sa.Column('country', sa.String(length=80), nullable=True),
    sa.Column('ethnicity', sa.String(length=80), nullable=True),
    sa.Column('gender', sa.String(length=80), nullable=True),
    sa.Column('race', sa.String(length=80), nullable=True),
    sa.Column('resource', BlobUTF8(), nullable=False),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('modified', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('user_source_id', name='uniqe_user_source_id')
    )
    op.create_table('workbench_researcher_history',
    sa.Column('user_source_id', sa.Integer(), nullable=False),
    sa.Column('creation_time', sa.DateTime(), nullable=True),
    sa.Column('modified_time', sa.DateTime(), nullable=True),
    sa.Column('given_name', sa.String(length=100), nullable=True),
    sa.Column('family_name', sa.String(length=100), nullable=True),
    sa.Column('street_address1', sa.String(length=250), nullable=True),
    sa.Column('street_address2', sa.String(length=250), nullable=True),
    sa.Column('city', sa.String(length=80), nullable=True),
    sa.Column('state', sa.String(length=80), nullable=True),
    sa.Column('zip_code', sa.String(length=80), nullable=True),
    sa.Column('country', sa.String(length=80), nullable=True),
    sa.Column('ethnicity', sa.String(length=80), nullable=True),
    sa.Column('gender', sa.String(length=80), nullable=True),
    sa.Column('race', sa.String(length=80), nullable=True),
    sa.Column('resource', BlobUTF8(), nullable=False),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('modified', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('workbench_workspace',
    sa.Column('workspace_source_id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=250), nullable=False),
    sa.Column('creation_time', sa.DateTime(), nullable=True),
    sa.Column('modified_time', sa.DateTime(), nullable=True),
    sa.Column('status', Enum(WorkbenchWorkspaceStatus), nullable=True),
    sa.Column('exclude_from_public_directory', sa.Boolean(), nullable=True),
    sa.Column('disease_focused_research', sa.Boolean(), nullable=True),
    sa.Column('disease_focused_research_name', sa.String(length=250), nullable=True),
    sa.Column('other_purpose_details', sa.String(length=250), nullable=True),
    sa.Column('methods_development', sa.Boolean(), nullable=True),
    sa.Column('control_set', sa.Boolean(), nullable=True),
    sa.Column('ancestry', sa.Boolean(), nullable=True),
    sa.Column('social_behavioral', sa.Boolean(), nullable=True),
    sa.Column('population_health', sa.Boolean(), nullable=True),
    sa.Column('drug_development', sa.Boolean(), nullable=True),
    sa.Column('commercial_purpose', sa.Boolean(), nullable=True),
    sa.Column('educational', sa.Boolean(), nullable=True),
    sa.Column('other_purpose', sa.Boolean(), nullable=True),
    sa.Column('resource', BlobUTF8(), nullable=False),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('modified', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('workspace_source_id', name='uniqe_workspace_source_id')
    )
    op.create_table('workbench_workspace_history',
    sa.Column('workspace_source_id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=250), nullable=False),
    sa.Column('creation_time', sa.DateTime(), nullable=True),
    sa.Column('modified_time', sa.DateTime(), nullable=True),
    sa.Column('status', Enum(WorkbenchWorkspaceStatus), nullable=True),
    sa.Column('exclude_from_public_directory', sa.Boolean(), nullable=True),
    sa.Column('disease_focused_research', sa.Boolean(), nullable=True),
    sa.Column('disease_focused_research_name', sa.String(length=250), nullable=True),
    sa.Column('other_purpose_details', sa.String(length=250), nullable=True),
    sa.Column('methods_development', sa.Boolean(), nullable=True),
    sa.Column('control_set', sa.Boolean(), nullable=True),
    sa.Column('ancestry', sa.Boolean(), nullable=True),
    sa.Column('social_behavioral', sa.Boolean(), nullable=True),
    sa.Column('population_health', sa.Boolean(), nullable=True),
    sa.Column('drug_development', sa.Boolean(), nullable=True),
    sa.Column('commercial_purpose', sa.Boolean(), nullable=True),
    sa.Column('educational', sa.Boolean(), nullable=True),
    sa.Column('other_purpose', sa.Boolean(), nullable=True),
    sa.Column('resource', BlobUTF8(), nullable=False),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('modified', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('workbench_institutional_affiliations',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('modified', sa.DateTime(), nullable=True),
    sa.Column('researcher_id', sa.Integer(), nullable=False),
    sa.Column('institution', sa.String(length=250), nullable=True),
    sa.Column('role', sa.String(length=80), nullable=True),
    sa.Column('non_academic_affiliation', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['researcher_id'], ['workbench_researcher.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('workbench_institutional_affiliations_history',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('modified', sa.DateTime(), nullable=True),
    sa.Column('researcher_id', sa.Integer(), nullable=False),
    sa.Column('institution', sa.String(length=250), nullable=True),
    sa.Column('role', sa.String(length=80), nullable=True),
    sa.Column('non_academic_affiliation', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['researcher_id'], ['workbench_researcher_history.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('workbench_workspace_user',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('modified', sa.DateTime(), nullable=True),
    sa.Column('workspace_id', sa.Integer(), nullable=False),
    sa.Column('researcher_Id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('role', Enum(WorkbenchWorkspaceUserRole), nullable=True),
    sa.Column('status', Enum(WorkbenchWorkspaceStatus), nullable=True),
    sa.ForeignKeyConstraint(['researcher_Id'], ['workbench_researcher.id'], ),
    sa.ForeignKeyConstraint(['workspace_id'], ['workbench_workspace.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('workbench_workspace_user_history',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('modified', sa.DateTime(), nullable=True),
    sa.Column('workspace_id', sa.Integer(), nullable=False),
    sa.Column('researcher_Id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('role', Enum(WorkbenchWorkspaceUserRole), nullable=True),
    sa.Column('status', Enum(WorkbenchWorkspaceStatus), nullable=True),
    sa.ForeignKeyConstraint(['researcher_Id'], ['workbench_researcher_history.id'], ),
    sa.ForeignKeyConstraint(['workspace_id'], ['workbench_workspace_history.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###


def downgrade_rdr():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('workbench_workspace_user_history')
    op.drop_table('workbench_workspace_user')
    op.drop_table('workbench_institutional_affiliations_history')
    op.drop_table('workbench_institutional_affiliations')
    op.drop_table('workbench_workspace_history')
    op.drop_table('workbench_workspace')
    op.drop_table('workbench_researcher_history')
    op.drop_table('workbench_researcher')
    # ### end Alembic commands ###


def upgrade_metrics():
    # ### commands auto generated by Alembic - please adjust! ###
    pass
    # ### end Alembic commands ###


def downgrade_metrics():
    # ### commands auto generated by Alembic - please adjust! ###
    pass
    # ### end Alembic commands ###

23a212069250f26a6a663baeaa97957d630cfcb5
<mask token>


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


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


def upgrade_rdr():
    op.create_table('workbench_researcher', sa.Column('user_source_id', sa.
        Integer(), nullable=False), sa.Column('creation_time', sa.DateTime(
        ), nullable=True), sa.Column('modified_time', sa.DateTime(),
        nullable=True), sa.Column('given_name', sa.String(length=100),
        nullable=True), sa.Column('family_name', sa.String(length=100),
        nullable=True), sa.Column('street_address1', sa.String(length=250),
        nullable=True), sa.Column('street_address2', sa.String(length=250),
        nullable=True), sa.Column('city', sa.String(length=80), nullable=
        True), sa.Column('state', sa.String(length=80), nullable=True), sa.
        Column('zip_code', sa.String(length=80), nullable=True), sa.Column(
        'country', sa.String(length=80), nullable=True), sa.Column(
        'ethnicity', sa.String(length=80), nullable=True), sa.Column(
        'gender', sa.String(length=80), nullable=True), sa.Column('race',
        sa.String(length=80), nullable=True), sa.Column('resource',
        BlobUTF8(), nullable=False), sa.Column('id', sa.Integer(),
        autoincrement=True, nullable=False), sa.Column('created', sa.
        DateTime(), nullable=True), sa.Column('modified', sa.DateTime(),
        nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint(
        'user_source_id', name='uniqe_user_source_id'))
    op.create_table('workbench_researcher_history', sa.Column(
        'user_source_id', sa.Integer(), nullable=False), sa.Column(
        'creation_time', sa.DateTime(), nullable=True), sa.Column(
        'modified_time', sa.DateTime(), nullable=True), sa.Column(
        'given_name', sa.String(length=100), nullable=True), sa.Column(
        'family_name', sa.String(length=100), nullable=True), sa.Column(
        'street_address1', sa.String(length=250), nullable=True), sa.Column
        ('street_address2', sa.String(length=250), nullable=True), sa.
        Column('city', sa.String(length=80), nullable=True), sa.Column(
        'state', sa.String(length=80), nullable=True), sa.Column('zip_code',
        sa.String(length=80), nullable=True), sa.Column('country', sa.
        String(length=80), nullable=True), sa.Column('ethnicity', sa.String
        (length=80), nullable=True), sa.Column('gender', sa.String(length=
        80), nullable=True), sa.Column('race', sa.String(length=80),
        nullable=True), sa.Column('resource', BlobUTF8(), nullable=False),
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('created', sa.DateTime(), nullable=True), sa.Column(
        'modified', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint(
        'id'))
    op.create_table('workbench_workspace', sa.Column('workspace_source_id',
        sa.Integer(), nullable=False), sa.Column('name', sa.String(length=
        250), nullable=False), sa.Column('creation_time', sa.DateTime(),
        nullable=True), sa.Column('modified_time', sa.DateTime(), nullable=
        True), sa.Column('status', Enum(WorkbenchWorkspaceStatus), nullable
        =True), sa.Column('exclude_from_public_directory', sa.Boolean(),
        nullable=True), sa.Column('disease_focused_research', sa.Boolean(),
        nullable=True), sa.Column('disease_focused_research_name', sa.
        String(length=250), nullable=True), sa.Column(
        'other_purpose_details', sa.String(length=250), nullable=True), sa.
        Column('methods_development', sa.Boolean(), nullable=True), sa.
        Column('control_set', sa.Boolean(), nullable=True), sa.Column(
        'ancestry', sa.Boolean(), nullable=True), sa.Column(
        'social_behavioral', sa.Boolean(), nullable=True), sa.Column(
        'population_health', sa.Boolean(), nullable=True), sa.Column(
        'drug_development', sa.Boolean(), nullable=True), sa.Column(
        'commercial_purpose', sa.Boolean(), nullable=True), sa.Column(
        'educational', sa.Boolean(), nullable=True), sa.Column(
        'other_purpose', sa.Boolean(), nullable=True), sa.Column('resource',
        BlobUTF8(), nullable=False), sa.Column('id', sa.Integer(),
        autoincrement=True, nullable=False), sa.Column('created', sa.
        DateTime(), nullable=True), sa.Column('modified', sa.DateTime(),
        nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint(
        'workspace_source_id', name='uniqe_workspace_source_id'))
    op.create_table('workbench_workspace_history', sa.Column(
        'workspace_source_id', sa.Integer(), nullable=False), sa.Column(
        'name', sa.String(length=250), nullable=False), sa.Column(
        'creation_time', sa.DateTime(), nullable=True), sa.Column(
        'modified_time', sa.DateTime(), nullable=True), sa.Column('status',
        Enum(WorkbenchWorkspaceStatus), nullable=True), sa.Column(
        'exclude_from_public_directory', sa.Boolean(), nullable=True), sa.
        Column('disease_focused_research', sa.Boolean(), nullable=True), sa
        .Column('disease_focused_research_name', sa.String(length=250),
        nullable=True), sa.Column('other_purpose_details', sa.String(length
        =250), nullable=True), sa.Column('methods_development', sa.Boolean(
        ), nullable=True), sa.Column('control_set', sa.Boolean(), nullable=
        True), sa.Column('ancestry', sa.Boolean(), nullable=True), sa.
        Column('social_behavioral', sa.Boolean(), nullable=True), sa.Column
        ('population_health', sa.Boolean(), nullable=True), sa.Column(
        'drug_development', sa.Boolean(), nullable=True), sa.Column(
        'commercial_purpose', sa.Boolean(), nullable=True), sa.Column(
        'educational', sa.Boolean(), nullable=True), sa.Column(
        'other_purpose', sa.Boolean(), nullable=True), sa.Column('resource',
        BlobUTF8(), nullable=False), sa.Column('id', sa.Integer(),
        autoincrement=True, nullable=False), sa.Column('created', sa.
        DateTime(), nullable=True), sa.Column('modified', sa.DateTime(),
        nullable=True), sa.PrimaryKeyConstraint('id'))
    op.create_table('workbench_institutional_affiliations', sa.Column('id',
        sa.Integer(), autoincrement=True, nullable=False), sa.Column(
        'created', sa.DateTime(), nullable=True), sa.Column('modified', sa.
        DateTime(), nullable=True), sa.Column('researcher_id', sa.Integer(),
        nullable=False), sa.Column('institution', sa.String(length=250),
        nullable=True), sa.Column('role', sa.String(length=80), nullable=
        True), sa.Column('non_academic_affiliation', sa.Boolean(), nullable
        =True), sa.ForeignKeyConstraint(['researcher_id'], [
        'workbench_researcher.id']), sa.PrimaryKeyConstraint('id'))
    op.create_table('workbench_institutional_affiliations_history', sa.
        Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.
        Column('created', sa.DateTime(), nullable=True), sa.Column(
        'modified', sa.DateTime(), nullable=True), sa.Column(
        'researcher_id', sa.Integer(), nullable=False), sa.Column(
        'institution', sa.String(length=250), nullable=True), sa.Column(
        'role', sa.String(length=80), nullable=True), sa.Column(
        'non_academic_affiliation', sa.Boolean(), nullable=True), sa.
        ForeignKeyConstraint(['researcher_id'], [
        'workbench_researcher_history.id']), sa.PrimaryKeyConstraint('id'))
    op.create_table('workbench_workspace_user', sa.Column('id', sa.Integer(
        ), autoincrement=True, nullable=False), sa.Column('created', sa.
        DateTime(), nullable=True), sa.Column('modified', sa.DateTime(),
        nullable=True), sa.Column('workspace_id', sa.Integer(), nullable=
        False), sa.Column('researcher_Id', sa.Integer(), nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=False), sa.Column(
        'role', Enum(WorkbenchWorkspaceUserRole), nullable=True), sa.Column
        ('status', Enum(WorkbenchWorkspaceStatus), nullable=True), sa.
        ForeignKeyConstraint(['researcher_Id'], ['workbench_researcher.id']
        ), sa.ForeignKeyConstraint(['workspace_id'], [
        'workbench_workspace.id']), sa.PrimaryKeyConstraint('id'))
    op.create_table('workbench_workspace_user_history', sa.Column('id', sa.
        Integer(), autoincrement=True, nullable=False), sa.Column('created',
        sa.DateTime(), nullable=True), sa.Column('modified', sa.DateTime(),
        nullable=True), sa.Column('workspace_id', sa.Integer(), nullable=
        False), sa.Column('researcher_Id', sa.Integer(), nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=False), sa.Column(
        'role', Enum(WorkbenchWorkspaceUserRole), nullable=True), sa.Column
        ('status', Enum(WorkbenchWorkspaceStatus), nullable=True), sa.
        ForeignKeyConstraint(['researcher_Id'], [
        'workbench_researcher_history.id']), sa.ForeignKeyConstraint([
        'workspace_id'], ['workbench_workspace_history.id']), sa.
        PrimaryKeyConstraint('id'))


def downgrade_rdr():
    op.drop_table('workbench_workspace_user_history')
    op.drop_table('workbench_workspace_user')
    op.drop_table('workbench_institutional_affiliations_history')
    op.drop_table('workbench_institutional_affiliations')
    op.drop_table('workbench_workspace_history')
    op.drop_table('workbench_workspace')
    op.drop_table('workbench_researcher_history')
    op.drop_table('workbench_researcher')


<mask token>


def downgrade_metrics():
    pass

<mask token>


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


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


def upgrade_rdr():
    op.create_table('workbench_researcher', sa.Column('user_source_id', sa.
        Integer(), nullable=False), sa.Column('creation_time', sa.DateTime(
        ), nullable=True), sa.Column('modified_time', sa.DateTime(),
        nullable=True), sa.Column('given_name', sa.String(length=100),
        nullable=True), sa.Column('family_name', sa.String(length=100),
        nullable=True), sa.Column('street_address1', sa.String(length=250),
        nullable=True), sa.Column('street_address2', sa.String(length=250),
        nullable=True), sa.Column('city', sa.String(length=80), nullable=
        True), sa.Column('state', sa.String(length=80), nullable=True), sa.
        Column('zip_code', sa.String(length=80), nullable=True), sa.Column(
        'country', sa.String(length=80), nullable=True), sa.Column(
        'ethnicity', sa.String(length=80), nullable=True), sa.Column(
        'gender', sa.String(length=80), nullable=True), sa.Column('race',
        sa.String(length=80), nullable=True), sa.Column('resource',
        BlobUTF8(), nullable=False), sa.Column('id', sa.Integer(),
        autoincrement=True, nullable=False), sa.Column('created', sa.
        DateTime(), nullable=True), sa.Column('modified', sa.DateTime(),
        nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint(
        'user_source_id', name='uniqe_user_source_id'))
    op.create_table('workbench_researcher_history', sa.Column(
        'user_source_id', sa.Integer(), nullable=False), sa.Column(
        'creation_time', sa.DateTime(), nullable=True), sa.Column(
        'modified_time', sa.DateTime(), nullable=True), sa.Column(
        'given_name', sa.String(length=100), nullable=True), sa.Column(
        'family_name', sa.String(length=100), nullable=True), sa.Column(
        'street_address1', sa.String(length=250), nullable=True), sa.Column
        ('street_address2', sa.String(length=250), nullable=True), sa.
        Column('city', sa.String(length=80), nullable=True), sa.Column(
        'state', sa.String(length=80), nullable=True), sa.Column('zip_code',
        sa.String(length=80), nullable=True), sa.Column('country', sa.
        String(length=80), nullable=True), sa.Column('ethnicity', sa.String
        (length=80), nullable=True), sa.Column('gender', sa.String(length=
        80), nullable=True), sa.Column('race', sa.String(length=80),
        nullable=True), sa.Column('resource', BlobUTF8(), nullable=False),
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('created', sa.DateTime(), nullable=True), sa.Column(
        'modified', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint(
        'id'))
    op.create_table('workbench_workspace', sa.Column('workspace_source_id',
        sa.Integer(), nullable=False), sa.Column('name', sa.String(length=
        250), nullable=False), sa.Column('creation_time', sa.DateTime(),
        nullable=True), sa.Column('modified_time', sa.DateTime(), nullable=
        True), sa.Column('status', Enum(WorkbenchWorkspaceStatus), nullable
        =True), sa.Column('exclude_from_public_directory', sa.Boolean(),
        nullable=True), sa.Column('disease_focused_research', sa.Boolean(),
        nullable=True), sa.Column('disease_focused_research_name', sa.
        String(length=250), nullable=True), sa.Column(
        'other_purpose_details', sa.String(length=250), nullable=True), sa.
        Column('methods_development', sa.Boolean(), nullable=True), sa.
        Column('control_set', sa.Boolean(), nullable=True), sa.Column(
        'ancestry', sa.Boolean(), nullable=True), sa.Column(
        'social_behavioral', sa.Boolean(), nullable=True), sa.Column(
        'population_health', sa.Boolean(), nullable=True), sa.Column(
        'drug_development', sa.Boolean(), nullable=True), sa.Column(
        'commercial_purpose', sa.Boolean(), nullable=True), sa.Column(
        'educational', sa.Boolean(), nullable=True), sa.Column(
        'other_purpose', sa.Boolean(), nullable=True), sa.Column('resource',
        BlobUTF8(), nullable=False), sa.Column('id', sa.Integer(),
        autoincrement=True, nullable=False), sa.Column('created', sa.
        DateTime(), nullable=True), sa.Column('modified', sa.DateTime(),
        nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint(
        'workspace_source_id', name='uniqe_workspace_source_id'))
    op.create_table('workbench_workspace_history', sa.Column(
        'workspace_source_id', sa.Integer(), nullable=False), sa.Column(
        'name', sa.String(length=250), nullable=False), sa.Column(
        'creation_time', sa.DateTime(), nullable=True), sa.Column(
        'modified_time', sa.DateTime(), nullable=True), sa.Column('status',
        Enum(WorkbenchWorkspaceStatus), nullable=True), sa.Column(
        'exclude_from_public_directory', sa.Boolean(), nullable=True), sa.
        Column('disease_focused_research', sa.Boolean(), nullable=True), sa
        .Column('disease_focused_research_name', sa.String(length=250),
        nullable=True), sa.Column('other_purpose_details', sa.String(length
        =250), nullable=True), sa.Column('methods_development', sa.Boolean(
        ), nullable=True), sa.Column('control_set', sa.Boolean(), nullable=
        True), sa.Column('ancestry', sa.Boolean(), nullable=True), sa.
        Column('social_behavioral', sa.Boolean(), nullable=True), sa.Column
        ('population_health', sa.Boolean(), nullable=True), sa.Column(
        'drug_development', sa.Boolean(), nullable=True), sa.Column(
        'commercial_purpose', sa.Boolean(), nullable=True), sa.Column(
        'educational', sa.Boolean(), nullable=True), sa.Column(
        'other_purpose', sa.Boolean(), nullable=True), sa.Column('resource',
        BlobUTF8(), nullable=False), sa.Column('id', sa.Integer(),
        autoincrement=True, nullable=False), sa.Column('created', sa.
        DateTime(), nullable=True), sa.Column('modified', sa.DateTime(),
        nullable=True), sa.PrimaryKeyConstraint('id'))
    op.create_table('workbench_institutional_affiliations', sa.Column('id',
        sa.Integer(), autoincrement=True, nullable=False), sa.Column(
        'created', sa.DateTime(), nullable=True), sa.Column('modified', sa.
        DateTime(), nullable=True), sa.Column('researcher_id', sa.Integer(),
        nullable=False), sa.Column('institution', sa.String(length=250),
        nullable=True), sa.Column('role', sa.String(length=80), nullable=
        True), sa.Column('non_academic_affiliation', sa.Boolean(), nullable
        =True), sa.ForeignKeyConstraint(['researcher_id'], [
        'workbench_researcher.id']), sa.PrimaryKeyConstraint('id'))
    op.create_table('workbench_institutional_affiliations_history', sa.
        Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.
        Column('created', sa.DateTime(), nullable=True), sa.Column(
        'modified', sa.DateTime(), nullable=True), sa.Column(
        'researcher_id', sa.Integer(), nullable=False), sa.Column(
        'institution', sa.String(length=250), nullable=True), sa.Column(
        'role', sa.String(length=80), nullable=True), sa.Column(
        'non_academic_affiliation', sa.Boolean(), nullable=True), sa.
        ForeignKeyConstraint(['researcher_id'], [
        'workbench_researcher_history.id']), sa.PrimaryKeyConstraint('id'))
    op.create_table('workbench_workspace_user', sa.Column('id', sa.Integer(
        ), autoincrement=True, nullable=False), sa.Column('created', sa.
        DateTime(), nullable=True), sa.Column('modified', sa.DateTime(),
        nullable=True), sa.Column('workspace_id', sa.Integer(), nullable=
        False), sa.Column('researcher_Id', sa.Integer(), nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=False), sa.Column(
        'role', Enum(WorkbenchWorkspaceUserRole), nullable=True), sa.Column
        ('status', Enum(WorkbenchWorkspaceStatus), nullable=True), sa.
        ForeignKeyConstraint(['researcher_Id'], ['workbench_researcher.id']
        ), sa.ForeignKeyConstraint(['workspace_id'], [
        'workbench_workspace.id']), sa.PrimaryKeyConstraint('id'))
    op.create_table('workbench_workspace_user_history', sa.Column('id', sa.
        Integer(), autoincrement=True, nullable=False), sa.Column('created',
        sa.DateTime(), nullable=True), sa.Column('modified', sa.DateTime(),
        nullable=True), sa.Column('workspace_id', sa.Integer(), nullable=
        False), sa.Column('researcher_Id', sa.Integer(), nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=False), sa.Column(
        'role', Enum(WorkbenchWorkspaceUserRole), nullable=True), sa.Column
        ('status', Enum(WorkbenchWorkspaceStatus), nullable=True), sa.
        ForeignKeyConstraint(['researcher_Id'], [
        'workbench_researcher_history.id']), sa.ForeignKeyConstraint([
        'workspace_id'], ['workbench_workspace_history.id']), sa.
        PrimaryKeyConstraint('id'))


def downgrade_rdr():
    op.drop_table('workbench_workspace_user_history')
    op.drop_table('workbench_workspace_user')
    op.drop_table('workbench_institutional_affiliations_history')
    op.drop_table('workbench_institutional_affiliations')
    op.drop_table('workbench_workspace_history')
    op.drop_table('workbench_workspace')
    op.drop_table('workbench_researcher_history')
    op.drop_table('workbench_researcher')


def upgrade_metrics():
    pass


def downgrade_metrics():
    pass

<mask token>
revision = 'f38451075acc'
down_revision = '2681d14b61d8'
branch_labels = None
depends_on = None


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


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


def upgrade_rdr():
    op.create_table('workbench_researcher', sa.Column('user_source_id', sa.
        Integer(), nullable=False), sa.Column('creation_time', sa.DateTime(
        ), nullable=True), sa.Column('modified_time', sa.DateTime(),
        nullable=True), sa.Column('given_name', sa.String(length=100),
        nullable=True), sa.Column('family_name', sa.String(length=100),
        nullable=True), sa.Column('street_address1', sa.String(length=250),
        nullable=True), sa.Column('street_address2', sa.String(length=250),
        nullable=True), sa.Column('city', sa.String(length=80), nullable=
        True), sa.Column('state', sa.String(length=80), nullable=True), sa.
        Column('zip_code', sa.String(length=80), nullable=True), sa.Column(
        'country', sa.String(length=80), nullable=True), sa.Column(
        'ethnicity', sa.String(length=80), nullable=True), sa.Column(
        'gender', sa.String(length=80), nullable=True), sa.Column('race',
        sa.String(length=80), nullable=True), sa.Column('resource',
        BlobUTF8(), nullable=False), sa.Column('id', sa.Integer(),
        autoincrement=True, nullable=False), sa.Column('created', sa.
        DateTime(), nullable=True), sa.Column('modified', sa.DateTime(),
        nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint(
        'user_source_id', name='uniqe_user_source_id'))
    op.create_table('workbench_researcher_history', sa.Column(
        'user_source_id', sa.Integer(), nullable=False), sa.Column(
        'creation_time', sa.DateTime(), nullable=True), sa.Column(
        'modified_time', sa.DateTime(), nullable=True), sa.Column(
        'given_name', sa.String(length=100), nullable=True), sa.Column(
        'family_name', sa.String(length=100), nullable=True), sa.Column(
        'street_address1', sa.String(length=250), nullable=True), sa.Column
        ('street_address2', sa.String(length=250), nullable=True), sa.
        Column('city', sa.String(length=80), nullable=True), sa.Column(
        'state', sa.String(length=80), nullable=True), sa.Column('zip_code',
        sa.String(length=80), nullable=True), sa.Column('country', sa.
        String(length=80), nullable=True), sa.Column('ethnicity', sa.String
        (length=80), nullable=True), sa.Column('gender', sa.String(length=
        80), nullable=True), sa.Column('race', sa.String(length=80),
        nullable=True), sa.Column('resource', BlobUTF8(), nullable=False),
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('created', sa.DateTime(), nullable=True), sa.Column(
        'modified', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint(
        'id'))
    op.create_table('workbench_workspace', sa.Column('workspace_source_id',
        sa.Integer(), nullable=False), sa.Column('name', sa.String(length=
        250), nullable=False), sa.Column('creation_time', sa.DateTime(),
        nullable=True), sa.Column('modified_time', sa.DateTime(), nullable=
        True), sa.Column('status', Enum(WorkbenchWorkspaceStatus), nullable
        =True), sa.Column('exclude_from_public_directory', sa.Boolean(),
        nullable=True), sa.Column('disease_focused_research', sa.Boolean(),
        nullable=True), sa.Column('disease_focused_research_name', sa.
        String(length=250), nullable=True), sa.Column(
        'other_purpose_details', sa.String(length=250), nullable=True), sa.
        Column('methods_development', sa.Boolean(), nullable=True), sa.
        Column('control_set', sa.Boolean(), nullable=True), sa.Column(
        'ancestry', sa.Boolean(), nullable=True), sa.Column(
        'social_behavioral', sa.Boolean(), nullable=True), sa.Column(
        'population_health', sa.Boolean(), nullable=True), sa.Column(
        'drug_development', sa.Boolean(), nullable=True), sa.Column(
        'commercial_purpose', sa.Boolean(), nullable=True), sa.Column(
        'educational', sa.Boolean(), nullable=True), sa.Column(
        'other_purpose', sa.Boolean(), nullable=True), sa.Column('resource',
        BlobUTF8(), nullable=False), sa.Column('id', sa.Integer(),
        autoincrement=True, nullable=False), sa.Column('created', sa.
        DateTime(), nullable=True), sa.Column('modified', sa.DateTime(),
        nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint(
        'workspace_source_id', name='uniqe_workspace_source_id'))
    op.create_table('workbench_workspace_history', sa.Column(
        'workspace_source_id', sa.Integer(), nullable=False), sa.Column(
        'name', sa.String(length=250), nullable=False), sa.Column(
        'creation_time', sa.DateTime(), nullable=True), sa.Column(
        'modified_time', sa.DateTime(), nullable=True), sa.Column('status',
        Enum(WorkbenchWorkspaceStatus), nullable=True), sa.Column(
        'exclude_from_public_directory', sa.Boolean(), nullable=True), sa.
        Column('disease_focused_research', sa.Boolean(), nullable=True), sa
        .Column('disease_focused_research_name', sa.String(length=250),
        nullable=True), sa.Column('other_purpose_details', sa.String(length
        =250), nullable=True), sa.Column('methods_development', sa.Boolean(
        ), nullable=True), sa.Column('control_set', sa.Boolean(), nullable=
        True), sa.Column('ancestry', sa.Boolean(), nullable=True), sa.
        Column('social_behavioral', sa.Boolean(), nullable=True), sa.Column
        ('population_health', sa.Boolean(), nullable=True), sa.Column(
        'drug_development', sa.Boolean(), nullable=True), sa.Column(
        'commercial_purpose', sa.Boolean(), nullable=True), sa.Column(
        'educational', sa.Boolean(), nullable=True), sa.Column(
        'other_purpose', sa.Boolean(), nullable=True), sa.Column('resource',
        BlobUTF8(), nullable=False), sa.Column('id', sa.Integer(),
        autoincrement=True, nullable=False), sa.Column('created', sa.
        DateTime(), nullable=True), sa.Column('modified', sa.DateTime(),
        nullable=True), sa.PrimaryKeyConstraint('id'))
    op.create_table('workbench_institutional_affiliations', sa.Column('id',
        sa.Integer(), autoincrement=True, nullable=False), sa.Column(
        'created', sa.DateTime(), nullable=True), sa.Column('modified', sa.
        DateTime(), nullable=True), sa.Column('researcher_id', sa.Integer(),
        nullable=False), sa.Column('institution', sa.String(length=250),
        nullable=True), sa.Column('role', sa.String(length=80), nullable=
        True), sa.Column('non_academic_affiliation', sa.Boolean(), nullable
        =True), sa.ForeignKeyConstraint(['researcher_id'], [
        'workbench_researcher.id']), sa.PrimaryKeyConstraint('id'))
    op.create_table('workbench_institutional_affiliations_history', sa.
        Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.
        Column('created', sa.DateTime(), nullable=True), sa.Column(
        'modified', sa.DateTime(), nullable=True), sa.Column(
        'researcher_id', sa.Integer(), nullable=False), sa.Column(
        'institution', sa.String(length=250), nullable=True), sa.Column(
        'role', sa.String(length=80), nullable=True), sa.Column(
        'non_academic_affiliation', sa.Boolean(), nullable=True), sa.
        ForeignKeyConstraint(['researcher_id'], [
        'workbench_researcher_history.id']), sa.PrimaryKeyConstraint('id'))
    op.create_table('workbench_workspace_user', sa.Column('id', sa.Integer(
        ), autoincrement=True, nullable=False), sa.Column('created', sa.
        DateTime(), nullable=True), sa.Column('modified', sa.DateTime(),
        nullable=True), sa.Column('workspace_id', sa.Integer(), nullable=
        False), sa.Column('researcher_Id', sa.Integer(), nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=False), sa.Column(
        'role', Enum(WorkbenchWorkspaceUserRole), nullable=True), sa.Column
        ('status', Enum(WorkbenchWorkspaceStatus), nullable=True), sa.
        ForeignKeyConstraint(['researcher_Id'], ['workbench_researcher.id']
        ), sa.ForeignKeyConstraint(['workspace_id'], [
        'workbench_workspace.id']), sa.PrimaryKeyConstraint('id'))
    op.create_table('workbench_workspace_user_history', sa.Column('id', sa.
        Integer(), autoincrement=True, nullable=False), sa.Column('created',
        sa.DateTime(), nullable=True), sa.Column('modified', sa.DateTime(),
        nullable=True), sa.Column('workspace_id', sa.Integer(), nullable=
        False), sa.Column('researcher_Id', sa.Integer(), nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=False), sa.Column(
        'role', Enum(WorkbenchWorkspaceUserRole), nullable=True), sa.Column
        ('status', Enum(WorkbenchWorkspaceStatus), nullable=True), sa.
        ForeignKeyConstraint(['researcher_Id'], [
        'workbench_researcher_history.id']), sa.ForeignKeyConstraint([
        'workspace_id'], ['workbench_workspace_history.id']), sa.
        PrimaryKeyConstraint('id'))


def downgrade_rdr():
    op.drop_table('workbench_workspace_user_history')
    op.drop_table('workbench_workspace_user')
    op.drop_table('workbench_institutional_affiliations_history')
    op.drop_table('workbench_institutional_affiliations')
    op.drop_table('workbench_workspace_history')
    op.drop_table('workbench_workspace')
    op.drop_table('workbench_researcher_history')
    op.drop_table('workbench_researcher')


def upgrade_metrics():
    pass


def downgrade_metrics():
    pass

<mask token>
from alembic import op
import sqlalchemy as sa
from rdr_service.model.field_types import BlobUTF8
from rdr_service.model.utils import Enum
from rdr_service.participant_enums import WorkbenchWorkspaceStatus, WorkbenchWorkspaceUserRole
revision = 'f38451075acc'
down_revision = '2681d14b61d8'
branch_labels = None
depends_on = None


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


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


def upgrade_rdr():
    op.create_table('workbench_researcher', sa.Column('user_source_id', sa.
        Integer(), nullable=False), sa.Column('creation_time', sa.DateTime(
        ), nullable=True), sa.Column('modified_time', sa.DateTime(),
        nullable=True), sa.Column('given_name', sa.String(length=100),
        nullable=True), sa.Column('family_name', sa.String(length=100),
        nullable=True), sa.Column('street_address1', sa.String(length=250),
        nullable=True), sa.Column('street_address2', sa.String(length=250),
        nullable=True), sa.Column('city', sa.String(length=80), nullable=
        True), sa.Column('state', sa.String(length=80), nullable=True), sa.
        Column('zip_code', sa.String(length=80), nullable=True), sa.Column(
        'country', sa.String(length=80), nullable=True), sa.Column(
        'ethnicity', sa.String(length=80), nullable=True), sa.Column(
        'gender', sa.String(length=80), nullable=True), sa.Column('race',
        sa.String(length=80), nullable=True), sa.Column('resource',
        BlobUTF8(), nullable=False), sa.Column('id', sa.Integer(),
        autoincrement=True, nullable=False), sa.Column('created', sa.
        DateTime(), nullable=True), sa.Column('modified', sa.DateTime(),
        nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint(
        'user_source_id', name='uniqe_user_source_id'))
    op.create_table('workbench_researcher_history', sa.Column(
        'user_source_id', sa.Integer(), nullable=False), sa.Column(
        'creation_time', sa.DateTime(), nullable=True), sa.Column(
        'modified_time', sa.DateTime(), nullable=True), sa.Column(
        'given_name', sa.String(length=100), nullable=True), sa.Column(
        'family_name', sa.String(length=100), nullable=True), sa.Column(
        'street_address1', sa.String(length=250), nullable=True), sa.Column
        ('street_address2', sa.String(length=250), nullable=True), sa.
        Column('city', sa.String(length=80), nullable=True), sa.Column(
        'state', sa.String(length=80), nullable=True), sa.Column('zip_code',
        sa.String(length=80), nullable=True), sa.Column('country', sa.
        String(length=80), nullable=True), sa.Column('ethnicity', sa.String
        (length=80), nullable=True), sa.Column('gender', sa.String(length=
        80), nullable=True), sa.Column('race', sa.String(length=80),
        nullable=True), sa.Column('resource', BlobUTF8(), nullable=False),
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('created', sa.DateTime(), nullable=True), sa.Column(
        'modified', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint(
        'id'))
    op.create_table('workbench_workspace', sa.Column('workspace_source_id',
        sa.Integer(), nullable=False), sa.Column('name', sa.String(length=
        250), nullable=False), sa.Column('creation_time', sa.DateTime(),
        nullable=True), sa.Column('modified_time', sa.DateTime(), nullable=
        True), sa.Column('status', Enum(WorkbenchWorkspaceStatus), nullable
        =True), sa.Column('exclude_from_public_directory', sa.Boolean(),
        nullable=True), sa.Column('disease_focused_research', sa.Boolean(),
        nullable=True), sa.Column('disease_focused_research_name', sa.
        String(length=250), nullable=True), sa.Column(
        'other_purpose_details', sa.String(length=250), nullable=True), sa.
        Column('methods_development', sa.Boolean(), nullable=True), sa.
        Column('control_set', sa.Boolean(), nullable=True), sa.Column(
        'ancestry', sa.Boolean(), nullable=True), sa.Column(
        'social_behavioral', sa.Boolean(), nullable=True), sa.Column(
        'population_health', sa.Boolean(), nullable=True), sa.Column(
        'drug_development', sa.Boolean(), nullable=True), sa.Column(
        'commercial_purpose', sa.Boolean(), nullable=True), sa.Column(
        'educational', sa.Boolean(), nullable=True), sa.Column(
        'other_purpose', sa.Boolean(), nullable=True), sa.Column('resource',
        BlobUTF8(), nullable=False), sa.Column('id', sa.Integer(),
        autoincrement=True, nullable=False), sa.Column('created', sa.
        DateTime(), nullable=True), sa.Column('modified', sa.DateTime(),
        nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint(
        'workspace_source_id', name='uniqe_workspace_source_id'))
    op.create_table('workbench_workspace_history', sa.Column(
        'workspace_source_id', sa.Integer(), nullable=False), sa.Column(
        'name', sa.String(length=250), nullable=False), sa.Column(
        'creation_time', sa.DateTime(), nullable=True), sa.Column(
        'modified_time', sa.DateTime(), nullable=True), sa.Column('status',
        Enum(WorkbenchWorkspaceStatus), nullable=True), sa.Column(
        'exclude_from_public_directory', sa.Boolean(), nullable=True), sa.
        Column('disease_focused_research', sa.Boolean(), nullable=True), sa
        .Column('disease_focused_research_name', sa.String(length=250),
        nullable=True), sa.Column('other_purpose_details', sa.String(length
        =250), nullable=True), sa.Column('methods_development', sa.Boolean(
        ), nullable=True), sa.Column('control_set', sa.Boolean(), nullable=
        True), sa.Column('ancestry', sa.Boolean(), nullable=True), sa.
        Column('social_behavioral', sa.Boolean(), nullable=True), sa.Column
        ('population_health', sa.Boolean(), nullable=True), sa.Column(
        'drug_development', sa.Boolean(), nullable=True), sa.Column(
        'commercial_purpose', sa.Boolean(), nullable=True), sa.Column(
        'educational', sa.Boolean(), nullable=True), sa.Column(
        'other_purpose', sa.Boolean(), nullable=True), sa.Column('resource',
        BlobUTF8(), nullable=False), sa.Column('id', sa.Integer(),
        autoincrement=True, nullable=False), sa.Column('created', sa.
        DateTime(), nullable=True), sa.Column('modified', sa.DateTime(),
        nullable=True), sa.PrimaryKeyConstraint('id'))
    op.create_table('workbench_institutional_affiliations', sa.Column('id',
        sa.Integer(), autoincrement=True, nullable=False), sa.Column(
        'created', sa.DateTime(), nullable=True), sa.Column('modified', sa.
        DateTime(), nullable=True), sa.Column('researcher_id', sa.Integer(),
        nullable=False), sa.Column('institution', sa.String(length=250),
        nullable=True), sa.Column('role', sa.String(length=80), nullable=
        True), sa.Column('non_academic_affiliation', sa.Boolean(), nullable
        =True), sa.ForeignKeyConstraint(['researcher_id'], [
        'workbench_researcher.id']), sa.PrimaryKeyConstraint('id'))
    op.create_table('workbench_institutional_affiliations_history', sa.
        Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.
        Column('created', sa.DateTime(), nullable=True), sa.Column(
        'modified', sa.DateTime(), nullable=True), sa.Column(
        'researcher_id', sa.Integer(), nullable=False), sa.Column(
        'institution', sa.String(length=250), nullable=True), sa.Column(
        'role', sa.String(length=80), nullable=True), sa.Column(
        'non_academic_affiliation', sa.Boolean(), nullable=True), sa.
        ForeignKeyConstraint(['researcher_id'], [
        'workbench_researcher_history.id']), sa.PrimaryKeyConstraint('id'))
    op.create_table('workbench_workspace_user', sa.Column('id', sa.Integer(
        ), autoincrement=True, nullable=False), sa.Column('created', sa.
        DateTime(), nullable=True), sa.Column('modified', sa.DateTime(),
        nullable=True), sa.Column('workspace_id', sa.Integer(), nullable=
        False), sa.Column('researcher_Id', sa.Integer(), nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=False), sa.Column(
        'role', Enum(WorkbenchWorkspaceUserRole), nullable=True), sa.Column
        ('status', Enum(WorkbenchWorkspaceStatus), nullable=True), sa.
        ForeignKeyConstraint(['researcher_Id'], ['workbench_researcher.id']
        ), sa.ForeignKeyConstraint(['workspace_id'], [
        'workbench_workspace.id']), sa.PrimaryKeyConstraint('id'))
    op.create_table('workbench_workspace_user_history', sa.Column('id', sa.
        Integer(), autoincrement=True, nullable=False), sa.Column('created',
        sa.DateTime(), nullable=True), sa.Column('modified', sa.DateTime(),
        nullable=True), sa.Column('workspace_id', sa.Integer(), nullable=
        False), sa.Column('researcher_Id', sa.Integer(), nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=False), sa.Column(
        'role', Enum(WorkbenchWorkspaceUserRole), nullable=True), sa.Column
        ('status', Enum(WorkbenchWorkspaceStatus), nullable=True), sa.
        ForeignKeyConstraint(['researcher_Id'], [
        'workbench_researcher_history.id']), sa.ForeignKeyConstraint([
        'workspace_id'], ['workbench_workspace_history.id']), sa.
        PrimaryKeyConstraint('id'))


def downgrade_rdr():
    op.drop_table('workbench_workspace_user_history')
    op.drop_table('workbench_workspace_user')
    op.drop_table('workbench_institutional_affiliations_history')
    op.drop_table('workbench_institutional_affiliations')
    op.drop_table('workbench_workspace_history')
    op.drop_table('workbench_workspace')
    op.drop_table('workbench_researcher_history')
    op.drop_table('workbench_researcher')


def upgrade_metrics():
    pass


def downgrade_metrics():
    pass

"""add workbench tables

Revision ID: f38451075acc
Revises: 2681d14b61d8
Create Date: 2019-12-04 13:44:24.237092

"""
from alembic import op
import sqlalchemy as sa
from rdr_service.model.field_types import BlobUTF8
from rdr_service.model.utils import Enum
from rdr_service.participant_enums import WorkbenchWorkspaceStatus, WorkbenchWorkspaceUserRole
# revision identifiers, used by Alembic.
revision = 'f38451075acc'
down_revision = '2681d14b61d8'
branch_labels = None
depends_on = None


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


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



def upgrade_rdr():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('workbench_researcher',
    sa.Column('user_source_id', sa.Integer(), nullable=False),
    sa.Column('creation_time', sa.DateTime(), nullable=True),
    sa.Column('modified_time', sa.DateTime(), nullable=True),
    sa.Column('given_name', sa.String(length=100), nullable=True),
    sa.Column('family_name', sa.String(length=100), nullable=True),
    sa.Column('street_address1', sa.String(length=250), nullable=True),
    sa.Column('street_address2', sa.String(length=250), nullable=True),
    sa.Column('city', sa.String(length=80), nullable=True),
    sa.Column('state', sa.String(length=80), nullable=True),
    sa.Column('zip_code', sa.String(length=80), nullable=True),
    sa.Column('country', sa.String(length=80), nullable=True),
    sa.Column('ethnicity', sa.String(length=80), nullable=True),
    sa.Column('gender', sa.String(length=80), nullable=True),
    sa.Column('race', sa.String(length=80), nullable=True),
    sa.Column('resource', BlobUTF8(), nullable=False),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('modified', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('user_source_id', name='uniqe_user_source_id')
    )
    op.create_table('workbench_researcher_history',
    sa.Column('user_source_id', sa.Integer(), nullable=False),
    sa.Column('creation_time', sa.DateTime(), nullable=True),
    sa.Column('modified_time', sa.DateTime(), nullable=True),
    sa.Column('given_name', sa.String(length=100), nullable=True),
    sa.Column('family_name', sa.String(length=100), nullable=True),
    sa.Column('street_address1', sa.String(length=250), nullable=True),
    sa.Column('street_address2', sa.String(length=250), nullable=True),
    sa.Column('city', sa.String(length=80), nullable=True),
    sa.Column('state', sa.String(length=80), nullable=True),
    sa.Column('zip_code', sa.String(length=80), nullable=True),
    sa.Column('country', sa.String(length=80), nullable=True),
    sa.Column('ethnicity', sa.String(length=80), nullable=True),
    sa.Column('gender', sa.String(length=80), nullable=True),
    sa.Column('race', sa.String(length=80), nullable=True),
    sa.Column('resource', BlobUTF8(), nullable=False),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('modified', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('workbench_workspace',
    sa.Column('workspace_source_id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=250), nullable=False),
    sa.Column('creation_time', sa.DateTime(), nullable=True),
    sa.Column('modified_time', sa.DateTime(), nullable=True),
    sa.Column('status', Enum(WorkbenchWorkspaceStatus), nullable=True),
    sa.Column('exclude_from_public_directory', sa.Boolean(), nullable=True),
    sa.Column('disease_focused_research', sa.Boolean(), nullable=True),
    sa.Column('disease_focused_research_name', sa.String(length=250), nullable=True),
    sa.Column('other_purpose_details', sa.String(length=250), nullable=True),
    sa.Column('methods_development', sa.Boolean(), nullable=True),
    sa.Column('control_set', sa.Boolean(), nullable=True),
    sa.Column('ancestry', sa.Boolean(), nullable=True),
    sa.Column('social_behavioral', sa.Boolean(), nullable=True),
    sa.Column('population_health', sa.Boolean(), nullable=True),
    sa.Column('drug_development', sa.Boolean(), nullable=True),
    sa.Column('commercial_purpose', sa.Boolean(), nullable=True),
    sa.Column('educational', sa.Boolean(), nullable=True),
    sa.Column('other_purpose', sa.Boolean(), nullable=True),
    sa.Column('resource', BlobUTF8(), nullable=False),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('modified', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('workspace_source_id', name='uniqe_workspace_source_id')
    )
    op.create_table('workbench_workspace_history',
    sa.Column('workspace_source_id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=250), nullable=False),
    sa.Column('creation_time', sa.DateTime(), nullable=True),
    sa.Column('modified_time', sa.DateTime(), nullable=True),
    sa.Column('status', Enum(WorkbenchWorkspaceStatus), nullable=True),
    sa.Column('exclude_from_public_directory', sa.Boolean(), nullable=True),
    sa.Column('disease_focused_research', sa.Boolean(), nullable=True),
    sa.Column('disease_focused_research_name', sa.String(length=250), nullable=True),
    sa.Column('other_purpose_details', sa.String(length=250), nullable=True),
    sa.Column('methods_development', sa.Boolean(), nullable=True),
    sa.Column('control_set', sa.Boolean(), nullable=True),
    sa.Column('ancestry', sa.Boolean(), nullable=True),
    sa.Column('social_behavioral', sa.Boolean(), nullable=True),
    sa.Column('population_health', sa.Boolean(), nullable=True),
    sa.Column('drug_development', sa.Boolean(), nullable=True),
    sa.Column('commercial_purpose', sa.Boolean(), nullable=True),
    sa.Column('educational', sa.Boolean(), nullable=True),
    sa.Column('other_purpose', sa.Boolean(), nullable=True),
    sa.Column('resource', BlobUTF8(), nullable=False),
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('modified', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('workbench_institutional_affiliations',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('modified', sa.DateTime(), nullable=True),
    sa.Column('researcher_id', sa.Integer(), nullable=False),
    sa.Column('institution', sa.String(length=250), nullable=True),
    sa.Column('role', sa.String(length=80), nullable=True),
    sa.Column('non_academic_affiliation', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['researcher_id'], ['workbench_researcher.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('workbench_institutional_affiliations_history',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('modified', sa.DateTime(), nullable=True),
    sa.Column('researcher_id', sa.Integer(), nullable=False),
    sa.Column('institution', sa.String(length=250), nullable=True),
    sa.Column('role', sa.String(length=80), nullable=True),
    sa.Column('non_academic_affiliation', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['researcher_id'], ['workbench_researcher_history.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('workbench_workspace_user',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('modified', sa.DateTime(), nullable=True),
    sa.Column('workspace_id', sa.Integer(), nullable=False),
    sa.Column('researcher_Id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('role', Enum(WorkbenchWorkspaceUserRole), nullable=True),
    sa.Column('status', Enum(WorkbenchWorkspaceStatus), nullable=True),
    sa.ForeignKeyConstraint(['researcher_Id'], ['workbench_researcher.id'], ),
    sa.ForeignKeyConstraint(['workspace_id'], ['workbench_workspace.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('workbench_workspace_user_history',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('modified', sa.DateTime(), nullable=True),
    sa.Column('workspace_id', sa.Integer(), nullable=False),
    sa.Column('researcher_Id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('role', Enum(WorkbenchWorkspaceUserRole), nullable=True),
    sa.Column('status', Enum(WorkbenchWorkspaceStatus), nullable=True),
    sa.ForeignKeyConstraint(['researcher_Id'], ['workbench_researcher_history.id'], ),
    sa.ForeignKeyConstraint(['workspace_id'], ['workbench_workspace_history.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###


def downgrade_rdr():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('workbench_workspace_user_history')
    op.drop_table('workbench_workspace_user')
    op.drop_table('workbench_institutional_affiliations_history')
    op.drop_table('workbench_institutional_affiliations')
    op.drop_table('workbench_workspace_history')
    op.drop_table('workbench_workspace')
    op.drop_table('workbench_researcher_history')
    op.drop_table('workbench_researcher')
    # ### end Alembic commands ###


def upgrade_metrics():
    # ### commands auto generated by Alembic - please adjust! ###
    pass
    # ### end Alembic commands ###


def downgrade_metrics():
    # ### commands auto generated by Alembic - please adjust! ###
    pass
    # ### end Alembic commands ###
