"""empty message

Revision ID: 7bb51084235d
Revises: 
Create Date: 2022-09-08 15:08:47.669322

"""
from alembic import op
import sqlalchemy as sa
import sqlalchemy_utils
import sqlmodel


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


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('task',
    sa.Column('default_args', sa.JSON(), nullable=True),
    sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('resource_type', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('module', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('input_type', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('output_type', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_table('user_oauth',
    sa.Column('id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False),
    sa.Column('email', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('hashed_password', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('is_active', sa.Boolean(), nullable=False),
    sa.Column('is_superuser', sa.Boolean(), nullable=False),
    sa.Column('is_verified', sa.Boolean(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_user_oauth_email'), 'user_oauth', ['email'], unique=True)
    op.create_table('oauthaccount',
    sa.Column('id', sqlmodel.sql.sqltypes.GUID(), nullable=False),
    sa.Column('user_id', sqlmodel.sql.sqltypes.GUID(), nullable=False),
    sa.Column('oauth_name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('access_token', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('expires_at', sa.Integer(), nullable=True),
    sa.Column('refresh_token', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('account_id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('account_email', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['user_oauth.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_oauthaccount_account_id'), 'oauthaccount', ['account_id'], unique=False)
    op.create_index(op.f('ix_oauthaccount_oauth_name'), 'oauthaccount', ['oauth_name'], unique=False)
    op.create_table('project',
    sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('project_dir', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('read_only', sa.Boolean(), nullable=False),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('slug', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('user_owner_id', sqlmodel.sql.sqltypes.GUID(), nullable=True),
    sa.ForeignKeyConstraint(['user_owner_id'], ['user_oauth.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('subtask',
    sa.Column('args', sa.JSON(), nullable=True),
    sa.Column('parent_task_id', sa.Integer(), nullable=False),
    sa.Column('subtask_id', sa.Integer(), nullable=False),
    sa.Column('order', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['parent_task_id'], ['task.id'], ),
    sa.ForeignKeyConstraint(['subtask_id'], ['task.id'], ),
    sa.PrimaryKeyConstraint('parent_task_id', 'subtask_id')
    )
    op.create_table('dataset',
    sa.Column('meta', sa.JSON(), nullable=True),
    sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('project_id', sa.Integer(), nullable=False),
    sa.Column('type', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('read_only', sa.Boolean(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('resource',
    sa.Column('path', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('glob_pattern', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('dataset_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['dataset_id'], ['dataset.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('resource')
    op.drop_table('dataset')
    op.drop_table('subtask')
    op.drop_table('project')
    op.drop_index(op.f('ix_oauthaccount_oauth_name'), table_name='oauthaccount')
    op.drop_index(op.f('ix_oauthaccount_account_id'), table_name='oauthaccount')
    op.drop_table('oauthaccount')
    op.drop_index(op.f('ix_user_oauth_email'), table_name='user_oauth')
    op.drop_table('user_oauth')
    op.drop_table('task')
    # ### end Alembic commands ###
