2018-10-24 14:33:44 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Engelsystem\Migrations;
|
|
|
|
|
|
|
|
use Engelsystem\Database\Migration\Migration;
|
|
|
|
|
|
|
|
class CleanupGroupPrivileges extends Migration
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Run the migration
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function up(): void
|
2018-10-24 14:33:44 +02:00
|
|
|
{
|
|
|
|
if (!$this->schema->hasTable('GroupPrivileges')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$connection = $this->schema->getConnection();
|
|
|
|
|
|
|
|
// Add permissions to shikos to assign worklog entries
|
|
|
|
$connection->insert(
|
|
|
|
'
|
|
|
|
INSERT INTO `GroupPrivileges` (`group_id`, `privilege_id`)
|
|
|
|
VALUES (?, ?)
|
|
|
|
',
|
|
|
|
[
|
|
|
|
-40, // Shift Coordinator
|
|
|
|
43, // admin_user_worklog
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Delete unused privileges
|
|
|
|
$connection->delete('
|
|
|
|
DELETE FROM `Privileges`
|
|
|
|
WHERE `name` IN(
|
|
|
|
\'user_wakeup\',
|
|
|
|
\'faq\',
|
|
|
|
\'credits\'
|
|
|
|
)
|
|
|
|
');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reverse the migration
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function down(): void
|
2018-10-24 14:33:44 +02:00
|
|
|
{
|
|
|
|
if (!$this->schema->hasTable('GroupPrivileges')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add permissions to shikos to assign worklog entries
|
|
|
|
$this->schema->getConnection()->delete(
|
|
|
|
'
|
|
|
|
DELETE FROM `GroupPrivileges`
|
|
|
|
WHERE
|
2020-05-13 18:26:32 +02:00
|
|
|
group_id = ?
|
|
|
|
AND privilege_id = ?
|
2018-10-24 14:33:44 +02:00
|
|
|
',
|
|
|
|
[
|
|
|
|
-40, // Shift Coordinator
|
|
|
|
43, // admin_user_worklog
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|