<?php
/**
 * Migration to add marks column to exam_subjects table
 */

echo "Adding marks column to exam_subjects table...\n";

try {
    // Database connection
    require_once __DIR__ . '/../config/database.php';
    
    // Add marks column to exam_subjects table
    $sql = "ALTER TABLE exam_subjects ADD COLUMN marks VARCHAR(50) NULL DEFAULT NULL AFTER invigilator";
    
    $pdo->exec($sql);
    
    echo "SUCCESS: Marks column added to exam_subjects table.\n";
    
} catch (Exception $e) {
    if (strpos($e->getMessage(), 'Duplicate column name') !== false) {
        echo "INFO: Marks column already exists. No changes made.\n";
    } else {
        echo "ERROR: " . $e->getMessage() . "\n";
        exit(1);
    }
}

echo "Migration completed.\n";