From f228e970664e666acd88bc60243f460147b14d46 Mon Sep 17 00:00:00 2001
From: David Siegfried <david.siegfried@uni-vechta.de>
Date: Tue, 4 Apr 2023 08:44:05 +0000
Subject: [PATCH] remove description fields from semester_data and termine,
 closes #2483

Closes #2483

Merge request studip/studip!1675
---
 app/controllers/admin/semester.php            |  1 -
 app/routes/Semester.php                       |  1 -
 app/views/admin/semester/edit.php             |  8 -----
 app/views/admin/semester/index.php            |  2 +-
 .../5.4.2_remove_description_fields.php       | 34 +++++++++++++++++++
 lib/classes/JsonApi/Schemas/Semester.php      |  1 -
 lib/models/CourseDate.class.php               |  1 -
 lib/models/CourseExDate.class.php             |  1 -
 lib/models/Semester.class.php                 |  2 --
 9 files changed, 35 insertions(+), 16 deletions(-)
 create mode 100644 db/migrations/5.4.2_remove_description_fields.php

diff --git a/app/controllers/admin/semester.php b/app/controllers/admin/semester.php
index 2130390a132..0dc8a5da502 100644
--- a/app/controllers/admin/semester.php
+++ b/app/controllers/admin/semester.php
@@ -75,7 +75,6 @@ class Admin_SemesterController extends AuthenticatedController
 
             // Extract values
             $this->semester->name           = Request::i18n('name');
-            $this->semester->description    = Request::i18n('description');
             $this->semester->semester_token = Request::i18n('token');
             $this->semester->beginn         = $this->getTimeStamp('beginn');
             $this->semester->ende           = $this->getTimeStamp('ende', '23:59:59');
diff --git a/app/routes/Semester.php b/app/routes/Semester.php
index 80922826653..bdb1ee7cb14 100644
--- a/app/routes/Semester.php
+++ b/app/routes/Semester.php
@@ -105,7 +105,6 @@ class Semester extends \RESTAPI\RouteMap
             'id'             => $semester['semester_id'],
             'title'          => (string) $semester['name'],
             'token'          => (string) $semester['semester_token'],
-            'description'    => (string) $semester['description'],
             'begin'          => (int) $semester['beginn'],
             'end'            => (int) $semester['ende'],
             'seminars_begin' => (int) $semester['vorles_beginn'],
diff --git a/app/views/admin/semester/edit.php b/app/views/admin/semester/edit.php
index 1a40d23c17d..9ef8b6fa7b1 100644
--- a/app/views/admin/semester/edit.php
+++ b/app/views/admin/semester/edit.php
@@ -29,14 +29,6 @@
             ]) ?>
         </label>
 
-        <label>
-            <?= _('Beschreibung') ?>
-
-            <?= I18N::textarea('description', $semester->description, [
-                'id' => 'description',
-            ]) ?>
-        </label>
-
         <label>
             <?= _('Externe ID') ?>
 
diff --git a/app/views/admin/semester/index.php b/app/views/admin/semester/index.php
index 1fc87a749e1..511dbfb89f0 100644
--- a/app/views/admin/semester/index.php
+++ b/app/views/admin/semester/index.php
@@ -60,7 +60,7 @@
                     <? endif; ?>
                 >
             </td>
-            <td title="<?= htmlReady($semester->description) ?>">
+            <td>
                 <?= htmlReady($semester->name) ?>
                 <? if (!$semester->visible): ?>
                 <?= '(' . _('gesperrt') . ')'; ?>
diff --git a/db/migrations/5.4.2_remove_description_fields.php b/db/migrations/5.4.2_remove_description_fields.php
new file mode 100644
index 00000000000..1723778387c
--- /dev/null
+++ b/db/migrations/5.4.2_remove_description_fields.php
@@ -0,0 +1,34 @@
+<?php
+final class RemoveDescriptionFields extends Migration
+{
+    public function description()
+    {
+        return 'Removes the unused database columns `termine`.`description`, `ex_termine`.`description` and `semester_data`.`description`';
+    }
+
+    protected function up()
+    {
+        $query = "ALTER TABLE `termine`
+                  DROP COLUMN `description`";
+        DBManager::get()->exec($query);
+        $query = "ALTER TABLE `ex_termine`
+                  DROP COLUMN `description`";
+        DBManager::get()->exec($query);
+        $query = "ALTER TABLE `semester_data`
+                  DROP COLUMN `description`";
+        DBManager::get()->exec($query);
+    }
+
+    protected function down()
+    {
+        $query = "ALTER TABLE `termine`
+                  ADD COLUMN `description` TEXT AFTER `content`";
+        DBManager::get()->exec($query);
+        $query = "ALTER TABLE `ex_termine`
+                  ADD COLUMN `description` TEXT AFTER `content`";
+        DBManager::get()->exec($query);
+        $query = "ALTER TABLE `semester_data`
+                  ADD COLUMN `description` TEXT NOT NULL AFTER `name`";
+        DBManager::get()->exec($query);
+    }
+}
diff --git a/lib/classes/JsonApi/Schemas/Semester.php b/lib/classes/JsonApi/Schemas/Semester.php
index f1bca9cba99..75aef03c96b 100644
--- a/lib/classes/JsonApi/Schemas/Semester.php
+++ b/lib/classes/JsonApi/Schemas/Semester.php
@@ -17,7 +17,6 @@ class Semester extends SchemaProvider
     {
         return [
             'title' => (string) $semester->name,
-            'description' => (string) $semester->description,
             'token' => (string) $semester->token,
             'start' => date('c', $semester->beginn),
             'end' => date('c', $semester->ende),
diff --git a/lib/models/CourseDate.class.php b/lib/models/CourseDate.class.php
index 1465fa1d0cd..9ae0268e490 100644
--- a/lib/models/CourseDate.class.php
+++ b/lib/models/CourseDate.class.php
@@ -15,7 +15,6 @@
  * @property string range_id database column
  * @property string autor_id database column
  * @property string content database column
- * @property string description database column
  * @property string date database column
  * @property string end_time database column
  * @property string mkdate database column
diff --git a/lib/models/CourseExDate.class.php b/lib/models/CourseExDate.class.php
index 625653e4139..f2c75b51610 100644
--- a/lib/models/CourseExDate.class.php
+++ b/lib/models/CourseExDate.class.php
@@ -15,7 +15,6 @@
  * @property string range_id database column
  * @property string autor_id database column
  * @property string content database column
- * @property string description database column
  * @property string date database column
  * @property string end_time database column
  * @property string mkdate database column
diff --git a/lib/models/Semester.class.php b/lib/models/Semester.class.php
index 21481f2f394..1a490a60c78 100644
--- a/lib/models/Semester.class.php
+++ b/lib/models/Semester.class.php
@@ -16,7 +16,6 @@
  * @property string semester_id database column
  * @property string id alias column for semester_id
  * @property string name database column
- * @property string description database column
  * @property string semester_token database column
  * @property string beginn database column
  * @property string ende database column
@@ -64,7 +63,6 @@ class Semester extends SimpleORMap
         $config['registered_callbacks']['after_delete'][] = 'refreshCache';
 
         $config['i18n_fields']['name'] = true;
-        $config['i18n_fields']['description'] = true;
         $config['i18n_fields']['semester_token'] = true;
 
         parent::configure($config);
-- 
GitLab