<?php
// Update database schema to make celebrant2 optional
require_once 'config.php';

$conn = getDBConnection();

// Check if celebrant2 column allows NULL
$result = $conn->query("SHOW COLUMNS FROM events WHERE Field = 'celebrant2'");
$column = $result->fetch_assoc();

if ($column && $column['Null'] === 'NO') {
    // Update column to allow NULL
    $sql = "ALTER TABLE events MODIFY celebrant2 VARCHAR(255) NULL";
    
    if ($conn->query($sql) === TRUE) {
        echo "Database schema updated successfully!<br>";
        echo "The 'celebrant2' field is now optional.<br>";
    } else {
        echo "Error updating schema: " . $conn->error . "<br>";
    }
} else {
    echo "Schema is already up to date.<br>";
}

$conn->close();
echo "<br><a href='admin.php'>Go to Admin Panel</a>";
?>

