-- Migration 029: Einheitliche Fähigkeitsstufen 1–5 (Basis … Optimierung)
-- Datum: 2026-04-27

-- exercise_skills: Legacy- und Zahl-Strings → kanonische Slugs
UPDATE exercise_skills SET required_level = 'basis' WHERE required_level IN ('einsteiger', '1');
UPDATE exercise_skills SET required_level = 'optimierung' WHERE required_level IN ('experte', '5');
UPDATE exercise_skills SET required_level = 'grundlagen' WHERE required_level = '2';
UPDATE exercise_skills SET required_level = 'aufbau' WHERE required_level = '3';
UPDATE exercise_skills SET required_level = 'fortgeschritten' WHERE required_level = '4';

UPDATE exercise_skills SET target_level = 'basis' WHERE target_level IN ('einsteiger', '1');
UPDATE exercise_skills SET target_level = 'optimierung' WHERE target_level IN ('experte', '5');
UPDATE exercise_skills SET target_level = 'grundlagen' WHERE target_level = '2';
UPDATE exercise_skills SET target_level = 'aufbau' WHERE target_level = '3';
UPDATE exercise_skills SET target_level = 'fortgeschritten' WHERE target_level = '4';

-- Reifegradmodell-Stufen (einheitliche Bezeichnungen für Stufe 1–5)
UPDATE model_levels SET
  name = CASE level_number
    WHEN 1 THEN 'Basis'
    WHEN 2 THEN 'Grundlagen'
    WHEN 3 THEN 'Aufbau'
    WHEN 4 THEN 'Fortgeschritten'
    WHEN 5 THEN 'Optimierung'
    ELSE name
  END
WHERE level_number BETWEEN 1 AND 5;
