Files

44 lines
1.4 KiB
PHP

<?php
/**
* CLI-ONLY migration script.
* Moved out of the public webroot on 2026-07-30 - it used to be reachable
* unauthenticated over HTTP. Run with: php scripts/legacy_migrations/<file>
*/
if (PHP_SAPI !== 'cli') {
http_response_code(404);
exit('Not Found');
}
require_once __DIR__ . '/../../app/bootstrap/init.php';
use App\Core\Database;
try {
$db = Database::getInstance();
echo "Checking columns in 'users' table...\n";
$stmt = $db->query("DESCRIBE users");
$columns = $stmt->fetchAll(PDO::FETCH_COLUMN);
if (!in_array('phone_hash', $columns)) {
echo "Adding 'phone_hash' column...\n";
$db->exec("ALTER TABLE users ADD COLUMN phone_hash VARCHAR(64) NULL AFTER phone");
$db->exec("CREATE INDEX idx_phone_hash ON users(phone_hash)");
echo "Column 'phone_hash' added successfully.\n";
} else {
echo "Column 'phone_hash' already exists.\n";
}
if (!in_array('email_hash', $columns)) {
echo "Adding 'email_hash' column...\n";
$db->exec("ALTER TABLE users ADD COLUMN email_hash VARCHAR(64) NULL AFTER email");
$db->exec("CREATE INDEX idx_email_hash ON users(email_hash)");
echo "Column 'email_hash' added successfully.\n";
} else {
echo "Column 'email_hash' already exists.\n";
}
echo "Migration completed.\n";
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}