From 8c630a2148fc40e1cd178c4486fdc74d836c67fb Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Sat, 12 Sep 2020 21:27:40 +0200 Subject: [PATCH] Groups: Added Welcome Angel --- ...create_welcome_angel_permissions_group.php | 52 +++++++++++++++++++ tests/Unit/HasDatabase.php | 2 + 2 files changed, 54 insertions(+) create mode 100644 db/migrations/2020_09_12_000000_create_welcome_angel_permissions_group.php diff --git a/db/migrations/2020_09_12_000000_create_welcome_angel_permissions_group.php b/db/migrations/2020_09_12_000000_create_welcome_angel_permissions_group.php new file mode 100644 index 00000000..50a73360 --- /dev/null +++ b/db/migrations/2020_09_12_000000_create_welcome_angel_permissions_group.php @@ -0,0 +1,52 @@ +schema->hasTable('Groups')) { + return; + } + + $db = $this->schema->getConnection(); + + $db + ->table('Groups') + ->insert([ + 'UID' => -25, + 'Name' => 'Welcome Angel', + ]); + + $privilege = $db->table('Privileges') + ->where('name', 'admin_arrive') + ->first(); + + $db->table('GroupPrivileges') + ->insert([ + 'group_id' => -25, + 'privilege_id' => $privilege->id, + ]); + } + + /** + * Reverse the migration + */ + public function down() + { + if (!$this->schema->hasTable('Groups')) { + return; + } + + $this->schema->getConnection() + ->table('Groups') + ->where('UID', -25) + ->delete(); + } +} diff --git a/tests/Unit/HasDatabase.php b/tests/Unit/HasDatabase.php index 9729af79..0be90bf6 100644 --- a/tests/Unit/HasDatabase.php +++ b/tests/Unit/HasDatabase.php @@ -38,6 +38,7 @@ trait HasDatabase ->table('migrations') ->insert( [ + // Migrations that can be skipped as they only use legacy tables ['migration' => '2018_01_01_000001_import_install_sql'], ['migration' => '2018_01_01_000002_import_update_sql'], ['migration' => '2018_01_01_000003_fix_old_tables'], @@ -46,6 +47,7 @@ trait HasDatabase ['migration' => '2018_12_27_000000_fix_missing_arrival_dates'], ['migration' => '2019_09_07_000000_migrate_admin_schedule_permissions'], ['migration' => '2020_04_07_000000_change_mysql_database_encoding_to_utf8mb4'], + ['migration' => '2020_09_12_000000_create_welcome_angel_permissions_group'], ] );