aboutsummaryrefslogtreecommitdiff
path: root/db/migrations/5.1.57_cleanup_tool_activations.php
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrations/5.1.57_cleanup_tool_activations.php')
-rw-r--r--db/migrations/5.1.57_cleanup_tool_activations.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/db/migrations/5.1.57_cleanup_tool_activations.php b/db/migrations/5.1.57_cleanup_tool_activations.php
new file mode 100644
index 0000000..2f4bda2
--- /dev/null
+++ b/db/migrations/5.1.57_cleanup_tool_activations.php
@@ -0,0 +1,24 @@
+<?php
+/**
+ * @see https://gitlab.studip.de/studip/studip/-/issues/3977
+ */
+return new class extends Migration
+{
+ public function description()
+ {
+ return 'Removes invalid tool activations (that are no longer connected '
+ . 'to a StandardPlugin';
+ }
+
+ protected function up()
+ {
+ $query = "DELETE FROM `tools_activated`
+ WHERE `plugin_id` NOT IN (
+ SELECT `pluginid`
+ FROM `plugins`
+ WHERE FIND_IN_SET(?, `plugintype`)
+ OR FIND_IN_SET(?, `plugintype`)
+ )";
+ DBManager::get()->execute($query, [StudipModule::class, StandardPlugin::class]);
+ }
+};