Quantcast
Channel: Topic Tag: MySQL | WordPress.org
Viewing all articles
Browse latest Browse all 5527

jjbte on "Error Creating woocommerce_tax_rate_locations table"

$
0
0

Now that WordPress is using utf8mb4 collation by default, there is a problem with the creation of the woocommerce_tax_rate_locations table upon WooCommerce plugin activation. The table is not created due to the following error:

WordPress database error Specified key was too long; max key length is 1000 bytes for query
CREATE TABLE wp_woocommerce_tax_rate_locations (
  location_id bigint(20) NOT NULL auto_increment,
  location_code varchar(255) NOT NULL,
  tax_rate_id bigint(20) NOT NULL,
  location_type varchar(40) NOT NULL,
  PRIMARY KEY  (location_id),
  KEY tax_rate_id (tax_rate_id),
  KEY location_type (location_type),
  KEY location_type_code (location_type,location_code)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci

To get the table to install, I have to perform the installation manually with the following modified code (changes size of location_code key to 191):

CREATE TABLE IF NOT EXISTS wp_woocommerce_tax_rate_locations (
  location_id bigint(20) NOT NULL AUTO_INCREMENT,
  location_code varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  tax_rate_id bigint(20) NOT NULL,
  location_type varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (location_id),
  KEY tax_rate_id (tax_rate_id),
  KEY location_type (location_type),
  KEY location_type_code (location_type,location_code (191))
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

Another option would be to force another collation, such as utf8_unicode_ci or utf8_general_ci.

I hope there are plans to address this issue in the next update.

https://wordpress.org/plugins/woocommerce/


Viewing all articles
Browse latest Browse all 5527

Trending Articles