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'], ] );