aboutsummaryrefslogtreecommitdiff
path: root/db/migrations/1.306_tic_9101.php
blob: 02e1b44374e2d72112d89d4fbc190f373e196284 (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
<?php
class Tic9101 extends Migration
{
    const MAPPING = [
         1 =>  7,
         2 =>  1,
         3 =>  2,
         4 =>  8,
         5 =>  4,
         6 =>  9,
         7 =>  6,
         8 =>  3,
         9 =>  5,
        10 => 14,
        11 => 10,
        12 => 11,
        13 => 14,
        14 => 13,
        15 => 12,
    ];

    public function description()
    {
        return 'Align colors in schedule with color mapping in my courses';
    }

    public function up()
    {
        $query = "UPDATE `schedule_seminare`
                  SET `color` = :new
                  WHERE `color` = :old";
        $statement = DBManager::get()->prepare($query);

        foreach (self::MAPPING as $old => $new) {
            $statement->bindValue(':new', $new);
            $statement->bindValue(':old', $old);
            $statement->execute();
        }
    }

    public function down()
    {
        $query = "UPDATE `schedule_seminare`
                  SET `color` = :new
                  WHERE `color` = :old";
        $statement = DBManager::get()->prepare($query);

        foreach (self::MAPPING as $old => $new) {
            $statement->bindValue(':new', $old);
            $statement->bindValue(':old', $new);
            $statement->execute();
        }
    }
}