<?php
require_once __DIR__ . '/../config/database.php';

$database = new Database();
$db = $database->getConnection();

try {
    // Add phone column and make email nullable
    $sql = "ALTER TABLE users ADD COLUMN phone VARCHAR(20) UNIQUE AFTER name, MODIFY COLUMN email VARCHAR(100) NULL";
    $db->exec($sql);
    echo "Successfully updated users table: added phone and made email nullable.\n";
} catch (PDOException $e) {
    if (strpos($e->getMessage(), "Duplicate column name") !== false) {
        echo "Column 'phone' already exists.\n";
    } else {
        echo "Error updating table: " . $e->getMessage() . "\n";
    }
}
?>