aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+studip@gmail.com>2025-11-20 14:23:19 +0100
committerJan-Hendrik Willms <tleilax+studip@gmail.com>2025-11-20 14:23:19 +0100
commit091e85611b2bc83d8d760bcd209dcc7306c85dae (patch)
tree70e44c9971530c5081ff66ff81bff4e980db68fe
parent21a45ae19c5ec632236c86f53f24c9b0a1666bb8 (diff)
fix migrations and add migration that aligns wiki_pages.name and wiki_versions.name, fixes #6048
Closes #6048 Merge request studip/studip!4616
-rw-r--r--db/migrations/5.5.23_modernize_wiki.php14
-rw-r--r--db/migrations/5.5.25_alter_calendar_tables.php12
-rw-r--r--db/migrations/5.5.36_fix_wiki_versions_name_length.php18
-rw-r--r--db/migrations/6.0.34_add_dummy_teacher.php13
4 files changed, 43 insertions, 14 deletions
diff --git a/db/migrations/5.5.23_modernize_wiki.php b/db/migrations/5.5.23_modernize_wiki.php
index 75e26d3..cfa3b89 100644
--- a/db/migrations/5.5.23_modernize_wiki.php
+++ b/db/migrations/5.5.23_modernize_wiki.php
@@ -34,7 +34,7 @@ final class ModernizeWiki extends Migration
CREATE TABLE `wiki_versions` (
`version_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`page_id` int(11) unsigned NOT NULL,
- `name` varchar(128) NOT NULL,
+ `name` varchar(255) NOT NULL,
`content` text DEFAULT NULL,
`user_id` char(32) COLLATE `latin1_bin` NOT NULL,
`mkdate` bigint(20) NOT NULL,
@@ -53,8 +53,8 @@ final class ModernizeWiki extends Migration
IF(`wiki_page_config`.`read_restricted` > 0, 'tutor', 'all'),
IF(`wiki_page_config`.`edit_restricted` > 0 OR (`wiki_page_config`.`edit_restricted` IS NULL AND `config_values`.`value` IS NOT NULL), 'tutor', 'all'),
`wiki`.`user_id`,
- `wiki`.`chdate`,
- IFNULL(`wiki`.`mkdate`, UNIX_TIMESTAMP())
+ COALESCE(`wiki`.`chdate`, `wiki`.`mkdate`, UNIX_TIMESTAMP()),
+ COALESCE(`wiki`.`mkdate`, UNIX_TIMESTAMP())
FROM `wiki`
INNER JOIN (
SELECT `wiki`.`range_id`, `wiki`.`keyword`, MAX(`version`) AS `version`
@@ -176,8 +176,8 @@ final class ModernizeWiki extends Migration
DBManager::get()->exec("
INSERT INTO `wiki_pages` (`range_id`, `name`, `content`, `parent_id`, `read_permission`, `write_permission`, `user_id`, `chdate`, `mkdate`)
SELECT `superwiki_pages`.`seminar_id`,
- `superwiki_pages`.`name`,
- `superwiki_pages`.`content`,
+ CONVERT(`superwiki_pages`.`name` USING utf8mb4),
+ CONVERT(`superwiki_pages`.`content` USING utf8mb4),
NULL,
`superwiki_pages`.`read_permission`,
`superwiki_pages`.`write_permission`,
@@ -189,8 +189,8 @@ final class ModernizeWiki extends Migration
DBManager::get()->exec("
INSERT INTO `wiki_versions` (`page_id`, `name`, `content`, `user_id`, `mkdate`)
SELECT `wiki_pages`.`page_id`,
- `superwiki_versions`.`name`,
- `superwiki_versions`.`content`,
+ CONVERT(`superwiki_versions`.`name` USING utf8mb4),
+ CONVERT(`superwiki_versions`.`content` USING utf8mb4),
`superwiki_versions`.`last_author`,
`superwiki_versions`.`chdate`
FROM `superwiki_versions`
diff --git a/db/migrations/5.5.25_alter_calendar_tables.php b/db/migrations/5.5.25_alter_calendar_tables.php
index e9bf455..9b64d08 100644
--- a/db/migrations/5.5.25_alter_calendar_tables.php
+++ b/db/migrations/5.5.25_alter_calendar_tables.php
@@ -23,6 +23,13 @@ class AlterCalendarTables extends Migration
WHERE `day` <> ''"
);
+ // Prevent errors if column count is null
+ $db->exec(
+ "UPDATE `calendar_dates`
+ SET `count` = 0
+ WHERE `count` IS NULL"
+ );
+
$db->exec(
"ALTER TABLE `calendar_dates`
DROP COLUMN `ts`,
@@ -180,7 +187,10 @@ class AlterCalendarTables extends Migration
$group_member_stmt = $db->prepare(
"INSERT INTO `contact_group_items`
(`group_id`, `user_id`, `mkdate`, `chdate`)
- SELECT `contact_groups`.`id` AS group_id, `user_id`, `statusgruppe_user`.`mkdate` as mkdate, `statusgruppe_user`.`mkdate` AS chdate
+ SELECT `contact_groups`.`id` AS group_id,
+ `user_id`,
+ COALESCE(`statusgruppe_user`.`mkdate`, UNIX_TIMESTAMP()) as mkdate,
+ COALESCE(`statusgruppe_user`.`mkdate`, UNIX_TIMESTAMP()) AS chdate
FROM `statusgruppe_user`
INNER JOIN `contact_groups`
ON `statusgruppe_user`.`statusgruppe_id` = `contact_groups`.`old_group_id`
diff --git a/db/migrations/5.5.36_fix_wiki_versions_name_length.php b/db/migrations/5.5.36_fix_wiki_versions_name_length.php
new file mode 100644
index 0000000..ead5015
--- /dev/null
+++ b/db/migrations/5.5.36_fix_wiki_versions_name_length.php
@@ -0,0 +1,18 @@
+<?php
+/**
+ * @see https://gitlab.studip.de/studip/studip/-/issues/6048
+ */
+final class FixWikiVersionsNameLength extends Migration
+{
+ public function description()
+ {
+ return 'Changes the length of column wiki_versions.name to match wiki_pages.name';
+ }
+
+ protected function up()
+ {
+ $query = "ALTER TABLE `wiki_versions`
+ MODIFY COLUMN `name` VARCHAR(255) NOT NULL";
+ DBManager::get()->exec($query);
+ }
+}
diff --git a/db/migrations/6.0.34_add_dummy_teacher.php b/db/migrations/6.0.34_add_dummy_teacher.php
index d987dc2..ac34f28 100644
--- a/db/migrations/6.0.34_add_dummy_teacher.php
+++ b/db/migrations/6.0.34_add_dummy_teacher.php
@@ -19,12 +19,13 @@ class AddDummyTeacher extends Migration
DBManager::get()->execute(
"INSERT INTO `auth_user_md5` (user_id, username, perms, Vorname, Nachname, visible) VALUES (:user_id, :username, :perms, :Vorname, :Nachname, :visible)",
[
- 'user_id' => $user_id,
- 'username' => 'N.N.',
- 'perms' => 'dozent',
- 'Vorname' => 'N.',
- 'Nachname' => 'N.',
- 'visible' => 'never'
+ 'user_id' => $user_id,
+ 'username' => 'N.N.',
+ 'perms' => 'dozent',
+ 'Vorname' => 'N.',
+ 'Nachname' => 'N.',
+ 'visible' => 'never',
+ 'validation_key' => '',
]
);
}