diff --git a/backend/migrations/010_rename_training_styles_to_style_directions.sql b/backend/migrations/010_rename_training_styles_to_style_directions.sql new file mode 100644 index 0000000..bfea830 --- /dev/null +++ b/backend/migrations/010_rename_training_styles_to_style_directions.sql @@ -0,0 +1,67 @@ +-- Migration 010: Umbenennung "training_styles" → "style_directions" +-- Erstellt: 2026-04-23 +-- Beschreibung: Konsistente Terminologie - "Stilrichtungen" statt "Trainingsstile" +-- Grund: "Trainingsstil" wird neue separate Dimension (Breitensport/Leistungssport) + +-- ============================================================================ +-- PHASE 1: Tabellen umbenennen +-- ============================================================================ + +-- Haupttabelle umbenennen +ALTER TABLE IF EXISTS training_styles RENAME TO style_directions; + +-- Junction-Tabelle umbenennen +ALTER TABLE IF EXISTS exercise_styles RENAME TO exercise_style_directions; + +-- Training-Style-Target-Groups Junction umbenennen +ALTER TABLE IF EXISTS training_style_target_groups RENAME TO style_direction_target_groups; + +-- ============================================================================ +-- PHASE 2: Spalten umbenennen +-- ============================================================================ + +-- In style_directions (vormals training_styles) +-- Keine Spalten-Umbennung nötig - parent_style_id kann bleiben (bedeutet parent_direction) + +-- In exercise_style_directions (vormals exercise_styles) +DO $$ +BEGIN + IF EXISTS ( + SELECT 1 FROM information_schema.columns + WHERE table_name = 'exercise_style_directions' AND column_name = 'training_style_id' + ) THEN + ALTER TABLE exercise_style_directions + RENAME COLUMN training_style_id TO style_direction_id; + END IF; +END $$; + +-- In style_direction_target_groups (vormals training_style_target_groups) +DO $$ +BEGIN + IF EXISTS ( + SELECT 1 FROM information_schema.columns + WHERE table_name = 'style_direction_target_groups' AND column_name = 'training_style_id' + ) THEN + ALTER TABLE style_direction_target_groups + RENAME COLUMN training_style_id TO style_direction_id; + END IF; +END $$; + +-- ============================================================================ +-- PHASE 3: Constraints umbenennen (automatisch durch ALTER TABLE) +-- ============================================================================ + +-- Foreign Key Constraints werden automatisch umbenannt +-- Indizes werden automatisch umbenannt + +-- ============================================================================ +-- PHASE 4: Validierung +-- ============================================================================ + +-- Nach dieser Migration: +-- - training_styles → style_directions +-- - exercise_styles → exercise_style_directions +-- - training_style_target_groups → style_direction_target_groups +-- - training_style_id → style_direction_id (in Junction-Tabellen) + +-- Nächste Migration 011: Neue Dimension "training_types" (Breitensport/Leistungssport) diff --git a/backend/migrations/011_create_training_types.sql b/backend/migrations/011_create_training_types.sql new file mode 100644 index 0000000..da3a737 --- /dev/null +++ b/backend/migrations/011_create_training_types.sql @@ -0,0 +1,65 @@ +-- Migration 011: Neue Dimension "Trainingsstil" (Breitensport/Leistungssport) +-- Erstellt: 2026-04-23 +-- Beschreibung: Neue Katalog-Dimension für Trainingsausrichtung +-- Grund: Trennung von "Stilrichtung" (Shotokan) und "Trainingsstil" (Breitensport) + +-- ============================================================================ +-- PHASE 1: Haupttabelle erstellen +-- ============================================================================ + +CREATE TABLE IF NOT EXISTS training_types ( + id SERIAL PRIMARY KEY, + name VARCHAR(100) UNIQUE NOT NULL, + abbreviation VARCHAR(20), + description TEXT, + sort_order INT DEFAULT 99, + status VARCHAR(50) DEFAULT 'active' CHECK (status IN ('active', 'archived')), + created_at TIMESTAMP DEFAULT NOW(), + updated_at TIMESTAMP DEFAULT NOW() +); + +-- ============================================================================ +-- PHASE 2: Seed-Daten +-- ============================================================================ + +INSERT INTO training_types (name, abbreviation, description, sort_order) VALUES + ('Breitensport', 'BS', 'Freizeitorientiertes Training für Gesundheit und Spaß', 1), + ('Leistungssport', 'LS', 'Wettkampforientiertes Training mit Leistungsfokus', 2), + ('Wettkampf', 'WK', 'Spezifische Wettkampfvorbereitung', 3) +ON CONFLICT (name) DO NOTHING; + +-- ============================================================================ +-- PHASE 3: Junction-Tabelle für M:N Übungszuordnung +-- ============================================================================ + +CREATE TABLE IF NOT EXISTS exercise_training_types ( + id SERIAL PRIMARY KEY, + exercise_id INT REFERENCES exercises(id) ON DELETE CASCADE, + training_type_id INT REFERENCES training_types(id) ON DELETE RESTRICT, + is_primary BOOLEAN DEFAULT false, + created_at TIMESTAMP DEFAULT NOW(), + UNIQUE(exercise_id, training_type_id) +); + +-- ============================================================================ +-- PHASE 4: Indizes +-- ============================================================================ + +CREATE INDEX IF NOT EXISTS idx_exercise_training_types_exercise + ON exercise_training_types(exercise_id); + +CREATE INDEX IF NOT EXISTS idx_exercise_training_types_type + ON exercise_training_types(training_type_id); + +CREATE INDEX IF NOT EXISTS idx_exercise_training_types_primary + ON exercise_training_types(is_primary); + +-- ============================================================================ +-- PHASE 5: Validierung +-- ============================================================================ + +-- Nach dieser Migration: +-- - Neue Dimension "training_types" (Breitensport, Leistungssport, Wettkampf) +-- - M:N Zuordnung zu Übungen über exercise_training_types +-- - is_primary Flag für Haupt-Trainingsstil +-- - ON DELETE RESTRICT: Training Types können nicht gelöscht werden wenn zugeordnet diff --git a/backend/version.py b/backend/version.py index 3b62e38..2b87d67 100644 --- a/backend/version.py +++ b/backend/version.py @@ -1,6 +1,6 @@ # Shinkan Jinkendo Version Information -APP_VERSION = "0.3.4" +APP_VERSION = "0.4.0" BUILD_DATE = "2026-04-23" DB_SCHEMA_VERSION = "20260423" @@ -22,6 +22,19 @@ MODULE_VERSIONS = { } CHANGELOG = [ + { + "version": "0.4.0", + "date": "2026-04-23", + "changes": [ + "BREAKING: Migration 010 - Umbenennung training_styles → style_directions", + "BREAKING: Migration 011 - Neue Dimension training_types (Breitensport/Leistungssport)", + "DB: Konsistente Terminologie - Stilrichtungen vs. Trainingsstile", + "DB: Neue Tabelle training_types mit Seed-Daten (Breitensport, Leistungssport, Wettkampf)", + "DB: Neue Junction-Tabelle exercise_training_types (M:N)", + "Architektur: Fokusbereich → Stilrichtung → Trainingsstil → Zielgruppe (alle M:N)", + "Phase 1: Nur Datenbank-Migrationen - Backend/Frontend-Updates folgen", + ] + }, { "version": "0.3.4", "date": "2026-04-23",