11--
22-- Step 2 of the UTF-8 Multibyte (utf8mb4) conversion for MySQL
33--
4- -- Add back indexes previosly dropped with step 1, utf8mb4-conversion-01.sql,
5- -- but with limited lenghts of columns, and then perform the conversions
6- -- for utf8mb4.
4+ -- Enlarge some database columns to avoid data losses, then convert all tables
5+ -- to utf8mb4 or utf8, then set default character sets and collations for all
6+ -- tables, then add back indexes previosly dropped with step 1,
7+ -- utf8mb4-conversion-01.sql, but addd them back with limited lenghts of
8+ -- columns.
79--
810-- Do not rename this file or any other of the utf8mb4-conversion-*.sql
911-- files unless you want to change PHP code, too.
1012--
11- -- This file here will the be processed with reporting exceptions.
13+ -- IMPORTANT: When adding an index modification to this file for limiting the
14+ -- length by which one or more columns go into that index,
1215--
13-
16+ -- 1. remember to add the statement to drop the index to the file for step 1,
17+ -- utf8mb4-conversion-01.sql, and
1418--
15- -- Step 2.1: Limit indexes to first 100 so their max allowed lengths would not get exceeded with utf8mb4
19+ -- 2. check if the index is created created or modified in some old schema
20+ -- update sql in an "ALTER TABLE" statement and limit the column length
21+ -- there, too ("CREATE TABLE" is ok, no need to modify those).
22+ --
23+ -- This file here will the be processed with reporting exceptions, in opposite
24+ -- to the file for step 1.
1625--
17-
18- ALTER TABLE ` #__banners` ADD KEY ` idx_metakey_prefix` (` metakey_prefix` (100 ));
19- ALTER TABLE ` #__banner_clients` ADD KEY ` idx_metakey_prefix` (` metakey_prefix` (100 ));
20- ALTER TABLE ` #__categories` ADD KEY ` idx_path` (` path` (100 ));
21- ALTER TABLE ` #__categories` ADD KEY ` idx_alias` (` alias` (100 ));
22- ALTER TABLE ` #__content_types` ADD KEY ` idx_alias` (` type_alias` (100 ));
23- ALTER TABLE ` #__finder_links` ADD KEY ` idx_title` (` title` (100 ));
24- ALTER TABLE ` #__menu` ADD KEY ` idx_alias` (` alias` (100 ));
25- ALTER TABLE ` #__menu` ADD UNIQUE ` idx_client_id_parent_id_alias_language` (` client_id` ,` parent_id` ,` alias` (100 ),` language` );
26- ALTER TABLE ` #__redirect_links` ADD KEY ` idx_old_url` (` old_url` (100 ));
27- ALTER TABLE ` #__tags` ADD KEY ` idx_path` (` path` (100 ));
28- ALTER TABLE ` #__tags` ADD KEY ` idx_alias` (` alias` (100 ));
29- ALTER TABLE ` #__ucm_content` ADD KEY ` idx_alias` (` core_alias` (100 ));
30- ALTER TABLE ` #__ucm_content` ADD KEY ` idx_title` (` core_title` (100 ));
31- ALTER TABLE ` #__ucm_content` ADD KEY ` idx_content_type` (` core_type_alias` (100 ));
3226
3327--
34- -- Step 2.2 : Enlarge columns to avoid data loss on later conversion to utf8mb4
28+ -- Step 2.1 : Enlarge columns to avoid data loss on later conversion to utf8mb4
3529--
3630
3731ALTER TABLE ` #__banners` MODIFY ` alias` varchar (400 ) NOT NULL DEFAULT ' ' ;
@@ -49,9 +43,10 @@ ALTER TABLE `#__tags` MODIFY `alias` varchar(400) NOT NULL DEFAULT '';
4943ALTER TABLE ` #__ucm_content` MODIFY ` core_type_alias` varchar (400 ) NOT NULL DEFAULT ' ' COMMENT ' FK to the content types table' ;
5044ALTER TABLE ` #__ucm_content` MODIFY ` core_title` varchar (400 ) NOT NULL ;
5145ALTER TABLE ` #__ucm_content` MODIFY ` core_alias` varchar (400 ) NOT NULL DEFAULT ' ' ;
46+ ALTER TABLE ` #__users` MODIFY ` name` varchar (400 ) NOT NULL DEFAULT ' ' ;
5247
5348--
54- -- Step 2.3 : Convert all tables to utf8mb4 chracter set with utf8mb4_unicode_ci collation
49+ -- Step 2.2 : Convert all tables to utf8mb4 chracter set with utf8mb4_unicode_ci collation
5550-- except #__finder_xxx tables, those will have utf8mb4_general_ci collation.
5651-- Note: The database driver for mysql will change utf8mb4 to utf8 if utf8mb4 is not supported
5752--
@@ -126,7 +121,7 @@ ALTER TABLE `#__utf8_conversion` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb
126121ALTER TABLE ` #__viewlevels` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
127122
128123--
129- -- Step 2.4 : Set collation to utf8mb4_bin for formerly utf8_bin collated columns
124+ -- Step 2.3 : Set collation to utf8mb4_bin for formerly utf8_bin collated columns
130125-- and for the lang_code column of the languages table
131126--
132127
@@ -141,7 +136,7 @@ ALTER TABLE `#__tags` MODIFY `alias` varchar(400) CHARACTER SET utf8mb4 COLLATE
141136ALTER TABLE ` #__ucm_content` MODIFY ` core_alias` varchar (400 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT ' ' ;
142137
143138--
144- -- Step 2.5 : Set default character set and collation for all tables
139+ -- Step 2.4 : Set default character set and collation for all tables
145140--
146141
147142ALTER TABLE ` #__assets` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
@@ -212,3 +207,24 @@ ALTER TABLE `#__user_profiles` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_uni
212207ALTER TABLE ` #__user_usergroup_map` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
213208ALTER TABLE ` #__utf8_conversion` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
214209ALTER TABLE ` #__viewlevels` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
210+
211+ --
212+ -- Step 2.5: Limit indexes to first 100 so their max allowed lengths would not get exceeded with utf8mb4
213+ --
214+
215+ ALTER TABLE ` #__banners` ADD KEY ` idx_metakey_prefix` (` metakey_prefix` (100 ));
216+ ALTER TABLE ` #__banner_clients` ADD KEY ` idx_metakey_prefix` (` metakey_prefix` (100 ));
217+ ALTER TABLE ` #__categories` ADD KEY ` idx_path` (` path` (100 ));
218+ ALTER TABLE ` #__categories` ADD KEY ` idx_alias` (` alias` (100 ));
219+ ALTER TABLE ` #__content_types` ADD KEY ` idx_alias` (` type_alias` (100 ));
220+ ALTER TABLE ` #__finder_links` ADD KEY ` idx_title` (` title` (100 ));
221+ ALTER TABLE ` #__menu` ADD KEY ` idx_alias` (` alias` (100 ));
222+ ALTER TABLE ` #__menu` ADD UNIQUE ` idx_client_id_parent_id_alias_language` (` client_id` ,` parent_id` ,` alias` (100 ),` language` );
223+ ALTER TABLE ` #__menu` ADD KEY ` idx_path` (` path` (100 ));
224+ ALTER TABLE ` #__redirect_links` ADD KEY ` idx_old_url` (` old_url` (100 ));
225+ ALTER TABLE ` #__tags` ADD KEY ` idx_path` (` path` (100 ));
226+ ALTER TABLE ` #__tags` ADD KEY ` idx_alias` (` alias` (100 ));
227+ ALTER TABLE ` #__ucm_content` ADD KEY ` idx_alias` (` core_alias` (100 ));
228+ ALTER TABLE ` #__ucm_content` ADD KEY ` idx_title` (` core_title` (100 ));
229+ ALTER TABLE ` #__ucm_content` ADD KEY ` idx_content_type` (` core_type_alias` (100 ));
230+ ALTER TABLE ` #__users` ADD KEY ` idx_name` (` name` (100 ));
0 commit comments