-- ========================================
-- Combined Database Schema - All Parts
-- Import this file to create complete database
-- ========================================


CREATE DATABASE IF NOT EXISTS `course_online` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE `course_online`;

-- ========================================
-- 2. System Settings (needed first)
-- ========================================

CREATE TABLE `site_settings` (
  `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `setting_key` varchar(100) NOT NULL,
  `setting_value` text DEFAULT NULL,
  `setting_type` enum('text','number','boolean','json') NOT NULL DEFAULT 'text',
  `description` varchar(255) DEFAULT NULL,
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `setting_key` (`setting_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Default Site Settings
INSERT INTO `site_settings` (`setting_key`, `setting_value`, `setting_type`, `description`) VALUES
('site_name', 'Course Online', 'text', 'Website Name'),
('site_logo', '', 'text', 'Logo Path'),
('site_favicon', '', 'text', 'Favicon Path'),
('site_description', 'Online Learning Platform', 'text', 'Website Description'),
('contact_email', 'info@example.com', 'text', 'Contact Email'),
('contact_phone', '', 'text', 'Contact Phone'),
('allow_registration', '1', 'boolean', 'Allow User Registration'),
('require_email_verification', '1', 'boolean', 'Require Email Verification');
