-- Add missing columns to ai_token_transactions table

USE ashlya_ashlya_academy_new;

-- Add all missing columns that the code expects
ALTER TABLE ai_token_transactions
ADD COLUMN IF NOT EXISTS endpoint VARCHAR(255),
ADD COLUMN IF NOT EXISTS ai_model VARCHAR(100),
ADD COLUMN IF NOT EXISTS provider VARCHAR(100),
ADD COLUMN IF NOT EXISTS session_id VARCHAR(255),
ADD COLUMN IF NOT EXISTS message_id VARCHAR(255),
ADD COLUMN IF NOT EXISTS request_tokens INT DEFAULT 0,
ADD COLUMN IF NOT EXISTS response_tokens INT DEFAULT 0,
ADD COLUMN IF NOT EXISTS total_tokens INT DEFAULT 0,
ADD COLUMN IF NOT EXISTS cost_per_1k_tokens DECIMAL(10,4) DEFAULT 0,
ADD COLUMN IF NOT EXISTS metadata TEXT;

-- Verify
SHOW COLUMNS FROM ai_token_transactions;
