DROP TABLE IF EXISTS `woocommerceproduct`;
CREATE TABLE `woocommerceproduct` (
  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `wooCommerceInfoId` int(10) UNSIGNED NOT NULL,
  `wooProductId` int(10) NOT NULL,
  `type` varchar(20) NOT NULL DEFAULT '',
  `sku` varchar(50) NOT NULL DEFAULT '',
  `title` varchar(255) NOT NULL DEFAULT '',
  `permalink` varchar(255) NOT NULL DEFAULT '',
  `linkedProductId` int(10) UNSIGNED NULL,
  `active` tinyint(1) NOT NULL DEFAULT 1,
  `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `createdById` int(10) UNSIGNED NOT NULL DEFAULT 10 ,
  `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `updatedById` int(10) UNSIGNED NOT NULL DEFAULT 10,
  PRIMARY KEY (`id`),
  INDEX `linkedProductId` (`linkedProductId`) USING BTREE,
  INDEX `wooCommerceInfoId` (`wooCommerceInfoId`) USING BTREE,
  INDEX `wooProductId` (`wooProductId`) USING BTREE,
  INDEX `sku` (`sku`) USING BTREE,
  INDEX `title` (`title`) USING BTREE,
  INDEX `permalink` (`permalink`) USING BTREE,
  INDEX `active` (`active`) USING BTREE
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `woocommercecategory`;
CREATE TABLE `woocommercecategory` (
  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `wooCommerceInfoId` int(10) UNSIGNED NOT NULL,
  `wooCategoryId` int(10) NOT NULL,
  `name` varchar(50) NOT NULL DEFAULT '',
  `linkedCategoryId` int(10) UNSIGNED NULL,
  `active` tinyint(1) NOT NULL DEFAULT 1,
  `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `createdById` int(10) UNSIGNED NOT NULL DEFAULT 10 ,
  `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `updatedById` int(10) UNSIGNED NOT NULL DEFAULT 10,
  PRIMARY KEY (`id`),
  INDEX `linkedCategoryId` (`linkedCategoryId`) USING BTREE,
  INDEX `wooCommerceInfoId` (`wooCommerceInfoId`) USING BTREE,
  INDEX `wooCategoryId` (`wooCategoryId`) USING BTREE,
  INDEX `name` (`name`) USING BTREE,
  INDEX `active` (`active`) USING BTREE
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

ALTER TABLE `woocommerceinfo` ADD COLUMN `title` varchar(20) NOT NULL DEFAULT '' AFTER `storeId`;
ALTER TABLE `woocommerceinfo` ADD COLUMN `orderPrefix` varchar(4) NOT NULL DEFAULT '' AFTER `title`;
CREATE INDEX `title` ON `woocommerceinfo`(`title`) USING BTREE;
CREATE INDEX `orderPrefix` ON `woocommerceinfo`(`orderPrefix`) USING BTREE;

ALTER TABLE product
ADD FULLTEXT INDEX `FUL_TXT_NAME` (`name`);
