aboutsummaryrefslogtreecommitdiff
path: root/db/migrations/5.1.57_cleanup_tool_activations.php
blob: 2f4bda283fde259af1975267f850462d249d5f59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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]);
    }
};