diff --git a/administrator/components/com_admin/sql/others/mysql/utf8mb4-conversion-02.sql b/administrator/components/com_admin/sql/others/mysql/utf8mb4-conversion-02.sql index 6f4acb6ec7afa..7bb87849af6c6 100644 --- a/administrator/components/com_admin/sql/others/mysql/utf8mb4-conversion-02.sql +++ b/administrator/components/com_admin/sql/others/mysql/utf8mb4-conversion-02.sql @@ -1,37 +1,31 @@ -- -- Step 2 of the UTF-8 Multibyte (utf8mb4) conversion for MySQL -- --- Add back indexes previosly dropped with step 1, utf8mb4-conversion-01.sql, --- but with limited lenghts of columns, and then perform the conversions --- for utf8mb4. +-- Enlarge some database columns to avoid data losses, then convert all tables +-- to utf8mb4 or utf8, then set default character sets and collations for all +-- tables, then add back indexes previosly dropped with step 1, +-- utf8mb4-conversion-01.sql, but addd them back with limited lenghts of +-- columns. -- -- Do not rename this file or any other of the utf8mb4-conversion-*.sql -- files unless you want to change PHP code, too. -- --- This file here will the be processed with reporting exceptions. +-- IMPORTANT: When adding an index modification to this file for limiting the +-- length by which one or more columns go into that index, -- - +-- 1. remember to add the statement to drop the index to the file for step 1, +-- utf8mb4-conversion-01.sql, and -- --- Step 2.1: Limit indexes to first 100 so their max allowed lengths would not get exceeded with utf8mb4 +-- 2. check if the index is created created or modified in some old schema +-- update sql in an "ALTER TABLE" statement and limit the column length +-- there, too ("CREATE TABLE" is ok, no need to modify those). +-- +-- This file here will the be processed with reporting exceptions, in opposite +-- to the file for step 1. -- - -ALTER TABLE `#__banners` ADD KEY `idx_metakey_prefix` (`metakey_prefix`(100)); -ALTER TABLE `#__banner_clients` ADD KEY `idx_metakey_prefix` (`metakey_prefix`(100)); -ALTER TABLE `#__categories` ADD KEY `idx_path` (`path`(100)); -ALTER TABLE `#__categories` ADD KEY `idx_alias` (`alias`(100)); -ALTER TABLE `#__content_types` ADD KEY `idx_alias` (`type_alias`(100)); -ALTER TABLE `#__finder_links` ADD KEY `idx_title` (`title`(100)); -ALTER TABLE `#__menu` ADD KEY `idx_alias` (`alias`(100)); -ALTER TABLE `#__menu` ADD UNIQUE `idx_client_id_parent_id_alias_language` (`client_id`,`parent_id`,`alias`(100),`language`); -ALTER TABLE `#__redirect_links` ADD KEY `idx_old_url` (`old_url`(100)); -ALTER TABLE `#__tags` ADD KEY `idx_path` (`path`(100)); -ALTER TABLE `#__tags` ADD KEY `idx_alias` (`alias`(100)); -ALTER TABLE `#__ucm_content` ADD KEY `idx_alias` (`core_alias`(100)); -ALTER TABLE `#__ucm_content` ADD KEY `idx_title` (`core_title`(100)); -ALTER TABLE `#__ucm_content` ADD KEY `idx_content_type` (`core_type_alias`(100)); -- --- Step 2.2: Enlarge columns to avoid data loss on later conversion to utf8mb4 +-- Step 2.1: Enlarge columns to avoid data loss on later conversion to utf8mb4 -- ALTER TABLE `#__banners` MODIFY `alias` varchar(400) NOT NULL DEFAULT ''; @@ -52,7 +46,7 @@ ALTER TABLE `#__ucm_content` MODIFY `core_alias` varchar(400) NOT NULL DEFAULT ' ALTER TABLE `#__users` MODIFY `name` varchar(400) NOT NULL DEFAULT ''; -- --- Step 2.3: Convert all tables to utf8mb4 chracter set with utf8mb4_unicode_ci collation +-- Step 2.2: Convert all tables to utf8mb4 chracter set with utf8mb4_unicode_ci collation -- except #__finder_xxx tables, those will have utf8mb4_general_ci collation. -- Note: The database driver for mysql will change utf8mb4 to utf8 if utf8mb4 is not supported -- @@ -127,7 +121,7 @@ ALTER TABLE `#__utf8_conversion` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb ALTER TABLE `#__viewlevels` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; -- --- Step 2.4: Set collation to utf8mb4_bin for formerly utf8_bin collated columns +-- Step 2.3: Set collation to utf8mb4_bin for formerly utf8_bin collated columns -- and for the lang_code column of the languages table -- @@ -142,7 +136,7 @@ ALTER TABLE `#__tags` MODIFY `alias` varchar(400) CHARACTER SET utf8mb4 COLLATE ALTER TABLE `#__ucm_content` MODIFY `core_alias` varchar(400) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT ''; -- --- Step 2.5: Set default character set and collation for all tables +-- Step 2.4: Set default character set and collation for all tables -- ALTER TABLE `#__assets` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; @@ -213,3 +207,24 @@ ALTER TABLE `#__user_profiles` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_uni ALTER TABLE `#__user_usergroup_map` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE `#__utf8_conversion` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE `#__viewlevels` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- +-- Step 2.5: Limit indexes to first 100 so their max allowed lengths would not get exceeded with utf8mb4 +-- + +ALTER TABLE `#__banners` ADD KEY `idx_metakey_prefix` (`metakey_prefix`(100)); +ALTER TABLE `#__banner_clients` ADD KEY `idx_metakey_prefix` (`metakey_prefix`(100)); +ALTER TABLE `#__categories` ADD KEY `idx_path` (`path`(100)); +ALTER TABLE `#__categories` ADD KEY `idx_alias` (`alias`(100)); +ALTER TABLE `#__content_types` ADD KEY `idx_alias` (`type_alias`(100)); +ALTER TABLE `#__finder_links` ADD KEY `idx_title` (`title`(100)); +ALTER TABLE `#__menu` ADD KEY `idx_alias` (`alias`(100)); +ALTER TABLE `#__menu` ADD UNIQUE `idx_client_id_parent_id_alias_language` (`client_id`,`parent_id`,`alias`(100),`language`); +ALTER TABLE `#__menu` ADD KEY `idx_path` (`path`(100)); +ALTER TABLE `#__redirect_links` ADD KEY `idx_old_url` (`old_url`(100)); +ALTER TABLE `#__tags` ADD KEY `idx_path` (`path`(100)); +ALTER TABLE `#__tags` ADD KEY `idx_alias` (`alias`(100)); +ALTER TABLE `#__ucm_content` ADD KEY `idx_alias` (`core_alias`(100)); +ALTER TABLE `#__ucm_content` ADD KEY `idx_title` (`core_title`(100)); +ALTER TABLE `#__ucm_content` ADD KEY `idx_content_type` (`core_type_alias`(100)); +ALTER TABLE `#__users` ADD KEY `idx_name` (`name`(100)); diff --git a/administrator/components/com_admin/sql/updates/mysql/2.5.0-2011-12-24.sql b/administrator/components/com_admin/sql/updates/mysql/2.5.0-2011-12-24.sql index 8f7014c7014f2..53c4b413ac82c 100644 --- a/administrator/components/com_admin/sql/updates/mysql/2.5.0-2011-12-24.sql +++ b/administrator/components/com_admin/sql/updates/mysql/2.5.0-2011-12-24.sql @@ -1,3 +1,8 @@ ALTER TABLE `#__menu` DROP INDEX `idx_client_id_parent_id_alias`; -ALTER TABLE `#__menu` ADD UNIQUE `idx_client_id_parent_id_alias_language` ( `client_id` , `parent_id` , `alias` , `language` ); \ No newline at end of file +-- +-- The following statment had to be modified for utf8mb4, changing +-- `alias` to `alias`(100) +-- + +ALTER TABLE `#__menu` ADD UNIQUE `idx_client_id_parent_id_alias_language` ( `client_id` , `parent_id` , `alias`(100) , `language` ); \ No newline at end of file diff --git a/administrator/components/com_admin/sql/updates/mysql/3.5.1-2016-03-29.sql b/administrator/components/com_admin/sql/updates/mysql/3.5.1-2016-03-29.sql new file mode 100644 index 0000000000000..fc7067adc0d71 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/mysql/3.5.1-2016-03-29.sql @@ -0,0 +1,6 @@ +-- +-- Reset UTF-8 Multibyte (utf8mb4) or UTF-8 conversion status +-- to force a new conversion when updating from version 3.5.0 +-- + +UPDATE `#__utf8_conversion` SET converted = 0 WHERE (SELECT COUNT(*) FROM `#__extensions` WHERE `extension_id`=700 AND `manifest_cache` LIKE '%"version":"3.5.0"%') = 1; diff --git a/administrator/components/com_installer/models/database.php b/administrator/components/com_installer/models/database.php index ea580d539bf40..66ac0d92bc0d5 100644 --- a/administrator/components/com_installer/models/database.php +++ b/administrator/components/com_installer/models/database.php @@ -42,6 +42,10 @@ protected function populateState($ordering = null, $direction = null) $this->setState('extension_message', $app->getUserState('com_installer.extension_message')); $app->setUserState('com_installer.message', ''); $app->setUserState('com_installer.extension_message', ''); + + // Prepare the utf8mb4 conversion check table + $this->prepareUtf8mb4StatusTable(); + parent::populateState('name', 'asc'); } @@ -67,9 +71,16 @@ public function fix() $installer->deleteUnexistingFiles(); $this->fixDefaultTextFilters(); - // Finally make sure the database is converted to utf8mb4 or, if not suported - // by the server, compatible to it - $this->convertTablesToUtf8mb4(); + /* + * Finally, if the schema updates succeeded, make sure the database is + * converted to utf8mb4 or, if not suported by the server, compatible to it. + */ + $statusArray = $changeSet->getStatus(); + + if (count($statusArray['error']) == 0) + { + $this->convertTablesToUtf8mb4(); + } } /**