From c0f19eb2ffc92639e83e3435bdc99405f8f65152 Mon Sep 17 00:00:00 2001 From: Luca Date: Thu, 7 Apr 2022 18:42:52 +0200 Subject: [PATCH] Rename groups --- .../2022_04_07_000000_rename_groups.php | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 db/migrations/2022_04_07_000000_rename_groups.php diff --git a/db/migrations/2022_04_07_000000_rename_groups.php b/db/migrations/2022_04_07_000000_rename_groups.php new file mode 100644 index 00000000..79d0bdb0 --- /dev/null +++ b/db/migrations/2022_04_07_000000_rename_groups.php @@ -0,0 +1,47 @@ +schema->getConnection(); + + foreach (GROUPS as [$id, $old, $new]) { + $connection->update( + 'UPDATE `Groups` SET `Name` = ? WHERE `UID` = ?', + [$new, $id] + ); + } + } + + /** + * Reverse the migration + */ + public function down() + { + $connection = $this->schema->getConnection(); + + foreach (GROUPS as [$id, $old, $new]) { + $connection->update( + 'UPDATE `Groups` SET `Name` = ? WHERE `UID` = ?', + [$old, $id] + ); + } + } +}