From 2de05897621baf06e419b997974e82540d0f562c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Sun, 24 Sep 2023 00:35:15 +0200 Subject: [PATCH] add username migration --- database/migrations/data/20230923_1905_username.php | 13 +++++++++++++ .../migrations/structure/20230923_1905_username.sql | 3 +++ 2 files changed, 16 insertions(+) create mode 100644 database/migrations/data/20230923_1905_username.php create mode 100644 database/migrations/structure/20230923_1905_username.sql diff --git a/database/migrations/data/20230923_1905_username.php b/database/migrations/data/20230923_1905_username.php new file mode 100644 index 0000000..a73e130 --- /dev/null +++ b/database/migrations/data/20230923_1905_username.php @@ -0,0 +1,13 @@ +selectMultipleFromDb($select, User::class); + +foreach ($users as $user) { + $user->setUsername(Factory::create()->userName); + Container::$persistentDataManager->saveToDb($user); +} diff --git a/database/migrations/structure/20230923_1905_username.sql b/database/migrations/structure/20230923_1905_username.sql new file mode 100644 index 0000000..bb7f9f7 --- /dev/null +++ b/database/migrations/structure/20230923_1905_username.sql @@ -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`);