From f89a7ca4c04f6606754992cd1fd9d2245f4f8c29 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sun, 20 Nov 2016 13:14:32 +0100 Subject: [PATCH] Added worker script to handle column resizing --- com.woltlab.wcf/package.xml | 1 + com.woltlab.wcf/update.sql | 100 ------------ ...pdate_com.woltlab.wcf_3.0_columnLength.php | 147 ++++++++++++++++++ 3 files changed, 148 insertions(+), 100 deletions(-) create mode 100644 wcfsetup/install/files/acp/update_com.woltlab.wcf_3.0_columnLength.php diff --git a/com.woltlab.wcf/package.xml b/com.woltlab.wcf/package.xml index 01457f011f..44723feca8 100644 --- a/com.woltlab.wcf/package.xml +++ b/com.woltlab.wcf/package.xml @@ -57,6 +57,7 @@ update_part1.sql files.tar + acp/update_com.woltlab.wcf_3.0_columnLength.php update.sql acptemplates.tar diff --git a/com.woltlab.wcf/update.sql b/com.woltlab.wcf/update.sql index 416de9b2f8..b74b3dc79e 100644 --- a/com.woltlab.wcf/update.sql +++ b/com.woltlab.wcf/update.sql @@ -1,103 +1,3 @@ --- reduce column length to support utf8mb4_unicode_ci -UPDATE wcf1_acl_option SET optionName = SUBSTRING(optionName, 1, 191); -ALTER TABLE wcf1_acl_option CHANGE optionName optionName VARCHAR(191) NOT NULL; -UPDATE wcf1_acl_option SET categoryName = SUBSTRING(categoryName, 1, 191); -ALTER TABLE wcf1_acl_option CHANGE categoryName categoryName VARCHAR(191) NOT NULL; -UPDATE wcf1_acl_option_category SET categoryName = SUBSTRING(categoryName, 1, 191); -ALTER TABLE wcf1_acl_option_category CHANGE categoryName categoryName VARCHAR(191) NOT NULL; -UPDATE wcf1_acp_menu_item SET menuItem = SUBSTRING(menuItem, 1, 191); -ALTER TABLE wcf1_acp_menu_item CHANGE menuItem menuItem VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_acp_menu_item SET parentMenuItem = SUBSTRING(parentMenuItem, 1, 191); -ALTER TABLE wcf1_acp_menu_item CHANGE parentMenuItem parentMenuItem VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_acp_search_provider SET providerName = SUBSTRING(providerName, 1, 191); -ALTER TABLE wcf1_acp_search_provider CHANGE providerName providerName VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_acp_template SET templateName = SUBSTRING(templateName, 1, 191); -ALTER TABLE wcf1_acp_template CHANGE templateName templateName VARCHAR(191) NOT NULL; -UPDATE wcf1_bbcode SET bbcodeTag = SUBSTRING(bbcodeTag, 1, 191); -ALTER TABLE wcf1_bbcode CHANGE bbcodeTag bbcodeTag VARCHAR(191) NOT NULL; -UPDATE wcf1_clipboard_action SET actionClassName = SUBSTRING(actionClassName, 1, 191); -ALTER TABLE wcf1_clipboard_action CHANGE actionClassName actionClassName VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_core_object SET objectName = SUBSTRING(objectName, 1, 191); -ALTER TABLE wcf1_core_object CHANGE objectName objectName VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_import_mapping SET oldID = SUBSTRING(oldID, 1, 191); -ALTER TABLE wcf1_import_mapping CHANGE oldID oldID VARCHAR(191) NOT NULL; -UPDATE wcf1_language_category SET languageCategory = SUBSTRING(languageCategory, 1, 191); -ALTER TABLE wcf1_language_category CHANGE languageCategory languageCategory VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_language_item SET languageItem = SUBSTRING(languageItem, 1, 191); -ALTER TABLE wcf1_language_item CHANGE languageItem languageItem VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_object_type SET objectType = SUBSTRING(objectType, 1, 191); -ALTER TABLE wcf1_object_type CHANGE objectType objectType VARCHAR(191) NOT NULL; -UPDATE wcf1_object_type_definition SET definitionName = SUBSTRING(definitionName, 1, 191); -ALTER TABLE wcf1_object_type_definition CHANGE definitionName definitionName VARCHAR(191) NOT NULL; -UPDATE wcf1_option SET optionName = SUBSTRING(optionName, 1, 191); -ALTER TABLE wcf1_option CHANGE optionName optionName VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_option SET categoryName = SUBSTRING(categoryName, 1, 191); -ALTER TABLE wcf1_option CHANGE categoryName categoryName VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_option_category SET categoryName = SUBSTRING(categoryName, 1, 191); -ALTER TABLE wcf1_option_category CHANGE categoryName categoryName VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_option_category SET parentCategoryName = SUBSTRING(parentCategoryName, 1, 191); -ALTER TABLE wcf1_option_category CHANGE parentCategoryName parentCategoryName VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_package SET package = SUBSTRING(package, 1, 191); -ALTER TABLE wcf1_package CHANGE package package VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_package_exclusion SET excludedPackage = SUBSTRING(excludedPackage, 1, 191); -ALTER TABLE wcf1_package_exclusion CHANGE excludedPackage excludedPackage VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_package_installation_file_log SET filename = SUBSTRING(filename, 1, 191); -ALTER TABLE wcf1_package_installation_file_log CHANGE filename filename VARBINARY(765) NOT NULL; -UPDATE wcf1_package_installation_plugin SET pluginName = SUBSTRING(pluginName, 1, 191); -ALTER TABLE wcf1_package_installation_plugin CHANGE pluginName pluginName VARCHAR(191) NOT NULL; -UPDATE wcf1_package_update SET package = SUBSTRING(package, 1, 191); -ALTER TABLE wcf1_package_update CHANGE package package VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_package_update_exclusion SET excludedPackage = SUBSTRING(excludedPackage, 1, 191); -ALTER TABLE wcf1_package_update_exclusion CHANGE excludedPackage excludedPackage VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_package_update_requirement SET package = SUBSTRING(package, 1, 191); -ALTER TABLE wcf1_package_update_requirement CHANGE package package VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_search_keyword SET keyword = SUBSTRING(keyword, 1, 191); -ALTER TABLE wcf1_search_keyword CHANGE keyword keyword VARCHAR(191) NOT NULL; -UPDATE wcf1_session SET userAgent = SUBSTRING(userAgent, 1, 191); -ALTER TABLE wcf1_session CHANGE userAgent userAgent VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_session_virtual SET userAgent = SUBSTRING(userAgent, 1, 191); -ALTER TABLE wcf1_session_virtual CHANGE userAgent userAgent VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_smiley SET smileyCode = SUBSTRING(smileyCode, 1, 191); -ALTER TABLE wcf1_smiley CHANGE smileyCode smileyCode VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_spider SET spiderIdentifier = SUBSTRING(spiderIdentifier, 1, 191); -ALTER TABLE wcf1_spider CHANGE spiderIdentifier spiderIdentifier VARCHAR(191) DEFAULT ''; -UPDATE wcf1_tag SET name = SUBSTRING(name, 1, 191); -ALTER TABLE wcf1_tag CHANGE name name VARCHAR(191) NOT NULL; -UPDATE wcf1_template SET templateName = SUBSTRING(templateName, 1, 191); -ALTER TABLE wcf1_template CHANGE templateName templateName VARCHAR(191) NOT NULL; -UPDATE wcf1_user SET username = SUBSTRING(username, 1, 100); -ALTER TABLE wcf1_user CHANGE username username VARCHAR(100) NOT NULL DEFAULT ''; -UPDATE wcf1_user SET email = SUBSTRING(email, 1, 191); -ALTER TABLE wcf1_user CHANGE email email VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_user SET authData = SUBSTRING(authData, 1, 191); -ALTER TABLE wcf1_user CHANGE authData authData VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_user_collapsible_content SET objectID = SUBSTRING(objectID, 1, 191); -ALTER TABLE wcf1_user_collapsible_content CHANGE objectID objectID VARCHAR(191) NOT NULL; -UPDATE wcf1_user_group_option SET optionName = SUBSTRING(optionName, 1, 191); -ALTER TABLE wcf1_user_group_option CHANGE optionName optionName VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_user_group_option SET categoryName = SUBSTRING(categoryName, 1, 191); -ALTER TABLE wcf1_user_group_option CHANGE categoryName categoryName VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_user_group_option_category SET categoryName = SUBSTRING(categoryName, 1, 191); -ALTER TABLE wcf1_user_group_option_category CHANGE categoryName categoryName VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_user_group_option_category SET parentCategoryName = SUBSTRING(parentCategoryName, 1, 191); -ALTER TABLE wcf1_user_group_option_category CHANGE parentCategoryName parentCategoryName VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_user_menu_item SET menuItem = SUBSTRING(menuItem, 1, 191); -ALTER TABLE wcf1_user_menu_item CHANGE menuItem menuItem VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_user_menu_item SET parentMenuItem = SUBSTRING(parentMenuItem, 1, 191); -ALTER TABLE wcf1_user_menu_item CHANGE parentMenuItem parentMenuItem VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_user_notification_event SET eventName = SUBSTRING(eventName, 1, 191); -ALTER TABLE wcf1_user_notification_event CHANGE eventName eventName VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_user_option SET optionName = SUBSTRING(optionName, 1, 191); -ALTER TABLE wcf1_user_option CHANGE optionName optionName VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_user_option SET categoryName = SUBSTRING(categoryName, 1, 191); -ALTER TABLE wcf1_user_option CHANGE categoryName categoryName VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_user_option_category SET categoryName = SUBSTRING(categoryName, 1, 191); -ALTER TABLE wcf1_user_option_category CHANGE categoryName categoryName VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_user_option_category SET parentCategoryName = SUBSTRING(parentCategoryName, 1, 191); -ALTER TABLE wcf1_user_option_category CHANGE parentCategoryName parentCategoryName VARCHAR(191) NOT NULL DEFAULT ''; -UPDATE wcf1_user_profile_menu_item SET menuItem = SUBSTRING(menuItem, 1, 191); -ALTER TABLE wcf1_user_profile_menu_item CHANGE menuItem menuItem VARCHAR(191) NOT NULL; - -- other changes DROP TABLE IF EXISTS wcf1_acl_simple_to_user; CREATE TABLE wcf1_acl_simple_to_user ( diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_3.0_columnLength.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_3.0_columnLength.php new file mode 100644 index 0000000000..bb229d0da3 --- /dev/null +++ b/wcfsetup/install/files/acp/update_com.woltlab.wcf_3.0_columnLength.php @@ -0,0 +1,147 @@ + + * @package WoltLabSuite\Core + */ +$data = <<getVar('__wcfUpdateRebuildTables'); +if ($rebuildData === null) { + $rebuildData = [ + 'i' => 0, + 'max' => $lines / 2 + ]; +} + +$i = $rebuildData['i']; + +// truncate values +$statement = WCF::getDB()->prepareStatement($lines[$i * 2]); +$statement->execute(); + +// decrease column width +$statement = WCF::getDB()->prepareStatement($lines[$i * 2 + 1]); +$statement->execute(); + +$rebuildData['i']++; + +if ($rebuildData['i'] === $rebuildData['max']) { + WCF::getSession()->unregister('__wcfUpdateRebuildTables'); +} +else { + WCF::getSession()->register('__wcfUpdateRebuildTables', $rebuildData); + + // call this script again + throw new SplitNodeException(); +} -- 2.20.1