mitai-jinkendo/backend/migrations/016_workflows_graph_data.sql

36 lines
1.4 KiB
MySQL
Raw Normal View History

-- Migration 016: Workflow Support in ai_prompts (Phase 5)
-- Erweitert ai_prompts für type='workflow' (Option B - Backward-kompatibel)
-- Neue Spalte für Workflow-Graphen
ALTER TABLE ai_prompts ADD COLUMN graph_data JSONB;
-- Index für Workflow-Queries
CREATE INDEX IF NOT EXISTS idx_ai_prompts_type ON ai_prompts(type);
CREATE INDEX IF NOT EXISTS idx_ai_prompts_graph_data ON ai_prompts USING GIN (graph_data);
-- Kommentar
COMMENT ON COLUMN ai_prompts.graph_data IS 'Workflow-Graph (nur für type=workflow): {nodes: [...], edges: [...], metadata: {...}}';
-- Beispiel-Struktur (Dokumentation):
-- {
-- "nodes": [
-- {"id": "start", "type": "start", "label": "Start", "position": {"x": 100, "y": 100}},
-- {"id": "analysis_1", "type": "analysis", "prompt_id": 5, "questions": [...], ...},
-- {"id": "logic_1", "type": "logic", "condition": {...}, ...},
-- {"id": "join_1", "type": "join", "join_strategy": "wait_all", ...},
-- {"id": "end", "type": "end", "label": "Ende", "position": {"x": 500, "y": 300}}
-- ],
-- "edges": [
-- {"id": "e1", "source": "start", "target": "analysis_1"},
-- {"id": "e2", "source": "analysis_1", "target": "logic_1"},
-- {"id": "e3", "source": "logic_1", "target": "join_1"},
-- {"id": "e4", "source": "join_1", "target": "end"}
-- ],
-- "metadata": {
-- "created_at": "2026-04-04T12:00:00Z",
-- "version": "1.0"
-- }
-- }
-- Migration erfolgreich