In database_mysql.md the CONVERT TO CHARSET only updates tables with CHAR columns

In https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/install/database_mysql.md it says:

SELECT CONCAT('ALTER TABLE `', TABLE_NAME,'` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;')
  AS 'Copy & run these SQL statements:' FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA="gitlabhq_production" AND TABLE_COLLATION != "utf8mb4_general_ci" AND TABLE_TYPE="BASE TABLE";

After running that, some tables which lack a CHAR column are not affected.

For instance, because boards contains no char/text columns, its state was unaffected:

CREATE TABLE `boards` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `project_id` int(11) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `index_boards_on_project_id` (`project_id`),
  CONSTRAINT `fk_rails_f15266b5f9` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=68 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC

Solution

Also run this:

SELECT CONCAT('ALTER TABLE `', TABLE_NAME,'` default CHARSET utf8mb4 COLLATE utf8mb4_general_ci;')
  AS 'Copy & run these SQL statements:' FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA="gitlabhq_production" AND TABLE_COLLATION != "utf8mb4_general_ci" AND TABLE_TYPE="BASE TABLE";

Which yields -- among others:

ALTER TABLE `boards` default CHARSET utf8mb4 COLLATE utf8mb4_general_ci;

Now the table has the correct default charset/collation in case a text/char column is added at a later stage:

CREATE TABLE `boards` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `project_id` int(11) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `index_boards_on_project_id` (`project_id`),
  CONSTRAINT `fk_rails_f15266b5f9` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=68 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC
Assignee Loading
Time tracking Loading