<?php
require_once __DIR__ . '/../config/database.php';
try {
    // Create the manual_room_allocations table
    $sql = "
    CREATE TABLE IF NOT EXISTS manual_room_allocations (
        id INT AUTO_INCREMENT PRIMARY KEY,
        exam_id INT NOT NULL,
        exam_date DATE NOT NULL,
        room_number VARCHAR(50) NOT NULL,
        from_roll VARCHAR(50) NOT NULL,
        to_roll VARCHAR(50) NOT NULL,
        department VARCHAR(100) NOT NULL,
        total_count VARCHAR(50) NOT NULL,
        font_size INT DEFAULT 14,
        text_color VARCHAR(7) DEFAULT '#000000',
        font_weight VARCHAR(10) DEFAULT 'normal',
        header_font_size INT DEFAULT 24,
        header_text_color VARCHAR(7) DEFAULT '#000000',
        header_font_weight VARCHAR(10) DEFAULT 'bold',
        selected_text_font_size INT DEFAULT 14,
        selected_text_color VARCHAR(7) DEFAULT '#000000',
        selected_text_font_weight VARCHAR(10) DEFAULT 'normal',
        created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
        updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
        FOREIGN KEY (exam_id) REFERENCES exams(id) ON DELETE CASCADE,
        INDEX idx_exam_date (exam_id, exam_date)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ";
    
    $pdo->exec($sql);
    
    echo "Table 'manual_room_allocations' created successfully!";
    
} catch (PDOException $e) {
    echo "Error: " . $e->getMessage();
}
?>