summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/migrations/2018_01_01_000004_cleanup_group_privileges.php66
-rw-r--r--tests/Unit/HasDatabase.php1
2 files changed, 67 insertions, 0 deletions
diff --git a/db/migrations/2018_01_01_000004_cleanup_group_privileges.php b/db/migrations/2018_01_01_000004_cleanup_group_privileges.php
new file mode 100644
index 00000000..aead4422
--- /dev/null
+++ b/db/migrations/2018_01_01_000004_cleanup_group_privileges.php
@@ -0,0 +1,66 @@
+<?php
+
+namespace Engelsystem\Migrations;
+
+use Engelsystem\Database\Migration\Migration;
+
+class CleanupGroupPrivileges extends Migration
+{
+ /**
+ * Run the migration
+ */
+ public function up()
+ {
+ 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
+ */
+ public function down()
+ {
+ if (!$this->schema->hasTable('GroupPrivileges')) {
+ return;
+ }
+
+ // Add permissions to shikos to assign worklog entries
+ $this->schema->getConnection()->delete(
+ '
+ DELETE FROM `GroupPrivileges`
+ WHERE
+ group_id = ?
+ AND privilege_id = ?
+ ',
+ [
+ -40, // Shift Coordinator
+ 43, // admin_user_worklog
+ ]
+ );
+ }
+}
diff --git a/tests/Unit/HasDatabase.php b/tests/Unit/HasDatabase.php
index 36f9fba2..467f95fc 100644
--- a/tests/Unit/HasDatabase.php
+++ b/tests/Unit/HasDatabase.php
@@ -41,6 +41,7 @@ trait HasDatabase
['migration' => '2018_01_01_000001_import_install_sql'],
['migration' => '2018_01_01_000002_import_update_sql'],
['migration' => '2018_01_01_000003_fix_old_tables'],
+ ['migration' => '2018_01_01_000004_cleanup_group_privileges'],
]);
$migration->run(__DIR__ . '/../../db/migrations');