aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/migrations/5.4.23_fix_files_search_index_pk.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/db/migrations/5.4.23_fix_files_search_index_pk.php b/db/migrations/5.4.23_fix_files_search_index_pk.php
new file mode 100644
index 0000000..874e245
--- /dev/null
+++ b/db/migrations/5.4.23_fix_files_search_index_pk.php
@@ -0,0 +1,30 @@
+<?php
+/**
+ * @see https://gitlab.studip.de/studip/studip/-/issues/6184
+ */
+final class FixFilesSearchIndexPk extends Migration
+{
+ use DatabaseMigrationTrait;
+
+ public function description()
+ {
+ return 'Add PK id to files_search_index and remove explicit FTS_DOC_ID if present';
+ }
+
+ protected function up()
+ {
+ if ($this->columnExists('files_search_index', 'FTS_DOC_ID')) {
+ DBManager::get()->exec(
+ "ALTER TABLE `files_search_index`
+ DROP COLUMN `FTS_DOC_ID`,
+ ADD COLUMN `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST"
+ );
+ } else {
+ DBManager::get()->exec(
+ "ALTER TABLE `files_search_index`
+ ADD COLUMN `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST"
+ );
+ }
+
+ }
+}