-- Create email_logs table
CREATE TABLE IF NOT EXISTS email_logs (
    id INT AUTO_INCREMENT PRIMARY KEY,
    recipient TEXT NOT NULL,
    subject VARCHAR(255),
    status ENUM('success', 'failure') NOT NULL,
    error_message TEXT,
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);

-- Add consecutive_failures to smtp_settings to track repeated issues
ALTER TABLE smtp_settings ADD COLUMN consecutive_failures INT DEFAULT 0;
ALTER TABLE smtp_settings ADD COLUMN max_failures INT DEFAULT 5;
ALTER TABLE smtp_settings ADD COLUMN is_enabled TINYINT(1) DEFAULT 1;
