aboutsummaryrefslogtreecommitdiff
path: root/db/migrations/5.3.28_cleanup_studygroup_invitations.php
blob: 9c672242e07dfc0d5646458ef33704ed5ffa45fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
return new class extends Migration {
    public function description()
    {
        return 'Removes orphaned entries in table "studygroup_invitations"';
    }

    protected function up()
    {
        $query = "DELETE FROM `studygroup_invitations`
                  WHERE `user_id` NOT IN (
                      SELECT `user_id` FROM `auth_user_md5`
                  ) OR `sem_id` NOT IN (
                      SELECT `Seminar_id` FROM `seminare`
                  )";
        DBManager::get()->exec($query);
    }
};