aboutsummaryrefslogtreecommitdiff
path: root/db/migrations/1.294_mvv_bugs.php
blob: baf5ceb4518bcb6ce268c35af0a248eb1f73a68b (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
class MvvBugs extends Migration
{
    public function description()
    {
        return 'This migration fixes several bugs related to mvv';
    }

    public function up()
    {
        // Create table mvv_extern_contacts
        $query = "CREATE TABLE IF NOT EXISTS `mvv_extern_contacts` (
                    `extern_contact_id` CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
                    `name` VARCHAR(255) COLLATE utf8mb4_unicode_ci NOT NULL,
                    `vorname` VARCHAR(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
                    `homepage` VARCHAR(255) COLLATE utf8mb4_unicode_ci NOT NULL,
                    `mail` VARCHAR(255) COLLATE utf8mb4_unicode_ci NOT NULL,
                    `tel` VARCHAR(255) COLLATE utf8mb4_unicode_ci NOT NULL,
                    `author_id` CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL,
                    `editor_id` CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL,
                    `mkdate` INT(11) NOT NULL,
                    `chdate` INT(11) NOT NULL,
                    PRIMARY KEY (`extern_contact_id`)
                  ) ENGINE=InnoDB ROW_FORMAT=DYNAMIC";
        DBManager::get()->exec($query);

        // Allow decimal credit point specifications
        $query = "ALTER TABLE `mvv_modul`
                  MODIFY COLUMN `kp` DOUBLE(5,2) DEFAULT NULL";
        DBManager::get()->exec($query);

        $query = "ALTER TABLE `mvv_modulteil`
                  MODIFY COLUMN `kp` DOUBLE(5,2) DEFAULT NULL";
        DBManager::get()->exec($query);

        $query = "ALTER TABLE `mvv_stgteilabschnitt`
                  MODIFY COLUMN `kp` DOUBLE(5,2) DEFAULT NULL";
        DBManager::get()->exec($query);

        // Adjust config sections for mvv
        $query = "UPDATE `config`
                  SET `section` = 'mvv'
                  WHERE `field` LIKE 'MVV%'";
        DBManager::get()->exec($query);
    }

    public function down()
    {
        // Remove table mvv_extern_contacts
        $query = "DROP TABLE IF EXISTS `mvv_extern_contacts`";
        DBManager::get()->exec($query);

        // Disallow decimal credit point specifications
        $query = "ALTER TABLE `mvv_modul`
                  MODIFY COLUMN `kp` INT(11) DEFAULT NULL";
        DBManager::get()->exec($query);

        $query = "ALTER TABLE `mvv_modulteil`
                  MODIFY COLUMN `kp` INT(11) DEFAULT NULL";
        DBManager::get()->exec($query);

        $query = "ALTER TABLE `mvv_stgteilabschnitt`
                  MODIFY COLUMN `kp` INT(11) DEFAULT NULL";
        DBManager::get()->exec($query);
    }
}