aboutsummaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+studip@gmail.com>2023-02-09 16:32:38 +0000
committerJan-Hendrik Willms <tleilax+studip@gmail.com>2023-02-09 16:32:38 +0000
commit218fd2a4452e1214f0254ac6fbf1dca1c6f78118 (patch)
tree4573a5a1df19f2a0e4a5cb9f97c4f4b48412e6d7 /db
parent33b51b95ea631e0bc4d575d155904e1e4c96c073 (diff)
remove course notifications as well when deleting user and cleanup table via migration, fixes #2141
Closes #2141 Merge request studip/studip!1389
Diffstat (limited to 'db')
-rw-r--r--db/migrations/5.1.41_cleanup_seminar_user_notifications.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/db/migrations/5.1.41_cleanup_seminar_user_notifications.php b/db/migrations/5.1.41_cleanup_seminar_user_notifications.php
new file mode 100644
index 0000000..6279ac7
--- /dev/null
+++ b/db/migrations/5.1.41_cleanup_seminar_user_notifications.php
@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * @see https://gitlab.studip.de/studip/studip/-/issues/2141
+ */
+final class CleanupSeminarUserNotifications extends Migration
+{
+ public function description()
+ {
+ return "Removes all entries from `seminar_user_notifications` that are not in `seminar_user` as well";
+ }
+
+ protected function up()
+ {
+ $query = "DELETE `seminar_user_notifications`
+ FROM `seminar_user_notifications`
+ LEFT JOIN `seminar_user` USING(`user_id`, `Seminar_id`)
+ WHERE `seminar_user`.`user_id` IS NULL";
+ DBManager::get()->exec($query);
+ }
+}