Skip to content
Snippets Groups Projects
Commit 227573a4 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms Committed by Jan-Hendrik Willms
Browse files

add migration that removes column ex_termine.topic_id, fixes #1224

Closes #1224

Merge request studip/studip!735
parent 1eae8ca7
No related branches found
No related tags found
No related merge requests found
<?php
/**
* @see https://gitlab.studip.de/studip/studip/-/issues/1224
* @see https://gitlab.studip.de/studip/studip/-/issues/881
*/
final class RemoveColumnExTermineTopicId extends Migration
{
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);
}
protected function columnExists(string $table, string $column): bool
{
$query = "SHOW COLUMNS FROM `{$table}` LIKE ?";
return (bool) DBManager::get()->fetchOne($query, [$column]);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment