aboutsummaryrefslogtreecommitdiff
path: root/db/migrations/6.1.7_step_4270.php
blob: 7178d5be9dadc28ffd8506e657f628123230728f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php

/**
 * Adds namespace values to UserFilter database entries that already existed pre-6.0.
 */
final class Step4270 extends Migration
{

    public function description()
    {
        return 'Add additional field to table object_contentmodules';
    }

    public function up()
    {
        DBManager::get()->execute(
            "ALTER TABLE `object_contentmodules` 
             ADD `object_type` VARCHAR(32) NOT NULL DEFAULT '' AFTER `module_type`, 
             ADD `object_parent_id` VARCHAR(32) NOT NULL DEFAULT '' AFTER `object_type`, 
             ADD `object_parent_type` VARCHAR(32) NOT NULL DEFAULT '' AFTER `object_parent_id`"
        );
        DBManager::get()->execute(
            "ALTER TABLE `object_contentmodules`
             DROP PRIMARY KEY, 
             ADD PRIMARY KEY (`object_id`, `module_id`, `system_type`, `object_parent_id`)"
        );
    }

    public function down()
    {
        DBManager::get()->execute(
            "ALTER TABLE `object_contentmodules`
             DROP PRIMARY KEY, 
             ADD PRIMARY KEY (`object_id`, `module_id`, `system_type`)"
        );
        DBManager::get()->execute(
            "ALTER TABLE `object_contentmodules`
             DROP `object_type`,
             DROP `object_parent_id`,
             DROP `object_parent_type`;"
        );
    }
}