-- Fix missing columns for AI Alert Generation
-- Run this in phpMyAdmin or mysql terminal if you see "Unknown column" errors

ALTER TABLE alerts ADD COLUMN is_ai_generated BOOLEAN DEFAULT FALSE;
ALTER TABLE alerts ADD COLUMN min_level INT DEFAULT 1;
ALTER TABLE alerts ADD COLUMN path_code VARCHAR(20) DEFAULT NULL;
ALTER TABLE alerts ADD COLUMN difficulty VARCHAR(50) DEFAULT 'Intermediate';

-- Verify operation_alerts structure
CREATE TABLE IF NOT EXISTS operation_alerts (
    id INT AUTO_INCREMENT PRIMARY KEY,
    operation_id INT NOT NULL,
    alert_id INT NOT NULL,
    sequence_order INT NOT NULL,
    intel_report_title VARCHAR(255),
    intel_report_content TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (operation_id) REFERENCES operations(id) ON DELETE CASCADE,
    FOREIGN KEY (alert_id) REFERENCES alerts(id) ON DELETE CASCADE
);
