-- Migration 017: AI Prompts Flexibilisierung (Issue #28)
-- Add category column to ai_prompts for better organization and filtering

-- Add category column
ALTER TABLE ai_prompts ADD COLUMN IF NOT EXISTS category VARCHAR(20) DEFAULT 'ganzheitlich';

-- Create index for category filtering
CREATE INDEX IF NOT EXISTS idx_ai_prompts_category ON ai_prompts(category);

-- Add comment
COMMENT ON COLUMN ai_prompts.category IS 'Prompt category: körper, ernährung, training, schlaf, vitalwerte, ziele, ganzheitlich';

-- Update existing prompts with appropriate categories
-- Based on slug patterns and content
UPDATE ai_prompts SET category = 'körper' WHERE slug IN ('koerperkomposition', 'gewichtstrend', 'umfaenge', 'caliper');
UPDATE ai_prompts SET category = 'ernährung' WHERE slug IN ('ernaehrung', 'kalorienbilanz', 'protein', 'makros');
UPDATE ai_prompts SET category = 'training' WHERE slug IN ('aktivitaet', 'trainingsanalyse', 'erholung', 'leistung');
UPDATE ai_prompts SET category = 'schlaf' WHERE slug LIKE '%schlaf%';
UPDATE ai_prompts SET category = 'vitalwerte' WHERE slug IN ('vitalwerte', 'herzfrequenz', 'ruhepuls', 'hrv');
UPDATE ai_prompts SET category = 'ziele' WHERE slug LIKE '%ziel%' OR slug LIKE '%goal%';

-- Pipeline prompts remain 'ganzheitlich' (default)
