ALTER TABLE `ebayaccountinfo` ADD COLUMN `marketplaceId` varchar(4) NOT NULL DEFAULT '' AFTER `storeId`;
ALTER TABLE `ebayaccountinfo` ADD INDEX(`marketplaceId`);
ALTER TABLE `ebayaccountinfo` ADD COLUMN `marketplaceCountryCode` varchar(2) NOT NULL DEFAULT '' AFTER `marketplaceId`;
ALTER TABLE `ebayaccountinfo` ADD INDEX(`marketplaceCountryCode`);

CREATE TABLE `ebaycategory` (
    `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
    `marketplaceId` int(5) UNSIGNED NOT NULL,
    `categoryId` int(10) UNSIGNED NOT NULL,
    `parentId` int(10) UNSIGNED NULL,
    `title` varchar(50) NOT NULL DEFAULT '',
    `path` varchar(255) NOT NULL DEFAULT '',
    `hasChild` tinyint(1) NOT NULL DEFAULT 0,
    `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 `marketplaceId` (`marketplaceId`) USING BTREE,
    INDEX `categoryId` (`categoryId`) USING BTREE,
    INDEX `parentId` (`parentId`) USING BTREE,
    INDEX `title` (`title`) USING BTREE,
    INDEX `active` (`active`) USING BTREE,
    INDEX `hasChild` (`hasChild`) USING BTREE,
    INDEX `path` (`path`) USING BTREE
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

CREATE TABLE `ebaylistingproduct` (
    `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
    `ebayAccountInfoId` int(10) UNSIGNED NOT NULL,
    `ebayItemId` varchar(20) NOT NULL DEFAULT '',
    `ebayCategoryId` int(10) UNSIGNED NOT NULL,
    `sku` varchar(50) NOT NULL DEFAULT '',
    `title` varchar(255) NOT NULL DEFAULT '',
    `variationSpecifics` json null,
    `productId` int(10) UNSIGNED NULL,
    `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 `productId` (`productId`) USING BTREE,
    INDEX `linkedProductId` (`linkedProductId`) USING BTREE,
    INDEX `ebayAccountInfoId` (`ebayAccountInfoId`) USING BTREE,
    INDEX `ebayItemId` (`ebayItemId`) USING BTREE,
    INDEX `ebayCategoryId` (`ebayCategoryId`) USING BTREE,
    INDEX `sku` (`sku`) USING BTREE,
    INDEX `title` (`title`) USING BTREE,
    INDEX `active` (`active`) USING BTREE
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

delete from productinfotype where name = 'eBay Product Id';
