"""Initial migration

Revision ID: 9881d330df53
Revises: 
Create Date: 2023-03-10 03:05:36.314576

"""
from alembic import op
import sqlalchemy as sa


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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('airflow_task_instance',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('task_name', sa.String(length=260), nullable=False),
    sa.Column('dag_name', sa.String(length=260), nullable=False),
    sa.Column('run_id', sa.String(length=260), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    schema='main'
    )
    op.create_table('owner',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('first_name', sa.String(length=260), nullable=False),
    sa.Column('last_name', sa.String(length=260), nullable=False),
    sa.Column('username', sa.String(length=260), nullable=False),
    sa.Column('color', sa.String(length=10), nullable=False),
    sa.Column('password', sa.String(length=60), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('username'),
    schema='main'
    )
    op.create_table('tag',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(length=260), nullable=False),
    sa.Column('color', sa.String(length=10), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    schema='main'
    )
    op.create_table('workspace',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(length=260), nullable=False),
    sa.Column('color', sa.String(length=10), nullable=False),
    sa.Column('created_by', sa.String(length=260), nullable=False),
    sa.Column('description', sa.String(length=260), nullable=False),
    sa.Column('created_on', sa.DateTime(), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    schema='main'
    )
    op.create_table('chart',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('descriptive_id', sa.String(length=4), nullable=False),
    sa.Column('superset_id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(length=260), nullable=False),
    sa.Column('type', sa.String(length=260), nullable=False),
    sa.Column('created_by', sa.String(length=260), nullable=False),
    sa.Column('datasource', sa.String(length=260), nullable=False),
    sa.Column('datasource_type', sa.String(length=260), nullable=False),
    sa.Column('last_modified_on', sa.DateTime(), nullable=False),
    sa.Column('last_saved_by', sa.String(length=260), nullable=False),
    sa.Column('status', sa.String(length=60), nullable=False),
    sa.Column('delete_on', sa.DateTime(), nullable=True),
    sa.Column('img', sa.Text(), nullable=True),
    sa.Column('extra', sa.Text(), nullable=True),
    sa.Column('task_id', sa.Integer(), nullable=True),
    sa.Column('workspace_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['task_id'], ['main.airflow_task_instance.id'], ),
    sa.ForeignKeyConstraint(['workspace_id'], ['main.workspace.id'], ),
    sa.PrimaryKeyConstraint('id'),
    schema='main'
    )
    op.create_table('dashboard',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('descriptive_id', sa.String(length=4), nullable=False),
    sa.Column('superset_id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(length=260), nullable=False),
    sa.Column('created_by', sa.String(length=260), nullable=False),
    sa.Column('delete_on', sa.DateTime(), nullable=True),
    sa.Column('last_modified_on', sa.DateTime(), nullable=False),
    sa.Column('last_saved_by', sa.String(length=260), nullable=False),
    sa.Column('status', sa.String(length=60), nullable=False),
    sa.Column('extra', sa.Text(), nullable=True),
    sa.Column('task_id', sa.Integer(), nullable=True),
    sa.Column('workspace_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['task_id'], ['main.airflow_task_instance.id'], ),
    sa.ForeignKeyConstraint(['workspace_id'], ['main.workspace.id'], ),
    sa.PrimaryKeyConstraint('id'),
    schema='main'
    )
    op.create_table('workspace_owner',
    sa.Column('workspace_id', sa.Integer(), nullable=True),
    sa.Column('owner_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['owner_id'], ['main.owner.id'], ),
    sa.ForeignKeyConstraint(['workspace_id'], ['main.workspace.id'], ),
    schema='main'
    )
    op.create_table('chart_owner',
    sa.Column('chart_id', sa.Integer(), nullable=True),
    sa.Column('owner_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['chart_id'], ['main.chart.id'], ),
    sa.ForeignKeyConstraint(['owner_id'], ['main.owner.id'], ),
    schema='main'
    )
    op.create_table('chart_tag',
    sa.Column('chart_id', sa.Integer(), nullable=True),
    sa.Column('tag_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['chart_id'], ['main.chart.id'], ),
    sa.ForeignKeyConstraint(['tag_id'], ['main.tag.id'], ),
    schema='main'
    )
    op.create_table('dashboard_owner',
    sa.Column('dashboard_id', sa.Integer(), nullable=True),
    sa.Column('owner_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['dashboard_id'], ['main.dashboard.id'], ),
    sa.ForeignKeyConstraint(['owner_id'], ['main.owner.id'], ),
    schema='main'
    )
    op.create_table('dashboard_tag',
    sa.Column('dashboard_id', sa.Integer(), nullable=True),
    sa.Column('tag_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['dashboard_id'], ['main.dashboard.id'], ),
    sa.ForeignKeyConstraint(['tag_id'], ['main.tag.id'], ),
    schema='main'
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('dashboard_tag', schema='main')
    op.drop_table('dashboard_owner', schema='main')
    op.drop_table('chart_tag', schema='main')
    op.drop_table('chart_owner', schema='main')
    op.drop_table('workspace_owner', schema='main')
    op.drop_table('dashboard', schema='main')
    op.drop_table('chart', schema='main')
    op.drop_table('workspace', schema='main')
    op.drop_table('tag', schema='main')
    op.drop_table('owner', schema='main')
    op.drop_table('airflow_task_instance', schema='main')
    # ### end Alembic commands ###
