-- =============================================
-- TODAY'S QUEUE FIX - Missing Columns
-- Run this in phpMyAdmin to fix the empty queue
-- =============================================

-- Step 1: Add missing columns to alerts table
ALTER TABLE alerts 
ADD COLUMN path_code VARCHAR(20) DEFAULT NULL,
ADD COLUMN min_level INT DEFAULT 1;

-- Step 2: Create index for performance
ALTER TABLE alerts ADD INDEX idx_alerts_path_level (path_code, min_level);

-- Step 3: Set min_level based on difficulty
UPDATE alerts SET min_level = 1 WHERE difficulty = 'Beginner';
UPDATE alerts SET min_level = 3 WHERE difficulty = 'Intermediate';
UPDATE alerts SET min_level = 5 WHERE difficulty = 'Advanced';
UPDATE alerts SET min_level = 7 WHERE difficulty = 'Expert';

-- Step 4: Set path_code based on alert_type (optional - for path filtering)
UPDATE alerts SET path_code = 'CORE' WHERE path_code IS NULL;

-- Step 5: Verify the changes
SELECT 
    difficulty, 
    min_level, 
    COUNT(*) as count 
FROM alerts 
GROUP BY difficulty, min_level;
