aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+github@gmail.com>2022-03-11 11:50:21 +0100
committerJan-Hendrik Willms <tleilax+studip@gmail.com>2022-03-11 11:07:57 +0000
commit927020820e4ae40825403a0db2c0aeeedc4c662c (patch)
tree46ba7613ac3ec1222ba3b7cc57811df4aac0fa3a
parent7f1bdc86e4daf7ca48f47dc4daaa4a0f4b2350c5 (diff)
add migrations that fixes issues with clipboard tables, fixes #776
-rw-r--r--db/migrations/5.1.25_adjust_clipboard_tables.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/db/migrations/5.1.25_adjust_clipboard_tables.php b/db/migrations/5.1.25_adjust_clipboard_tables.php
new file mode 100644
index 0000000..837eec4
--- /dev/null
+++ b/db/migrations/5.1.25_adjust_clipboard_tables.php
@@ -0,0 +1,36 @@
+<?php
+final class AdjustClipboardTables extends Migration
+{
+ public function description()
+ {
+ return 'Alter clipboard tables by fixing indices, column types and collations';
+ }
+
+ protected function up()
+ {
+ $query = "ALTER TABLE `clipboards`
+ CHANGE COLUMN `name` `name` VARCHAR(256) NOT NULL DEFAULT '',
+ ADD INDEX `user_id` (`user_id`)";
+ DBManager::get()->exec($query);
+
+ $query = "ALTER TABLE `clipboard_items`
+ CHANGE COLUMN `range_id` `range_id` CHAR(32) CHARACTER SET latin1 COLLATE `latin1_bin` NOT NULL,
+ ADD INDEX `clipboard_id` (`clipboard_id`),
+ ADD INDEX `range` (`range_id`,`range_type`)";
+ DBManager::get()->exec($query);
+ }
+
+ protected function down()
+ {
+ $query = "ALTER TABLE `clipboard_items`
+ CHANGE COLUMN `range_id` `range_id` VARCHAR(98) CHARACTER SET latin1 COLLATE `latin1_bin` NOT NULL,
+ DROP INDEX `clipboard_id`,
+ DROP INDEX `range`";
+ DBManager::get()->exec($query);
+
+ $query = "ALTER TABLE `clipboards`
+ CHANGE COLUMN `name` `name` VARCHAR(256) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
+ DROP INDEX `user_id`";
+ DBManager::get()->exec($query);
+ }
+}