"""Add EveAIAsset m& associated models

Revision ID: 4a9f7a6285cc
Revises: ed981a641be9
Create Date: 2025-03-12 09:43:05.390895

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

# revision identifiers, used by Alembic.
revision = '4a9f7a6285cc'
down_revision = 'ed981a641be9'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('eve_ai_asset',
    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('type_version', sa.String(length=20), nullable=True),
    sa.Column('valid_from', sa.DateTime(), nullable=True),
    sa.Column('valid_to', sa.DateTime(), 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_asset_version',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('asset_id', sa.Integer(), nullable=False),
    sa.Column('bucket_name', sa.String(length=255), 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(['asset_id'], ['eve_ai_asset.id'], ),
    sa.ForeignKeyConstraint(['created_by'], ['public.user.id'], ),
    sa.ForeignKeyConstraint(['updated_by'], ['public.user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('eve_ai_asset_instruction',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('asset_version_id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=255), nullable=False),
    sa.Column('content', sa.Text(), nullable=True),
    sa.ForeignKeyConstraint(['asset_version_id'], ['eve_ai_asset_version.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('eve_ai_processed_asset',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('asset_version_id', sa.Integer(), nullable=False),
    sa.Column('specialist_id', sa.Integer(), nullable=True),
    sa.Column('chat_session_id', sa.Integer(), nullable=True),
    sa.Column('bucket_name', sa.String(length=255), nullable=True),
    sa.Column('object_name', sa.String(length=255), nullable=True),
    sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
    sa.ForeignKeyConstraint(['asset_version_id'], ['eve_ai_asset_version.id'], ),
    sa.ForeignKeyConstraint(['chat_session_id'], ['chat_session.id'], ),
    sa.ForeignKeyConstraint(['specialist_id'], ['specialist.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('eve_ai_processed_asset')
    op.drop_table('eve_ai_asset_instruction')
    op.drop_table('eve_ai_asset_version')
    op.drop_table('eve_ai_asset')
    # ### end Alembic commands ###
