aboutsummaryrefslogtreecommitdiff
path: root/db/migrations
diff options
context:
space:
mode:
authorPhilipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de>2024-09-24 10:53:31 +0200
committerPhilipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de>2024-09-24 10:53:31 +0200
commit4459dd7917f4d1c34f40bb68f0e991e9c3d53e4c (patch)
tree5c07151ae61276d334e88f6309c30d439a85c12e /db/migrations
parentda0022e5c1abbf9825ae76debaabdff7e8623bb4 (diff)
parent97a188592c679890a25c37ab78463add76a52ff7 (diff)
Merge branch 'main' into issue-3911issue-3911
Diffstat (limited to 'db/migrations')
-rw-r--r--db/migrations/1.127_setup_api.php71
-rw-r--r--db/migrations/1.128_step00240_coursesets.php2
-rw-r--r--db/migrations/1.12_step_120_userpic.php2
-rw-r--r--db/migrations/1.154_recalculate_score.php5
-rw-r--r--db/migrations/1.224_db_cache_table.php2
-rw-r--r--db/migrations/1.231_add_files_search_index.php7
-rw-r--r--db/migrations/1.2_step_102_datenfeldtypen.php2
-rw-r--r--db/migrations/1.314_step_00349.php4
-rw-r--r--db/migrations/1.318_step_00353_cache.php13
-rw-r--r--db/migrations/1.6_step_25_raumzeit_db_conversion.php4
-rw-r--r--db/migrations/5.1.34_activate_semester_routes.php6
-rw-r--r--db/migrations/5.1.55_fix_collation_on_oer_campus_tables.php79
-rw-r--r--db/migrations/5.1.56_cleanup_blubber.php48
-rw-r--r--db/migrations/5.1.57_cleanup_tool_activations.php24
-rw-r--r--db/migrations/5.1.58_add_missing_indices_for_table_schedule_seminare.php27
-rw-r--r--db/migrations/5.3.23_fix_questionnaire_questiondata.php18
-rw-r--r--db/migrations/5.5.26_tic3193_no_unlimited_courses.php5
-rw-r--r--db/migrations/6.0.10_remove_restapi.php63
-rw-r--r--db/migrations/6.0.11_adjust_cronjobs.php43
-rw-r--r--db/migrations/6.0.1_remove_cronjobs_scheduling_once_and_priority.php19
-rw-r--r--db/migrations/6.0.2_captcha_by_altcha.php39
-rw-r--r--db/migrations/6.0.3_adjust_cache_configuration.php38
-rw-r--r--db/migrations/6.0.4_adjust_cache_types_table.php37
-rw-r--r--db/migrations/6.0.5_remove_old_evaluation.php33
-rw-r--r--db/migrations/6.0.6_adjust_default_cache_name.php27
-rw-r--r--db/migrations/6.0.7_add_consecutive_flag_for_consultations.php45
-rw-r--r--db/migrations/6.0.8_add_max_show_admin_courses_config.php32
-rw-r--r--db/migrations/6.0.9_notification_positioning.php35
28 files changed, 674 insertions, 56 deletions
diff --git a/db/migrations/1.127_setup_api.php b/db/migrations/1.127_setup_api.php
index 7cae3f9..73b36f6 100644
--- a/db/migrations/1.127_setup_api.php
+++ b/db/migrations/1.127_setup_api.php
@@ -1,12 +1,46 @@
<?php
class SetupApi extends Migration
{
- function description()
+ public function description()
{
return 'Creates api tables in database and according config entries';
}
- function up()
+ public function up()
+ {
+ $this->createTables();
+
+ // Add config entries
+ $query = "INSERT IGNORE INTO `config`
+ (`config_id`, `field`, `value`, `is_default`, `type`, `range`, `section`,
+ `mkdate`, `chdate`, `description`)
+ VALUES (MD5(:field), :field, :value, 1, :type, 'global', 'global',
+ UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), :description)";
+ $statement = DBManager::get()->prepare($query);
+
+ $statement->execute([
+ ':field' => 'API_ENABLED',
+ ':value' => (int)false,
+ ':type' => 'boolean',
+ ':description' => 'Schaltet die REST-API an',
+ ]);
+
+ $statement->execute([
+ ':field' => 'API_OAUTH_AUTH_PLUGIN',
+ ':value' => 'Standard',
+ ':type' => 'string',
+ ':description' => 'Definiert das für OAuth verwendete Authentifizierungsverfahren',
+ ]);
+ }
+
+ public function down()
+ {
+ DBManager::get()->exec("DELETE FROM config WHERE field IN ('API_ENABLED', 'API_OAUTH_AUTH_PLUGIN')");
+
+ $this->dropTables();
+ }
+
+ public function createTables(): void
{
// Add vendor tables
$query = "CREATE TABLE IF NOT EXISTS `oauth_consumer_registry` (
@@ -29,7 +63,7 @@ class SetupApi extends Migration
KEY `ocr_usa_id_ref` (`ocr_usa_id_ref`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8";
DBManager::get()->exec($query);
-
+
$query = "CREATE TABLE IF NOT EXISTS `oauth_consumer_token` (
`oct_id` int(11) NOT NULL AUTO_INCREMENT,
`oct_ocr_id_ref` int(11) NOT NULL,
@@ -47,7 +81,7 @@ class SetupApi extends Migration
CONSTRAINT `oauth_consumer_token_ibfk_1` FOREIGN KEY (`oct_ocr_id_ref`) REFERENCES `oauth_consumer_registry` (`ocr_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=MyISAM DEFAULT CHARSET=utf8";
DBManager::get()->exec($query);
-
+
$query = "CREATE TABLE IF NOT EXISTS `oauth_log` (
`olg_id` int(11) NOT NULL AUTO_INCREMENT,
`olg_osr_consumer_key` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
@@ -80,7 +114,7 @@ class SetupApi extends Migration
UNIQUE KEY `osn_consumer_key` (`osn_consumer_key`,`osn_token`,`osn_timestamp`,`osn_nonce`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8";
DBManager::get()->exec($query);
-
+
$query = "CREATE TABLE IF NOT EXISTS `oauth_server_registry` (
`osr_id` int(11) NOT NULL AUTO_INCREMENT,
`osr_usa_id_ref` int(11) DEFAULT NULL,
@@ -176,39 +210,16 @@ class SetupApi extends Migration
PRIMARY KEY (`user_id`,`consumer_id`)
) ENGINE=MyISAM";
DBManager::get()->exec($query);
-
- // Add config entries
- $query = "INSERT IGNORE INTO `config`
- (`config_id`, `field`, `value`, `is_default`, `type`, `range`, `section`,
- `mkdate`, `chdate`, `description`)
- VALUES (MD5(:field), :field, :value, 1, :type, 'global', 'global',
- UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), :description)";
- $statement = DBManager::get()->prepare($query);
-
- $statement->execute([
- ':field' => 'API_ENABLED',
- ':value' => (int)false,
- ':type' => 'boolean',
- ':description' => 'Schaltet die REST-API an',
- ]);
-
- $statement->execute([
- ':field' => 'API_OAUTH_AUTH_PLUGIN',
- ':value' => 'Standard',
- ':type' => 'string',
- ':description' => 'Definiert das für OAuth verwendete Authentifizierungsverfahren',
- ]);
}
- function down()
+ public function dropTables(): void
{
- DBManager::get()->exec("DELETE FROM config WHERE field IN ('API_ENABLED', 'API_OAUTH_AUTH_PLUGIN')");
DBManager::get()->exec("DROP TABLE IF EXISTS `oauth_consumer_registry`,
`oauth_consumer_token`,
`oauth_log`,
`oauth_server_nonce`,
`oauth_server_registry`,
- `oauth_server_token`
+ `oauth_server_token`,
`api_consumer_permissions`,
`api_consumers`,
`api_oauth_user_mapping`,
diff --git a/db/migrations/1.128_step00240_coursesets.php b/db/migrations/1.128_step00240_coursesets.php
index b767ae3..2f47805 100644
--- a/db/migrations/1.128_step00240_coursesets.php
+++ b/db/migrations/1.128_step00240_coursesets.php
@@ -1,6 +1,6 @@
<?php
require_once 'vendor/phpass/PasswordHash.php';
-require_once 'lib/classes/admission/CourseSet.class.php';
+require_once 'lib/classes/admission/CourseSet.php';
class Step00240CourseSets extends Migration
{
diff --git a/db/migrations/1.12_step_120_userpic.php b/db/migrations/1.12_step_120_userpic.php
index f907b9f..eeb787a 100644
--- a/db/migrations/1.12_step_120_userpic.php
+++ b/db/migrations/1.12_step_120_userpic.php
@@ -10,7 +10,7 @@
* the License, or (at your option) any later version.
*/
-require_once 'lib/classes/Avatar.class.php';
+require_once 'lib/classes/Avatar.php';
class Step120Userpic extends Migration {
diff --git a/db/migrations/1.154_recalculate_score.php b/db/migrations/1.154_recalculate_score.php
index 158582e..9391e7d 100644
--- a/db/migrations/1.154_recalculate_score.php
+++ b/db/migrations/1.154_recalculate_score.php
@@ -38,7 +38,7 @@ class RecalculateScore extends Migration {
private static function getScore($user_id)
{
$user_id || $user_id = $GLOBALS['user']->id;
- $cache = StudipCacheFactory::getCache();
+ $cache = \Studip\Cache\Factory::getCache();
if ($cache->read("user_score_of_".$user_id)) {
return $cache->read("user_score_of_".$user_id);
}
@@ -130,7 +130,7 @@ class RecalculateScore extends Migration {
'date_column' => "chdate"
];
- foreach (PluginManager::getInstance()->getPlugins("ScorePlugin") as $plugin) {
+ foreach (PluginManager::getInstance()->getPlugins(ScorePlugin::class) as $plugin) {
foreach ((array) $plugin->getPluginActivityTables() as $table) {
if ($table['table']) {
$tables[] = $table;
@@ -142,4 +142,3 @@ class RecalculateScore extends Migration {
}
}
-
diff --git a/db/migrations/1.224_db_cache_table.php b/db/migrations/1.224_db_cache_table.php
index 66227d0..9abe7e3 100644
--- a/db/migrations/1.224_db_cache_table.php
+++ b/db/migrations/1.224_db_cache_table.php
@@ -17,7 +17,7 @@ class DbCacheTable extends Migration
PRIMARY KEY (cache_key)
) ENGINE=InnoDB ROW_FORMAT=DYNAMIC');
- StudipCacheFactory::getCache()->flush();
+ \Studip\Cache\Factory::getCache()->flush();
}
public function down()
diff --git a/db/migrations/1.231_add_files_search_index.php b/db/migrations/1.231_add_files_search_index.php
index 18a22ae..5ac455a 100644
--- a/db/migrations/1.231_add_files_search_index.php
+++ b/db/migrations/1.231_add_files_search_index.php
@@ -181,12 +181,7 @@ class AddFilesSearchIndex extends Migration
private function installCronjob()
{
- $scheduler = CronjobScheduler::getInstance();
-
require_once 'lib/classes/FilesSearch/Cronjob.php';
- $task = new \FilesSearch\Cronjob();
- $taskId = $scheduler->registerTask($task);
- $scheduler->scheduleOnce($taskId, strtotime('+1 minute'))->activate();
- $scheduler->schedulePeriodic($taskId, 55, 0)->activate();
+ \FilesSearch\Cronjob::register()->schedule(55, 0)->activate(true);
}
}
diff --git a/db/migrations/1.2_step_102_datenfeldtypen.php b/db/migrations/1.2_step_102_datenfeldtypen.php
index 1e7b552..b639132 100644
--- a/db/migrations/1.2_step_102_datenfeldtypen.php
+++ b/db/migrations/1.2_step_102_datenfeldtypen.php
@@ -63,7 +63,7 @@ class Step102Datenfeldtypen extends Migration {
return;
}
- require_once 'lib/classes/DataFieldStructure.class.php';
+ require_once 'lib/classes/DataFieldStructure.php';
$ids = array_keys(DataFieldStructure::getDataFieldStructures());
diff --git a/db/migrations/1.314_step_00349.php b/db/migrations/1.314_step_00349.php
index a777cc2..a1094d8 100644
--- a/db/migrations/1.314_step_00349.php
+++ b/db/migrations/1.314_step_00349.php
@@ -98,8 +98,8 @@ class Step00349 extends Migration
'participants' => 'CoreParticipants',
'courseware' => 'CoursewareModule'
];
- PluginManager::getInstance()->getPlugin('CoreForum');
- PluginManager::getInstance()->getPlugin('Blubber');
+ PluginManager::getInstance()->getPlugin(CoreForum::class);
+ PluginManager::getInstance()->getPlugin(Blubber::class);
foreach ($core_plugins as $plugin) {
try {
diff --git a/db/migrations/1.318_step_00353_cache.php b/db/migrations/1.318_step_00353_cache.php
index 901db60..5959945 100644
--- a/db/migrations/1.318_step_00353_cache.php
+++ b/db/migrations/1.318_step_00353_cache.php
@@ -1,5 +1,10 @@
<?php
+use Studip\Cache\DbCache;
+use Studip\Cache\FileCache;
+use Studip\Cache\MemcachedCache;
+use Studip\Cache\RedisCache;
+
class Step00353Cache extends Migration
{
public function description()
@@ -20,10 +25,10 @@ class Step00353Cache extends Migration
) ENGINE=InnoDB ROW_FORMAT=DYNAMIC");
$types = [
- 'StudipDbCache',
- 'StudipFileCache',
- 'StudipMemcachedCache',
- 'StudipRedisCache'
+ DbCache::class,
+ FileCache::class,
+ MemcachedCache::class,
+ RedisCache::class,
];
// Insert pre-defined cache types in to database
diff --git a/db/migrations/1.6_step_25_raumzeit_db_conversion.php b/db/migrations/1.6_step_25_raumzeit_db_conversion.php
index 1dd8edf..9a8ffd7 100644
--- a/db/migrations/1.6_step_25_raumzeit_db_conversion.php
+++ b/db/migrations/1.6_step_25_raumzeit_db_conversion.php
@@ -55,8 +55,8 @@ class Step25RaumzeitDbConversion extends Migration
// include business logic
- require_once('lib/classes/Seminar.class.php');
- require_once('lib/resources/lib/VeranstaltungResourcesAssign.class.php');
+ require_once('lib/classes/Seminar.php');
+ require_once('lib/resources/lib/VeranstaltungResourcesAssign.php');
diff --git a/db/migrations/5.1.34_activate_semester_routes.php b/db/migrations/5.1.34_activate_semester_routes.php
index 082a5db..21cbb64 100644
--- a/db/migrations/5.1.34_activate_semester_routes.php
+++ b/db/migrations/5.1.34_activate_semester_routes.php
@@ -8,7 +8,9 @@ class ActivateSemesterRoutes extends Migration
public function up()
{
- require_once 'app/routes/Semester.php';
- RESTAPI\ConsumerPermissions::get()->activateRouteMap(new RESTAPI\Routes\Semester());
+ // Deactivated since the restapi was removed in Stud.IP 6.0
+
+ # require_once 'app/routes/Semester.php';
+ # RESTAPI\ConsumerPermissions::get()->activateRouteMap(new RESTAPI\Routes\Semester());
}
}
diff --git a/db/migrations/5.1.55_fix_collation_on_oer_campus_tables.php b/db/migrations/5.1.55_fix_collation_on_oer_campus_tables.php
new file mode 100644
index 0000000..8c9a8b4
--- /dev/null
+++ b/db/migrations/5.1.55_fix_collation_on_oer_campus_tables.php
@@ -0,0 +1,79 @@
+<?php
+
+/**
+ * This migration will set the columns of the oer campus to the correct state
+ * regarding the collations of some columns. This should only be necessary if
+ * the plugin "Lernmarktplatz" was installed before the migration of Stud.IP
+ * that introduced the oer campus. In any other case the tables should not be
+ * changed since they are already in the correct format.
+ *
+ * @see https://gitlab.studip.de/studip/studip/-/issues/3964
+ *
+ * @author Jan-Hendrik Willms <tleilax+studip@gmail.com>
+ */
+final class FixCollationOnOerCampusTables extends Migration
+{
+ public function description()
+ {
+ return 'Correct collations for oer campus tables';
+ }
+
+ protected function up()
+ {
+ $query = "ALTER TABLE `oer_abo`
+ MODIFY COLUMN `user_id` CHAR(32) COLLATE `latin1_bin` NOT NULL DEFAULT '',
+ MODIFY COLUMN `material_id` CHAR(32) COLLATE `latin1_bin` DEFAULT NULL";
+ DBManager::get()->exec($query);
+
+ $query = "ALTER TABLE `oer_comments`
+ MODIFY COLUMN `comment_id` CHAR(32) COLLATE `latin1_bin` NOT NULL,
+ MODIFY COLUMN `review_id` CHAR(32) COLLATE `latin1_bin` NOT NULL,
+ MODIFY COLUMN `foreign_comment_id` CHAR(32) COLLATE `latin1_bin` DEFAULT NULL,
+ MODIFY COLUMN `host_id` CHAR(32) COLLATE `latin1_bin` DEFAULT NULL,
+ MODIFY COLUMN `user_id` CHAR(32) COLLATE `latin1_bin` NOT NULL";
+ DBManager::get()->exec($query);
+
+ $query = "ALTER TABLE `oer_downloadcounter`
+ MODIFY COLUMN `counter_id` CHAR(32) COLLATE `latin1_bin` NOT NULL DEFAULT '',
+ MODIFY COLUMN `material_id` CHAR(32) COLLATE `latin1_bin` NOT NULL";
+ DBManager::get()->exec($query);
+
+ $query = "ALTER TABLE `oer_hosts`
+ MODIFY COLUMN `host_id` CHAR(32) COLLATE `latin1_bin` NOT NULL";
+ DBManager::get()->exec($query);
+
+ $query = "ALTER TABLE `oer_material`
+ MODIFY COLUMN `material_id` CHAR(32) COLLATE `latin1_bin` NOT NULL,
+ MODIFY COLUMN `foreign_material_id` CHAR(32) COLLATE `latin1_bin` DEFAULT NULL,
+ MODIFY COLUMN `host_id` CHAR(32) COLLATE `latin1_bin` DEFAULT NULL";
+ DBManager::get()->exec($query);
+
+ $query = "ALTER TABLE `oer_material_users`
+ MODIFY COLUMN `material_id` CHAR(32) COLLATE `latin1_bin` NOT NULL DEFAULT '',
+ MODIFY COLUMN `user_id` CHAR(32) COLLATE `latin1_bin` NOT NULL DEFAULT ''";
+ DBManager::get()->exec($query);
+
+ $query = "ALTER TABLE `oer_reviews`
+ MODIFY COLUMN `review_id` CHAR(32) COLLATE `latin1_bin` NOT NULL,
+ MODIFY COLUMN `material_id` CHAR(32) COLLATE `latin1_bin` NOT NULL,
+ MODIFY COLUMN `foreign_review_id` CHAR(32) COLLATE `latin1_bin` DEFAULT NULL,
+ MODIFY COLUMN `user_id` CHAR(32) COLLATE `latin1_bin` NOT NULL,
+ MODIFY COLUMN `host_id` CHAR(32) COLLATE `latin1_bin` DEFAULT NULL";
+ DBManager::get()->exec($query);
+
+ $query = "ALTER TABLE `oer_tags`
+ MODIFY COLUMN `tag_hash` CHAR(32) COLLATE `latin1_bin` NOT NULL";
+ DBManager::get()->exec($query);
+
+ $query = "ALTER TABLE `oer_tags_material`
+ MODIFY COLUMN `material_id` CHAR(32) COLLATE `latin1_bin` NOT NULL,
+ MODIFY COLUMN `tag_hash` CHAR(32) COLLATE `latin1_bin` NOT NULL";
+ DBManager::get()->exec($query);
+
+ $query = "ALTER TABLE `oer_user`
+ MODIFY COLUMN `user_id` CHAR(32) COLLATE `latin1_bin` NOT NULL,
+ MODIFY COLUMN `foreign_user_id` CHAR(32) COLLATE `latin1_bin` NOT NULL,
+ MODIFY COLUMN `host_id` CHAR(32) COLLATE `latin1_bin` NOT NULL";
+ DBManager::get()->exec($query);
+ }
+}
diff --git a/db/migrations/5.1.56_cleanup_blubber.php b/db/migrations/5.1.56_cleanup_blubber.php
new file mode 100644
index 0000000..b870d78
--- /dev/null
+++ b/db/migrations/5.1.56_cleanup_blubber.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * @see https://gitlab.studip.de/studip/studip/-/issues/4097
+ */
+return new class extends Migration
+{
+ public function description()
+ {
+ return 'Removes orhpaned blubber entries';
+ }
+
+ protected function up()
+ {
+ $query = "DELETE bt, ouv
+ FROM `blubber_threads` AS bt
+ LEFT JOIN `object_user_visits` AS ouv
+ ON (bt.`thread_id` = ouv.`object_id`)
+ WHERE bt.`external_contact` = 0
+ AND bt.`thread_id` != 'global'
+ AND bt.`user_id` != ''
+ AND bt.`user_id` NOT IN (
+ SELECT `user_id` FROM `auth_user_md5`
+ )";
+ DBManager::get()->exec($query);
+
+ $query = "DELETE FROM `blubber_comments`
+ WHERE (
+ `external_contact` = 0
+ AND `user_id` NOT IN (
+ SELECT `user_id` FROM `auth_user_md5`
+ )
+ ) OR `thread_id` NOT IN (
+ SELECT `thread_id` FROM `blubber_threads`
+ )";
+ DBManager::get()->exec($query);
+
+ $query = "DELETE FROM `blubber_mentions`
+ WHERE (
+ `external_contact` = 0
+ AND `user_id` NOT IN (
+ SELECT `user_id` FROM `auth_user_md5`
+ )
+ ) OR `thread_id` NOT IN (
+ SELECT `thread_id` FROM `blubber_threads`
+ )";
+ DBManager::get()->exec($query);
+ }
+};
diff --git a/db/migrations/5.1.57_cleanup_tool_activations.php b/db/migrations/5.1.57_cleanup_tool_activations.php
new file mode 100644
index 0000000..2f4bda2
--- /dev/null
+++ b/db/migrations/5.1.57_cleanup_tool_activations.php
@@ -0,0 +1,24 @@
+<?php
+/**
+ * @see https://gitlab.studip.de/studip/studip/-/issues/3977
+ */
+return new class extends Migration
+{
+ public function description()
+ {
+ return 'Removes invalid tool activations (that are no longer connected '
+ . 'to a StandardPlugin';
+ }
+
+ protected function up()
+ {
+ $query = "DELETE FROM `tools_activated`
+ WHERE `plugin_id` NOT IN (
+ SELECT `pluginid`
+ FROM `plugins`
+ WHERE FIND_IN_SET(?, `plugintype`)
+ OR FIND_IN_SET(?, `plugintype`)
+ )";
+ DBManager::get()->execute($query, [StudipModule::class, StandardPlugin::class]);
+ }
+};
diff --git a/db/migrations/5.1.58_add_missing_indices_for_table_schedule_seminare.php b/db/migrations/5.1.58_add_missing_indices_for_table_schedule_seminare.php
new file mode 100644
index 0000000..f051f6d
--- /dev/null
+++ b/db/migrations/5.1.58_add_missing_indices_for_table_schedule_seminare.php
@@ -0,0 +1,27 @@
+<?php
+/**
+ * @see https://gitlab.studip.de/studip/studip/-/issues/4157
+ */
+return new class extends Migration
+{
+ public function description()
+ {
+ return 'Adds missing indices for columns "seminar_id" and "metadate_id" for table "schedule_seminare"';
+ }
+
+ protected function up()
+ {
+ $query = "ALTER TABLE `schedule_seminare`
+ ADD INDEX `seminar_id` (`seminar_id`),
+ ADD INDEX `metadate_id` (`metadate_id`)";
+ DBManager::get()->exec($query);
+ }
+
+ protected function down()
+ {
+ $query = "ALTER TABLE `schedule_seminare`
+ DROP INDEX `seminar_id`,
+ DROP INDEX `metadate_id`";
+ DBManager::get()->exec($query);
+ }
+};
diff --git a/db/migrations/5.3.23_fix_questionnaire_questiondata.php b/db/migrations/5.3.23_fix_questionnaire_questiondata.php
new file mode 100644
index 0000000..be115fc
--- /dev/null
+++ b/db/migrations/5.3.23_fix_questionnaire_questiondata.php
@@ -0,0 +1,18 @@
+<?php
+
+class FixQuestionnaireQuestiondata extends Migration
+{
+ public function description()
+ {
+ return 'fix invalid boolean values in questionnaire_questions';
+ }
+
+ public function up()
+ {
+ DBManager::get()->exec("
+ UPDATE questionnaire_questions
+ SET questiondata = REPLACE(questiondata, ':\"false\"', ':false')
+ WHERE questiondata LIKE '%:\"false\"%'
+ ");
+ }
+}
diff --git a/db/migrations/5.5.26_tic3193_no_unlimited_courses.php b/db/migrations/5.5.26_tic3193_no_unlimited_courses.php
index ef45bce..21a80ca 100644
--- a/db/migrations/5.5.26_tic3193_no_unlimited_courses.php
+++ b/db/migrations/5.5.26_tic3193_no_unlimited_courses.php
@@ -12,15 +12,14 @@ final class Tic3193NoUnlimitedCourses extends Migration
DBManager::get()->exec("
ALTER TABLE `sem_classes` ADD `unlimited_forbidden` TINYINT UNSIGNED NOT NULL DEFAULT 0 AFTER `is_group`
");
- $cache = StudipCacheFactory::getCache();
+ $cache = \Studip\Cache\Factory::getCache();
$cache->expire('DB_SEM_CLASSES_ARRAY');
}
public function down()
{
DBManager::get()->exec("ALTER TABLE `sem_classes` DROP `unlimited_forbidden`");
- $cache = StudipCacheFactory::getCache();
+ $cache = \Studip\Cache\Factory::getCache();
$cache->expire('DB_SEM_CLASSES_ARRAY');
}
}
-
diff --git a/db/migrations/6.0.10_remove_restapi.php b/db/migrations/6.0.10_remove_restapi.php
new file mode 100644
index 0000000..5062916
--- /dev/null
+++ b/db/migrations/6.0.10_remove_restapi.php
@@ -0,0 +1,63 @@
+<?php
+final class RemoveRestapi extends Migration
+{
+ private Migration $other_migration;
+
+ public function __construct($verbose = false)
+ {
+ parent::__construct($verbose);
+
+ require_once __DIR__ . '/1.127_setup_api.php';
+ $this->other_migration = new SetupApi($verbose);
+ }
+
+ public function description()
+ {
+ return 'Removes the deprecated REST API (essentially reverts migration 1.127)';
+ }
+
+ protected function up()
+ {
+ $this->other_migration->dropTables();
+
+ // Delete config
+ $query = "DELETE `config`, `config_values`
+ FROM `config`
+ LEFT JOIN `config_values` USING(`field`)
+ WHERE `field` IN ('API_ENABLED', 'API_OAUTH_AUTH_PLUGIN')";
+ DBManager::get()->exec($query);
+
+ // Disable all RESTAPI-Plugins
+ $query = "UPDATE `plugins`
+ SET `enabled` = 'no'
+ WHERE FIND_IN_SET('RESTAPIPlugin', `plugintype`)";
+ DBManager::get()->exec($query);
+ }
+
+ protected function down()
+ {
+ // Add config entries
+ $query = "INSERT IGNORE INTO `config`
+ (`field`, `value`, `type`, `range`, `section`,
+ `mkdate`, `chdate`, `description`)
+ VALUES (:field, :value, :type, 'global', 'global',
+ UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), :description)";
+ $statement = DBManager::get()->prepare($query);
+
+ $statement->execute([
+ ':field' => 'API_ENABLED',
+ ':value' => 0,
+ ':type' => 'boolean',
+ ':description' => 'Schaltet die REST-API an',
+ ]);
+
+ $statement->execute([
+ ':field' => 'API_OAUTH_AUTH_PLUGIN',
+ ':value' => 'Standard',
+ ':type' => 'string',
+ ':description' => 'Definiert das für OAuth verwendete Authentifizierungsverfahren',
+ ]);
+
+ $this->other_migration->createTables();
+ }
+}
diff --git a/db/migrations/6.0.11_adjust_cronjobs.php b/db/migrations/6.0.11_adjust_cronjobs.php
new file mode 100644
index 0000000..132885e
--- /dev/null
+++ b/db/migrations/6.0.11_adjust_cronjobs.php
@@ -0,0 +1,43 @@
+<?php
+return new class extends Migration
+{
+ private const ADJUSTMENTS = [
+ 'lib/cronjobs/purge_cache',
+ 'lib/cronjobs/check_admission',
+ 'lib/cronjobs/session_gc',
+ 'lib/cronjobs/cleanup_log',
+ 'lib/cronjobs/garbage_collector',
+ 'lib/cronjobs/send_mail_queue',
+ 'lib/cronjobs/remind_oer_upload',
+ 'lib/cronjobs/send_mail_notifications',
+ ];
+
+ public function description()
+ {
+ return 'Adjusts the class names for core cronjobs by losing the .class suffix';
+ }
+
+ protected function up()
+ {
+ $this->changeCronjobFilenames('.class.php', '.php');
+ }
+
+ protected function down()
+ {
+ $this->changeCronjobFilenames('.php', '.class.php');
+ }
+
+ private function changeCronjobFilenames(string $fromExtension, string $toExtension): void
+ {
+ $query = "UPDATE `cronjobs_tasks`
+ SET `filename` = :new
+ WHERE `filename` = :old";
+ $statement = DBManager::get()->prepare($query);
+
+ foreach (self::ADJUSTMENTS as $filename) {
+ $statement->bindValue(':new', $filename . $toExtension);
+ $statement->bindValue(':old', $filename . $fromExtension);
+ $statement->execute();
+ }
+ }
+};
diff --git a/db/migrations/6.0.1_remove_cronjobs_scheduling_once_and_priority.php b/db/migrations/6.0.1_remove_cronjobs_scheduling_once_and_priority.php
new file mode 100644
index 0000000..d3d95b0
--- /dev/null
+++ b/db/migrations/6.0.1_remove_cronjobs_scheduling_once_and_priority.php
@@ -0,0 +1,19 @@
+<?php
+ return new class extends Migration
+ {
+ protected function up()
+ {
+ $query = "ALTER TABLE `cronjobs_schedules`
+ DROP COLUMN `priority`,
+ DROP COLUMN `type`";
+ DBManager::get()->exec($query);
+ }
+
+ protected function down()
+ {
+ $query = "ALTER TABLE `cronjobs_schedules`
+ ADD COLUMN `priority` ENUM('low', 'normal', 'high') COLLATE `latin1_bin` DEFAULT NULL AFTER `parameters`,
+ ADD COLUMN `type` ENUM('periodic', 'once') COLLATE `latin1_bin` DEFAULT NULL AFTER `priority`";
+ DBManager::get()->exec($query);
+ }
+ };
diff --git a/db/migrations/6.0.2_captcha_by_altcha.php b/db/migrations/6.0.2_captcha_by_altcha.php
new file mode 100644
index 0000000..3749c71
--- /dev/null
+++ b/db/migrations/6.0.2_captcha_by_altcha.php
@@ -0,0 +1,39 @@
+<?php
+return new class extends Migration
+{
+ public function description(): string
+ {
+ return 'Creates a config entry for the key used for captchas and '
+ . 'db storage for solved challenges.';
+ }
+
+ protected function up(): void
+ {
+ $query = "INSERT INTO `config` (`field`, `value`, `type`, `range`, `mkdate`, `chdate`, `description`)
+ VALUES ('CAPTCHA_KEY', '', 'string', 'global', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), ?)";
+ DBManager::get()->execute($query, [
+ 'Speichert den für Captchas verwendeten Schlüssel (Wert leeren, um einen neuen zu generieren)',
+ ]);
+
+ $query = "CREATE TABLE `captcha_challenges` (
+ `challenge_id` int(11) NOT NULL AUTO_INCREMENT,
+ `salt` CHAR(32) COLLATE `latin1_bin` NOT NULL,
+ `number` INT(11) UNSIGNED NOT NULL,
+ `mkdate` INT(11) UNSIGNED NOT NULL,
+ PRIMARY KEY (`challenge_id`)
+ )";
+ DBManager::get()->exec($query);
+ }
+
+ protected function down(): void
+ {
+ $query = "DROP TABLE `captcha_challenges`";
+ DBManager::get()->exec($query);
+
+ $query = "DELETE `config`, `config_values`
+ FROM `config`
+ LEFT JOIN `config_values` USING (`field`)
+ WHERE `field` = 'CAPTCHA_KEY'";
+ DBManager::get()->exec($query);
+ }
+};
diff --git a/db/migrations/6.0.3_adjust_cache_configuration.php b/db/migrations/6.0.3_adjust_cache_configuration.php
new file mode 100644
index 0000000..2432e84
--- /dev/null
+++ b/db/migrations/6.0.3_adjust_cache_configuration.php
@@ -0,0 +1,38 @@
+<?php
+return new class extends Migration
+{
+ private const MAPPING = [
+ StudipDbCache::class => Studip\Cache\DbCache::class,
+ StudipFileCache::class => Studip\Cache\FileCache::class,
+ StudipMemcachedCache::class => Studip\Cache\MemcachedCache::class,
+ StudipRedisCache::class => Studip\Cache\RedisCache::class,
+ ];
+
+ public function description()
+ {
+ return 'Replaces the renamed cache classes in system configuration';
+ }
+
+ protected function up()
+ {
+ foreach (self::MAPPING as $old => $new) {
+ self::replaceCache($old, $new);
+ }
+ }
+
+ protected function down()
+ {
+ foreach (self::MAPPING as $old => $new) {
+ self::replaceCache($new, $old);
+ }
+ }
+
+ private function replaceCache(string $old, string $new): void
+ {
+ $query = "UPDATE `config_values`
+ SET `value` = JSON_REPLACE(`value`, '$.type', ?)
+ WHERE `field` = 'SYSTEMCACHE'
+ AND JSON_CONTAINS(`value`, JSON_QUOTE(?), '$.type')";
+ DBManager::get()->execute($query, [$new, $old]);
+ }
+};
diff --git a/db/migrations/6.0.4_adjust_cache_types_table.php b/db/migrations/6.0.4_adjust_cache_types_table.php
new file mode 100644
index 0000000..dfe0b27
--- /dev/null
+++ b/db/migrations/6.0.4_adjust_cache_types_table.php
@@ -0,0 +1,37 @@
+<?php
+return new class extends Migration
+{
+ private const MAPPING = [
+ StudipDbCache::class => Studip\Cache\DbCache::class,
+ StudipFileCache::class => Studip\Cache\FileCache::class,
+ StudipMemcachedCache::class => Studip\Cache\MemcachedCache::class,
+ StudipRedisCache::class => Studip\Cache\RedisCache::class,
+ ];
+
+ public function description()
+ {
+ return 'Replaces the renamed cache classes in table "cache_types"';
+ }
+
+ protected function up()
+ {
+ foreach (self::MAPPING as $old => $new) {
+ self::updateCacheTypesTable($old, $new);
+ }
+ }
+
+ protected function down()
+ {
+ foreach (self::MAPPING as $old => $new) {
+ self::updateCacheTypesTable($new, $old);
+ }
+ }
+
+ private function updateCacheTypesTable(string $old, string $new): void
+ {
+ $query = "UPDATE `cache_types`
+ SET `class_name` = ?
+ WHERE `class_name` = ?";
+ DBManager::get()->execute($query, [$new, $old]);
+ }
+};
diff --git a/db/migrations/6.0.5_remove_old_evaluation.php b/db/migrations/6.0.5_remove_old_evaluation.php
new file mode 100644
index 0000000..ff1a26e
--- /dev/null
+++ b/db/migrations/6.0.5_remove_old_evaluation.php
@@ -0,0 +1,33 @@
+<?php
+
+final class RemoveOldEvaluation extends Migration
+{
+ public function description()
+ {
+ return 'removes old evaluation tables';
+ }
+
+ public function up()
+ {
+ DBManager::get()->exec('DROP TABLE `eval`');
+ DBManager::get()->exec('DROP TABLE `eval_group_template`');
+ DBManager::get()->exec('DROP TABLE `eval_range`');
+ DBManager::get()->exec('DROP TABLE `eval_templates`');
+ DBManager::get()->exec('DROP TABLE `eval_templates_eval`');
+ DBManager::get()->exec('DROP TABLE `eval_templates_user`');
+ DBManager::get()->exec('DROP TABLE `eval_user`');
+ DBManager::get()->exec('DROP TABLE `evalanswer`');
+ DBManager::get()->exec('DROP TABLE `evalanswer_user`');
+ DBManager::get()->exec('DROP TABLE `evalgroup`');
+ DBManager::get()->exec('DROP TABLE `evalquestion`');
+
+ $query = "DELETE `config`, `config_values`
+ FROM `config`
+ LEFT JOIN `config_values` USING (`field`)
+ WHERE field IN (
+ 'EVAL_AUSWERTUNG_GRAPH_FORMAT',
+ 'EVAL_ENABLE', 'EVAL_AUSWERTUNG_CONFIG_ENABLE'
+ )";
+ DBManager::get()->exec($query);
+ }
+}
diff --git a/db/migrations/6.0.6_adjust_default_cache_name.php b/db/migrations/6.0.6_adjust_default_cache_name.php
new file mode 100644
index 0000000..ea71f35
--- /dev/null
+++ b/db/migrations/6.0.6_adjust_default_cache_name.php
@@ -0,0 +1,27 @@
+<?php
+/**
+ * @see https://gitlab.studip.de/studip/studip/-/issues/4196
+ */
+return new class extends Migration
+{
+ public function description()
+ {
+ return 'Adjust the default cache in table "config" as well"';
+ }
+
+ protected function up()
+ {
+ $query = "UPDATE `config`
+ SET `value` = JSON_REPLACE(`value`, '$.type', ?)
+ WHERE `field` = 'SYSTEMCACHE'";
+ DBManager::get()->execute($query, [Studip\Cache\DbCache::class]);
+ }
+
+ protected function down()
+ {
+ $query = "UPDATE `config`
+ SET `value` = JSON_REPLACE(`value`, '$.type', ?)
+ WHERE `field` = 'SYSTEMCACHE'";
+ DBManager::get()->execute($query, [StudipDbCache::class]);
+ }
+};
diff --git a/db/migrations/6.0.7_add_consecutive_flag_for_consultations.php b/db/migrations/6.0.7_add_consecutive_flag_for_consultations.php
new file mode 100644
index 0000000..9c45a2a
--- /dev/null
+++ b/db/migrations/6.0.7_add_consecutive_flag_for_consultations.php
@@ -0,0 +1,45 @@
+<?php
+return new class extends Migration
+{
+ public function description()
+ {
+ return 'Adds new flag "consecutive" to table "consultation_blocks" and stores previous slot information per slot';
+ }
+
+ protected function up()
+ {
+ $query = "ALTER TABLE `consultation_blocks`
+ ADD COLUMN `consecutive` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0' AFTER `lock_time`";
+ DBManager::get()->exec($query);
+
+ $query = "ALTER TABLE `consultation_slots`
+ ADD COLUMN `previous_slot_id` INT(11) UNSIGNED DEFAULT NULL AFTER `block_id`";
+ DBManager::get()->exec($query);
+
+ // THis will set the previous slot relation for all slots
+ $query = "UPDATE consultation_slots AS s0
+ JOIN consultation_slots AS s1
+ ON s1.slot_id = (
+ SELECT slot_id
+ FROM (SELECT slot_id, block_id, start_time FROM consultation_slots) AS s2
+ WHERE s2.block_id = s0.block_id
+ AND s2.start_time < s0.start_time
+ AND s2.slot_id != s0.slot_id
+ ORDER BY s2.start_time DESC
+ LIMIT 1
+ )
+ SET s0.previous_slot_id = s1.slot_id";
+ DBManager::get()->exec($query);
+ }
+
+ protected function down()
+ {
+ $query = "ALTER TABLE `consultation_slots`
+ DROP COLUMN `previous_slot_id`";
+ DBManager::get()->exec($query);
+
+ $query = "ALTER TABLE `consultation_blocks`
+ DROP COLUMN `consecutive`";
+ DBManager::get()->exec($query);
+ }
+};
diff --git a/db/migrations/6.0.8_add_max_show_admin_courses_config.php b/db/migrations/6.0.8_add_max_show_admin_courses_config.php
new file mode 100644
index 0000000..dbc1929
--- /dev/null
+++ b/db/migrations/6.0.8_add_max_show_admin_courses_config.php
@@ -0,0 +1,32 @@
+<?php
+
+final class AddMaxShowAdminCoursesConfig extends Migration
+{
+ public function description()
+ {
+ return 'Adds the configuration MAX_SHOW_ADMIN_COURSES, if it doesn\'t exist yet and set a default value.';
+ }
+
+ public function up()
+ {
+ DBManager::get()->exec("INSERT IGNORE INTO `config`
+ (`field`, `value`, `type`, `range`, `section`, `mkdate`, `chdate`, `description`)
+ VALUES
+ (
+ 'MAX_SHOW_ADMIN_COURSES',
+ 500,
+ 'integer',
+ 'global',
+ 'MeineVeranstaltungen',
+ UNIX_TIMESTAMP(),
+ UNIX_TIMESTAMP(),
+ 'Wie viele Veranstaltungen sollen auf der Admin-Veranstaltungsseite angezeigt werden.'
+ )"
+ );
+ }
+
+ public function down()
+ {
+ DBManager::get()->exec("DELETE FROM `config_values` WHERE `field` = 'MAX_SHOW_ADMIN_COURSES'");
+ }
+}
diff --git a/db/migrations/6.0.9_notification_positioning.php b/db/migrations/6.0.9_notification_positioning.php
new file mode 100644
index 0000000..d6693f3
--- /dev/null
+++ b/db/migrations/6.0.9_notification_positioning.php
@@ -0,0 +1,35 @@
+<?php
+class NotificationPositioning extends Migration
+{
+ public function description()
+ {
+ return 'Adds a personal config option to select the on-screen position of system notifications';
+ }
+
+ protected function up()
+ {
+ DBManager::get()->execute(
+ "INSERT IGNORE INTO `config` VALUES (:field, :value, :type, :range, :section, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), :desc)",
+ [
+ 'field' => 'SYSTEM_NOTIFICATIONS_PLACEMENT',
+ 'value' => 'topcenter',
+ 'type' => 'string',
+ 'range' => 'user',
+ 'section' => '',
+ 'desc' => 'Wo sollen Systembenachrichtigungen im Fenster angezeigt werden? Gültige Werte sind "topcenter" und "bottomright"'
+ ]
+ );
+ }
+
+ protected function down()
+ {
+ DBManager::get()->execute(
+ "DELETE FROM `config_values` WHERE `field` = :field",
+ ['field' => 'SYSTEM_NOTIFICATIONS_PLACEMENT']
+ );
+ DBManager::get()->execute(
+ "DELETE FROM `config` WHERE `field` = :field",
+ ['field' => 'SYSTEM_NOTIFICATIONS_PLACEMENT']
+ );
+ }
+};