aboutsummaryrefslogtreecommitdiff
path: root/db/migrations/5.1.51_cleanup_resource_properties.php
blob: ac8042533b5bec20790a027d268baa5297d59209 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
/**
 * @see https://gitlab.studip.de/studip/studip/-/issues/3282
 */
final class CleanupResourceProperties extends Migration
{
    public function description()
    {
        return 'Removes orphaned rows from table "resource_properties" with no '
             . 'definition in table "resource_property_definitions"';
    }

    protected function up()
    {
        $query = "DELETE FROM `resource_properties`
                  WHERE `property_id` NOT IN (
                      SELECT `property_id`
                      FROM `resource_property_definitions`
                  )";
        DBManager::get()->exec($query);
    }
}