RE: Liferay 6.2 CE GA5 Database Migration from SQL Server to MySQL

Mashuk Choudhury, modified 7 Years ago. Junior Member Posts: 33 Join Date: 1/31/14 Recent Posts
Hi,

We are migrating a Liferay instance (6.2 CE GA5) which is currently running off MS SQL Server 2012 and into MySQL 5.6. MySQL Workbench has a migration tool which we used but we are getting errors around Index sizes, see below:
ERROR: Error executing 'CREATE TABLE IF NOT EXISTS `SchemaName`.`JournalContentSearch` (
      `contentSearchId` BIGINT NOT NULL,
      `groupId` BIGINT NULL,
      `companyId` BIGINT NULL,
      `privateLayout` SMALLINT NULL,
      `layoutId` BIGINT NULL,
      `portletId` VARCHAR(200) CHARACTER SET 'utf8mb4' NULL,
      `articleId` VARCHAR(75) CHARACTER SET 'utf8mb4' NULL,
      INDEX `IX_9207CB31` (`articleId` ASC),
      INDEX `IX_6838E427` (`groupId` ASC, `articleId` ASC),
      INDEX `IX_20962903` (`groupId` ASC, `privateLayout` ASC),
      INDEX `IX_7CC7D73E` (`groupId` ASC, `privateLayout` ASC, `articleId` ASC),
      INDEX `IX_B3B318DC` (`groupId` ASC, `privateLayout` ASC, `layoutId` ASC),
      INDEX `IX_7ACC74C9` (`groupId` ASC, `privateLayout` ASC, `layoutId` ASC, `portletId` ASC),
      UNIQUE INDEX `IX_C3AA93B8` (`groupId` ASC, `privateLayout` ASC, `layoutId` ASC, `portletId` ASC, `articleId` ASC),
      INDEX `IX_8DAF8A35` (`portletId` ASC))'
    Index column size too large. The maximum column size is 767 bytes..
    SQL Error: 1709
​​​​​​​Since the characterset is utf8mb4, each character is using 4 bytes per character and with the portletid set to VARCHAR(200), that is exceeding the limit. 
I have experimented by changing the character limits, which does migrate the DB, but then Liferay does not start.


Any ideas on what I should try next?

Thanks
Mashuk
thumbnail
Alberto Chaparro, modified 7 Years ago. Liferay Master Posts: 560 Join Date: 4/25/11 Recent Posts
Hi Mashuk,

As far as I remember in Mysql 5.6, you have to modify each create table statement to designate for UTF8MB4. This constraint forces you to change all the create table statements.

Could you use Mysql 5.7 where this restriction is not needed?

If the problem persist, can you try to remove the problematic indexes before doing the migration and try to recreate them (with a limitation for varchar fields in the final database)?

I hope it helps.
Mashuk Choudhury, modified 7 Years ago. Junior Member Posts: 33 Join Date: 1/31/14 Recent Posts

Hi Alberto,

 

I managed to resolve the issue by setting a character limit on the troublesome index, which in my case was portletId.

 

ERROR: Error executing 'CREATE TABLE IF NOT EXISTS `SchemaName`.`JournalContentSearch` (
      `contentSearchId` BIGINT NOT NULL,
      `groupId` BIGINT NULL,
      `companyId` BIGINT NULL,
      `privateLayout` SMALLINT NULL,
      `layoutId` BIGINT NULL,
      `portletId` VARCHAR(200) CHARACTER SET 'utf8mb4' NULL,
      `articleId` VARCHAR(75) CHARACTER SET 'utf8mb4' NULL,
      INDEX `IX_9207CB31` (`articleId` ASC),
      INDEX `IX_6838E427` (`groupId` ASC, `articleId` ASC),
      INDEX `IX_20962903` (`groupId` ASC, `privateLayout` ASC),
      INDEX `IX_7CC7D73E` (`groupId` ASC, `privateLayout` ASC, `articleId` ASC),
      INDEX `IX_B3B318DC` (`groupId` ASC, `privateLayout` ASC, `layoutId` ASC),
      INDEX `IX_7ACC74C9` (`groupId` ASC, `privateLayout` ASC, `layoutId` ASC, `portletId`(190) ASC),
      UNIQUE INDEX `IX_C3AA93B8` (`groupId` ASC, `privateLayout` ASC, `layoutId` ASC, `portletId`(190) ASC, `articleId` ASC),
      INDEX `IX_8DAF8A35` (`portletId`(190) ASC))'
    Index column size too large. The maximum column size is 767 bytes..
    SQL Error: 1709

Thanks

Mashuk