-- Migration: Add intelligence_icon column to daily_challenges table
-- Date: 2025-12-18
-- Description: Adds field to store the icon key for displaying in the app

ALTER TABLE `daily_challenges` 
ADD COLUMN `intelligence_icon` VARCHAR(50) DEFAULT NULL AFTER `intelligence_id`;

-- Create settings table for system configuration if not exists
CREATE TABLE IF NOT EXISTS `system_settings` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `setting_key` VARCHAR(100) NOT NULL,
    `setting_value` TEXT,
    `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    `updated_at` TIMESTAMP NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_setting_key` (`setting_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Insert default AI setting (enabled by default)
INSERT INTO `system_settings` (`setting_key`, `setting_value`) 
VALUES ('quiz_ai_enabled', '1')
ON DUPLICATE KEY UPDATE `setting_key` = `setting_key`;
