aboutsummaryrefslogtreecommitdiff
path: root/db/migrations/5.1.33_remove_column_ex_termine_topic_id.php
blob: 363c2d5c9021b596f7c91d5718fd5a9772b01fce (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
<?php
/**
 * @see https://gitlab.studip.de/studip/studip/-/issues/1224
 * @see https://gitlab.studip.de/studip/studip/-/issues/881
 */
final class RemoveColumnExTermineTopicId extends Migration
{
    use DatabaseMigrationTrait;

    public function description()
    {
        return 'Removes unused column topic_id from table ex_termine.';
    }

    protected function up()
    {
        if (!$this->columnExists('ex_termine', 'topic_id')) {
            $this->write("Column ex_termine.topic_id does not exist");
            return;
        }

        $query = "ALTER TABLE `ex_termine`
                  DROP COLUMN `topic_id`";
        DBManager::get()->exec($query);
    }

    protected function down()
    {
        if ($this->columnExists('ex_termine', 'topic_id')) {
            $this->write("Column ex_termine.topic_id already exists");
            return;
        }

        $query = "ALTER TABLE `ex_termine`
                  ADD COLUMN `topic_id` VARCHAR(32) COLLATE latin1_bin DEFAULT NULL";
        DBManager::get()->exec($query);
    }
}