diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2023-06-02 09:17:04 +0000 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2023-06-02 09:17:04 +0000 |
| commit | cc4a9f0d2f238c258850951f4641e34cf4413b7b (patch) | |
| tree | f693ccc8b9c3be9ff81feead53904381c9f52e58 /db | |
| parent | da5ab26fec2e9634a13a3b7b5eeeba81a90ca844 (diff) | |
remove all consultation responsibilities upon range deletion and clean up db table, fixes #2673
Closes #2673
Merge request studip/studip!1813
Diffstat (limited to 'db')
| -rw-r--r-- | db/migrations/5.1.48_cleanup_consultation_responsibilities.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/db/migrations/5.1.48_cleanup_consultation_responsibilities.php b/db/migrations/5.1.48_cleanup_consultation_responsibilities.php new file mode 100644 index 0000000..0dc3bfc --- /dev/null +++ b/db/migrations/5.1.48_cleanup_consultation_responsibilities.php @@ -0,0 +1,33 @@ +<?php +final class CleanupConsultationResponsibilities extends Migration +{ + public function description() + { + return 'Remove all orphaned entries in table "consultation_responsibilities"'; + } + + protected function up() + { + $query = "DELETE FROM `consultation_responsibilities` + WHERE ( + `range_type` = 'user' + AND `range_id` NOT IN ( + SELECT `user_id` + FROM `auth_user_md5` + ) + ) OR ( + `range_type` = 'institute' + AND `range_id` NOT IN ( + SELECT `Institut_id` + FROM `Institute` + ) + ) OR ( + `range_type` = 'statusgroup' + AND `range_id` NOT IN ( + SELECT `statusgruppe_id` + FROM `statusgruppen` + ) + )"; + DBManager::get()->exec($query); + } +} |
