"""add confidence and expires_at columns to global_knowledge table Revision ID: 010_add_global_knowledge Revises: 009_notif_sched_feishu Create Date: 2026-05-06 """ from alembic import op import sqlalchemy as sa revision = "010_add_global_knowledge" down_revision = "009_notif_sched_feishu" branch_labels = None depends_on = None def upgrade() -> None: # Add confidence column (if table doesn't exist, this is a no-op handled below) try: op.add_column( "global_knowledge", sa.Column("confidence", sa.String(20), default="medium", comment="置信度: low/medium/high"), ) except Exception: pass # Add expires_at column try: op.add_column( "global_knowledge", sa.Column("expires_at", sa.DateTime(), nullable=True, comment="过期时间,NULL 表示永不过期"), ) except Exception: pass def downgrade() -> None: try: op.drop_column("global_knowledge", "expires_at") except Exception: pass try: op.drop_column("global_knowledge", "confidence") except Exception: pass