-- Apple Health Workout-CSV: Zeit oft ohne Sekunden (HH:MM); dateutil dayfirst bricht ISO YYYY-MM-DD.
-- type_converter: zusätzliche Patterns + ISO-reihenfolge in _dateutil_parse.
-- Bestehende System-Vorlagen: flexible für Start/End (idempotent).

UPDATE csv_field_mappings
SET type_conversions = jsonb_set(
    jsonb_set(
        COALESCE(type_conversions, '{}'::jsonb),
        '{start_time}',
        COALESCE(type_conversions->'start_time', '{}'::jsonb) || '{"flexible": true}'::jsonb,
        true
    ),
    '{end_time}',
    COALESCE(type_conversions->'end_time', '{}'::jsonb) || '{"flexible": true}'::jsonb,
    true
)
WHERE is_system = true
  AND profile_id IS NULL
  AND module = 'activity'
  AND mapping_name IN (
    'Apple Health Workout Export (English)',
    'Apple Health Workout Export (Deutsch)'
  )
  AND type_conversions IS NOT NULL
  AND type_conversions ? 'start_time'
  AND type_conversions ? 'end_time';
