-- Create app_settings table for managing app-wide configurations
CREATE TABLE IF NOT EXISTS app_settings (
    id INT PRIMARY KEY AUTO_INCREMENT,
    setting_key VARCHAR(100) UNIQUE NOT NULL,
    setting_value VARCHAR(500) NOT NULL,
    description TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

-- Insert default settings
INSERT INTO app_settings (setting_key, setting_value, description) VALUES
('update_available', 'false', 'Flag to force app update. Set to true to block app access until update.'),
('min_app_version', '1.0.0', 'Minimum required app version'),
('update_message', 'A new version is available. Please update to continue.', 'Message shown in update dialog'),
('update_url', 'https://play.google.com/store/apps/details?id=com.trackmychild.parent', 'URL to redirect for app update')
ON DUPLICATE KEY UPDATE 
    setting_value = VALUES(setting_value),
    description = VALUES(description);
