From e337897b7a73b3490b4c5606e8284219cebf01d3 Mon Sep 17 00:00:00 2001 From: Nelson <1475262689@qq.com> Date: Sun, 12 Jul 2026 15:31:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=9F=A5=E8=AF=86?= =?UTF-8?q?=E5=BA=93=E5=94=AF=E4=B8=80=E7=BA=A6=E6=9D=9F=E8=BF=81=E7=A7=BB?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../0008_unique_knowledge_feishu_node.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ai_knowledge_base_v2/apps/backend/alembic/versions/0008_unique_knowledge_feishu_node.py b/ai_knowledge_base_v2/apps/backend/alembic/versions/0008_unique_knowledge_feishu_node.py index 06ec548..d2c1e67 100644 --- a/ai_knowledge_base_v2/apps/backend/alembic/versions/0008_unique_knowledge_feishu_node.py +++ b/ai_knowledge_base_v2/apps/backend/alembic/versions/0008_unique_knowledge_feishu_node.py @@ -1,20 +1,25 @@ from __future__ import annotations from alembic import op +import sqlalchemy as sa -revision = "0008_unique_knowledge_feishu_node" +revision = "0008_unique_kb_node" down_revision = "0007_knowledge_agent_rebuild" branch_labels = None depends_on = None def upgrade() -> None: - op.create_unique_constraint( - "uq_knowledge_feishu_node", - "sys_knowledge", - ["feishu_space_id", "feishu_node_id"], - ) + constraints = {item["name"] for item in sa.inspect(op.get_bind()).get_unique_constraints("sys_knowledge")} + if "uq_knowledge_feishu_node" not in constraints: + op.create_unique_constraint( + "uq_knowledge_feishu_node", + "sys_knowledge", + ["feishu_space_id", "feishu_node_id"], + ) def downgrade() -> None: - op.drop_constraint("uq_knowledge_feishu_node", "sys_knowledge", type_="unique") + constraints = {item["name"] for item in sa.inspect(op.get_bind()).get_unique_constraints("sys_knowledge")} + if "uq_knowledge_feishu_node" in constraints: + op.drop_constraint("uq_knowledge_feishu_node", "sys_knowledge", type_="unique")