add username migration
This commit is contained in:
parent
5b045335a1
commit
2de0589762
13
database/migrations/data/20230923_1905_username.php
Normal file
13
database/migrations/data/20230923_1905_username.php
Normal 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);
|
||||
}
|
3
database/migrations/structure/20230923_1905_username.sql
Normal file
3
database/migrations/structure/20230923_1905_username.sql
Normal 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`);
|
Loading…
Reference in New Issue
Block a user