aboutsummaryrefslogtreecommitdiff
path: root/db/migrations/5.1.30_remove_column_termine_topic_id.php
blob: 23972c37f2cb88b0ddb543ca094373bb4dd410be (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
<?php
/**
 * @see https://gitlab.studip.de/studip/studip/-/issues/881
 */
final class RemoveColumnTermineTopicId extends Migration
{
    use DatabaseMigrationTrait;

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

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

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

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

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