-- Fix ai_models table - add missing cost columns

USE ashlya_ashlya_academy_new;

-- Add cost columns if they don't exist
ALTER TABLE ai_models 
ADD COLUMN IF NOT EXISTS cost_per_1k_input_tokens DECIMAL(10,4) DEFAULT 0.5,
ADD COLUMN IF NOT EXISTS cost_per_1k_output_tokens DECIMAL(10,4) DEFAULT 1.0;

-- Set default pricing for existing models
UPDATE ai_models 
SET cost_per_1k_input_tokens = 0.5,
    cost_per_1k_output_tokens = 1.0
WHERE cost_per_1k_input_tokens IS NULL OR cost_per_1k_output_tokens IS NULL;

-- Optional: Set specific pricing for known expensive models
UPDATE ai_models 
SET cost_per_1k_input_tokens = 3.0,
    cost_per_1k_output_tokens = 15.0
WHERE name LIKE '%gpt-4%';

UPDATE ai_models 
SET cost_per_1k_input_tokens = 2.0,
    cost_per_1k_output_tokens = 6.0
WHERE name LIKE '%claude-3.5%';

-- Verify
SELECT name, cost_per_1k_input_tokens, cost_per_1k_output_tokens 
FROM ai_models 
LIMIT 10;
