Files
zclaw_openfang/crates/zclaw-saas/migrations/20260331000002_agent_templates_extensions.sql
iven 3e57fadfc9 feat(saas): extend agent templates with soul_content, add /available endpoint, key pool cleanup, and industry seed templates
- Add 9 extended fields to AgentTemplateInfo: soul_content, scenarios,
  welcome_message, quick_commands, personality, communication_style,
  emoji, version, source_id
- Refactor service.rs to use sqlx::Row (manual column extraction) to
  avoid the 16-element tuple FromRow limit
- Add /api/v1/agent-templates/available (lightweight public listing)
  and /api/v1/agent-templates/:id/full endpoints
- Add 24h key_usage_window cleanup task in scheduler
- Update seed data with extended fields for all 5 existing templates
  plus new Medical Assistant template (healthcare category)
2026-03-31 02:58:09 +08:00

17 lines
1021 B
SQL

-- 20260331000002_agent_templates_extensions.sql
-- 行业 Agent 模板扩展: soul_content, scenarios, welcome_message, quick_commands 等
ALTER TABLE agent_templates ADD COLUMN IF NOT EXISTS soul_content TEXT;
ALTER TABLE agent_templates ADD COLUMN IF NOT EXISTS scenarios TEXT NOT NULL DEFAULT '[]';
ALTER TABLE agent_templates ADD COLUMN IF NOT EXISTS welcome_message TEXT;
ALTER TABLE agent_templates ADD COLUMN IF NOT EXISTS quick_commands TEXT NOT NULL DEFAULT '[]';
ALTER TABLE agent_templates ADD COLUMN IF NOT EXISTS personality TEXT;
ALTER TABLE agent_templates ADD COLUMN IF NOT EXISTS communication_style TEXT;
ALTER TABLE agent_templates ADD COLUMN IF NOT EXISTS emoji TEXT;
ALTER TABLE agent_templates ADD COLUMN IF NOT EXISTS version INTEGER NOT NULL DEFAULT 1;
ALTER TABLE agent_templates ADD COLUMN IF NOT EXISTS source_id TEXT;
-- source_id 唯一约束(仅非 NULL 值)
CREATE UNIQUE INDEX IF NOT EXISTS idx_agent_templates_source_id
ON agent_templates(source_id) WHERE source_id IS NOT NULL;