"""Adding Catalogs to Document Domain

Revision ID: 0f5932ff3051
Revises: 5a75fb6da7b8
Create Date: 2024-10-14 15:20:45.058329

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

# revision identifiers, used by Alembic.
revision = '0f5932ff3051'
down_revision = '5a75fb6da7b8'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('catalog',
                    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('html_tags', postgresql.ARRAY(sa.String(length=10)), nullable=True),
                    sa.Column('html_end_tags', postgresql.ARRAY(sa.String(length=10)), nullable=True),
                    sa.Column('html_included_elements', postgresql.ARRAY(sa.String(length=50)), nullable=True),
                    sa.Column('html_excluded_elements', postgresql.ARRAY(sa.String(length=50)), nullable=True),
                    sa.Column('html_excluded_classes', postgresql.ARRAY(sa.String(length=200)), nullable=True),
                    sa.Column('min_chunk_size', sa.Integer(), nullable=True),
                    sa.Column('max_chunk_size', sa.Integer(), nullable=True),
                    sa.Column('es_k', sa.Integer(), nullable=True),
                    sa.Column('es_similarity_threshold', sa.Float(), nullable=True),
                    sa.Column('chat_RAG_temperature', sa.Float(), nullable=True),
                    sa.Column('chat_no_RAG_temperature', sa.Float(), nullable=True),
                    sa.Column('embed_tuning', sa.Boolean(), nullable=True),
                    sa.Column('rag_tuning', 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(['updated_by'], ['public.user.id'], ),
                    sa.PrimaryKeyConstraint('id')
                    )
    op.add_column('document', sa.Column('catalog_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'document', 'catalog', ['catalog_id'], ['id'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('document', 'catalog_id')
    op.drop_table('catalog')
    # ### end Alembic commands ###
