add username migration

This commit is contained in:
Bence Pőcze 2023-09-24 00:35:15 +02:00
parent 5b045335a1
commit 2de0589762
Signed by: bence
GPG Key ID: DC5BD6E95A333E6D
2 changed files with 16 additions and 0 deletions

View File

@ -0,0 +1,13 @@
<?php
use Faker\Factory;
use MapGuesser\PersistentData\Model\User;
use SokoWeb\Database\Query\Select;
$select = new Select(Container::$dbConnection);
$users = Container::$persistentDataManager->selectMultipleFromDb($select, User::class);
foreach ($users as $user) {
$user->setUsername(Factory::create()->userName);
Container::$persistentDataManager->saveToDb($user);
}

View File

@ -0,0 +1,3 @@
ALTER TABLE `users`
ADD `username` VARCHAR(255) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL AFTER `email`,
ADD UNIQUE `username` (`username`);