Files
shinkan-jinkendo/backend/migrations/098_ai_model_roles.sql
T
LarsandCursor b537750671
Deploy Development / deploy (push) Successful in 53s
Test Suite / pytest-backend (push) Successful in 50s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 17s
Test Suite / k6 /health Baseline (push) Successful in 35s
Test Suite / playwright-tests (push) Failing after 7m40s
Let superadmins assign one OpenRouter model per task group.
Reasoning, drafting, and matching prompts inherit that model, so each prompt does not need its own setting.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-23 09:59:28 +01:00

87 lines
2.6 KiB
SQL

-- Migration 098: Aufgabengruppen für OpenRouter-Modelle.
-- Ein Prompt nutzt: eigenes openrouter_model, sonst das Modell seiner Gruppe,
-- sonst platform_ai_settings.openrouter_model, sonst OPENROUTER_MODEL.
-- model_role IS NULL wird nur beim ersten Setzen gefüllt, damit spätere
-- Umgruppierungen im Admin bei einem erneuten Lauf erhalten bleiben.
CREATE TABLE IF NOT EXISTS platform_ai_model_roles (
role_key VARCHAR(40) PRIMARY KEY,
display_name VARCHAR(120) NOT NULL,
description TEXT NOT NULL,
openrouter_model VARCHAR(200),
sort_order INT NOT NULL DEFAULT 0,
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_by_profile_id INT REFERENCES profiles(id) ON DELETE SET NULL
);
INSERT INTO platform_ai_model_roles (role_key, display_name, description, sort_order)
VALUES
(
'reasoning',
'Denken',
'Didaktische Entwürfe und Qualitätsurteile: Start und Ziel, Zielanalyse, Roadmap, Stufen und die Prüfung eines Übungspfads.',
10
),
(
'drafting',
'Formulieren',
'Texte und eng gefasste Profile: Zusammenfassung, Anleitung, Suchabsicht, Semantik und Erwartungsprofil.',
20
),
(
'matching',
'Zuordnen',
'Auswahl aus einer vorgegebenen Menge: Fähigkeiten vorschlagen und Suchtreffer neu ordnen.',
30
)
ON CONFLICT (role_key) DO UPDATE
SET display_name = EXCLUDED.display_name,
description = EXCLUDED.description,
sort_order = EXCLUDED.sort_order;
ALTER TABLE ai_prompts ADD COLUMN IF NOT EXISTS model_role VARCHAR(40);
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM pg_constraint WHERE conname = 'ai_prompts_model_role_fkey'
) THEN
ALTER TABLE ai_prompts
ADD CONSTRAINT ai_prompts_model_role_fkey
FOREIGN KEY (model_role) REFERENCES platform_ai_model_roles(role_key);
END IF;
END $$;
COMMENT ON COLUMN ai_prompts.model_role IS
'Aufgabengruppe für das Standardmodell; NULL = Plattformstandard. openrouter_model am Prompt hat Vorrang.';
UPDATE ai_prompts
SET model_role = 'reasoning'
WHERE model_role IS NULL
AND slug IN (
'planning_progression_start_target',
'planning_progression_goal_analysis',
'planning_progression_roadmap',
'planning_progression_stage_spec',
'planning_exercise_path_qa'
);
UPDATE ai_prompts
SET model_role = 'drafting'
WHERE model_role IS NULL
AND slug IN (
'exercise_summary',
'exercise_instruction_rewrite',
'planning_exercise_search_intent',
'planning_exercise_query_semantics',
'planning_exercise_expectation_profile'
);
UPDATE ai_prompts
SET model_role = 'matching'
WHERE model_role IS NULL
AND slug IN (
'exercise_skill_suggestions',
'planning_exercise_search_rank'
);