<?php
require_once __DIR__ . '/../src/Utils/Env.php';
require_once __DIR__ . '/../src/Config/Database.php';

use App\Utils\Env;
use App\Config\Database;

Env::load(__DIR__ . '/../../.env');
$db = Database::getInstance()->getConnection();

echo "<pre>\n";

try {
    $stmt = $db->query("SHOW COLUMNS FROM users LIKE 'gender'");
    $col = $stmt->fetch();
    if ($col) {
        echo "users.gender already exists\n";
    } else {
        $db->exec("ALTER TABLE users ADD COLUMN gender ENUM('male','female','other') NULL");
        echo "Added users.gender\n";
    }
} catch (PDOException $e) {
    echo "users.gender: " . $e->getMessage() . "\n";
}

try {
    $stmt = $db->query("SHOW COLUMNS FROM users LIKE 'birth_date'");
    $col = $stmt->fetch();
    if ($col) {
        echo "users.birth_date already exists\n";
    } else {
        $db->exec("ALTER TABLE users ADD COLUMN birth_date DATE NULL");
        echo "Added users.birth_date\n";
    }
} catch (PDOException $e) {
    echo "users.birth_date: " . $e->getMessage() . "\n";
}

echo "\nDone.\n</pre>";

