<?php

declare(strict_types=1);

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

if (!in_array('--force', $argv, true)) {
    fwrite(STDOUT, "Use --force para aplicar o patch.\n");
    exit(1);
}

$pdo = \Core\Database::connection();
$exists = $pdo->query("SHOW COLUMNS FROM admissions LIKE 'professor_mei_cnpj'")->fetch();
if ($exists) {
    fwrite(STDOUT, "Coluna professor_mei_cnpj já existe.\n");
    exit(0);
}
$pdo->exec("ALTER TABLE admissions ADD COLUMN professor_mei_cnpj VARCHAR(18) NULL AFTER cref_number");
fwrite(STDOUT, "Patch aplicado com sucesso.\n");
