"""Introduction of CrewAI abtractions

Revision ID: 07d08b2cf0b3
Revises: 4bf121f340e5
Create Date: 2025-01-14 09:08:14.828800

"""
from alembic import op
import sqlalchemy as sa
import pgvector
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '07d08b2cf0b3'
down_revision = '4bf121f340e5'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('dispatcher',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=50), nullable=False),
    sa.Column('description', sa.Text(), nullable=True),
    sa.Column('type', sa.String(length=50), nullable=False),
    sa.Column('tuning', sa.Boolean(), nullable=True),
    sa.Column('configuration', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
    sa.Column('arguments', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
    sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
    sa.Column('created_by', sa.Integer(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
    sa.Column('updated_by', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['created_by'], ['public.user.id'], ),
    sa.ForeignKeyConstraint(['updated_by'], ['public.user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('eve_ai_agent',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('specialist_id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=50), nullable=False),
    sa.Column('description', sa.Text(), nullable=True),
    sa.Column('type', sa.String(length=50), nullable=False),
    sa.Column('role', sa.Text(), nullable=True),
    sa.Column('goal', sa.Text(), nullable=True),
    sa.Column('backstory', sa.Text(), nullable=True),
    sa.Column('tuning', sa.Boolean(), nullable=True),
    sa.Column('configuration', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
    sa.Column('arguments', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
    sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
    sa.Column('created_by', sa.Integer(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
    sa.Column('updated_by', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['created_by'], ['public.user.id'], ),
    sa.ForeignKeyConstraint(['specialist_id'], ['specialist.id'], ),
    sa.ForeignKeyConstraint(['updated_by'], ['public.user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('eve_ai_task',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('specialist_id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=50), nullable=False),
    sa.Column('description', sa.Text(), nullable=True),
    sa.Column('type', sa.String(length=50), nullable=False),
    sa.Column('expected_output', sa.Text(), nullable=True),
    sa.Column('tuning', sa.Boolean(), nullable=True),
    sa.Column('configuration', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
    sa.Column('arguments', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
    sa.Column('context', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
    sa.Column('asynchronous', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
    sa.Column('created_by', sa.Integer(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
    sa.Column('updated_by', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['created_by'], ['public.user.id'], ),
    sa.ForeignKeyConstraint(['specialist_id'], ['specialist.id'], ),
    sa.ForeignKeyConstraint(['updated_by'], ['public.user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('eve_ai_tool',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('specialist_id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=50), nullable=False),
    sa.Column('description', sa.Text(), nullable=True),
    sa.Column('type', sa.String(length=50), nullable=False),
    sa.Column('tuning', sa.Boolean(), nullable=True),
    sa.Column('configuration', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
    sa.Column('arguments', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
    sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
    sa.Column('created_by', sa.Integer(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
    sa.Column('updated_by', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['created_by'], ['public.user.id'], ),
    sa.ForeignKeyConstraint(['specialist_id'], ['specialist.id'], ),
    sa.ForeignKeyConstraint(['updated_by'], ['public.user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('specialist_dispatcher',
    sa.Column('specialist_id', sa.Integer(), nullable=False),
    sa.Column('dispatcher_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['dispatcher_id'], ['dispatcher.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['specialist_id'], ['specialist.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('specialist_id', 'dispatcher_id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('specialist_dispatcher')
    op.drop_table('eve_ai_tool')
    op.drop_table('eve_ai_task')
    op.drop_table('eve_ai_agent')
    op.drop_table('dispatcher')
    # ### end Alembic commands ###
