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] + ); + } + } +}