<?php
require __DIR__ . '/../vendor/autoload.php';
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/..');
$dotenv->safeLoad();
$pdo = App\Database::getConnection();
$stmt = $pdo->prepare("UPDATE users SET username = SUBSTRING_INDEX(email,'@',1) WHERE username IS NULL OR username = ''");
$ok = $stmt->execute();
echo $ok ? "Usernames updated\n" : "Update failed\n";
