From 927020820e4ae40825403a0db2c0aeeedc4c662c Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+github@gmail.com> Date: Fri, 11 Mar 2022 11:50:21 +0100 Subject: [PATCH] add migrations that fixes issues with clipboard tables, fixes #776 --- .../5.1.25_adjust_clipboard_tables.php | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 db/migrations/5.1.25_adjust_clipboard_tables.php 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 00000000000..837eec46049 --- /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); + } +} -- GitLab