aboutsummaryrefslogtreecommitdiff
path: root/db/migrations/1.295_remove_invalid_modul_user_assignments.php
blob: 26074cca6913c55d4198f6f70beb13f3bc9f7a72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
class RemoveInvalidModulUserAssignments extends Migration
{
    public function description()
    {
        return 'Removes invalid user assignemnts from table `mvv_contacts` and '
        . '`mvv_contacts_ranges` (see BIEST #9809)';
    }

    public function up()
    {
        $query = "DELETE `mvv_contacts`, `mvv_contacts_ranges`
                    FROM `mvv_contacts`INNER JOIN `mvv_contacts_ranges`
                    WHERE `mvv_contacts`.`contact_id` = `mvv_contacts_ranges`.`contact_id`
                        AND	`mvv_contacts`.`contact_status` = 'intern'
                        AND `mvv_contacts`.`contact_id` NOT IN (
                            SELECT `user_id`
                            FROM `auth_user_md5`
                        )";
        DBManager::get()->exec($query);
    }
}