"""202601081520

Revision ID: a959b201c507
Revises: c6d4afa27bf0
Create Date: 2026-01-08 15:20:29.742666

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'a959b201c507'
down_revision: Union[str, None] = 'c6d4afa27bf0'
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.create_table('forgetting_cycle_history',
    sa.Column('id', sa.UUID(), nullable=False, comment='主键ID'),
    sa.Column('end_user_id', sa.String(length=255), nullable=False, comment='终端用户ID'),
    sa.Column('execution_time', sa.DateTime(), nullable=False, comment='执行时间'),
    sa.Column('merged_count', sa.Integer(), nullable=True, comment='本次成功融合的节点对数'),
    sa.Column('failed_count', sa.Integer(), nullable=True, comment='本次融合失败的节点对数'),
    sa.Column('average_activation_value', sa.Float(), nullable=True, comment='平均激活值'),
    sa.Column('total_nodes', sa.Integer(), nullable=True, comment='总节点数'),
    sa.Column('low_activation_nodes', sa.Integer(), nullable=True, comment='低于遗忘阈值的节点总数（包含已融合、失败和待处理的）'),
    sa.Column('duration_seconds', sa.Float(), nullable=True, comment='执行耗时（秒）'),
    sa.Column('trigger_type', sa.String(length=50), nullable=True, comment='触发类型: manual/scheduled'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('idx_end_user_time', 'forgetting_cycle_history', ['end_user_id', 'execution_time'], unique=False)
    op.create_index('idx_execution_time', 'forgetting_cycle_history', ['execution_time'], unique=False)
    op.create_index(op.f('ix_forgetting_cycle_history_id'), 'forgetting_cycle_history', ['id'], unique=False)
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_forgetting_cycle_history_id'), table_name='forgetting_cycle_history')
    op.drop_index('idx_execution_time', table_name='forgetting_cycle_history')
    op.drop_index('idx_end_user_time', table_name='forgetting_cycle_history')
    op.drop_table('forgetting_cycle_history')
    # ### end Alembic commands ###
