"""Init tables

Revision ID: 645807399320
Revises: 
Create Date: 2019-06-21 13:14:40.700747+00:00

"""
from alembic import op
import sqlalchemy as sa


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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('comp_pipeline',
    sa.Column('project_id', sa.String(), nullable=False),
    sa.Column('dag_adjacency_list', sa.JSON(), nullable=True),
    sa.Column('state', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('project_id')
    )
    op.create_table('projects',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('type', sa.Enum('TEMPLATE', 'STANDARD', name='projecttype'), nullable=False),
    sa.Column('uuid', sa.String(), nullable=False),
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('description', sa.String(), nullable=False),
    sa.Column('thumbnail', sa.String(), nullable=False),
    sa.Column('prj_owner', sa.String(), nullable=False),
    sa.Column('creation_date', sa.DateTime(), nullable=False),
    sa.Column('last_change_date', sa.DateTime(), nullable=False),
    sa.Column('workbench', sa.JSON(), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('uuid')
    )
    op.create_table('users',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('email', sa.String(), nullable=False),
    sa.Column('password_hash', sa.String(), nullable=False),
    sa.Column('status', sa.Enum('CONFIRMATION_PENDING', 'ACTIVE', 'BANNED', name='userstatus'), nullable=False),
    sa.Column('role', sa.Enum('ANONYMOUS', 'GUEST', 'USER', 'TESTER', name='userrole'), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('created_ip', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('id', name='user_pkey'),
    sa.UniqueConstraint('email', name='user_login_key')
    )
    op.create_table('comp_tasks',
    sa.Column('task_id', sa.Integer(), nullable=False),
    sa.Column('project_id', sa.String(), nullable=True),
    sa.Column('node_id', sa.String(), nullable=True),
    sa.Column('job_id', sa.String(), nullable=True),
    sa.Column('internal_id', sa.Integer(), nullable=True),
    sa.Column('schema', sa.JSON(), nullable=True),
    sa.Column('inputs', sa.JSON(), nullable=True),
    sa.Column('outputs', sa.JSON(), nullable=True),
    sa.Column('image', sa.JSON(), nullable=True),
    sa.Column('state', sa.Integer(), nullable=True),
    sa.Column('submit', sa.DateTime(), nullable=True),
    sa.Column('start', sa.DateTime(), nullable=True),
    sa.Column('end', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['project_id'], ['comp_pipeline.project_id'], ),
    sa.PrimaryKeyConstraint('task_id')
    )
    op.create_table('confirmations',
    sa.Column('code', sa.Text(), nullable=False),
    sa.Column('user_id', sa.BigInteger(), nullable=True),
    sa.Column('action', sa.Enum('REGISTRATION', 'RESET_PASSWORD', 'CHANGE_EMAIL', 'INVITATION', name='confirmationaction'), nullable=False),
    sa.Column('data', sa.Text(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], name='user_confirmation_fkey', ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('code', name='confirmation_code')
    )
    op.create_table('tokens',
    sa.Column('token_id', sa.BigInteger(), nullable=False),
    sa.Column('user_id', sa.BigInteger(), nullable=False),
    sa.Column('token_service', sa.String(), nullable=False),
    sa.Column('token_data', sa.JSON(), nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('token_id')
    )
    op.create_table('user_to_projects',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('user_id', sa.BigInteger(), nullable=False),
    sa.Column('project_id', sa.BigInteger(), nullable=False),
    sa.ForeignKeyConstraint(['project_id'], ['projects.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('file_meta_data',
    sa.Column('file_uuid', sa.String(), nullable=False),
    sa.Column('location_id', sa.String(), nullable=True),
    sa.Column('location', sa.String(), nullable=True),
    sa.Column('bucket_name', sa.String(), nullable=True),
    sa.Column('object_name', sa.String(), nullable=True),
    sa.Column('project_id', sa.String(), nullable=True),
    sa.Column('project_name', sa.String(), nullable=True),
    sa.Column('node_id', sa.String(), nullable=True),
    sa.Column('node_name', sa.String(), nullable=True),
    sa.Column('file_name', sa.String(), nullable=True),
    sa.Column('user_id', sa.String(), nullable=True),
    sa.Column('user_name', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('file_uuid')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('file_meta_data')
    op.drop_table('user_to_projects')
    op.drop_table('tokens')
    op.drop_table('confirmations')
    op.drop_table('comp_tasks')
    op.drop_table('users')
    op.drop_table('projects')
    op.drop_table('comp_pipeline')
    # ### end Alembic commands ###

"""Init tables

Revision ID: 645807399320
Revises: 
Create Date: 2019-06-21 13:14:40.700747+00:00

"""
from alembic import op
import sqlalchemy as sa


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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('comp_pipeline',
    sa.Column('project_id', sa.String(), nullable=False),
    sa.Column('dag_adjacency_list', sa.JSON(), nullable=True),
    sa.Column('state', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('project_id')
    )
    op.create_table('projects',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('type', sa.Enum('TEMPLATE', 'STANDARD', name='projecttype'), nullable=False),
    sa.Column('uuid', sa.String(), nullable=False),
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('description', sa.String(), nullable=False),
    sa.Column('thumbnail', sa.String(), nullable=False),
    sa.Column('prj_owner', sa.String(), nullable=False),
    sa.Column('creation_date', sa.DateTime(), nullable=False),
    sa.Column('last_change_date', sa.DateTime(), nullable=False),
    sa.Column('workbench', sa.JSON(), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('uuid')
    )
    op.create_table('users',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('email', sa.String(), nullable=False),
    sa.Column('password_hash', sa.String(), nullable=False),
    sa.Column('status', sa.Enum('CONFIRMATION_PENDING', 'ACTIVE', 'BANNED', name='userstatus'), nullable=False),
    sa.Column('role', sa.Enum('ANONYMOUS', 'GUEST', 'USER', 'TESTER', name='userrole'), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('created_ip', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('id', name='user_pkey'),
    sa.UniqueConstraint('email', name='user_login_key')
    )
    op.create_table('comp_tasks',
    sa.Column('task_id', sa.Integer(), nullable=False),
    sa.Column('project_id', sa.String(), nullable=True),
    sa.Column('node_id', sa.String(), nullable=True),
    sa.Column('job_id', sa.String(), nullable=True),
    sa.Column('internal_id', sa.Integer(), nullable=True),
    sa.Column('schema', sa.JSON(), nullable=True),
    sa.Column('inputs', sa.JSON(), nullable=True),
    sa.Column('outputs', sa.JSON(), nullable=True),
    sa.Column('image', sa.JSON(), nullable=True),
    sa.Column('state', sa.Integer(), nullable=True),
    sa.Column('submit', sa.DateTime(), nullable=True),
    sa.Column('start', sa.DateTime(), nullable=True),
    sa.Column('end', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['project_id'], ['comp_pipeline.project_id'], ),
    sa.PrimaryKeyConstraint('task_id')
    )
    op.create_table('confirmations',
    sa.Column('code', sa.Text(), nullable=False),
    sa.Column('user_id', sa.BigInteger(), nullable=True),
    sa.Column('action', sa.Enum('REGISTRATION', 'RESET_PASSWORD', 'CHANGE_EMAIL', 'INVITATION', name='confirmationaction'), nullable=False),
    sa.Column('data', sa.Text(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], name='user_confirmation_fkey', ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('code', name='confirmation_code')
    )
    op.create_table('tokens',
    sa.Column('token_id', sa.BigInteger(), nullable=False),
    sa.Column('user_id', sa.BigInteger(), nullable=False),
    sa.Column('token_service', sa.String(), nullable=False),
    sa.Column('token_data', sa.JSON(), nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('token_id')
    )
    op.create_table('user_to_projects',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('user_id', sa.BigInteger(), nullable=False),
    sa.Column('project_id', sa.BigInteger(), nullable=False),
    sa.ForeignKeyConstraint(['project_id'], ['projects.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('file_meta_data',
    sa.Column('file_uuid', sa.String(), nullable=False),
    sa.Column('location_id', sa.String(), nullable=True),
    sa.Column('location', sa.String(), nullable=True),
    sa.Column('bucket_name', sa.String(), nullable=True),
    sa.Column('object_name', sa.String(), nullable=True),
    sa.Column('project_id', sa.String(), nullable=True),
    sa.Column('project_name', sa.String(), nullable=True),
    sa.Column('node_id', sa.String(), nullable=True),
    sa.Column('node_name', sa.String(), nullable=True),
    sa.Column('file_name', sa.String(), nullable=True),
    sa.Column('user_id', sa.String(), nullable=True),
    sa.Column('user_name', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('file_uuid')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('file_meta_data')
    op.drop_table('user_to_projects')
    op.drop_table('tokens')
    op.drop_table('confirmations')
    op.drop_table('comp_tasks')
    op.drop_table('users')
    op.drop_table('projects')
    op.drop_table('comp_pipeline')
    # ### end Alembic commands ###

Init tables  Revision ID: 645807399320 Revises:  Create Date: 2019-06-21 13:14:40.700747+00:00 # revision identifiers, used by Alembic. # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ### # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ###