<?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 'chat_history_cleared_at'");
    $col = $stmt->fetch();
    if ($col) {
        echo "users.chat_history_cleared_at already exists\n";
    } else {
        $db->exec("ALTER TABLE users ADD COLUMN chat_history_cleared_at TIMESTAMP NULL DEFAULT NULL");
        echo "Added users.chat_history_cleared_at\n";
    }
} catch (PDOException $e) {
    echo "users.chat_history_cleared_at: " . $e->getMessage() . "\n";
}

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

