<?php

declare(strict_types=1);

require dirname(__DIR__) . '/bootstrap.php';

use Core\Database;

$options = getopt('', ['force']);
if (!isset($options['force'])) {
    echo "Use --force para aplicar o patch da coluna cref_number.\n";
    exit(1);
}

$pdo = Database::connection();
$exists = (bool) $pdo->query("SHOW COLUMNS FROM admissions LIKE 'cref_number'")->fetchColumn();
if (!$exists) {
    $pdo->exec("ALTER TABLE admissions ADD COLUMN cref_number VARCHAR(30) NULL AFTER uniform_size");
    echo "Coluna cref_number adicionada com sucesso.\n";
} else {
    echo "Coluna cref_number já existe.\n";
}
