V20261117_03__ai_workbench_fix.sql 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. -- ============================================================================
  2. -- ops 迁移版本:V20261117_03
  3. -- 源脚本:sql/ai_workbench_fix_20261117.sql
  4. -- 说明:由 deploy/ops/db.sh 按版本顺序执行;已执行过的文件请勿再修改。
  5. -- ============================================================================
  6. -- ============================================================
  7. -- 智能工作台修复脚本(2026-11-17)
  8. --
  9. -- 适用场景:已经初始化过 ai_orchestration*.sql 的环境。
  10. -- 内容:
  11. -- 1) 完整移除「平台运行日报」能力(工具 / 技能 / 平台运维助手 / 日报表)
  12. -- 2) 修正内置 MCP 客户端 platform_system_info 的自连地址(8080 → 当前后端 8980)
  13. --
  14. -- 幂等:可重复执行;执行前请确认 ai_daily_digest 中无需要保留的历史数据。
  15. -- ============================================================
  16. -- ------------------------------------------------------------
  17. -- 1. 移除平台运行日报
  18. -- ------------------------------------------------------------
  19. -- 1.1 解除会话 / 场景包 / 智能体对日报工具、技能、专家的绑定
  20. delete from ai_session_resource
  21. where (resource_type = 'tool' and resource_key in ('platform_daily_digest', 'platform_daily_drill', 'write_daily_digest'))
  22. or (resource_type = 'skill' and resource_key = 'platform_daily_digest');
  23. delete from ai_scenario_pack_tool
  24. where tool_code in ('platform_daily_digest', 'platform_daily_drill', 'write_daily_digest');
  25. delete from ai_scenario_pack_skill
  26. where skill_id in (select id from ai_skill where name = 'platform_daily_digest');
  27. delete from ai_agent_tool
  28. where tool_code in ('platform_daily_digest', 'platform_daily_drill', 'write_daily_digest')
  29. or agent_id in (select id from ai_expert_agent where agent_code = 'platform_ops');
  30. delete from ai_agent_skill
  31. where skill_id in (select id from ai_skill where name = 'platform_daily_digest')
  32. or agent_id in (select id from ai_expert_agent where agent_code = 'platform_ops');
  33. -- 1.2 删除专家 / 技能 / 工具元数据
  34. delete from ai_expert_agent where agent_code = 'platform_ops';
  35. delete from ai_skill where name = 'platform_daily_digest';
  36. delete from ai_tool where tool_code in ('platform_daily_digest', 'platform_daily_drill', 'write_daily_digest');
  37. -- 1.3 删除日报落库表(如无需保留历史数据)
  38. drop table if exists ai_daily_digest cascade;
  39. -- ------------------------------------------------------------
  40. -- 2. 修正内置 MCP 客户端地址
  41. -- ------------------------------------------------------------
  42. -- 仅修正仍指向旧端口 8080 的内置演示连接;自定义连接不在此列。
  43. -- 请求头(Authorization)是 AES 密文,无法用 SQL 安全写入:
  44. -- 应用启动时 McpSelfBootstrap 会检测该内置连接,并按当前出口口令自动补齐请求头。
  45. update ai_mcp_client
  46. set url = 'http://localhost:8980/js/a/mcp',
  47. update_time = now()
  48. where server_name = 'platform_system_info'
  49. and url like '%:8080/%';