fix: 修复知识库唯一约束迁移兼容性

This commit is contained in:
2026-07-12 15:31:17 +08:00
parent 8266d845c0
commit e337897b7a

View File

@@ -1,14 +1,17 @@
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:
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",
@@ -17,4 +20,6 @@ def upgrade() -> None:
def downgrade() -> None:
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")