Merge branch 'dev' into hugo

This commit is contained in:
hugo committed 2026-06-23 11:22:39 +08:00
commit d5928b42f3
63 files changed
+5759 -1493

No files matched your search

@@ -0,0 +1,60 @@
"""
backend/migrations/versions/c6d7e8f9a0b1_add_faq_kb_stale_fields.py
用途:为 quick_questions 增加 KB 关联与待复审(stale)字段,支持方案 B 失效标记。
依赖:alembic.op、sqlalchemy。
逻辑:KB sync 成功后按 source_kb_document_ids / retriever_resources 标记 FAQ 待复审。
"""
from alembic import op
import sqlalchemy as sa
revision = "c6d7e8f9a0b1"
down_revision = "c5d6e7f8a9b0"
branch_labels = None
depends_on = None
def upgrade():
op.add_column(
"quick_questions",
sa.Column("source_kb_document_ids", sa.JSON(), nullable=True),
)
op.add_column(
"quick_questions",
sa.Column("stale_at", sa.DateTime(), nullable=True),
)
op.add_column(
"quick_questions",
sa.Column("stale_reason", sa.String(length=64), nullable=True),
)
op.add_column(
"quick_questions",
sa.Column("stale_kb_document_id", sa.Integer(), nullable=True),
)
op.create_foreign_key(
"fk_quick_questions_stale_kb_document_id",
"quick_questions",
"kb_documents",
["stale_kb_document_id"],
["id"],
)
op.create_index(
"ix_quick_questions_stale_at",
"quick_questions",
["stale_at"],
)
def downgrade():
op.drop_index("ix_quick_questions_stale_at", table_name="quick_questions")
op.drop_constraint(
"fk_quick_questions_stale_kb_document_id",
"quick_questions",
type_="foreignkey",
)
op.drop_column("quick_questions", "stale_kb_document_id")
op.drop_column("quick_questions", "stale_reason")
op.drop_column("quick_questions", "stale_at")
op.drop_column("quick_questions", "source_kb_document_ids")