From faa7fb47010712300e23ca490b3530be243cedfc Mon Sep 17 00:00:00 2001 From: Thomas Hackl <hackl@data-quest.de> Date: Wed, 6 Sep 2023 14:05:38 +0000 Subject: [PATCH] Resolve "Fehlermeldungen nach Entfernen der Spalte sem_tree.studip_object_id" Closes #3014 Merge request studip/studip!2120 --- .../5.4.14_restore_studip_object_id.php | 24 +++++++++++++++++ .../5.4.6.1_restore_studip_object_id.php | 26 ------------------- db/migrations/5.4.6_tree_changes.php | 8 ------ 3 files changed, 24 insertions(+), 34 deletions(-) create mode 100644 db/migrations/5.4.14_restore_studip_object_id.php delete mode 100644 db/migrations/5.4.6.1_restore_studip_object_id.php diff --git a/db/migrations/5.4.14_restore_studip_object_id.php b/db/migrations/5.4.14_restore_studip_object_id.php new file mode 100644 index 00000000000..00bb0c0b224 --- /dev/null +++ b/db/migrations/5.4.14_restore_studip_object_id.php @@ -0,0 +1,24 @@ +<? + +final class RestoreStudipObjectId extends Migration +{ + + use DatabaseMigrationTrait; + + public function description() + { + return 'Restores the studip_object_id column for sem_tree'; + } + + protected function up() + { + if (!$this->columnExists('sem_tree', 'studip_object_id')) { + // Add database column for sem_tree institute assignments. + DBManager::get()->exec("ALTER TABLE `sem_tree` ADD + `studip_object_id` CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin NULL DEFAULT NULL AFTER `name`"); + // Add index for studip_object_id. + DBManager::get()->exec("ALTER TABLE `sem_tree` ADD INDEX `studip_object_id` (`studip_object_id`)"); + } + } + +} diff --git a/db/migrations/5.4.6.1_restore_studip_object_id.php b/db/migrations/5.4.6.1_restore_studip_object_id.php deleted file mode 100644 index b79b93344c5..00000000000 --- a/db/migrations/5.4.6.1_restore_studip_object_id.php +++ /dev/null @@ -1,26 +0,0 @@ -<? - -final class RestoreStudipObjectId extends Migration -{ - - public function description() - { - return 'Restores the studip_object_id column for sem_tree'; - } - - protected function up() - { - // Add database column for sem_tree institute assignments. - DBManager::get()->exec("ALTER TABLE `sem_tree` ADD - `studip_object_id` CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin NULL DEFAULT NULL AFTER `name`"); - // Add index for studip_object_id. - DBManager::get()->exec("ALTER TABLE `sem_tree` ADD INDEX `studip_object_id` (`studip_object_id`)"); - } - - protected function down() - { - // Remove institute assignments for sem_tree entries. - DBManager::get()->exec("ALTER TABLE `sem_tree` DROP `studip_object_id`"); - } - -} diff --git a/db/migrations/5.4.6_tree_changes.php b/db/migrations/5.4.6_tree_changes.php index 146a77ae643..e71be6e29c4 100644 --- a/db/migrations/5.4.6_tree_changes.php +++ b/db/migrations/5.4.6_tree_changes.php @@ -33,8 +33,6 @@ final class TreeChanges extends Migration foreach (DBManager::get()->fetchAll($query) as $institute) { $stmt->execute(['name' => $institute['Name'], 'inst' => $institute['Institut_id']]); } - // Remove institute assignments for sem_tree entries. - DBManager::get()->exec("ALTER TABLE `sem_tree` DROP `studip_object_id`"); } protected function down() @@ -51,12 +49,6 @@ final class TreeChanges extends Migration UNIX_TIMESTAMP(), UNIX_TIMESTAMP() , 'mit welchem Status darf die Veranstaltungshierarchie bearbeitet werden (admin oder root)' )"); - - // Add database column for sem_tree institute assignments. - DBManager::get()->exec("ALTER TABLE `sem_tree` ADD - `studip_object_id` CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin NULL DEFAULT NULL AFTER `name`"); - // Add index for studip_object_id. - DBManager::get()->exec("ALTER TABLE `sem_tree` ADD INDEX `studip_object_id` (`studip_object_id`)"); } } -- GitLab