"""20251117211522

Revision ID: 9971d42f0e8c
Revises: afe962cdb0b1
Create Date: 2025-11-17 21:15:22.986813

"""
from typing import Sequence, Union

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

# revision identifiers, used by Alembic.
revision: str = '9971d42f0e8c'
down_revision: Union[str, None] = 'afe962cdb0b1'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('data_config_copy1')
    op.drop_table('data_config')
    op.add_column('agent_configs', sa.Column('model_parameters', postgresql.JSON(astext_type=sa.Text()), nullable=True, comment='模型参数配置（temperature、max_tokens等）'))
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('agent_configs', 'model_parameters')
    op.create_table('data_config',
    sa.Column('config_id', sa.BIGINT(), sa.Identity(always=True, start=1, increment=1, minvalue=1, maxvalue=9223372036854775807, cycle=False, cache=1), autoincrement=True, nullable=False),
    sa.Column('config_name', sa.VARCHAR(length=255), server_default=sa.text("'配置文件'::character varying"), autoincrement=False, nullable=False),
    sa.Column('group_id', sa.VARCHAR(length=255), server_default=sa.text("'group_id'::character varying"), autoincrement=False, nullable=False),
    sa.Column('user_id', sa.VARCHAR(length=255), server_default=sa.text("'user_id'::character varying"), autoincrement=False, nullable=False),
    sa.Column('apply_id', sa.VARCHAR(length=255), server_default=sa.text("'apply_id'::character varying"), autoincrement=False, nullable=False),
    sa.Column('enable_llm_dedup_blockwise', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=False),
    sa.Column('enable_llm_disambiguation', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=False),
    sa.Column('deep_retrieval', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=False),
    sa.Column('t_type_strict', sa.NUMERIC(), server_default=sa.text('0.5'), autoincrement=False, nullable=False),
    sa.Column('t_name_strict', sa.NUMERIC(), server_default=sa.text('0.8'), autoincrement=False, nullable=False),
    sa.Column('t_overall', sa.NUMERIC(), server_default=sa.text('0.56'), autoincrement=False, nullable=False),
    sa.Column('chunker_strategy', postgresql.ENUM('RecursiveChunker', 'TokenChunker', 'SemanticChunker', 'NeuralChunker', 'HybridChunker', 'LLMChunker', 'SentenceChunker', 'LateChunker', name='chunker_strategy_enum'), server_default=sa.text("'RecursiveChunker'::chunker_strategy_enum"), autoincrement=False, nullable=False, comment='选择分块策略：    \r\n    "RecursiveChunker",\r\n    "TokenChunker",\r\n    "SemanticChunker",\r\n    "NeuralChunker",\r\n    "HybridChunker",\r\n    "LLMChunker",\r\n    "SentenceChunker",\r\n    "LateChunker"'),
    sa.Column('statement_granularity', sa.VARCHAR(length=255), server_default=sa.text("'2'::character varying"), autoincrement=False, nullable=True),
    sa.Column('include_dialogue_context', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True),
    sa.Column('max_context', sa.VARCHAR(length=255), server_default=sa.text("'200'::character varying"), autoincrement=False, nullable=True),
    sa.Column('λ_time', sa.NUMERIC(), server_default=sa.text('0.3'), autoincrement=False, nullable=True),
    sa.Column('λ_mem', sa.NUMERIC(), server_default=sa.text('0.4'), autoincrement=False, nullable=True),
    sa.Column('offset', sa.NUMERIC(precision=255, scale=0), server_default=sa.text('0.56'), autoincrement=False, nullable=True),
    sa.Column('state', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=False),
    sa.Column('created_at', postgresql.TIMESTAMP(timezone=True, precision=6), server_default=sa.text('CURRENT_TIMESTAMP'), autoincrement=False, nullable=False),
    sa.Column('updated_at', postgresql.TIMESTAMP(timezone=True, precision=6), server_default=sa.text('CURRENT_TIMESTAMP'), autoincrement=False, nullable=False),
    sa.Column('config_desc', sa.TEXT(), server_default=sa.text("'配置文件描述'::text"), autoincrement=False, nullable=False),
    sa.Column('workspace_id', sa.VARCHAR(length=255), server_default=sa.text("'workspace_id'::character varying"), autoincrement=False, nullable=False),
    sa.Column('enable_self_reflexion', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True),
    sa.Column('iteration_period', sa.VARCHAR(length=50), server_default=sa.text("'三小时'::character varying"), autoincrement=False, nullable=True),
    sa.Column('baseline', sa.VARCHAR(length=50), server_default=sa.text("'时间'::character varying"), autoincrement=False, nullable=True),
    sa.Column('reflexion_range', sa.VARCHAR(length=25), server_default=sa.text("'部分'::character varying"), autoincrement=False, nullable=True),
    sa.Column('pruning_enabled', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True),
    sa.Column('pruning_scene', sa.VARCHAR(length=255), server_default=sa.text("'education'::character varying"), autoincrement=False, nullable=True),
    sa.Column('pruning_threshold', sa.REAL(), server_default=sa.text('0.3'), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('config_id', 'config_name', name=op.f('data_config_pkey')),
    sa.UniqueConstraint('config_name', name=op.f('uk_config_name'), postgresql_include=[], postgresql_nulls_not_distinct=False)
    )
    op.create_table('data_config_copy1',
    sa.Column('config_id', sa.BIGINT(), sa.Identity(always=True, start=1, increment=1, minvalue=1, maxvalue=9223372036854775807, cycle=False, cache=1), autoincrement=True, nullable=False),
    sa.Column('config_name', sa.VARCHAR(length=255), server_default=sa.text("'配置文件'::character varying"), autoincrement=False, nullable=False),
    sa.Column('group_id', sa.VARCHAR(length=255), server_default=sa.text("'group_id'::character varying"), autoincrement=False, nullable=False),
    sa.Column('user_id', sa.VARCHAR(length=255), server_default=sa.text("'user_id'::character varying"), autoincrement=False, nullable=False),
    sa.Column('apply_id', sa.VARCHAR(length=255), server_default=sa.text("'apply_id'::character varying"), autoincrement=False, nullable=False),
    sa.Column('enable_llm_dedup_blockwise', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=False),
    sa.Column('enable_llm_disambiguation', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=False),
    sa.Column('deep_retrieval', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=False),
    sa.Column('t_type_strict', sa.NUMERIC(), server_default=sa.text('0.5'), autoincrement=False, nullable=False),
    sa.Column('t_name_strict', sa.NUMERIC(), server_default=sa.text('0.8'), autoincrement=False, nullable=False),
    sa.Column('t_overall', sa.NUMERIC(), server_default=sa.text('0.56'), autoincrement=False, nullable=False),
    sa.Column('chunker_strategy', postgresql.ENUM('RecursiveChunker', 'TokenChunker', 'SemanticChunker', 'NeuralChunker', 'HybridChunker', 'LLMChunker', 'SentenceChunker', 'LateChunker', name='chunker_strategy_enum'), server_default=sa.text("'RecursiveChunker'::chunker_strategy_enum"), autoincrement=False, nullable=False, comment='选择分块策略：    \r\n    "RecursiveChunker",\r\n    "TokenChunker",\r\n    "SemanticChunker",\r\n    "NeuralChunker",\r\n    "HybridChunker",\r\n    "LLMChunker",\r\n    "SentenceChunker",\r\n    "LateChunker"'),
    sa.Column('statement_granularity', sa.VARCHAR(length=255), server_default=sa.text("'2'::character varying"), autoincrement=False, nullable=True),
    sa.Column('include_dialogue_context', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True),
    sa.Column('max_context', sa.VARCHAR(length=255), server_default=sa.text("'200'::character varying"), autoincrement=False, nullable=True),
    sa.Column('λ_time', sa.NUMERIC(), server_default=sa.text('0.3'), autoincrement=False, nullable=True),
    sa.Column('λ_mem', sa.NUMERIC(), server_default=sa.text('0.4'), autoincrement=False, nullable=True),
    sa.Column('offset', sa.NUMERIC(precision=255, scale=0), server_default=sa.text('0.56'), autoincrement=False, nullable=True),
    sa.Column('state', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=False),
    sa.Column('created_at', postgresql.TIMESTAMP(timezone=True, precision=6), server_default=sa.text('CURRENT_TIMESTAMP'), autoincrement=False, nullable=False),
    sa.Column('updated_at', postgresql.TIMESTAMP(timezone=True, precision=6), server_default=sa.text('CURRENT_TIMESTAMP'), autoincrement=False, nullable=False),
    sa.Column('config_desc', sa.TEXT(), server_default=sa.text("'配置文件描述'::text"), autoincrement=False, nullable=False),
    sa.Column('workspace_id', sa.VARCHAR(length=255), server_default=sa.text("'workspace_id'::character varying"), autoincrement=False, nullable=False),
    sa.Column('enable_self_reflexion', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True),
    sa.Column('iteration_period', sa.VARCHAR(length=50), server_default=sa.text("'三小时'::character varying"), autoincrement=False, nullable=True),
    sa.Column('baseline', sa.VARCHAR(length=50), server_default=sa.text("'时间'::character varying"), autoincrement=False, nullable=True),
    sa.Column('reflexion_range', sa.VARCHAR(length=25), server_default=sa.text("'部分'::character varying"), autoincrement=False, nullable=True),
    sa.Column('pruning_enabled', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True),
    sa.Column('pruning_scene', sa.VARCHAR(length=255), server_default=sa.text("'education'::character varying"), autoincrement=False, nullable=True),
    sa.Column('pruning_threshold', sa.REAL(), server_default=sa.text('0.3'), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('config_id', 'config_name', name=op.f('data_config_copy1_pkey')),
    sa.UniqueConstraint('config_name', name=op.f('data_config_copy1_config_name_key'), postgresql_include=[], postgresql_nulls_not_distinct=False)
    )
    # ### end Alembic commands ###
