-- Migration 029: Fix Missing Goal Types (flexibility, strength)
-- Date: 2026-03-27
-- Purpose: Ensure flexibility and strength goal types are active and properly configured

-- These types were created earlier but are inactive or misconfigured
-- This migration fixes them without breaking if they don't exist

-- ============================================================================
-- Upsert flexibility goal type
-- ============================================================================

INSERT INTO goal_type_definitions (
    type_key, label_de, label_en, unit, icon, category,
    source_table, source_column, aggregation_method,
    calculation_formula, filter_conditions, description, is_active
) VALUES (
    'flexibility',
    'Beweglichkeit',
    'Flexibility',
    'cm',
    '🤸',
    'training',
    NULL,  -- No automatic data source
    NULL,
    'latest',
    NULL,
    NULL,
    'Beweglichkeit und Mobilität - manuelle Erfassung',
    true
)
ON CONFLICT (type_key)
DO UPDATE SET
    label_de = 'Beweglichkeit',
    label_en = 'Flexibility',
    unit = 'cm',
    icon = '🤸',
    category = 'training',
    is_active = true,
    description = 'Beweglichkeit und Mobilität - manuelle Erfassung';

-- ============================================================================
-- Upsert strength goal type
-- ============================================================================

INSERT INTO goal_type_definitions (
    type_key, label_de, label_en, unit, icon, category,
    source_table, source_column, aggregation_method,
    calculation_formula, filter_conditions, description, is_active
) VALUES (
    'strength',
    'Kraftniveau',
    'Strength',
    'Punkte',
    '💪',
    'training',
    NULL,  -- No automatic data source
    NULL,
    'latest',
    NULL,
    NULL,
    'Allgemeines Kraftniveau - manuelle Erfassung',
    true
)
ON CONFLICT (type_key)
DO UPDATE SET
    label_de = 'Kraftniveau',
    label_en = 'Strength',
    unit = 'Punkte',
    icon = '💪',
    category = 'training',
    is_active = true,
    description = 'Allgemeines Kraftniveau - manuelle Erfassung';

COMMENT ON TABLE goal_type_definitions IS 'Goal type registry - defines all available goal types (v1.5: DB-driven, flexible system)';
