aboutsummaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+studip@gmail.com>2023-10-09 08:35:29 +0000
committerJan-Hendrik Willms <tleilax+studip@gmail.com>2023-10-09 08:35:29 +0000
commit6ebb7cfd4a6ad82265e4bb2f64619909cd3e850b (patch)
treee04e521245d23d45aa99719e9a47935ccbfd0380 /db
parent0ebdda16c6113490cbb0d528c6c87d8cf5d9b284 (diff)
fixes #3282
Closes #3282 Merge request studip/studip!2217
Diffstat (limited to 'db')
-rw-r--r--db/migrations/5.1.51_cleanup_resource_properties.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/db/migrations/5.1.51_cleanup_resource_properties.php b/db/migrations/5.1.51_cleanup_resource_properties.php
new file mode 100644
index 0000000..ac80425
--- /dev/null
+++ b/db/migrations/5.1.51_cleanup_resource_properties.php
@@ -0,0 +1,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);
+ }
+}