From 6d6e93d711ee8e4ae483fd23a69c64ae518ec120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Sun, 7 May 2023 01:43:14 +0200 Subject: [PATCH] RVRNEXT-24 add migration for slug for communities --- .../data/20230507_0051_slug_for_communities.php | 12 ++++++++++++ .../structure/20230507_0051_slug_for_communities.sql | 3 +++ 2 files changed, 15 insertions(+) create mode 100644 database/migrations/data/20230507_0051_slug_for_communities.php create mode 100644 database/migrations/structure/20230507_0051_slug_for_communities.sql diff --git a/database/migrations/data/20230507_0051_slug_for_communities.php b/database/migrations/data/20230507_0051_slug_for_communities.php new file mode 100644 index 0000000..5be5665 --- /dev/null +++ b/database/migrations/data/20230507_0051_slug_for_communities.php @@ -0,0 +1,12 @@ +selectMultipleFromDb($select, Community::class); + +foreach ($communities as $community) { + $community->generateSlug(); + Container::$persistentDataManager->saveToDb($community); +} diff --git a/database/migrations/structure/20230507_0051_slug_for_communities.sql b/database/migrations/structure/20230507_0051_slug_for_communities.sql new file mode 100644 index 0000000..2ec5162 --- /dev/null +++ b/database/migrations/structure/20230507_0051_slug_for_communities.sql @@ -0,0 +1,3 @@ +ALTER TABLE `communities` +ADD `slug` varchar(255) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL AFTER `id`, +ADD UNIQUE `slug` (`slug`);