-- --------------------------------------------------------
-- Versione server:              10.1.11-MariaDB - MariaDB Server
-- S.O. server:                  Linux
-- HeidiSQL Versione:            9.3.0.5045
-- --------------------------------------------------------


-- Dump della struttura di tabella barbagalloshop.ActivityLog
CREATE TABLE IF NOT EXISTS `ActivityLog` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `sid` varchar(64) NOT NULL,
  `userId` int(10) unsigned DEFAULT NULL,
  `referral` varchar(200) DEFAULT NULL,
  `requestedResource` varchar(500) DEFAULT NULL,
  `method` char(3) DEFAULT NULL,
  `actionArgs` varchar(300) DEFAULT NULL,
  `vars` varchar(300) DEFAULT NULL,
  `queryCount` tinyint(4) DEFAULT '0',
  `responseTime` varchar(9) DEFAULT NULL,
  `creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=864494 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ActivityLogOld
CREATE TABLE IF NOT EXISTS `ActivityLogOld` (
  `id` int(11) NOT NULL DEFAULT '0',
  `userId` int(10) unsigned DEFAULT NULL,
  `referral` varchar(200) DEFAULT NULL,
  `requestedResource` varchar(500) DEFAULT NULL,
  `method` char(3) DEFAULT NULL,
  `actionArgs` varchar(300) DEFAULT NULL,
  `vars` varchar(300) DEFAULT NULL,
  `creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ApiUser
CREATE TABLE IF NOT EXISTS `ApiUser` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(45) DEFAULT NULL,
  `token` varchar(64) DEFAULT NULL,
  `password` varchar(60) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ApplicationLog
CREATE TABLE IF NOT EXISTS `ApplicationLog` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `source` varchar(255) NOT NULL,
  `severity` varchar(45) NOT NULL,
  `title` varchar(45) DEFAULT NULL,
  `message` tinytext,
  `context` text,
  `creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `sid` varchar(64) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=196890 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.Article
CREATE TABLE IF NOT EXISTS `Article` (
  `id` int(10) unsigned NOT NULL,
  `langId` int(10) unsigned NOT NULL,
  `type` varchar(45) DEFAULT NULL,
  `url` varchar(45) DEFAULT NULL,
  `title` varchar(45) NOT NULL,
  `imgName` varchar(45) DEFAULT NULL,
  `text` mediumtext NOT NULL,
  `lastUpdate` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `creationDate` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`,`langId`),
  KEY `fk_Article_Lang1_idx` (`langId`),
  CONSTRAINT `fk_Article_Lang1` FOREIGN KEY (`langId`) REFERENCES `Lang` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.Blog
CREATE TABLE IF NOT EXISTS `Blog` (
  `id` int(10) unsigned NOT NULL,
  `name` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.Carrier
CREATE TABLE IF NOT EXISTS `Carrier` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(45) NOT NULL,
  `isActive` tinyint(1) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.City
CREATE TABLE IF NOT EXISTS `City` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `provinceId` int(11) NOT NULL,
  `name` varchar(45) NOT NULL,
  `fiscalCode` varchar(10) DEFAULT NULL,
  `population` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_City_Province1_idx` (`provinceId`),
  CONSTRAINT `fk_City_Province1` FOREIGN KEY (`provinceId`) REFERENCES `Province` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=8048 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.Country
CREATE TABLE IF NOT EXISTS `Country` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  `shippingCost` int(11) DEFAULT NULL,
  `ISO` varchar(2) DEFAULT NULL,
  `ISO3` varchar(3) DEFAULT NULL,
  `capital` varchar(45) DEFAULT NULL,
  `population` int(11) DEFAULT NULL,
  `continent` varchar(45) DEFAULT NULL,
  `tld` varchar(45) DEFAULT NULL,
  `currencyCode` varchar(45) DEFAULT NULL,
  `currency` varchar(45) DEFAULT NULL,
  `phone` varchar(45) DEFAULT NULL,
  `postCodeFormat` varchar(45) DEFAULT NULL,
  `postCodeRegex` varchar(45) DEFAULT NULL,
  `langs` varchar(45) DEFAULT NULL,
  `geonameId` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=253 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.CountryHasLang
CREATE TABLE IF NOT EXISTS `CountryHasLang` (
  `countryId` int(10) unsigned NOT NULL,
  `langId` int(10) unsigned NOT NULL,
  `name` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`countryId`,`langId`),
  KEY `fk_Country_has_Lang_Lang1_idx` (`langId`),
  KEY `fk_Country_has_Lang_Country1_idx` (`countryId`),
  CONSTRAINT `fk_Country_has_Lang_Country1` FOREIGN KEY (`countryId`) REFERENCES `Country` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_Country_has_Lang_Lang1` FOREIGN KEY (`langId`) REFERENCES `Lang` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.Coupon
CREATE TABLE IF NOT EXISTS `Coupon` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `couponTypeId` int(10) unsigned NOT NULL,
  `tagId` int(10) unsigned DEFAULT NULL,
  `code` varchar(19) NOT NULL,
  `issueDate` datetime NOT NULL,
  `validThru` datetime DEFAULT NULL,
  `amount` smallint(5) unsigned NOT NULL,
  `amountType` char(1) NOT NULL,
  `userId` int(10) unsigned DEFAULT NULL,
  `valid` binary(1) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`),
  UNIQUE KEY `code_UNIQUE` (`code`),
  KEY `fk_Coupon_CouponType1_idx` (`couponTypeId`),
  KEY `fk_Coupon_Tag1_idx` (`tagId`),
  KEY `userId` (`userId`),
  CONSTRAINT `Coupon_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `User` (`id`),
  CONSTRAINT `fk_Coupon_CouponType1` FOREIGN KEY (`couponTypeId`) REFERENCES `CouponType` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_Coupon_Tag1` FOREIGN KEY (`tagId`) REFERENCES `Tag` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=15122 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.CouponEvent
CREATE TABLE IF NOT EXISTS `CouponEvent` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `couponTypeId` int(10) unsigned NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` varchar(255) DEFAULT NULL,
  `click` int(10) NOT NULL DEFAULT '0',
  `startDate` datetime NOT NULL,
  `endDate` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name_UNIQUE` (`name`),
  KEY `1_idx` (`couponTypeId`),
  CONSTRAINT `1` FOREIGN KEY (`couponTypeId`) REFERENCES `CouponType` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.CouponType
CREATE TABLE IF NOT EXISTS `CouponType` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `amount` smallint(5) unsigned DEFAULT '0',
  `amountType` char(1) NOT NULL DEFAULT 'F',
  `validity` varchar(50) NOT NULL DEFAULT 'P1Y',
  `validForCartTotal` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.Currency
CREATE TABLE IF NOT EXISTS `Currency` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `code` varchar(4) NOT NULL,
  `conversionToEur` float NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.CurrencyTranslation
CREATE TABLE IF NOT EXISTS `CurrencyTranslation` (
  `currencyId` int(10) unsigned NOT NULL,
  `langId` int(10) unsigned NOT NULL,
  `name` varchar(255) NOT NULL,
  PRIMARY KEY (`currencyId`,`langId`),
  KEY `7_idx` (`langId`),
  CONSTRAINT `6` FOREIGN KEY (`currencyId`) REFERENCES `Currency` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.DictionaryBrand
CREATE TABLE IF NOT EXISTS `DictionaryBrand` (
  `shopId` int(10) unsigned NOT NULL,
  `term` varchar(45) NOT NULL,
  `productBrandId` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`shopId`,`term`),
  KEY `fk_Shop_has_ProductBrand_ProductBrand1_idx` (`productBrandId`),
  KEY `fk_Shop_has_ProductBrand_Shop1_idx` (`shopId`),
  CONSTRAINT `fk_Shop_has_ProductBrand_ProductBrand1` FOREIGN KEY (`productBrandId`) REFERENCES `ProductBrand` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_Shop_has_ProductBrand_Shop1` FOREIGN KEY (`shopId`) REFERENCES `Shop` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.DictionaryCategory
CREATE TABLE IF NOT EXISTS `DictionaryCategory` (
  `shopId` int(10) unsigned NOT NULL,
  `term` varchar(95) NOT NULL,
  `productCategoryId` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`shopId`,`term`),
  KEY `fk_ProductCategory_has_Shop_Shop1_idx` (`shopId`),
  KEY `fk_ProductCategory_has_Shop_ProductCategory1_idx` (`productCategoryId`),
  CONSTRAINT `fk_ProductCategory_has_Shop_ProductCategory1` FOREIGN KEY (`productCategoryId`) REFERENCES `ProductCategory` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_ProductCategory_has_Shop_Shop1` FOREIGN KEY (`shopId`) REFERENCES `Shop` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.DictionaryColorGroup
CREATE TABLE IF NOT EXISTS `DictionaryColorGroup` (
  `shopId` int(10) unsigned NOT NULL,
  `term` varchar(45) NOT NULL,
  `productColorGroupId` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`shopId`,`term`),
  KEY `fk_ProductColorGroup_has_Shop_Shop1_idx` (`shopId`),
  KEY `fk_ProductColorGroup_has_Shop_ProductColorGroup1_idx` (`productColorGroupId`),
  CONSTRAINT `fk_ProductColorGroup_has_Shop_ProductColorGroup1` FOREIGN KEY (`productColorGroupId`) REFERENCES `ProductColorGroup` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_ProductColorGroup_has_Shop_Shop1` FOREIGN KEY (`shopId`) REFERENCES `Shop` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.DictionaryDetail
CREATE TABLE IF NOT EXISTS `DictionaryDetail` (
  `shopId` int(10) unsigned NOT NULL,
  `term` varchar(45) NOT NULL,
  `productDetailId` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`shopId`,`term`),
  KEY `fk_ProductDetail_has_Shop_Shop1_idx` (`shopId`),
  KEY `fk_ProductDetail_has_Shop_ProductDetail1_idx` (`productDetailId`),
  CONSTRAINT `fk_ProductDetail_has_Shop_ProductDetail1` FOREIGN KEY (`productDetailId`) REFERENCES `ProductDetail` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_ProductDetail_has_Shop_Shop1` FOREIGN KEY (`shopId`) REFERENCES `Shop` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.DictionarySeason
CREATE TABLE IF NOT EXISTS `DictionarySeason` (
  `shopId` int(10) unsigned NOT NULL,
  `term` varchar(45) NOT NULL,
  `productSeasonId` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`shopId`,`term`),
  KEY `fk_Shop_has_ProductSeason_ProductSeason1_idx` (`productSeasonId`),
  KEY `fk_Shop_has_ProductSeason_Shop1_idx` (`shopId`),
  CONSTRAINT `fk_Shop_has_ProductSeason_ProductSeason1` FOREIGN KEY (`productSeasonId`) REFERENCES `ProductSeason` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_Shop_has_ProductSeason_Shop1` FOREIGN KEY (`shopId`) REFERENCES `Shop` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.DictionarySize
CREATE TABLE IF NOT EXISTS `DictionarySize` (
  `shopId` int(10) unsigned NOT NULL,
  `term` varchar(45) NOT NULL,
  `productSizeId` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`shopId`,`term`),
  KEY `fk_ProductSize_has_Shop_Shop1_idx` (`shopId`),
  KEY `fk_ProductSize_has_Shop_ProductSize1_idx` (`productSizeId`),
  CONSTRAINT `fk_ProductSize_has_Shop_ProductSize1` FOREIGN KEY (`productSizeId`) REFERENCES `ProductSize` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_ProductSize_has_Shop_Shop1` FOREIGN KEY (`shopId`) REFERENCES `Shop` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.DictionaryTag
CREATE TABLE IF NOT EXISTS `DictionaryTag` (
  `shopId` int(10) unsigned NOT NULL,
  `term` varchar(45) NOT NULL,
  `tagId` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`shopId`,`term`),
  KEY `fk_Tag_has_Shop_Shop1_idx` (`shopId`),
  KEY `fk_Tag_has_Shop_Tag1_idx` (`tagId`),
  CONSTRAINT `fk_Tag_has_Shop_Shop1` FOREIGN KEY (`shopId`) REFERENCES `Shop` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_Tag_has_Shop_Tag1` FOREIGN KEY (`tagId`) REFERENCES `Tag` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.DirtyDetail
CREATE TABLE IF NOT EXISTS `DirtyDetail` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `dirtyProductId` int(10) unsigned NOT NULL,
  `label` varchar(45) DEFAULT NULL,
  `content` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`,`dirtyProductId`),
  KEY `fk_dirtydetail_idx` (`dirtyProductId`),
  CONSTRAINT `fk_dirtydetail` FOREIGN KEY (`dirtyProductId`) REFERENCES `DirtyProduct` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=129855 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.DirtyPhoto
CREATE TABLE IF NOT EXISTS `DirtyPhoto` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `dirtyProductId` int(10) unsigned NOT NULL,
  `url` varchar(255) DEFAULT NULL,
  `location` varchar(45) DEFAULT NULL,
  `position` varchar(45) DEFAULT NULL,
  `worked` tinyint(1) DEFAULT NULL,
  `creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `shopId` int(10) NOT NULL,
  PRIMARY KEY (`id`,`dirtyProductId`),
  KEY `fk_dirtyProduct_id_idx` (`dirtyProductId`),
  CONSTRAINT `fk_dirtyProduct_id` FOREIGN KEY (`dirtyProductId`) REFERENCES `DirtyProduct` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=16620 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.DirtyProduct
CREATE TABLE IF NOT EXISTS `DirtyProduct` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `productId` int(10) unsigned DEFAULT NULL,
  `productVariantId` int(10) unsigned DEFAULT NULL,
  `shopId` int(10) unsigned NOT NULL,
  `extId` varchar(45) DEFAULT NULL,
  `brand` varchar(45) DEFAULT NULL,
  `itemno` varchar(45) DEFAULT NULL,
  `var` varchar(45) DEFAULT NULL,
  `value` double DEFAULT NULL,
  `price` double DEFAULT NULL,
  `salePrice` double DEFAULT NULL,
  `text` text,
  `checksum` char(32) DEFAULT NULL,
  `keysChecksum` char(32) DEFAULT NULL,
  `detailsChecksum` char(32) DEFAULT NULL,
  `photosChecksum` char(32) DEFAULT NULL,
  `sizesChecksum` char(32) DEFAULT NULL,
  `fullMatch` tinyint(1) NOT NULL DEFAULT '0',
  `dirtyStatus` char(1) NOT NULL,
  `clipboard` varchar(1000) DEFAULT NULL,
  `relationshipId` int(10) unsigned DEFAULT NULL,
  `parentName` varchar(45) DEFAULT NULL,
  `creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `checksum` (`shopId`,`checksum`),
  KEY `fk_DirtyProduct_ShopHasProduct1_idx` (`productId`,`productVariantId`,`shopId`),
  KEY `fk_DirtyProduct_DirtyProduct1_idx` (`relationshipId`),
  CONSTRAINT `fk_DirtyProduct_DirtyProduct1` FOREIGN KEY (`relationshipId`) REFERENCES `DirtyProduct` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_DirtyProduct_ShopHasProduct1` FOREIGN KEY (`productId`, `productVariantId`, `shopId`) REFERENCES `ShopHasProduct` (`productId`, `productVariantId`, `shopId`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_dirtyProduct_shop` FOREIGN KEY (`shopId`) REFERENCES `Shop` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=113358 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.DirtyProductExtend
CREATE TABLE IF NOT EXISTS `DirtyProductExtend` (
  `dirtyProductId` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `shopId` int(10) unsigned NOT NULL,
  `name` varchar(45) DEFAULT NULL,
  `description` varchar(45) DEFAULT NULL,
  `season` varchar(45) DEFAULT NULL,
  `audience` varchar(45) DEFAULT NULL,
  `cat1` varchar(45) DEFAULT NULL,
  `cat2` varchar(45) DEFAULT NULL,
  `cat3` varchar(45) DEFAULT NULL,
  `cat4` varchar(45) DEFAULT NULL,
  `cat5` varchar(45) DEFAULT NULL,
  `tag1` varchar(45) DEFAULT NULL,
  `tag2` varchar(45) DEFAULT NULL,
  `tag3` varchar(45) DEFAULT NULL,
  `generalColor` varchar(45) DEFAULT NULL,
  `colorDescription` varchar(45) DEFAULT NULL,
  `sizeGroup` varchar(45) DEFAULT NULL,
  `checksum` char(32) DEFAULT NULL,
  KEY `fk_dirtyProduct_idx` (`dirtyProductId`,`shopId`),
  CONSTRAINT `fk_dirtyProduct` FOREIGN KEY (`dirtyProductId`) REFERENCES `DirtyProduct` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=113356 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.DirtySku
CREATE TABLE IF NOT EXISTS `DirtySku` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `size` varchar(45) NOT NULL,
  `extSizeId` varchar(45) DEFAULT NULL,
  `extSkuId` varchar(45) DEFAULT NULL,
  `shopId` int(10) unsigned DEFAULT NULL,
  `productSizeId` int(10) unsigned DEFAULT NULL,
  `dirtyProductId` int(10) unsigned DEFAULT NULL,
  `value` double DEFAULT NULL,
  `price` double DEFAULT NULL,
  `salePrice` double DEFAULT NULL,
  `qty` int(11) DEFAULT NULL,
  `changed` tinyint(1) NOT NULL DEFAULT '1',
  `barcode` varchar(30) DEFAULT NULL,
  `text` text,
  `checksum` char(32) DEFAULT NULL,
  `status` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`id`,`size`),
  UNIQUE KEY `checksum_UNIQUE` (`checksum`),
  KEY `fk_DirtySku_DirtyProduct1_idx` (`dirtyProductId`),
  KEY `fk_DirtySku_ProductSize1_idx` (`productSizeId`),
  KEY `fk_DirtySku_Shop1_idx` (`shopId`),
  CONSTRAINT `fk_DirtySku_DirtyProduct1` FOREIGN KEY (`dirtyProductId`) REFERENCES `DirtyProduct` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_DirtySku_ProductSize1` FOREIGN KEY (`productSizeId`) REFERENCES `ProductSize` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_DirtySku_Shop1` FOREIGN KEY (`shopId`) REFERENCES `Shop` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=203465 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.EBayApp
CREATE TABLE IF NOT EXISTS `EBayApp` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `devid` varchar(37) NOT NULL,
  `appid` varchar(37) NOT NULL,
  `certid` varchar(37) NOT NULL,
  `eBaySiteIdDefault` int(10) unsigned NOT NULL,
  `errorLanguage` varchar(255) NOT NULL,
  `warningLevel` varchar(255) NOT NULL,
  `schema` varchar(255) NOT NULL,
  `endpoint` varchar(255) NOT NULL,
  `version` int(10) unsigned NOT NULL,
  `env` char(1) NOT NULL,
  `ruName` varchar(255) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `10_idx` (`eBaySiteIdDefault`),
  CONSTRAINT `10` FOREIGN KEY (`eBaySiteIdDefault`) REFERENCES `EBaySite` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.EBaySite
CREATE TABLE IF NOT EXISTS `EBaySite` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `countryId` int(10) unsigned NOT NULL,
  `currencyId` int(10) NOT NULL,
  `ebayCountryId` int(3) unsigned NOT NULL,
  `ebayCountryCode` varchar(4) NOT NULL,
  `ebayCountrySite` varchar(255) NOT NULL,
  `priceModifierPercentage` int(3) NOT NULL,
  `applyVat` tinyint(1) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `ebayId_UNIQUE` (`ebayCountryId`),
  KEY `5_idx` (`countryId`),
  KEY `8_idx` (`currencyId`),
  CONSTRAINT `5` FOREIGN KEY (`countryId`) REFERENCES `Country` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.EBayUser
CREATE TABLE IF NOT EXISTS `EBayUser` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `token` varchar(900) NOT NULL,
  `sessionId` varchar(900) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.EBayUserHasEBaySite
CREATE TABLE IF NOT EXISTS `EBayUserHasEBaySite` (
  `EBayUserId` int(10) unsigned NOT NULL,
  `EBaySiteId` int(10) unsigned NOT NULL,
  PRIMARY KEY (`EBayUserId`,`EBaySiteId`),
  KEY `9_idx` (`EBaySiteId`),
  KEY `4_idx` (`EBayUserId`),
  CONSTRAINT `4` FOREIGN KEY (`EBayUserId`) REFERENCES `EBayUser` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `9` FOREIGN KEY (`EBaySiteId`) REFERENCES `EBaySite` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.EMail
CREATE TABLE IF NOT EXISTS `EMail` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `eMailSenderId` int(11) NOT NULL,
  `subject` varchar(255) DEFAULT NULL,
  `to` varchar(255) DEFAULT NULL,
  `cc` varchar(255) DEFAULT NULL,
  `bcc` varchar(255) DEFAULT NULL,
  `html` tinyint(1) DEFAULT '1',
  `body` text,
  `altBody` text,
  `isReady` tinyint(1) NOT NULL DEFAULT '0',
  `isSend` tinyint(1) NOT NULL DEFAULT '0',
  `isError` tinyint(1) NOT NULL DEFAULT '0',
  `creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `sendDate` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `eMailSender_idx` (`eMailSenderId`),
  CONSTRAINT `eMailSender` FOREIGN KEY (`eMailSenderId`) REFERENCES `EMailSender` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.EMailSender
CREATE TABLE IF NOT EXISTS `EMailSender` (
  `id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `host` varchar(100) NOT NULL,
  `smtpAuth` tinyint(1) NOT NULL DEFAULT '1',
  `username` varchar(100) DEFAULT NULL,
  `password` varchar(100) DEFAULT NULL,
  `smtpSecure` varchar(3) NOT NULL DEFAULT 'TLS',
  `port` int(11) NOT NULL DEFAULT '584',
  `from` varchar(100) DEFAULT NULL,
  `fromName` varchar(100) DEFAULT NULL,
  `active` tinyint(1) DEFAULT '1',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.Event
CREATE TABLE IF NOT EXISTS `Event` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(45) NOT NULL,
  `stopped` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.EventHasListener
CREATE TABLE IF NOT EXISTS `EventHasListener` (
  `eventId` int(10) unsigned NOT NULL,
  `listenerId` int(10) unsigned NOT NULL,
  PRIMARY KEY (`eventId`,`listenerId`),
  KEY `fk_Event_has_Listener_Listener1_idx` (`listenerId`),
  KEY `fk_Event_has_Listener_Event1_idx` (`eventId`),
  CONSTRAINT `fk_Event_has_Listener_Event1` FOREIGN KEY (`eventId`) REFERENCES `Event` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_Event_has_Listener_Listener1` FOREIGN KEY (`listenerId`) REFERENCES `EventListener` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.EventListener
CREATE TABLE IF NOT EXISTS `EventListener` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `classToInvoke` varchar(45) NOT NULL,
  `stopped` tinyint(1) NOT NULL DEFAULT '0',
  `isAsync` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ExceptionLog
CREATE TABLE IF NOT EXISTS `ExceptionLog` (
  `id` int(10) NOT NULL,
  `creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `userId` int(10) DEFAULT NULL,
  `exception` longtext NOT NULL,
  PRIMARY KEY (`id`,`creationDate`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.FixedPage
CREATE TABLE IF NOT EXISTS `FixedPage` (
  `id` int(10) unsigned NOT NULL,
  `langId` int(10) unsigned NOT NULL,
  `fixedPageTypeId` int(10) unsigned NOT NULL,
  `title` varchar(255) DEFAULT NULL,
  `subtitle` varchar(255) DEFAULT NULL,
  `slug` varchar(255) DEFAULT NULL,
  `text` longtext,
  `mainImage` varchar(255) DEFAULT NULL,
  `creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `lastUpdate` datetime DEFAULT NULL,
  PRIMARY KEY (`id`,`langId`,`fixedPageTypeId`),
  KEY `fk_FixedPage_has_Lang_Lang1_idx` (`langId`),
  KEY `fk_FixedPage_FixedPageType1_idx` (`fixedPageTypeId`),
  CONSTRAINT `fk_FixedPage_FixedPageType1` FOREIGN KEY (`fixedPageTypeId`) REFERENCES `FixedPageType` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_FixedPage_has_Lang_Lang1` FOREIGN KEY (`langId`) REFERENCES `Lang` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.FixedPageType
CREATE TABLE IF NOT EXISTS `FixedPageType` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(45) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ImporterConnector
CREATE TABLE IF NOT EXISTS `ImporterConnector` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `shopId` int(10) unsigned NOT NULL,
  `name` varchar(45) DEFAULT NULL,
  `scope` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_ImporterConnector_Shop1_idx` (`shopId`),
  CONSTRAINT `fk_ImporterConnector_Shop1` FOREIGN KEY (`shopId`) REFERENCES `Shop` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ImporterConnectorOperation
CREATE TABLE IF NOT EXISTS `ImporterConnectorOperation` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `importerFieldModifierId` int(10) unsigned DEFAULT NULL,
  `importerFieldId` int(10) unsigned NOT NULL,
  `importerOperatorId` int(10) unsigned NOT NULL,
  `value` varchar(45) NOT NULL,
  `importerLogicConnectorId` int(10) unsigned DEFAULT NULL,
  `nextOperationId` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_ImporterConnectorOperation_ImporterConnectorOperation_idx` (`nextOperationId`),
  KEY `fk_ImporterField_idx` (`importerFieldId`),
  KEY `fk_ImporterConnectorOperation_ImporterFieldModifier1_idx` (`importerFieldModifierId`),
  KEY `fk_ImporterConnectorOperation_ImporterLogicConnector1_idx` (`importerLogicConnectorId`),
  CONSTRAINT `fk_ImporterConnectorOperation_ImporterConnectorOperation` FOREIGN KEY (`nextOperationId`) REFERENCES `ImporterConnectorOperation` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_ImporterConnectorOperation_ImporterFieldModifier1` FOREIGN KEY (`importerFieldModifierId`) REFERENCES `ImporterFieldModifier` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_ImporterConnectorOperation_ImporterLogicConnector1` FOREIGN KEY (`importerLogicConnectorId`) REFERENCES `ImporterLogicConnector` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_ImporterField` FOREIGN KEY (`importerFieldId`) REFERENCES `ImporterField` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ImporterConnectorStart
CREATE TABLE IF NOT EXISTS `ImporterConnectorStart` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `importerConnectorId` int(10) unsigned NOT NULL,
  `value` varchar(45) NOT NULL,
  `priority` tinyint(4) NOT NULL DEFAULT '100',
  `importerConnectorOperationId` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_ImporterConnectorStart_ImporterConnector1_idx1` (`importerConnectorId`),
  KEY `fk_ImporterConnectorStart_ImporterConnectorOperation1_idx1` (`importerConnectorOperationId`),
  CONSTRAINT `fk_ImporterConnectorStart_ImporterConnector1` FOREIGN KEY (`importerConnectorId`) REFERENCES `ImporterConnector` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_ImporterConnectorStart_ImporterConnectorOperation1` FOREIGN KEY (`importerConnectorOperationId`) REFERENCES `ImporterConnectorOperation` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ImporterField
CREATE TABLE IF NOT EXISTS `ImporterField` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(45) NOT NULL,
  `location` varchar(45) NOT NULL,
  `title` varchar(45) DEFAULT NULL,
  `description` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ImporterFieldModifier
CREATE TABLE IF NOT EXISTS `ImporterFieldModifier` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `modifier` varchar(45) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ImporterLogicConnector
CREATE TABLE IF NOT EXISTS `ImporterLogicConnector` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(45) NOT NULL,
  `title` varchar(45) DEFAULT NULL,
  `description` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ImporterOperator
CREATE TABLE IF NOT EXISTS `ImporterOperator` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(45) NOT NULL,
  `title` varchar(45) DEFAULT NULL,
  `description` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ImportItemsReview
CREATE TABLE IF NOT EXISTS `ImportItemsReview` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `shopId` int(10) unsigned NOT NULL DEFAULT '0',
  `jobId` int(10) unsigned DEFAULT '0',
  `jobExecutionId` int(10) unsigned DEFAULT '0',
  `action` varchar(5) NOT NULL DEFAULT '0',
  `object` varchar(10) DEFAULT '0',
  `fileType` varchar(5) NOT NULL,
  `file` int(10) unsigned DEFAULT '0',
  `creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `data` text,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=56 DEFAULT CHARSET=utf8 COMMENT='Table to store the item with problem in the standard importer';

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.Job
CREATE TABLE IF NOT EXISTS `Job` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(45) NOT NULL,
  `protocol` varchar(45) NOT NULL DEFAULT 'curl',
  `host` varchar(255) NOT NULL DEFAULT 'barbagalloshop.com',
  `command` varchar(255) NOT NULL,
  `defaultArgs` varchar(255) DEFAULT NULL,
  `isActive` tinyint(1) NOT NULL DEFAULT '0',
  `isRunning` tinyint(1) NOT NULL DEFAULT '0',
  `manualStart` tinyint(1) NOT NULL DEFAULT '0',
  `manualKill` tinyint(1) NOT NULL DEFAULT '0',
  `secondsToLive` int(11) NOT NULL DEFAULT '600',
  `username` varchar(45) DEFAULT NULL,
  `password` varchar(45) DEFAULT NULL,
  `minute` varchar(45) DEFAULT '*',
  `hour` varchar(45) DEFAULT '*',
  `mday` varchar(45) DEFAULT '*',
  `month` varchar(45) DEFAULT '*',
  `wday` varchar(45) DEFAULT '*',
  `logFile` varchar(255) DEFAULT NULL,
  `notificationSetup` varchar(45) DEFAULT NULL,
  `notificationEmail` varchar(255) DEFAULT NULL,
  `lastExecution` timestamp NULL DEFAULT NULL,
  `lastUpdate` timestamp NULL DEFAULT NULL,
  `isDebug` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=latin1;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.JobExecution
CREATE TABLE IF NOT EXISTS `JobExecution` (
  `id` int(11) NOT NULL,
  `jobId` int(11) NOT NULL,
  `threadId` varchar(45) NOT NULL,
  `status` varchar(45) DEFAULT NULL,
  `start` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `args` varchar(255) DEFAULT NULL,
  `end` timestamp NULL DEFAULT NULL,
  `exitValue` varchar(45) DEFAULT NULL,
  `error` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`id`,`jobId`),
  KEY `jobId_idx` (`jobId`),
  CONSTRAINT `jobId` FOREIGN KEY (`jobId`) REFERENCES `Job` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.JobLog
CREATE TABLE IF NOT EXISTS `JobLog` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `jobId` int(11) NOT NULL,
  `jobExecutionId` int(11) NOT NULL,
  `severity` varchar(10) NOT NULL DEFAULT 'REPORT',
  `subject` varchar(45) NOT NULL,
  `content` varchar(255) NOT NULL,
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `context` text,
  `manualKill` tinyint(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`,`jobId`,`jobExecutionId`),
  KEY `jobId_idx` (`jobId`,`jobExecutionId`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.Lang
CREATE TABLE IF NOT EXISTS `Lang` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `lang` varchar(2) NOT NULL,
  `name` varchar(45) NOT NULL,
  `isActive` tinyint(1) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `lang_UNIQUE` (`lang`),
  UNIQUE KEY `name_UNIQUE` (`name`),
  KEY `lang` (`lang`)
) ENGINE=InnoDB AUTO_INCREMENT=90 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.Locale
CREATE TABLE IF NOT EXISTS `Locale` (
  `langId` int(10) unsigned NOT NULL,
  `currencyId` int(10) unsigned NOT NULL,
  `countryId` int(10) unsigned NOT NULL,
  `dateFormat` varchar(255) NOT NULL,
  `numberFormat` varchar(255) NOT NULL,
  PRIMARY KEY (`langId`,`currencyId`,`countryId`),
  KEY `13_idx` (`currencyId`),
  KEY `14_idx` (`countryId`),
  CONSTRAINT `13` FOREIGN KEY (`currencyId`) REFERENCES `Currency` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `14` FOREIGN KEY (`countryId`) REFERENCES `Country` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `7` FOREIGN KEY (`langId`) REFERENCES `Lang` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.Marketplace
CREATE TABLE IF NOT EXISTS `Marketplace` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(45) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.Newsletter
CREATE TABLE IF NOT EXISTS `Newsletter` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `email` varchar(45) NOT NULL DEFAULT '0',
  `isActive` tinyint(1) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=541 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.Order
CREATE TABLE IF NOT EXISTS `Order` (
  `id` int(10) unsigned zerofill NOT NULL AUTO_INCREMENT,
  `orderPaymentMethodId` int(10) unsigned DEFAULT NULL,
  `orderShippingMethodId` int(10) unsigned DEFAULT NULL,
  `couponId` int(10) unsigned DEFAULT NULL,
  `userId` int(10) unsigned DEFAULT NULL,
  `status` varchar(15) NOT NULL DEFAULT 'CRT',
  `frozenBillingAddress` blob,
  `frozenShippingAddress` blob,
  `shippingPrice` double unsigned DEFAULT '0',
  `userDiscount` double unsigned DEFAULT '0',
  `couponDiscount` double DEFAULT NULL,
  `paymentModifier` double DEFAULT NULL,
  `grossTotal` double unsigned DEFAULT '0',
  `netTotal` double unsigned DEFAULT NULL,
  `vat` double unsigned DEFAULT NULL,
  `orderDate` timestamp NULL DEFAULT NULL,
  `note` varchar(255) DEFAULT NULL,
  `transactionNumber` int(11) DEFAULT NULL,
  `transactionMac` varchar(45) DEFAULT NULL,
  `paidAmount` double DEFAULT NULL,
  `paymentDate` timestamp NULL DEFAULT NULL,
  `lastUpdate` timestamp NULL DEFAULT NULL,
  `creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `fk_Order_OrderPaymentMethod1_idx` (`orderPaymentMethodId`),
  KEY `fk_Order_Coupon1_idx` (`couponId`),
  KEY `fk_Order_User1_idx` (`userId`),
  KEY `21_idx` (`orderShippingMethodId`),
  CONSTRAINT `fk_Order_Coupon1` FOREIGN KEY (`couponId`) REFERENCES `Coupon` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_Order_OrderPaymentMethod1` FOREIGN KEY (`orderPaymentMethodId`) REFERENCES `OrderPaymentMethod` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=2093425 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.Invoice
CREATE TABLE IF NOT EXISTS `Invoice` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `orderId` int(10) unsigned zerofill NOT NULL,
  `invoiceYear` year(4) NOT NULL,
  `invoiceType` char(1) NOT NULL DEFAULT 'F',
  `invoiceSiteChar` char(1) NOT NULL DEFAULT 'P',
  `invoiceNumber` int(6) unsigned NOT NULL,
  `invoiceDate` datetime NOT NULL,
  `invoiceText` text,
  `creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_invoice` (`invoiceYear`,`invoiceNumber`,`invoiceType`,`invoiceSiteChar`),
  KEY `fk_orderId_idx` (`orderId`),
  CONSTRAINT `fk_order_id` FOREIGN KEY (`orderId`) REFERENCES `Order` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=649 DEFAULT CHARSET=utf8;


-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.OrderAutomaticHistry
CREATE TABLE IF NOT EXISTS `OrderAutomaticHistry` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `orderId` int(10) unsigned NOT NULL,
  `query` varchar(455) DEFAULT NULL,
  `data` varchar(445) DEFAULT NULL,
  `oldStatus` varchar(20) DEFAULT NULL,
  `newStatus` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`id`,`orderId`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.OrderHistory
CREATE TABLE IF NOT EXISTS `OrderHistory` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `orderId` int(10) unsigned zerofill NOT NULL,
  `event` varchar(45) NOT NULL,
  `description` varchar(255) NOT NULL,
  `status` varchar(45) NOT NULL,
  `creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `fk_OrderHistory_Order1_idx` (`orderId`),
  CONSTRAINT `fk_OrderHistory_Order1` FOREIGN KEY (`orderId`) REFERENCES `Order` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=48590 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.OrderLine
CREATE TABLE IF NOT EXISTS `OrderLine` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `orderId` int(10) unsigned NOT NULL DEFAULT '0',
  `productId` int(10) unsigned NOT NULL DEFAULT '0',
  `productVariantId` int(10) unsigned NOT NULL DEFAULT '0',
  `productSizeId` int(10) unsigned NOT NULL DEFAULT '0',
  `shopId` int(10) unsigned NOT NULL DEFAULT '0',
  `status` varchar(15) NOT NULL DEFAULT 'CRT',
  `frozenProduct` blob,
  `fullPrice` double DEFAULT NULL,
  `activePrice` double DEFAULT NULL,
  `vat` double DEFAULT NULL,
  `cost` double DEFAULT NULL,
  `shippingCharge` double DEFAULT NULL,
  `couponCharge` double DEFAULT NULL,
  `userCharge` double DEFAULT NULL,
  `paymentCharge` double DEFAULT NULL,
  `netPrice` double DEFAULT NULL,
  `friendRevenue` double DEFAULT NULL,
  `acceptanceDate` timestamp NULL DEFAULT NULL,
  `friendAcceptanceDate` timestamp NULL DEFAULT NULL,
  `shipmentBookingDate` timestamp NULL DEFAULT NULL,
  `arrivalDate` timestamp NULL DEFAULT NULL,
  `creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `lastUpdate` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`,`orderId`),
  KEY `fk_OrderLine_Order1_idx1231235676` (`orderId`),
  KEY `fk_OrderLine_ProductSku1_idx151251756474` (`productId`,`productVariantId`,`productSizeId`,`shopId`),
  CONSTRAINT `fk_OrderLine_Order115215` FOREIGN KEY (`orderId`) REFERENCES `Order` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_OrderLine_ProductSku11241212` FOREIGN KEY (`productId`, `productVariantId`, `productSizeId`, `shopId`) REFERENCES `ProductSku` (`productId`, `productVariantId`, `productSizeId`, `shopId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=246 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.OrderLineHasShipment
CREATE TABLE IF NOT EXISTS `OrderLineHasShipment` (
  `orderLineId` int(10) unsigned NOT NULL,
  `orderId` int(10) unsigned NOT NULL,
  `shipmentId` int(10) unsigned NOT NULL,
  PRIMARY KEY (`orderLineId`,`orderId`,`shipmentId`),
  KEY `fk_OrderLine_has_Shipment_Shipment1_idx` (`shipmentId`),
  KEY `fk_OrderLine_has_Shipment_OrderLine1_idx` (`orderLineId`,`orderId`),
  CONSTRAINT `fk_OrderLine_has_Shipment_OrderLine1` FOREIGN KEY (`orderLineId`, `orderId`) REFERENCES `OrderLine` (`id`, `orderId`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_OrderLine_has_Shipment_Shipment1` FOREIGN KEY (`shipmentId`) REFERENCES `Shipment` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.OrderLineStatus
CREATE TABLE IF NOT EXISTS `OrderLineStatus` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `code` varchar(15) NOT NULL,
  `title` varchar(45) NOT NULL,
  `description` varchar(100) DEFAULT NULL,
  `nextOrderLineStatusId` int(11) DEFAULT NULL,
  `errOrderLineStatusId` int(11) DEFAULT NULL,
  `phase` tinyint(4) DEFAULT NULL,
  `isManageable` tinyint(1) DEFAULT NULL,
  `colore` varchar(10) DEFAULT NULL,
  `notify` smallint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `code_UNIQUE` (`code`),
  KEY `fk_OrderLineStatus_OrderLineStatus1_idx` (`errOrderLineStatusId`),
  KEY `fk_OrderLineStatus_OrderLineStatus2_idx` (`nextOrderLineStatusId`),
  CONSTRAINT `fk_OrderLineStatus_OrderLineStatus1` FOREIGN KEY (`errOrderLineStatusId`) REFERENCES `OrderLineStatus` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_OrderLineStatus_OrderLineStatus2` FOREIGN KEY (`nextOrderLineStatusId`) REFERENCES `OrderLineStatus` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=latin1;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.OrderPaymentMethod
CREATE TABLE IF NOT EXISTS `OrderPaymentMethod` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(45) NOT NULL,
  `isActive` tinyint(1) NOT NULL,
  `modifier` varchar(10) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name_UNIQUE` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.OrderPaymentMethodTranslation
CREATE TABLE IF NOT EXISTS `OrderPaymentMethodTranslation` (
  `orderPaymentMethodId` int(10) unsigned NOT NULL,
  `langId` int(10) unsigned NOT NULL,
  `name` varchar(45) NOT NULL,
  PRIMARY KEY (`orderPaymentMethodId`,`langId`),
  KEY `fk_OrderPaymentMethodTranslation_Lang1_idx` (`langId`),
  CONSTRAINT `fk_OrderPaymentMethodTranslation_Lang1` FOREIGN KEY (`langId`) REFERENCES `Lang` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_OrderPaymentMethodTranslation_OrderPaymentMethod1` FOREIGN KEY (`orderPaymentMethodId`) REFERENCES `OrderPaymentMethod` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.OrderStatus
CREATE TABLE IF NOT EXISTS `OrderStatus` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `code` varchar(15) NOT NULL,
  `title` varchar(45) NOT NULL,
  `description` varchar(100) DEFAULT NULL,
  `nextOrderStatusId` int(11) DEFAULT NULL,
  `errOrderStatusId` int(11) DEFAULT NULL,
  `order` tinyint(4) DEFAULT NULL,
  `color` varchar(10) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `code_UNIQUE` (`code`),
  KEY `fk_OrderStatus_OrderStatus2_idx` (`nextOrderStatusId`),
  KEY `fk_OrderStatus_OrderStatus1_idx` (`errOrderStatusId`),
  CONSTRAINT `fk_OrderStatus_OrderStatus1` FOREIGN KEY (`errOrderStatusId`) REFERENCES `OrderStatus` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_OrderStatus_OrderStatus2` FOREIGN KEY (`nextOrderStatusId`) REFERENCES `OrderStatus` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.OrderStatusHasLang
CREATE TABLE IF NOT EXISTS `OrderStatusHasLang` (
  `orderStatusId` int(11) NOT NULL DEFAULT '0',
  `langId` int(10) unsigned NOT NULL DEFAULT '0',
  `title` varchar(45) DEFAULT NULL,
  `description` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`orderStatusId`,`langId`),
  KEY `fk_OrderStatus_has_Lang_Lang1_idx` (`langId`),
  KEY `fk_OrderStatus_has_Lang_OrderStatus1_idx` (`orderStatusId`),
  CONSTRAINT `OrderStatusHasLang_ibfk_1` FOREIGN KEY (`orderStatusId`) REFERENCES `OrderStatus` (`id`),
  CONSTRAINT `OrderStatusHasLang_ibfk_2` FOREIGN KEY (`langId`) REFERENCES `Lang` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.OrderStatusTranslation
CREATE TABLE IF NOT EXISTS `OrderStatusTranslation` (
  `orderStatusId` int(11) NOT NULL DEFAULT '0',
  `langId` int(10) unsigned NOT NULL DEFAULT '0',
  `title` varchar(45) DEFAULT NULL,
  `name` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`orderStatusId`,`langId`),
  KEY `fk_OrderStatusTranslation_Lang1_idx` (`langId`),
  KEY `fk_OrderStatusTranslation_OrderStatus1_idx` (`orderStatusId`),
  CONSTRAINT `OrderStatusTranslation_ibfk_1` FOREIGN KEY (`orderStatusId`) REFERENCES `OrderStatus` (`id`),
  CONSTRAINT `OrderStatusTranslation_ibfk_2` FOREIGN KEY (`langId`) REFERENCES `Lang` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.Page
CREATE TABLE IF NOT EXISTS `Page` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `slug` varchar(255) NOT NULL,
  `url` varchar(255) NOT NULL,
  `icon` varchar(45) NOT NULL,
  `permission` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=93 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.PageTranslation
CREATE TABLE IF NOT EXISTS `PageTranslation` (
  `pageId` int(10) unsigned NOT NULL,
  `langId` int(10) unsigned NOT NULL,
  `title` varchar(255) NOT NULL,
  `description` varchar(300) DEFAULT NULL,
  `keywords` varchar(300) DEFAULT NULL,
  PRIMARY KEY (`pageId`,`langId`),
  KEY `fk_Page_has_Lang_Lang1_idx` (`langId`),
  KEY `fk_Page_has_Lang_Page1_idx` (`pageId`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.Post
CREATE TABLE IF NOT EXISTS `Post` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `blogId` int(10) unsigned NOT NULL,
  `userId` int(10) unsigned NOT NULL,
  `postStatusId` int(10) unsigned NOT NULL,
  `creationDate` datetime NOT NULL,
  `publishDate` datetime NOT NULL,
  `author` varchar(255) NOT NULL,
  `hits` int(10) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`,`blogId`),
  KEY `fk_Post_Blog1_idx` (`blogId`),
  KEY `fk_Post_User1_idx` (`userId`),
  KEY `fk_Post_PostStatus1_idx` (`postStatusId`),
  CONSTRAINT `fk_Post_Blog1` FOREIGN KEY (`blogId`) REFERENCES `Blog` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_Post_PostStatus1` FOREIGN KEY (`postStatusId`) REFERENCES `PostStatus` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_Post_User1` FOREIGN KEY (`userId`) REFERENCES `User` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.PostCategory
CREATE TABLE IF NOT EXISTS `PostCategory` (
  `id` int(10) unsigned NOT NULL,
  `parentPostCategoryId` int(10) unsigned DEFAULT NULL,
  `slug` varchar(255) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_PostCategory_PostCategory1_idx` (`parentPostCategoryId`),
  CONSTRAINT `fk_PostCategory_PostCategory1` FOREIGN KEY (`parentPostCategoryId`) REFERENCES `PostCategory` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.PostCategoryTranslation
CREATE TABLE IF NOT EXISTS `PostCategoryTranslation` (
  `postCategoryId` int(10) unsigned NOT NULL,
  `langId` int(10) unsigned NOT NULL,
  `name` varchar(255) NOT NULL,
  PRIMARY KEY (`postCategoryId`,`langId`),
  KEY `fk_PostCategory_has_Lang_Lang1_idx` (`langId`),
  KEY `fk_PostCategory_has_Lang_PostCategory1_idx` (`postCategoryId`),
  CONSTRAINT `fk_PostCategory_has_Lang_Lang1` FOREIGN KEY (`langId`) REFERENCES `Lang` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_PostCategory_has_Lang_PostCategory1` FOREIGN KEY (`postCategoryId`) REFERENCES `PostCategory` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.PostHasPostCategory
CREATE TABLE IF NOT EXISTS `PostHasPostCategory` (
  `postId` int(10) unsigned NOT NULL,
  `postBlogId` int(10) unsigned NOT NULL,
  `postCategoryId` int(10) unsigned NOT NULL,
  PRIMARY KEY (`postId`,`postBlogId`,`postCategoryId`),
  KEY `fk_Post_has_PostCategory_PostCategory1_idx` (`postCategoryId`),
  KEY `fk_Post_has_PostCategory_Post1_idx` (`postId`,`postBlogId`),
  CONSTRAINT `fk_Post_has_PostCategory_Post1` FOREIGN KEY (`postId`, `postBlogId`) REFERENCES `Post` (`id`, `blogId`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_Post_has_PostCategory_PostCategory1` FOREIGN KEY (`postCategoryId`) REFERENCES `PostCategory` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.PostHasPostTag
CREATE TABLE IF NOT EXISTS `PostHasPostTag` (
  `postId` int(10) unsigned NOT NULL,
  `postBlogId` int(10) unsigned NOT NULL,
  `postTagId` int(10) unsigned NOT NULL,
  PRIMARY KEY (`postId`,`postBlogId`,`postTagId`),
  KEY `fk_Post_has_PostTag_PostTag1_idx` (`postTagId`),
  KEY `fk_Post_has_PostTag_Post1_idx` (`postId`,`postBlogId`),
  CONSTRAINT `fk_Post_has_PostTag_Post1` FOREIGN KEY (`postId`, `postBlogId`) REFERENCES `Post` (`id`, `blogId`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_Post_has_PostTag_PostTag1` FOREIGN KEY (`postTagId`) REFERENCES `PostTag` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.PostStatus
CREATE TABLE IF NOT EXISTS `PostStatus` (
  `id` int(10) unsigned NOT NULL,
  `name` varchar(45) NOT NULL,
  `show` tinyint(4) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.PostTag
CREATE TABLE IF NOT EXISTS `PostTag` (
  `id` int(10) unsigned NOT NULL,
  `slug` varchar(45) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.PostTagTranslation
CREATE TABLE IF NOT EXISTS `PostTagTranslation` (
  `postTagId` int(10) unsigned NOT NULL,
  `langId` int(10) unsigned NOT NULL,
  `name` varchar(255) NOT NULL,
  PRIMARY KEY (`postTagId`,`langId`),
  KEY `fk_PostTag_has_Lang_Lang1_idx` (`langId`),
  KEY `fk_PostTag_has_Lang_PostTag1_idx` (`postTagId`),
  CONSTRAINT `fk_PostTag_has_Lang_Lang1` FOREIGN KEY (`langId`) REFERENCES `Lang` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_PostTag_has_Lang_PostTag1` FOREIGN KEY (`postTagId`) REFERENCES `PostTag` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.PostTranslation
CREATE TABLE IF NOT EXISTS `PostTranslation` (
  `postId` int(10) unsigned NOT NULL,
  `blogId` int(10) unsigned NOT NULL,
  `langId` int(10) unsigned NOT NULL,
  `title` varchar(255) NOT NULL,
  `subtitle` longtext NOT NULL,
  `content` longtext NOT NULL,
  `coverImage` varchar(255) NOT NULL,
  PRIMARY KEY (`postId`,`blogId`,`langId`),
  KEY `fk_Post_has_Lang_Lang1_idx` (`langId`),
  KEY `fk_Post_has_Lang_Post1_idx` (`postId`,`blogId`),
  CONSTRAINT `fk_Post_has_Lang_Lang1` FOREIGN KEY (`langId`) REFERENCES `Lang` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_Post_has_Lang_Post1` FOREIGN KEY (`postId`, `blogId`) REFERENCES `Post` (`id`, `blogId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di procedura barbagalloshop.pProductCategoryDepthUpdate
DROP PROCEDURE IF EXISTS `pProductCategoryDepthUpdate`;
DELIMITER //
//
DELIMITER ;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductStatus
CREATE TABLE IF NOT EXISTS `ProductStatus` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `code` char(1) NOT NULL,
  `name` varchar(45) DEFAULT NULL,
  `description` varchar(45) DEFAULT NULL,
  `isReady` tinyint(1) NOT NULL DEFAULT '0',
  `isVisible` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `code_UNIQUE` (`code`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;

-- Dump della struttura di tabella barbagalloshop.Product
CREATE TABLE IF NOT EXISTS `Product` (
  `id` int(10) unsigned NOT NULL,
  `productVariantId` int(10) unsigned NOT NULL,
  `itemno` varchar(32) NOT NULL,
  `creationDate` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `dummyPicture` varchar(100) DEFAULT NULL,
  `productSeasonId` int(10) unsigned DEFAULT NULL,
  `productBrandId` int(10) unsigned NOT NULL,
  `sortingPriorityId` int(10) unsigned NOT NULL DEFAULT '99',
  `productSizeGroupId` int(10) unsigned DEFAULT NULL,
  `productStatusId` int(10) unsigned NOT NULL DEFAULT '2',
  `productSheetPrototypeId` int(10) unsigned DEFAULT NULL,
  `externalId` varchar(45) DEFAULT NULL,
  `note` varchar(255) DEFAULT NULL,
  `sheetName` varchar(45) DEFAULT NULL,
  `lastUpdate` datetime DEFAULT NULL,
  `status` char(1) NOT NULL DEFAULT 'D',
  PRIMARY KEY (`id`,`productVariantId`),
  KEY `itemno` (`itemno`),
  KEY `fk_product_productSeason1_idx` (`productSeasonId`),
  KEY `fk_product_productColor1_idx` (`productVariantId`),
  KEY `fk_Product_Brand1_idx` (`productBrandId`),
  KEY `fk_Product_SortingPriority1_idx` (`sortingPriorityId`),
  KEY `fk_product_productStatus` (`status`),
  KEY `fk_product_productSheetPrototype_idx` (`productSheetPrototypeId`),
  KEY `fk_product_productStatusId_idx` (`productStatusId`),
  KEY `fk_product_productSizeGroup_idx` (`productSizeGroupId`),
  CONSTRAINT `fk_Product_Brand1` FOREIGN KEY (`productBrandId`) REFERENCES `ProductBrand` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_Product_SortingPriority1` FOREIGN KEY (`sortingPriorityId`) REFERENCES `SortingPriority` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_product_productColor1` FOREIGN KEY (`productVariantId`) REFERENCES `ProductVariant` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_product_productSeason1` FOREIGN KEY (`productSeasonId`) REFERENCES `ProductSeason` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_product_productSheetPrototype` FOREIGN KEY (`productSheetPrototypeId`) REFERENCES `ProductSheetPrototype` (`id`),
  CONSTRAINT `fk_product_productSizeGroup` FOREIGN KEY (`productSizeGroupId`) REFERENCES `ProductSizeGroup` (`id`),
  CONSTRAINT `fk_product_productStatusId` FOREIGN KEY (`productStatusId`) REFERENCES `ProductStatus` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductAttribute
CREATE TABLE IF NOT EXISTS `ProductAttribute` (
  `id` int(10) unsigned NOT NULL,
  `langId` int(10) unsigned NOT NULL,
  `name` varchar(45) NOT NULL,
  `order` int(11) NOT NULL DEFAULT '99',
  PRIMARY KEY (`id`,`langId`),
  KEY `fk_ProductAttribute_Lang1_idx` (`langId`),
  CONSTRAINT `fk_ProductAttribute_Lang1` FOREIGN KEY (`langId`) REFERENCES `Lang` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductAttributeValue
CREATE TABLE IF NOT EXISTS `ProductAttributeValue` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `productAttributeId` int(10) unsigned NOT NULL,
  `langId` int(10) unsigned NOT NULL,
  `name` varchar(255) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`,`productAttributeId`,`langId`),
  KEY `fk_productAttribute_idx` (`productAttributeId`,`langId`,`name`),
  CONSTRAINT `fk_productAttribute` FOREIGN KEY (`productAttributeId`, `langId`) REFERENCES `ProductAttribute` (`id`, `langId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=25031 DEFAULT CHARSET=latin1;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductBrand
CREATE TABLE IF NOT EXISTS `ProductBrand` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `slug` varchar(100) NOT NULL,
  `name` varchar(100) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name_UNIQUE` (`name`),
  UNIQUE KEY `ProductBrand_slug_uindex` (`slug`)
) ENGINE=InnoDB AUTO_INCREMENT=1095 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductCatalogFilter
CREATE TABLE IF NOT EXISTS `ProductCatalogFilter` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `langId` int(10) unsigned NOT NULL,
  `title` varchar(255) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `oohtoriqwht0yq486t7345buy2b4321` (`langId`),
  CONSTRAINT `fk_productSubtype_lang1agdasrgbvfaygrftauegbfeger` FOREIGN KEY (`langId`) REFERENCES `Lang` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductCategory
CREATE TABLE IF NOT EXISTS `ProductCategory` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `slug` varchar(255) COLLATE utf8_bin NOT NULL,
  `lft` int(10) unsigned NOT NULL,
  `rght` int(10) NOT NULL,
  `depth` int(3) unsigned DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `lft` (`lft`) USING BTREE,
  KEY `rgt` (`rght`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=752 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductCategoryHasProductCatalogFilter
CREATE TABLE IF NOT EXISTS `ProductCategoryHasProductCatalogFilter` (
  `productCategoryId` int(10) unsigned NOT NULL,
  `productCatalogFilterId` int(10) unsigned NOT NULL,
  PRIMARY KEY (`productCategoryId`,`productCatalogFilterId`),
  KEY `fk_ProductCategory_has_ProductCatalogFilter_ProductCatalogF_idx` (`productCatalogFilterId`),
  KEY `fk_ProductCategory_has_ProductCatalogFilter_ProductCategory_idx` (`productCategoryId`),
  CONSTRAINT `fk_ProductCategory_has_ProductCatalogFilter_ProductCatalogFil1` FOREIGN KEY (`productCatalogFilterId`) REFERENCES `ProductCatalogFilter` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_ProductCategory_has_ProductCatalogFilter_ProductCategory1` FOREIGN KEY (`productCategoryId`) REFERENCES `ProductCategory` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductCategoryMarketPlaceLookup
CREATE TABLE IF NOT EXISTS `ProductCategoryMarketPlaceLookup` (
  `productCategoryId` int(11) NOT NULL,
  `marketPlaceId` int(11) NOT NULL,
  `marketPlaceCategoryId` int(11) NOT NULL,
  `marketPlaceCategoryName` varchar(50) DEFAULT NULL,
  `marketPlaceCategoryPath` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`productCategoryId`,`marketPlaceId`,`marketPlaceCategoryId`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductCategoryTranslation
CREATE TABLE IF NOT EXISTS `ProductCategoryTranslation` (
  `productCategoryId` int(10) unsigned NOT NULL,
  `langId` int(10) unsigned NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text,
  `slug` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`productCategoryId`,`langId`),
  KEY `fk_ProductCategory_has_Lang_Lang1_idx` (`langId`),
  KEY `fk_ProductCategory_has_Lang_ProductCategory1_idx` (`productCategoryId`),
  KEY `slug_ProductCategoryTranslation_idx` (`slug`),
  CONSTRAINT `fk_ProductCategory_has_Lang_Lang1` FOREIGN KEY (`langId`) REFERENCES `Lang` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_ProductCategory_has_Lang_ProductCategory1PADREPIO` FOREIGN KEY (`productCategoryId`) REFERENCES `ProductCategory` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductColorGroup
CREATE TABLE IF NOT EXISTS `ProductColorGroup` (
  `id` int(10) unsigned NOT NULL,
  `langId` int(10) unsigned NOT NULL,
  `slug` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `hex` varchar(10) DEFAULT NULL,
  PRIMARY KEY (`id`,`langId`),
  KEY `fk_productColor_lang1_idx` (`langId`),
  CONSTRAINT `fk_productColor_lang10` FOREIGN KEY (`langId`) REFERENCES `Lang` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductDescription
CREATE TABLE IF NOT EXISTS `ProductDescription` (
  `productId` int(10) unsigned NOT NULL,
  `productVariantId` int(10) unsigned NOT NULL,
  `langId` int(10) unsigned NOT NULL,
  `marketplaceId` int(10) unsigned NOT NULL,
  `description` text NOT NULL,
  PRIMARY KEY (`productId`,`productVariantId`,`langId`,`marketplaceId`),
  KEY `fk_ProductName_Product1_idx` (`productId`,`productVariantId`),
  KEY `fk_ProductName_Lang1_idx` (`langId`),
  KEY `fk_ProductDescription_Marketplace1_idx` (`marketplaceId`),
  CONSTRAINT `fk_ProductDescription_Marketplace1` FOREIGN KEY (`marketplaceId`) REFERENCES `Marketplace` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_ProductName_Lang10` FOREIGN KEY (`langId`) REFERENCES `Lang` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_ProductName_Product10` FOREIGN KEY (`productId`, `productVariantId`) REFERENCES `Product` (`id`, `productVariantId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductDescriptionTranslation
CREATE TABLE IF NOT EXISTS `ProductDescriptionTranslation` (
  `productId` int(10) unsigned NOT NULL,
  `productVariantId` int(10) unsigned NOT NULL,
  `marketplaceId` int(10) unsigned NOT NULL,
  `langId` int(10) unsigned NOT NULL,
  `description` text NOT NULL,
  PRIMARY KEY (`productId`,`productVariantId`,`marketplaceId`,`langId`),
  KEY `fk_ProductName_Product1111_idx` (`productId`,`productVariantId`),
  KEY `fk_ProductDescription_Marketplace1111_idx` (`marketplaceId`),
  KEY `10_idx` (`langId`),
  CONSTRAINT `10111111` FOREIGN KEY (`langId`) REFERENCES `Lang` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_ProductDescriptionTranslation_Product1111` FOREIGN KEY (`productId`, `productVariantId`) REFERENCES `Product` (`id`, `productVariantId`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_ProductDescriptiontTranslation_Marketplace1111` FOREIGN KEY (`marketplaceId`) REFERENCES `Marketplace` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductDetail
CREATE TABLE IF NOT EXISTS `ProductDetail` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `slug` varchar(255) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`),
  UNIQUE KEY `slug` (`slug`)
) ENGINE=InnoDB AUTO_INCREMENT=32141 DEFAULT CHARSET=latin1;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductDetailLabel
CREATE TABLE IF NOT EXISTS `ProductDetailLabel` (
  `id` int(10) unsigned NOT NULL,
  `slug` varchar(45) NOT NULL,
  `order` int(11) NOT NULL DEFAULT '99',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductDetailLabelTranslation
CREATE TABLE IF NOT EXISTS `ProductDetailLabelTranslation` (
  `productDetailLabelId` int(10) unsigned NOT NULL,
  `langId` int(10) unsigned NOT NULL,
  `name` varchar(255) NOT NULL,
  PRIMARY KEY (`productDetailLabelId`,`langId`),
  KEY `5456456456456_idx` (`langId`),
  KEY `645645645645_idx` (`productDetailLabelId`),
  CONSTRAINT `556464564564` FOREIGN KEY (`langId`) REFERENCES `Lang` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `654645645645` FOREIGN KEY (`productDetailLabelId`) REFERENCES `ProductDetailLabel` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductDetailTranslation
CREATE TABLE IF NOT EXISTS `ProductDetailTranslation` (
  `productDetailId` int(10) unsigned NOT NULL,
  `langId` int(10) unsigned NOT NULL,
  `name` varchar(255) NOT NULL,
  PRIMARY KEY (`productDetailId`,`langId`),
  KEY `254645645645_idx` (`productDetailId`),
  KEY `3654645645645_idx` (`langId`),
  CONSTRAINT `24654645645` FOREIGN KEY (`productDetailId`) REFERENCES `ProductDetail` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `35645645645` FOREIGN KEY (`langId`) REFERENCES `Lang` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di vista barbagalloshop.ProductDetailTranslationView
DROP VIEW IF EXISTS `ProductDetailTranslationView`;
-- Creazione di una tabella temporanea per risolvere gli errori di dipendenza della vista
CREATE TABLE `ProductDetailTranslationView` (
  `id` INT(10) UNSIGNED NOT NULL,
  `slug` VARCHAR(255) NOT NULL COLLATE 'latin1_swedish_ci',
  `translatedLangId` TEXT NULL COLLATE 'utf8_general_ci',
  `translatedName` TEXT NULL COLLATE 'utf8_general_ci',
  `hasQuantity` INT(1) NOT NULL,
  `timesDetailIsUsedInProduct` BIGINT(21) NOT NULL
) ENGINE=MyISAM;

-- Dump della struttura di tabella barbagalloshop.ProductHasProductAttributeValue
CREATE TABLE IF NOT EXISTS `ProductHasProductAttributeValue` (
  `productId` int(10) unsigned NOT NULL,
  `productVariantId` int(10) unsigned NOT NULL,
  `productAttributeValueId` int(10) unsigned NOT NULL,
  `productAttributeId` int(10) unsigned NOT NULL,
  PRIMARY KEY (`productId`,`productVariantId`,`productAttributeValueId`,`productAttributeId`),
  KEY `fk_productAttributeValue_idx` (`productAttributeValueId`,`productAttributeId`),
  CONSTRAINT `fk_product` FOREIGN KEY (`productId`, `productVariantId`) REFERENCES `Product` (`id`, `productVariantId`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_productAttributeValue` FOREIGN KEY (`productAttributeValueId`, `productAttributeId`) REFERENCES `ProductAttributeValue` (`id`, `productAttributeId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductHasProductCategory
CREATE TABLE IF NOT EXISTS `ProductHasProductCategory` (
  `productId` int(10) unsigned NOT NULL,
  `productVariantId` int(10) unsigned NOT NULL,
  `productCategoryId` int(10) unsigned NOT NULL,
  PRIMARY KEY (`productId`,`productVariantId`,`productCategoryId`),
  KEY `fk_Product_has_ProductCategory_ProductCategory1_idx` (`productCategoryId`),
  KEY `fk_Product_has_ProductCategory_Product1_idx` (`productId`,`productVariantId`),
  CONSTRAINT `fk_Product_has_ProductCategory_Product1` FOREIGN KEY (`productId`, `productVariantId`) REFERENCES `Product` (`id`, `productVariantId`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_Product_has_ProductCategory_ProductCategory1` FOREIGN KEY (`productCategoryId`) REFERENCES `ProductCategory` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductHasProductColorGroup
CREATE TABLE IF NOT EXISTS `ProductHasProductColorGroup` (
  `productId` int(10) unsigned NOT NULL,
  `productVariantId` int(10) unsigned NOT NULL,
  `productColorGroupId` int(10) unsigned NOT NULL,
  PRIMARY KEY (`productId`,`productVariantId`,`productColorGroupId`),
  KEY `fk_Product_has_ProductColorGroup_Product1_idx` (`productId`,`productVariantId`),
  KEY `fk_Product_has_ProductColorGroup_ProductColorGroup1_idx` (`productColorGroupId`),
  CONSTRAINT `fk_Product_has_ProductColorGroup_Product1` FOREIGN KEY (`productId`, `productVariantId`) REFERENCES `Product` (`id`, `productVariantId`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_Product_has_ProductColorGroup_ProductColorGroup1` FOREIGN KEY (`productColorGroupId`) REFERENCES `ProductColorGroup` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductHasProductPhoto
CREATE TABLE IF NOT EXISTS `ProductHasProductPhoto` (
  `productId` int(10) unsigned NOT NULL,
  `productVariantId` int(10) unsigned NOT NULL,
  `productPhotoId` int(10) unsigned NOT NULL,
  PRIMARY KEY (`productId`,`productVariantId`,`productPhotoId`),
  KEY `fk_Product_has_ProductPhoto_ProductPhoto1_idx` (`productPhotoId`),
  KEY `fk_Product_has_ProductPhoto_Product1_idx` (`productId`,`productVariantId`),
  CONSTRAINT `fk_Product_has_ProductPhoto_Product1` FOREIGN KEY (`productId`, `productVariantId`) REFERENCES `Product` (`id`, `productVariantId`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_Product_has_ProductPhoto_ProductPhoto1` FOREIGN KEY (`productPhotoId`) REFERENCES `ProductPhoto` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductHasTag
CREATE TABLE IF NOT EXISTS `ProductHasTag` (
  `productId` int(10) unsigned NOT NULL,
  `productVariantId` int(10) unsigned NOT NULL,
  `tagId` int(10) unsigned NOT NULL,
  PRIMARY KEY (`productId`,`productVariantId`,`tagId`),
  KEY `fk_Product_has_Tag_Tag1_idx` (`tagId`),
  KEY `fk_Product_has_Tag_Product1_idx` (`productId`,`productVariantId`),
  CONSTRAINT `fk_Product_has_Tag_Product1` FOREIGN KEY (`productId`, `productVariantId`) REFERENCES `Product` (`id`, `productVariantId`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_Product_has_Tag_Tag1` FOREIGN KEY (`tagId`) REFERENCES `Tag` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductHistory
CREATE TABLE IF NOT EXISTS `ProductHistory` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `productId` int(10) unsigned NOT NULL,
  `productVariantId` int(10) unsigned NOT NULL,
  `creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `userId` int(10) unsigned NOT NULL,
  `action` varchar(255) NOT NULL,
  `description` text,
  PRIMARY KEY (`id`,`productId`,`productVariantId`,`userId`),
  KEY `2_idx` (`userId`),
  KEY `3_idx` (`productId`,`productVariantId`),
  CONSTRAINT `2` FOREIGN KEY (`userId`) REFERENCES `User` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `3` FOREIGN KEY (`productId`, `productVariantId`) REFERENCES `Product` (`id`, `productVariantId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=2430 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductName
CREATE TABLE IF NOT EXISTS `ProductName` (
  `productId` int(10) unsigned NOT NULL,
  `productVariantId` int(10) unsigned NOT NULL,
  `langId` int(10) unsigned NOT NULL,
  `name` varchar(255) NOT NULL,
  PRIMARY KEY (`productId`,`productVariantId`,`langId`),
  KEY `fk_ProductName_Product1_idx` (`productId`,`productVariantId`),
  KEY `fk_ProductName_Lang1_idx` (`langId`),
  CONSTRAINT `fk_ProductName_Lang1` FOREIGN KEY (`langId`) REFERENCES `Lang` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_ProductName_Product1` FOREIGN KEY (`productId`, `productVariantId`) REFERENCES `Product` (`id`, `productVariantId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductNameTranslation
CREATE TABLE IF NOT EXISTS `ProductNameTranslation` (
  `productId` int(10) unsigned NOT NULL,
  `productVariantId` int(10) unsigned NOT NULL,
  `langId` int(10) unsigned NOT NULL,
  `name` varchar(255) NOT NULL,
  PRIMARY KEY (`productId`,`productVariantId`,`langId`),
  KEY `fk_ProductName_Product13643645645_idx` (`productId`,`productVariantId`),
  KEY `fk_ProductName_Lang1456456544_idx` (`langId`),
  CONSTRAINT `fk_ProductName_Lang145645645` FOREIGN KEY (`langId`) REFERENCES `Lang` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_ProductName_Product145654645` FOREIGN KEY (`productId`, `productVariantId`) REFERENCES `Product` (`id`, `productVariantId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductOld
CREATE TABLE IF NOT EXISTS `ProductOld` (
  `id` int(10) unsigned NOT NULL,
  `productVariantId` int(10) unsigned NOT NULL,
  `itemno` varchar(32) NOT NULL,
  `creationDate` datetime NOT NULL,
  `dummyPicture` varchar(100) DEFAULT NULL,
  `productSeasonId` int(10) unsigned DEFAULT NULL,
  `productBrandId` int(10) unsigned NOT NULL,
  `sortingPriorityId` int(10) unsigned NOT NULL DEFAULT '99',
  `productSizeGroupId` int(10) unsigned DEFAULT NULL,
  `productSheetPrototypeId` int(10) unsigned DEFAULT NULL,
  `externalId` varchar(45) DEFAULT NULL,
  `note` varchar(255) DEFAULT NULL,
  `sheetName` varchar(45) DEFAULT NULL,
  `lastUpdate` datetime DEFAULT NULL,
  `status` char(1) NOT NULL DEFAULT 'D',
  PRIMARY KEY (`id`,`productVariantId`),
  KEY `itemno` (`itemno`),
  KEY `fk_product_productSeason1_idx` (`productSeasonId`),
  KEY `fk_product_productColor1_idx` (`productVariantId`),
  KEY `fk_Product_Brand1_idx` (`productBrandId`),
  KEY `fk_Product_SortingPriority1_idx` (`sortingPriorityId`),
  KEY `fk_product_productStatus` (`status`),
  KEY `9_idx` (`productSizeGroupId`),
  KEY `13_idx` (`productSheetPrototypeId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductPhoto
CREATE TABLE IF NOT EXISTS `ProductPhoto` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `size` int(10) unsigned NOT NULL,
  `width` int(10) unsigned DEFAULT NULL,
  `height` int(10) unsigned DEFAULT NULL,
  `dpi` int(10) unsigned NOT NULL DEFAULT '72',
  `name` varchar(255) NOT NULL,
  `mime` varchar(127) DEFAULT NULL,
  `order` int(10) unsigned NOT NULL,
  `creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `isPublic` tinyint(1) unsigned DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `isPublic_idx` (`isPublic`)
) ENGINE=InnoDB AUTO_INCREMENT=215189 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductPhotoStub
CREATE TABLE IF NOT EXISTS `ProductPhotoStub` (
  `id` int(10) unsigned NOT NULL DEFAULT '0',
  `size` int(10) unsigned NOT NULL,
  `width` int(10) unsigned DEFAULT NULL,
  `height` int(10) unsigned DEFAULT NULL,
  `dpi` int(10) unsigned NOT NULL DEFAULT '72',
  `name` varchar(255) NOT NULL,
  `mime` varchar(127) DEFAULT NULL,
  `order` int(10) unsigned NOT NULL,
  `creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `isPublic` tinyint(1) unsigned DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductSaleCount
CREATE TABLE IF NOT EXISTS `ProductSaleCount` (
  `productId` int(10) unsigned NOT NULL,
  `productVariantId` int(10) unsigned NOT NULL,
  `productSizeId` int(10) unsigned NOT NULL,
  `shopId` int(10) unsigned NOT NULL,
  `unitSold` int(10) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`productId`,`productVariantId`,`productSizeId`,`shopId`),
  CONSTRAINT `fk_ProductSaleCount_ProductSku1` FOREIGN KEY (`productId`, `productVariantId`, `productSizeId`, `shopId`) REFERENCES `ProductSku` (`productId`, `productVariantId`, `productSizeId`, `shopId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductSeason
CREATE TABLE IF NOT EXISTS `ProductSeason` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `year` year(4) NOT NULL,
  `isActive` tinyint(4) DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductSeasonTranslation
CREATE TABLE IF NOT EXISTS `ProductSeasonTranslation` (
  `productSeasonId` int(10) unsigned NOT NULL,
  `langId` int(10) unsigned NOT NULL,
  `name` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`productSeasonId`,`langId`),
  KEY `fk_ProductSeason_has_Lang_Lang1_idx` (`langId`),
  KEY `fk_ProductSeason_has_Lang_ProductSeason1_idx` (`productSeasonId`),
  CONSTRAINT `fk_ProductSeason_has_Lang_Lang1` FOREIGN KEY (`langId`) REFERENCES `Lang` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_ProductSeason_has_Lang_ProductSeason1` FOREIGN KEY (`productSeasonId`) REFERENCES `ProductSeason` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductSheet
CREATE TABLE IF NOT EXISTS `ProductSheet` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `productAttributeId` int(10) unsigned NOT NULL,
  `name` varchar(45) NOT NULL,
  `group` varchar(45) NOT NULL,
  PRIMARY KEY (`id`,`productAttributeId`),
  KEY `fk_ProductSheet_ProductAttribute1_idx` (`productAttributeId`),
  CONSTRAINT `fk_ProductSheet_ProductAttribute1` FOREIGN KEY (`productAttributeId`) REFERENCES `ProductAttribute` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=2394 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductSheetActual
CREATE TABLE IF NOT EXISTS `ProductSheetActual` (
  `productId` int(10) unsigned NOT NULL,
  `productVariantId` int(10) unsigned NOT NULL,
  `productDetailLabelId` int(10) unsigned NOT NULL,
  `productDetailId` int(10) unsigned NOT NULL,
  PRIMARY KEY (`productId`,`productVariantId`,`productDetailLabelId`,`productDetailId`),
  KEY `41241241241241_idx` (`productDetailId`),
  KEY `7424124124124_idx` (`productDetailLabelId`),
  CONSTRAINT `441241412412` FOREIGN KEY (`productDetailId`) REFERENCES `ProductDetail` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `7412412412412` FOREIGN KEY (`productDetailLabelId`) REFERENCES `ProductDetailLabel` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_product1112312231` FOREIGN KEY (`productId`, `productVariantId`) REFERENCES `Product` (`id`, `productVariantId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductSheetPrototype
CREATE TABLE IF NOT EXISTS `ProductSheetPrototype` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(45) NOT NULL,
  `group` varchar(45) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=34 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductSheetPrototypeHasProductDetailLabel
CREATE TABLE IF NOT EXISTS `ProductSheetPrototypeHasProductDetailLabel` (
  `productSheetPrototypeId` int(10) unsigned NOT NULL,
  `productDetailLabelId` int(10) unsigned NOT NULL,
  PRIMARY KEY (`productSheetPrototypeId`,`productDetailLabelId`),
  KEY `1245645645645_idx` (`productDetailLabelId`),
  KEY `16456456456451_idx` (`productSheetPrototypeId`),
  CONSTRAINT `1154645645645` FOREIGN KEY (`productSheetPrototypeId`) REFERENCES `ProductSheetPrototype` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `1254645645654` FOREIGN KEY (`productDetailLabelId`) REFERENCES `ProductDetailLabel` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductShippingInfo
CREATE TABLE IF NOT EXISTS `ProductShippingInfo` (
  `productId` int(10) unsigned NOT NULL,
  `productVariantId` int(10) unsigned NOT NULL,
  `productSizeId` int(10) unsigned NOT NULL,
  `boxWidthInMillimiters` int(10) NOT NULL,
  `boxLengthInMillimiters` int(10) NOT NULL,
  `boxHeightInMillimiters` int(10) NOT NULL,
  `boxWeightInGrams` int(10) NOT NULL,
  PRIMARY KEY (`productId`,`productVariantId`,`productSizeId`),
  KEY `23_idx` (`productId`,`productVariantId`,`productSizeId`),
  CONSTRAINT `23` FOREIGN KEY (`productId`, `productVariantId`, `productSizeId`) REFERENCES `ProductSku` (`productId`, `productVariantId`, `productSizeId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductSize
CREATE TABLE IF NOT EXISTS `ProductSize` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `slug` varchar(20) DEFAULT NULL,
  `name` varchar(20) DEFAULT NULL,
  `detail` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=541 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductSizeGroup
CREATE TABLE IF NOT EXISTS `ProductSizeGroup` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `macroName` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `locale` varchar(45) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=247 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductSizeGroupHasProductSize
CREATE TABLE IF NOT EXISTS `ProductSizeGroupHasProductSize` (
  `productSizeGroupId` int(10) unsigned NOT NULL,
  `productSizeId` int(10) unsigned NOT NULL,
  `position` int(2) unsigned NOT NULL,
  PRIMARY KEY (`productSizeGroupId`,`productSizeId`,`position`),
  KEY `fk_ProductSizeGroup_has_ProductSize_ProductSize1_idx` (`productSizeId`),
  KEY `fk_ProductSizeGroup_has_ProductSize_ProductSizeGroup1_idx` (`productSizeGroupId`),
  CONSTRAINT `fk_ProductSizeGroup_has_ProductSize_ProductSize1` FOREIGN KEY (`productSizeId`) REFERENCES `ProductSize` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_ProductSizeGroup_has_ProductSize_ProductSizeGroup1` FOREIGN KEY (`productSizeGroupId`) REFERENCES `ProductSizeGroup` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductSku
CREATE TABLE IF NOT EXISTS `ProductSku` (
  `productId` int(10) unsigned NOT NULL,
  `productVariantId` int(10) unsigned NOT NULL,
  `productSizeId` int(10) unsigned NOT NULL,
  `shopId` int(10) unsigned NOT NULL,
  `shippingBoxId` int(10) unsigned DEFAULT NULL,
  `currencyId` int(10) unsigned DEFAULT '1',
  `barcode` varchar(45) NOT NULL,
  `stockQty` int(10) unsigned NOT NULL DEFAULT '0',
  `padding` int(10) NOT NULL DEFAULT '0',
  `value` double unsigned NOT NULL DEFAULT '0',
  `price` double unsigned NOT NULL DEFAULT '0',
  `salePrice` double unsigned NOT NULL DEFAULT '0',
  `isOnSale` tinyint(1) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`productId`,`productVariantId`,`productSizeId`,`shopId`),
  KEY `fk_ProductSku_ProductSize1_idx123` (`productSizeId`),
  KEY `fk_ProductSku_Shop1_idx456` (`shopId`),
  KEY `fk_productSku_shippingBox_idx` (`shippingBoxId`),
  CONSTRAINT `fk_ProductSku_Product1222222` FOREIGN KEY (`productId`, `productVariantId`) REFERENCES `Product` (`id`, `productVariantId`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_ProductSku_ProductSize133333` FOREIGN KEY (`productSizeId`) REFERENCES `ProductSize` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_ProductSku_Shop1444444` FOREIGN KEY (`shopId`) REFERENCES `Shop` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductSkuHasProductPhoto
CREATE TABLE IF NOT EXISTS `ProductSkuHasProductPhoto` (
  `productId` int(10) unsigned NOT NULL,
  `productVariantId` int(10) unsigned NOT NULL,
  `productSizeId` int(10) unsigned NOT NULL,
  `productPhotoId` int(10) unsigned NOT NULL,
  PRIMARY KEY (`productId`,`productVariantId`,`productSizeId`,`productPhotoId`),
  KEY `fk_ProductSku_has_ProductPhoto_ProductPhoto1_idx` (`productPhotoId`),
  KEY `fk_ProductSkuHasProductPhoto_ProductSku1_idx` (`productId`,`productVariantId`,`productSizeId`),
  CONSTRAINT `fk_ProductSkuHasProductPhoto_ProductSku1` FOREIGN KEY (`productId`, `productVariantId`, `productSizeId`) REFERENCES `ProductSku` (`productId`, `productVariantId`, `productSizeId`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_ProductSku_has_ProductPhoto_ProductPhoto1` FOREIGN KEY (`productPhotoId`) REFERENCES `ProductPhoto` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ProductVariant
CREATE TABLE IF NOT EXISTS `ProductVariant` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `description` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=236199 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.Province
CREATE TABLE IF NOT EXISTS `Province` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `countryId` int(10) unsigned NOT NULL,
  `name` varchar(45) NOT NULL,
  `code` varchar(45) NOT NULL,
  `regionId` varchar(45) DEFAULT NULL,
  `regionName` varchar(45) DEFAULT NULL,
  `fiscalCode` varchar(45) DEFAULT NULL,
  `externalId` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_Province_Country1_idx` (`countryId`),
  CONSTRAINT `fk_Province_Country1` FOREIGN KEY (`countryId`) REFERENCES `Country` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=111 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.RbacPermission
CREATE TABLE IF NOT EXISTS `RbacPermission` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `lft` int(10) unsigned NOT NULL,
  `rght` int(10) unsigned NOT NULL,
  `title` varchar(64) NOT NULL,
  `description` text NOT NULL,
  PRIMARY KEY (`id`),
  KEY `title` (`title`),
  KEY `lft` (`lft`),
  KEY `rgt` (`rght`)
) ENGINE=InnoDB AUTO_INCREMENT=38 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.RbacRole
CREATE TABLE IF NOT EXISTS `RbacRole` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `lft` int(10) unsigned NOT NULL,
  `rght` int(10) unsigned NOT NULL,
  `title` varchar(64) NOT NULL,
  `description` text NOT NULL,
  PRIMARY KEY (`id`),
  KEY `title` (`title`),
  KEY `lft` (`lft`),
  KEY `rgt` (`rght`)
) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.RbacRoleHasRbacPermission
CREATE TABLE IF NOT EXISTS `RbacRoleHasRbacPermission` (
  `rbacRoleId` int(10) unsigned NOT NULL,
  `rbacPermissionId` int(10) unsigned NOT NULL,
  `assignmentDate` datetime NOT NULL,
  PRIMARY KEY (`rbacRoleId`,`rbacPermissionId`),
  KEY `fk_RbacRole_has_RbacPermission_RbacPermission1_idx` (`rbacPermissionId`),
  KEY `fk_RbacRole_has_RbacPermission_RbacRole1_idx` (`rbacRoleId`),
  CONSTRAINT `fk_RbacRole_has_RbacPermission_RbacPermission1` FOREIGN KEY (`rbacPermissionId`) REFERENCES `RbacPermission` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_RbacRole_has_RbacPermission_RbacRole1` FOREIGN KEY (`rbacRoleId`) REFERENCES `RbacRole` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.Shipment
CREATE TABLE IF NOT EXISTS `Shipment` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `carrierId` int(10) unsigned NOT NULL,
  `scope` varchar(45) NOT NULL,
  `bookingNumber` varchar(45) DEFAULT NULL,
  `trackingNumber` varchar(45) DEFAULT NULL,
  `predictedShipmentDate` datetime NOT NULL,
  `delivered` binary(1) DEFAULT NULL,
  `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `declaredValue` double DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_OrderLine_has_Carrier_Carrier1_idx` (`carrierId`),
  CONSTRAINT `fk_OrderLine_has_Carrier_Carrier1` FOREIGN KEY (`carrierId`) REFERENCES `Carrier` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ShippingBox
CREATE TABLE IF NOT EXISTS `ShippingBox` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `weight` int(10) unsigned NOT NULL,
  `width` int(10) unsigned NOT NULL,
  `height` int(10) unsigned NOT NULL,
  `length` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.Shop
CREATE TABLE IF NOT EXISTS `Shop` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `title` varchar(255) NOT NULL,
  `owner` varchar(45) NOT NULL,
  `currentSeasonMultiplier` float DEFAULT '35',
  `pastSeasonMultiplier` float DEFAULT '7',
  `referrerEmails` varchar(255) DEFAULT NULL,
  `saleMultiplier` float NOT NULL,
  `importer` varchar(100) DEFAULT NULL,
  `preOrderExport` tinyint(4) DEFAULT '0',
  `orderExport` tinyint(4) DEFAULT '0',
  `billingLogic` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `nome_UNIQUE` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.ShopHasProduct
CREATE TABLE IF NOT EXISTS `ShopHasProduct` (
  `productId` int(10) unsigned NOT NULL,
  `productVariantId` int(10) unsigned NOT NULL,
  `shopId` int(10) unsigned NOT NULL,
  `extId` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`productId`,`productVariantId`,`shopId`),
  KEY `fk_table1_Product1_idx` (`productId`,`productVariantId`),
  KEY `fk_table1_Shop1_idx` (`shopId`),
  CONSTRAINT `fk_table1_Product1` FOREIGN KEY (`productId`, `productVariantId`) REFERENCES `Product` (`id`, `productVariantId`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_table1_Shop1` FOREIGN KEY (`shopId`) REFERENCES `Shop` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.Sidebar
CREATE TABLE IF NOT EXISTS `Sidebar` (
  `sidebarGroupId` int(10) unsigned NOT NULL,
  `pageId` int(10) unsigned NOT NULL,
  `pageOrder` int(11) DEFAULT NULL,
  `groupOrder` int(3) NOT NULL DEFAULT '0',
  PRIMARY KEY (`sidebarGroupId`,`pageId`),
  KEY `fk_Sidebar_has_Page_Page1_idx` (`pageId`),
  KEY `fk_Sidebar_SidebarGroup1_idx` (`sidebarGroupId`),
  CONSTRAINT `fk_Sidebar_SidebarGroup1` FOREIGN KEY (`sidebarGroupId`) REFERENCES `SidebarGroup` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_Sidebar_has_Page_Page1` FOREIGN KEY (`pageId`) REFERENCES `Page` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.SidebarGroup
CREATE TABLE IF NOT EXISTS `SidebarGroup` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `slug` varchar(255) NOT NULL,
  `icon` varchar(45) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.SidebarGroupTranslation
CREATE TABLE IF NOT EXISTS `SidebarGroupTranslation` (
  `sidebarGroupId` int(10) unsigned NOT NULL,
  `langId` int(10) unsigned NOT NULL,
  `title` varchar(255) NOT NULL,
  PRIMARY KEY (`sidebarGroupId`,`langId`),
  KEY `fk_SidebarGroup_has_Lang_Lang1_idx` (`langId`),
  KEY `fk_SidebarGroupTranslation_SidebarGroup1_idx` (`sidebarGroupId`),
  CONSTRAINT `fk_SidebarGroupTranslation_SidebarGroup1` FOREIGN KEY (`sidebarGroupId`) REFERENCES `SidebarGroup` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_SidebarGroup_has_Lang_Lang1` FOREIGN KEY (`langId`) REFERENCES `Lang` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.SortingPriority
CREATE TABLE IF NOT EXISTS `SortingPriority` (
  `id` int(10) unsigned NOT NULL,
  `priority` varchar(45) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.Tag
CREATE TABLE IF NOT EXISTS `Tag` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `slug` varchar(255) NOT NULL,
  `sortingPriorityId` int(10) unsigned NOT NULL DEFAULT '99',
  PRIMARY KEY (`id`),
  KEY `fk_Tag_SortingPriority1_idx` (`sortingPriorityId`),
  CONSTRAINT `fk_Tag_SortingPriority1` FOREIGN KEY (`sortingPriorityId`) REFERENCES `SortingPriority` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.TagHasLang
CREATE TABLE IF NOT EXISTS `TagHasLang` (
  `tagId` int(10) unsigned NOT NULL,
  `langId` int(10) unsigned NOT NULL,
  `name` varchar(255) NOT NULL,
  PRIMARY KEY (`tagId`,`langId`),
  KEY `fk_Tag_has_Lang_Lang1_idx` (`langId`),
  KEY `fk_Tag_has_Lang_Tag1_idx` (`tagId`),
  CONSTRAINT `fk_Tag_has_Lang_Lang1` FOREIGN KEY (`langId`) REFERENCES `Lang` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_Tag_has_Lang_Tag1` FOREIGN KEY (`tagId`) REFERENCES `Tag` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.TagTranslation
CREATE TABLE IF NOT EXISTS `TagTranslation` (
  `tagId` int(10) unsigned NOT NULL,
  `langId` int(10) unsigned NOT NULL,
  `name` varchar(255) NOT NULL,
  PRIMARY KEY (`tagId`,`langId`),
  KEY `fk_TagTranslation_Lang1_idx` (`langId`),
  KEY `fk_TagTranslation_Tag1_idx` (`tagId`),
  CONSTRAINT `fk_TagTranslation_Lang1` FOREIGN KEY (`langId`) REFERENCES `Lang` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_TagTranslation_Tag1` FOREIGN KEY (`tagId`) REFERENCES `Tag` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.tempIndex
CREATE TABLE IF NOT EXISTS `tempIndex` (
  `id` int(10) unsigned NOT NULL,
  `productVariantId` int(10) unsigned NOT NULL,
  `langId` int(10) unsigned NOT NULL,
  `brand` varchar(100) NOT NULL,
  `color` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL,
  `itemno` varchar(32) NOT NULL,
  `category` varchar(255) NOT NULL,
  `details` text,
  FULLTEXT KEY `tempIndex_all2` (`brand`,`name`,`category`,`description`,`itemno`,`color`,`details`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.TestNs
CREATE TABLE IF NOT EXISTS `TestNs` (
  `id` int(10) unsigned NOT NULL DEFAULT '0',
  `slug` varchar(255) CHARACTER SET utf8 NOT NULL,
  `lft` int(10) unsigned NOT NULL,
  `rght` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `TestNs_lft_uindex` (`lft`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.Token
CREATE TABLE IF NOT EXISTS `Token` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `userId` int(10) unsigned NOT NULL,
  `token` char(128) NOT NULL,
  `tokenType` char(1) NOT NULL,
  `expirationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`,`userId`),
  UNIQUE KEY `token_idx` (`token`,`tokenType`),
  KEY `fk_Token_User` (`userId`),
  KEY `TokenType_idx` (`tokenType`),
  CONSTRAINT `fk_Token_User` FOREIGN KEY (`userId`) REFERENCES `User` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=3509 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.User
CREATE TABLE IF NOT EXISTS `User` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `langId` int(10) unsigned NOT NULL,
  `username` varchar(45) DEFAULT NULL,
  `password` varchar(60) DEFAULT NULL,
  `email` varchar(254) DEFAULT NULL,
  `registrationEntryPoint` varchar(45) NOT NULL,
  `isActive` tinyint(1) NOT NULL,
  `isDeleted` tinyint(1) NOT NULL,
  `lastSeen` timestamp NULL DEFAULT NULL,
  `creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `isEmailChanged` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `email_UNIQUE` (`email`),
  KEY `fk_User_Lang1_idx` (`langId`)
) ENGINE=InnoDB AUTO_INCREMENT=12827 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.UserAddress
CREATE TABLE IF NOT EXISTS `UserAddress` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `userId` int(10) unsigned NOT NULL,
  `isBilling` tinyint(1) NOT NULL DEFAULT '0',
  `isDefault` tinyint(1) NOT NULL DEFAULT '0',
  `name` varchar(45) NOT NULL,
  `surname` varchar(45) NOT NULL,
  `company` varchar(45) DEFAULT NULL,
  `address` varchar(500) NOT NULL,
  `extra` varchar(255) DEFAULT NULL,
  `province` varchar(2) DEFAULT NULL,
  `city` varchar(50) NOT NULL,
  `postcode` varchar(20) DEFAULT NULL,
  `countryId` int(10) unsigned NOT NULL,
  `phone` varchar(45) DEFAULT NULL,
  `lastUsed` tinyint(1) NOT NULL DEFAULT '0',
  `fiscalCode` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`id`,`userId`),
  KEY `fk_UserEmail_User1_idx` (`userId`),
  KEY `fk_UserAddress_Country1_idx` (`countryId`),
  CONSTRAINT `fk_UserAddress_Country1` FOREIGN KEY (`countryId`) REFERENCES `Country` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_UserEmail_User10` FOREIGN KEY (`userId`) REFERENCES `User` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=988 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.UserBrowser
CREATE TABLE IF NOT EXISTS `UserBrowser` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `calculatedId` char(32) NOT NULL,
  `userAgent` varchar(1000) NOT NULL,
  `accept` varchar(255) NOT NULL,
  `acceptEncoding` varchar(255) NOT NULL,
  `acceptLanguage` varchar(255) NOT NULL,
  `plugins` text NOT NULL,
  `timezone` varchar(255) NOT NULL,
  `screenSizeColorDepth` varchar(255) NOT NULL,
  `cookiesEnabled` tinyint(1) unsigned NOT NULL,
  `superCookie` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.UserCompany
CREATE TABLE IF NOT EXISTS `UserCompany` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `userId` int(10) unsigned NOT NULL,
  `name` varchar(45) NOT NULL,
  `vat` varchar(45) NOT NULL,
  `position` varchar(45) NOT NULL,
  PRIMARY KEY (`id`,`userId`),
  KEY `fk_UserCompany_User1_idx` (`userId`),
  CONSTRAINT `fk_UserCompany_User1` FOREIGN KEY (`userId`) REFERENCES `User` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.UserDetails
CREATE TABLE IF NOT EXISTS `UserDetails` (
  `userId` int(10) unsigned NOT NULL,
  `name` varchar(255) DEFAULT NULL,
  `surname` varchar(255) DEFAULT NULL,
  `screenName` varchar(45) DEFAULT NULL,
  `birthDate` date DEFAULT NULL,
  `phone` varchar(45) DEFAULT NULL,
  `gender` char(1) DEFAULT NULL,
  `regDate` datetime DEFAULT NULL,
  `fiscalCode` varchar(16) DEFAULT NULL,
  PRIMARY KEY (`userId`),
  KEY `fk_UserDetails_User1_idx` (`userId`),
  CONSTRAINT `fk_UserDetails_User1` FOREIGN KEY (`userId`) REFERENCES `User` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.UserEmail
CREATE TABLE IF NOT EXISTS `UserEmail` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `userId` int(10) unsigned NOT NULL,
  `address` varchar(100) NOT NULL,
  `isPrimary` tinyint(1) unsigned NOT NULL,
  PRIMARY KEY (`id`,`userId`),
  KEY `fk_UserEmail_User1_idx` (`userId`),
  CONSTRAINT `fk_UserEmail_User1` FOREIGN KEY (`userId`) REFERENCES `User` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=1873 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.UserHasRbacRole
CREATE TABLE IF NOT EXISTS `UserHasRbacRole` (
  `userId` int(10) unsigned NOT NULL,
  `rbacRoleId` int(10) unsigned NOT NULL,
  `assignmentDate` datetime NOT NULL,
  PRIMARY KEY (`userId`,`rbacRoleId`),
  KEY `fk_User_has_RbacRoles_RbacRoles1_idx` (`rbacRoleId`),
  KEY `fk_User_has_RbacRoles_User1_idx` (`userId`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.UserHasShop
CREATE TABLE IF NOT EXISTS `UserHasShop` (
  `userId` int(10) unsigned NOT NULL,
  `shopId` int(10) unsigned NOT NULL,
  PRIMARY KEY (`userId`,`shopId`),
  KEY `fk_Shop_has_User_User1_idx` (`userId`),
  KEY `fk_Shop_has_User_Shop1_idx` (`shopId`),
  CONSTRAINT `fk_Shop_has_User_Shop1` FOREIGN KEY (`shopId`) REFERENCES `Shop` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_Shop_has_User_User1` FOREIGN KEY (`userId`) REFERENCES `User` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.UserPrivacy
CREATE TABLE IF NOT EXISTS `UserPrivacy` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `userId` int(10) unsigned NOT NULL,
  `name` varchar(45) NOT NULL,
  `isActive` tinyint(1) NOT NULL,
  PRIMARY KEY (`id`,`userId`),
  KEY `fk_UserEmail_User1_idx` (`userId`),
  CONSTRAINT `fk_UserEmail_User11` FOREIGN KEY (`userId`) REFERENCES `User` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.UserRegistrationToken
CREATE TABLE IF NOT EXISTS `UserRegistrationToken` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `userId` int(10) unsigned NOT NULL,
  `token` varchar(64) NOT NULL,
  `expiration` datetime DEFAULT NULL,
  `creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `fk_RegistrationToken_User1_idx` (`userId`),
  CONSTRAINT `fk_RegistrationToken_User1` FOREIGN KEY (`userId`) REFERENCES `User` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=1613 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.UserSession
CREATE TABLE IF NOT EXISTS `UserSession` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `sid` char(64) NOT NULL,
  `userId` int(10) unsigned DEFAULT NULL,
  `userBrowserId` int(10) unsigned DEFAULT NULL,
  `ip` varchar(15) NOT NULL,
  `cookie` char(1) DEFAULT NULL,
  `creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `expire` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `request` int(10) NOT NULL DEFAULT '0',
  `lastUpdate` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`id`),
  UNIQUE KEY `sid` (`sid`),
  KEY `fk_UserSession_User1_idx` (`userId`),
  CONSTRAINT `fk_UserSession_User1` FOREIGN KEY (`userId`) REFERENCES `User` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=2095247 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.UserSessionHasOrder
CREATE TABLE IF NOT EXISTS `UserSessionHasOrder` (
  `userSessionId` int(10) unsigned NOT NULL,
  `orderId` int(10) unsigned zerofill NOT NULL,
  PRIMARY KEY (`userSessionId`,`orderId`),
  KEY `fk_UserSession_has_Order_Order1_idx` (`orderId`),
  KEY `userSessionId` (`userSessionId`),
  CONSTRAINT `fk_UserSession_has_Order_Order1` FOREIGN KEY (`orderId`) REFERENCES `Order` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_UserSession_has_Order_UserSession1` FOREIGN KEY (`userSessionId`) REFERENCES `UserSession` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di tabella barbagalloshop.UserToken
CREATE TABLE IF NOT EXISTS `UserToken` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `userId` int(10) unsigned NOT NULL,
  `token` varchar(1000) NOT NULL,
  `expirationDate` datetime NOT NULL,
  `creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`,`userId`),
  KEY `fk_UserToken_User1_idx` (`userId`),
  CONSTRAINT `fk_UserToken_User1` FOREIGN KEY (`userId`) REFERENCES `User` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=5721 DEFAULT CHARSET=utf8;

-- L’esportazione dei dati non era selezionata.
-- Dump della struttura di trigger barbagalloshop.OrderLine_BEFORE_INSERT
DROP TRIGGER IF EXISTS `OrderLine_BEFORE_INSERT`;
SET @OLDTMP_SQL_MODE=@@SQL_MODE, SQL_MODE='STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ALLOW_INVALID_DATES,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
DELIMITER //
CREATE TRIGGER `OrderLine_BEFORE_INSERT` BEFORE INSERT ON `OrderLine` FOR EACH ROW BEGIN
  SELECT COALESCE(MAX(`id`) + 1, 1) INTO @`id` FROM OrderLine WHERE `orderId` = NEW.`orderId`;
  SET NEW.`id` = @`id`;
END//
DELIMITER ;

-- Dump della struttura di trigger barbagalloshop.OrderLine_BEFORE_UPDATE
DROP TRIGGER IF EXISTS `OrderLine_BEFORE_UPDATE`;
SET @OLDTMP_SQL_MODE=@@SQL_MODE, SQL_MODE='STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ALLOW_INVALID_DATES,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
DELIMITER //
CREATE TRIGGER `OrderLine_BEFORE_UPDATE` BEFORE UPDATE ON `OrderLine` FOR EACH ROW BEGIN
  SET NEW.lastUpdate = current_timestamp();
END//
DELIMITER ;

-- Dump della struttura di trigger barbagalloshop.Order_BEFORE_UPDATE
DROP TRIGGER IF EXISTS `Order_BEFORE_UPDATE`;
SET @OLDTMP_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
DELIMITER //
CREATE TRIGGER `Order_BEFORE_UPDATE` BEFORE UPDATE ON `Order` FOR EACH ROW BEGIN
  SET NEW.lastUpdate = current_timestamp();
  IF (NEW.paidAmount is not null AND OLD.paidAmount is null)
  THEN
    SET NEW.paymentDate = current_timestamp();
  END IF;
END//
DELIMITER ;

-- Dump della struttura di trigger barbagalloshop.Post_BEFORE_INSERT
DROP TRIGGER IF EXISTS `Post_BEFORE_INSERT`;
SET @OLDTMP_SQL_MODE=@@SQL_MODE, SQL_MODE='STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ALLOW_INVALID_DATES,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
DELIMITER //
CREATE TRIGGER `Post_BEFORE_INSERT` BEFORE INSERT ON `Post` FOR EACH ROW BEGIN
  SELECT COALESCE(MAX(`id`) + 1, 1) INTO @`id` FROM Post WHERE `blogId` = NEW.`blogId`;
  SET NEW.`id` = @`id`;
END//
DELIMITER ;

-- Dump della struttura di trigger barbagalloshop.UserSession_BEFORE_UPDATE
DROP TRIGGER IF EXISTS `UserSession_BEFORE_UPDATE`;
SET @OLDTMP_SQL_MODE=@@SQL_MODE, SQL_MODE='STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ALLOW_INVALID_DATES,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
DELIMITER //
CREATE TRIGGER `UserSession_BEFORE_UPDATE` BEFORE UPDATE ON `UserSession` FOR EACH ROW BEGIN
  SET NEW.lastUpdate = current_timestamp();
END//
DELIMITER ;

-- Dump della struttura di vista barbagalloshop.ProductDetailTranslationView
DROP VIEW IF EXISTS `ProductDetailTranslationView`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `ProductDetailTranslationView` AS select `view`.`id` AS `id`,`view`.`slug` AS `slug`,`view`.`translatedLangId` AS `translatedLangId`,`view`.`translatedName` AS `translatedName`,if((sum(`ProductSku`.`stockQty`) > 0),1,0) AS `hasQuantity`,count(distinct `ProductSku`.`productVariantId`) AS `timesDetailIsUsedInProduct` from ((`vBluesealProductDetailTranslationStatus` `view` join `ProductSheetActual` on((`ProductSheetActual`.`productDetailId` = `view`.`id`))) join `ProductSku` on(((`ProductSheetActual`.`productId` = `ProductSku`.`productId`) and (`ProductSheetActual`.`productVariantId` = `ProductSku`.`productVariantId`)))) group by `view`.`id`;

-- Dump della struttura di vista barbagalloshop.vBluesealCouponEventList
DROP VIEW IF EXISTS `vBluesealCouponEventList`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealCouponEventList` AS select `CouponEvent`.`id` AS `id`,`CouponEvent`.`name` AS `name`,`CouponEvent`.`description` AS `description`,`CouponEvent`.`click` AS `click`,`CouponEvent`.`startDate` AS `startDate`,`CouponEvent`.`endDate` AS `endDate`,`CouponType`.`name` AS `couponType` from (`CouponEvent` join `CouponType` on((`CouponEvent`.`couponTypeId` = `CouponType`.`id`)));

-- Dump della struttura di vista barbagalloshop.vBluesealCouponList
DROP VIEW IF EXISTS `vBluesealCouponList`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealCouponList` AS select `Coupon`.`id` AS `id`,`Coupon`.`couponTypeId` AS `couponTypeId`,`Coupon`.`tagId` AS `tagId`,`Coupon`.`code` AS `code`,`Coupon`.`issueDate` AS `issueDate`,`Coupon`.`validThru` AS `validThru`,`Coupon`.`amount` AS `amount`,`Coupon`.`amountType` AS `amountType`,`Coupon`.`userId` AS `userId`,`Coupon`.`valid` AS `valid`,`CouponType`.`name` AS `couponType`,`CouponType`.`validForCartTotal` AS `validForCartTotal`,concat(`UserDetails`.`name`,' ',`UserDetails`.`surname`) AS `utente`,`Order`.`id` AS `orderId` from (((`Coupon` join `CouponType` on((`Coupon`.`couponTypeId` = `CouponType`.`id`))) left join `UserDetails` on((`UserDetails`.`userId` = `Coupon`.`userId`))) left join `Order` on((`Order`.`couponId` = `Coupon`.`id`)));

-- Dump della struttura di vista barbagalloshop.vBluesealCouponTypeList
DROP VIEW IF EXISTS `vBluesealCouponTypeList`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealCouponTypeList` AS select `CouponType`.`id` AS `id`,`CouponType`.`name` AS `name`,`CouponType`.`amount` AS `amount`,`CouponType`.`amountType` AS `amountType`,`CouponType`.`validity` AS `validity`,`CouponType`.`validForCartTotal` AS `validForCartTotal` from `CouponType`;

-- Dump della struttura di vista barbagalloshop.vBluesealDetailInLang
DROP VIEW IF EXISTS `vBluesealDetailInLang`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealDetailInLang` AS select `ProductDetail`.`id` AS `id`,`ProductDetail`.`slug` AS `slug`,`Lang`.`id` AS `langId` from (`ProductDetail` join `Lang`);

-- Dump della struttura di vista barbagalloshop.vBluesealDictionaryBrandEdit
DROP VIEW IF EXISTS `vBluesealDictionaryBrandEdit`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealDictionaryBrandEdit` AS select `DictionaryBrand`.`shopId` AS `shopId`,`DictionaryBrand`.`term` AS `term`,`DictionaryBrand`.`productBrandId` AS `foreign` from `DictionaryBrand`;

-- Dump della struttura di vista barbagalloshop.vBluesealDictionaryBrandList
DROP VIEW IF EXISTS `vBluesealDictionaryBrandList`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealDictionaryBrandList` AS select `d1`.`shopId` AS `id`,`d1`.`shopId` AS `shopId`,count(0) AS `count`,(select count(0) AS `count` from `DictionaryBrand` `d2` where ((`d2`.`shopId` = `d1`.`shopId`) and isnull(`d2`.`productBrandId`))) AS `mancanti` from `DictionaryBrand` `d1` group by `d1`.`shopId`;

-- Dump della struttura di vista barbagalloshop.vBluesealDictionaryCategoryEdit
DROP VIEW IF EXISTS `vBluesealDictionaryCategoryEdit`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealDictionaryCategoryEdit` AS select `DictionaryCategory`.`shopId` AS `shopId`,`DictionaryCategory`.`term` AS `term`,`DictionaryCategory`.`productCategoryId` AS `foreign` from `DictionaryCategory`;

-- Dump della struttura di vista barbagalloshop.vBluesealDictionaryCategoryList
DROP VIEW IF EXISTS `vBluesealDictionaryCategoryList`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealDictionaryCategoryList` AS select `d1`.`shopId` AS `id`,`d1`.`shopId` AS `shopId`,count(0) AS `count`,(select count(0) AS `count` from `DictionaryCategory` `d2` where ((`d2`.`shopId` = `d1`.`shopId`) and isnull(`d2`.`productCategoryId`))) AS `mancanti` from `DictionaryCategory` `d1` group by `d1`.`shopId`;

-- Dump della struttura di vista barbagalloshop.vBluesealDictionaryColorEdit
DROP VIEW IF EXISTS `vBluesealDictionaryColorEdit`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealDictionaryColorEdit` AS select `DictionaryColorGroup`.`shopId` AS `shopId`,`DictionaryColorGroup`.`term` AS `term`,`DictionaryColorGroup`.`productColorGroupId` AS `foreign` from `DictionaryColorGroup`;

-- Dump della struttura di vista barbagalloshop.vBluesealDictionaryColorList
DROP VIEW IF EXISTS `vBluesealDictionaryColorList`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealDictionaryColorList` AS select `d1`.`shopId` AS `id`,`d1`.`shopId` AS `shopId`,count(0) AS `count`,(select count(0) AS `count` from `DictionaryColorGroup` `d2` where ((`d2`.`shopId` = `d1`.`shopId`) and isnull(`d2`.`productColorGroupId`))) AS `mancanti` from `DictionaryColorGroup` `d1` group by `d1`.`shopId`;

-- Dump della struttura di vista barbagalloshop.vBluesealDictionarySeasonEdit
DROP VIEW IF EXISTS `vBluesealDictionarySeasonEdit`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealDictionarySeasonEdit` AS select `DictionarySeason`.`shopId` AS `shopId`,`DictionarySeason`.`term` AS `term`,`DictionarySeason`.`productSeasonId` AS `foreign` from `DictionarySeason`;

-- Dump della struttura di vista barbagalloshop.vBluesealDictionarySeasonList
DROP VIEW IF EXISTS `vBluesealDictionarySeasonList`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealDictionarySeasonList` AS select `d1`.`shopId` AS `id`,`d1`.`shopId` AS `shopId`,count(0) AS `count`,(select count(0) AS `count` from `DictionarySeason` `d2` where ((`d2`.`shopId` = `d1`.`shopId`) and isnull(`d2`.`productSeasonId`))) AS `mancanti` from `DictionarySeason` `d1` group by `d1`.`shopId`;

-- Dump della struttura di vista barbagalloshop.vBluesealDictionarySizeEdit
DROP VIEW IF EXISTS `vBluesealDictionarySizeEdit`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealDictionarySizeEdit` AS select `DictionarySize`.`shopId` AS `shopId`,`DictionarySize`.`term` AS `term`,`DictionarySize`.`productSizeId` AS `foreign` from `DictionarySize`;

-- Dump della struttura di vista barbagalloshop.vBluesealDictionarySizeList
DROP VIEW IF EXISTS `vBluesealDictionarySizeList`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealDictionarySizeList` AS select `d1`.`shopId` AS `id`,`d1`.`shopId` AS `shopId`,count(0) AS `count`,(select count(0) AS `count` from `DictionarySize` `d2` where ((`d2`.`shopId` = `d1`.`shopId`) and isnull(`d2`.`productSizeId`))) AS `mancanti` from `DictionarySize` `d1` group by `d1`.`shopId`;

-- Dump della struttura di vista barbagalloshop.vBluesealDictionaryTagEdit
DROP VIEW IF EXISTS `vBluesealDictionaryTagEdit`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealDictionaryTagEdit` AS select `DictionaryTag`.`shopId` AS `shopId`,`DictionaryTag`.`term` AS `term`,`DictionaryTag`.`tagId` AS `foreign` from `DictionaryTag`;

-- Dump della struttura di vista barbagalloshop.vBluesealDictionaryTagList
DROP VIEW IF EXISTS `vBluesealDictionaryTagList`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealDictionaryTagList` AS select `d1`.`shopId` AS `id`,`d1`.`shopId` AS `shopId`,count(0) AS `count`,(select count(0) AS `count` from `DictionaryTag` `d2` where ((`d2`.`shopId` = `d1`.`shopId`) and isnull(`d2`.`tagId`))) AS `mancanti` from `DictionaryTag` `d1` group by `d1`.`shopId`;

-- Dump della struttura di vista barbagalloshop.vBluesealDirtyProductList
DROP VIEW IF EXISTS `vBluesealDirtyProductList`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealDirtyProductList` AS select `s`.`id` AS `id`,`s`.`name` AS `name`,`s`.`title` AS `title`,`s`.`owner` AS `owner`,`j`.`defaultArgs` AS `args`,`j`.`isActive` AS `active`,`j`.`isRunning` AS `running`,`j`.`id` AS `jobId`,`j`.`name` AS `jobName`,`j`.`command` AS `jobCommand` from (`Shop` `s` join `Job` `j`) where (`s`.`id` in (select distinct `DirtyProduct`.`shopId` from `DirtyProduct`) and (`s`.`id` = `j`.`defaultArgs`));

-- Dump della struttura di vista barbagalloshop.vBluesealOrders
DROP VIEW IF EXISTS `vBluesealOrders`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealOrders` AS select `o`.`id` AS `id`,concat(`ud`.`name`,' ',`ud`.`surname`) AS `user`,`ud`.`name` AS `name`,`ud`.`surname` AS `surname`,`u`.`email` AS `email`,`o`.`orderDate` AS `orderDate`,`o`.`lastUpdate` AS `lastUpdate`,concat(`ol`.`productId`,'-',`ol`.`productVariantId`) AS `product`,`s`.`title` AS `shop`,`os`.`title` AS `status`,`o`.`status` AS `statusCode`,`opm`.`name` AS `payment`,`ols`.`title` AS `orderLineStatus`,`pb`.`name` AS `productBrand` from ((((((((((`Order` `o` join `User` `u`) join `UserDetails` `ud`) join `OrderPaymentMethod` `opm`) join `OrderStatus` `os`) join `OrderStatusTranslation` `oshl`) join `OrderLine` `ol`) join `Shop` `s`) join `OrderLineStatus` `ols`) join `Product` `p`) join `ProductBrand` `pb`) where ((`o`.`userId` = `u`.`id`) and (`ud`.`userId` = `u`.`id`) and (`o`.`orderPaymentMethodId` = `opm`.`id`) and (`o`.`status` = `os`.`code`) and (`o`.`status` like 'ORD%') and (`oshl`.`orderStatusId` = `os`.`id`) and (`ol`.`orderId` = `o`.`id`) and (`s`.`id` = `ol`.`shopId`) and (`ol`.`productId` = `p`.`id`) and (`ol`.`productVariantId` = `p`.`productVariantId`) and (`p`.`productBrandId` = `pb`.`id`) and (`ol`.`status` = convert(`ols`.`code` using utf8)));

-- Dump della struttura di vista barbagalloshop.vBluesealPostList
DROP VIEW IF EXISTS `vBluesealPostList`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealPostList` AS select `p`.`id` AS `id`,`p`.`blogId` AS `blogId`,`p`.`postStatusId` AS `postStatusId`,`pt`.`langId` AS `langId`,`p`.`userId` AS `userId`,`p`.`author` AS `author`,`p`.`hits` AS `hits`,`pt`.`coverImage` AS `coverImage`,`pt`.`title` AS `title`,`pt`.`subtitle` AS `subtitle`,`pt`.`content` AS `content`,`ps`.`name` AS `name`,`p`.`creationDate` AS `creationDate`,`p`.`publishDate` AS `status` from ((`Post` `p` join `PostTranslation` `pt` on(((`p`.`id` = `pt`.`postId`) and (`p`.`blogId` = `pt`.`blogId`)))) join `PostStatus` `ps` on((`p`.`postStatusId` = `ps`.`id`)));

-- Dump della struttura di vista barbagalloshop.vBluesealProductActive
DROP VIEW IF EXISTS `vBluesealProductActive`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealProductActive` AS select `Product`.`id` AS `id`,`Product`.`productVariantId` AS `productVariantId`,concat(`Product`.`id`,'-',`Product`.`productVariantId`) AS `code`,group_concat(distinct `Shop`.`title` separator ',') AS `shops`,`Tag`.`id` AS `tag`,`ProductStatus`.`name` AS `status`,`Product`.`sortingPriorityId` AS `productPriority`,min(`Tag`.`sortingPriorityId`) AS `tagPriority`,`ProductBrand`.`name` AS `brand`,sum(`ProductSku`.`stockQty`) AS `totalQty`,`Product`.`creationDate` AS `creation` from (((((((`Product` join `Tag`) join `ProductSku`) join `ProductHasTag`) join `ProductBrand`) join `ProductStatus`) join `Shop`) join `ProductHasProductPhoto`) where ((`ProductHasTag`.`productId` = `Product`.`id`) and (`ProductSku`.`shopId` = `Shop`.`id`) and (`ProductHasTag`.`productVariantId` = `Product`.`productVariantId`) and (convert(`ProductStatus`.`code` using utf8) = `Product`.`status`) and (`Product`.`status` in ('A','P','N')) and (`ProductHasTag`.`tagId` = `Tag`.`id`) and (`Product`.`id` = `ProductSku`.`productId`) and (`ProductSku`.`price` > 0) and (`Product`.`id` = `ProductHasProductPhoto`.`productId`) and (`Product`.`productVariantId` = `ProductHasProductPhoto`.`productVariantId`) and (`Product`.`productVariantId` = `ProductSku`.`productVariantId`) and (`ProductBrand`.`id` = `Product`.`productBrandId`)) group by `Product`.`id`,`Product`.`productVariantId`,`ProductSku`.`price` having (`totalQty` >= 0) order by `Product`.`creationDate` desc;

-- Dump della struttura di vista barbagalloshop.vBluesealProductDescriptionList
DROP VIEW IF EXISTS `vBluesealProductDescriptionList`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealProductDescriptionList` AS select `pd`.`productId` AS `productId`,`pd`.`productVariantId` AS `productVariantId`,1 AS `marketplaceId`,`pd`.`langId` AS `langId`,`l`.`lang` AS `lang`,`l`.`name` AS `langName`,`pd`.`description` AS `description` from (`ProductDescriptionTranslation` `pd` join `Lang` `l`) where ((`pd`.`langId` = `l`.`id`) and (`pd`.`description` <> '') and (`pd`.`description` <> '<br>') and (`pd`.`description` <> '<br><br>'));

-- Dump della struttura di vista barbagalloshop.vBluesealProductDetailByLang
DROP VIEW IF EXISTS `vBluesealProductDetailByLang`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealProductDetailByLang` AS select `ProductDetail`.`id` AS `id`,`ProductDetail`.`slug` AS `slug`,`Lang`.`id` AS `langId`,`Lang`.`lang` AS `langCode` from (`ProductDetail` join `Lang`) where (`ProductDetail`.`slug` <> '');

-- Dump della struttura di vista barbagalloshop.vBluesealProductDetailList2
DROP VIEW IF EXISTS `vBluesealProductDetailList2`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealProductDetailList2` AS select `sq1`.`id` AS `id`,`sq1`.`slug` AS `slug`,`sq1`.`langId` AS `langId`,`ProductDetailTranslation`.`name` AS `name` from (((`vBluesealDetailInLang` `sq1` join `ProductSheetActual` `psa` on((`psa`.`productDetailId` = `sq1`.`id`))) join `ProductSku` `ps` on(((`psa`.`productId` = `ps`.`productId`) and (`psa`.`productVariantId` = `ps`.`productVariantId`)))) left join `ProductDetailTranslation` on(((`ProductDetailTranslation`.`productDetailId` = `sq1`.`id`) and (`ProductDetailTranslation`.`langId` = `sq1`.`langId`)))) group by `sq1`.`id`,`sq1`.`langId` having (sum(`ps`.`stockQty`) > 0) order by `sq1`.`id`,`sq1`.`langId`;

-- Dump della struttura di vista barbagalloshop.vBluesealProductDetailTranslation
DROP VIEW IF EXISTS `vBluesealProductDetailTranslation`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealProductDetailTranslation` AS select `view`.`id` AS `id`,`view`.`slug` AS `slug`,`view`.`translatedLangId` AS `translatedLangId`,`view`.`translatedName` AS `translatedName`,if((sum(`ProductSku`.`stockQty`) > 0),1,0) AS `hasQuantity`,count(distinct `ProductSku`.`productVariantId`) AS `timesDetailIsUsedInProduct` from ((`vBluesealProductDetailTranslationStatus` `view` join `ProductSheetActual` on((`ProductSheetActual`.`productDetailId` = `view`.`id`))) join `ProductSku` on(((`ProductSheetActual`.`productId` = `ProductSku`.`productId`) and (`ProductSheetActual`.`productVariantId` = `ProductSku`.`productVariantId`)))) group by `view`.`id`;

-- Dump della struttura di vista barbagalloshop.vBluesealProductDetailTranslationStatus
DROP VIEW IF EXISTS `vBluesealProductDetailTranslationStatus`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealProductDetailTranslationStatus` AS select `sq1`.`id` AS `id`,`sq1`.`slug` AS `slug`,group_concat(ifnull(`sq1`.`langCode`,'x') order by `sq1`.`langId` ASC separator '|') AS `translatedLangCode`,group_concat(ifnull(`ProductDetailTranslation`.`langId`,'x') order by `sq1`.`langId` ASC separator '|') AS `translatedLangId`,group_concat(ifnull(`ProductDetailTranslation`.`name`,'x') order by `sq1`.`langId` ASC separator '|') AS `translatedName` from (`vBluesealProductDetailByLang` `sq1` left join `ProductDetailTranslation` on(((`ProductDetailTranslation`.`productDetailId` = `sq1`.`id`) and (`ProductDetailTranslation`.`langId` = `sq1`.`langId`)))) group by `sq1`.`id`;

-- Dump della struttura di vista barbagalloshop.vBluesealProductImporter
DROP VIEW IF EXISTS `vBluesealProductImporter`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealProductImporter` AS select `p`.`id` AS `id`,`p`.`productVariantId` AS `productVariantId`,concat(`p`.`itemno`,' # ',`pv`.`name`) AS `code`,`s`.`name` AS `shop`,`s`.`id` AS `shopId`,`pb`.`name` AS `brand`,`p`.`externalId` AS `externalId`,`ps`.`name` AS `status`,`p`.`creationDate` AS `creationDate` from (((((((`Product` `p` join `ProductVariant` `pv` on((`pv`.`id` = `p`.`productVariantId`))) join `ProductBrand` `pb` on((`p`.`productBrandId` = `pb`.`id`))) join `ProductStatus` `ps` on((`p`.`productStatusId` = `ps`.`id`))) join `DirtyProduct` `dp` on(((`p`.`id` = `dp`.`productId`) and (`p`.`productVariantId` = `dp`.`productVariantId`)))) join `DirtySku` `ds` on((`dp`.`id` = `ds`.`dirtyProductId`))) left join `ShopHasProduct` `sp` on(((`dp`.`productId` = `sp`.`productId`) and (`dp`.`productVariantId` = `sp`.`productVariantId`) and (`dp`.`shopId` = `sp`.`shopId`)))) join `Shop` `s` on((`sp`.`shopId` = `s`.`id`))) where ((`ps`.`code` not in ('N','C')) and (`s`.`importer` is not null) and (`ds`.`status` <> 'ok')) group by `dp`.`productId`,`dp`.`productVariantId`,`dp`.`shopId` having (sum(`ds`.`qty`) > 0);

-- Dump della struttura di vista barbagalloshop.vBluesealProductIncomplete
DROP VIEW IF EXISTS `vBluesealProductIncomplete`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealProductIncomplete` AS select `p`.`id` AS `id`,`p`.`productVariantId` AS `productVariantId`,`sp`.`shopId` AS `shopId`,`s`.`name` AS `shop`,concat(`p`.`itemno`,' # ',`pv`.`name`) AS `code`,`p`.`productSeasonId` AS `season`,`p`.`externalId` AS `externalId`,`pb`.`name` AS `brand`,sum(`pk`.`stockQty`) AS `totalQty`,`ps`.`name` AS `status`,`p`.`creationDate` AS `creationDate`,concat_ws(' ',if(isnull(`p`.`sizeGroupId`),'E400',NULL),if(isnull(`p`.`productSeasonId`),'E410',NULL),if((`p`.`productBrandId` = 1),'E420',NULL),if(isnull(`p`.`sheetName`),'E430',NULL),if(isnull(`pc`.`productColorGroupId`),'E440',NULL),if(isnull(`pp`.`productId`),'E450',NULL),if(isnull(`pk`.`productId`),'E460',NULL),if(isnull(`pn`.`name`),'E470',NULL),if(isnull(`pd`.`productId`),'E480',NULL)) AS `problems` from ((((((((((`Product` `p` left join `ShopHasProduct` `sp` on(((`p`.`id` = `sp`.`productId`) and (`p`.`productVariantId` = `sp`.`productVariantId`)))) left join `ProductHasProductColorGroup` `pc` on(((`pc`.`productId` = `p`.`id`) and (`pc`.`productVariantId` = `p`.`productVariantId`)))) left join `ProductName` `pn` on(((`pn`.`productId` = `p`.`id`) and (`pn`.`productVariantId` = `p`.`productVariantId`)))) left join `ProductBrand` `pb` on((`p`.`productBrandId` = `pb`.`id`))) left join `Shop` `s` on((`s`.`id` = `sp`.`shopId`))) left join `ProductVariant` `pv` on((`p`.`productVariantId` = `pv`.`id`))) left join `ProductStatus` `ps` on((convert(`ps`.`code` using utf8) = `p`.`status`))) left join `ProductSku` `pk` on(((`p`.`id` = `pk`.`productId`) and (`p`.`productVariantId` = `pk`.`productVariantId`)))) left join `ProductHasProductPhoto` `pp` on(((`p`.`id` = `pp`.`productId`) and (`p`.`productVariantId` = `pp`.`productVariantId`)))) left join `ProductDescription` `pd` on(((`p`.`id` = `pd`.`productId`) and (`p`.`productVariantId` = `pd`.`productVariantId`)))) where ((`p`.`status` not in ('C','N')) and (`pn`.`langId` = 1) and (`pn`.`name` = '') and (isnull(`pc`.`productColorGroupId`) or isnull(`p`.`sizeGroupId`) or isnull(`p`.`productSeasonId`) or (`p`.`productBrandId` = 1) or isnull(`p`.`sheetName`) or ((`p`.`status` in ('W','G')) and (`p`.`dummyPicture` <> '0000000000.jpg')))) group by `p`.`id`,`p`.`productVariantId` having (`totalQty` > 0) order by `p`.`creationDate` desc;

-- Dump della struttura di vista barbagalloshop.vBluesealProductList
DROP VIEW IF EXISTS `vBluesealProductList`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealProductList` AS select concat(`p`.`id`,'-',`pv`.`id`) AS `codice`,`p`.`id` AS `id`,`p`.`productVariantId` AS `productVariantId`,concat(`p`.`itemno`,' # ',`pv`.`name`) AS `cpf`,`s`.`name` AS `shop`,`p`.`externalId` AS `externalId`,`pb`.`name` AS `brand`,`ps`.`name` AS `status`,`p`.`creationDate` AS `creationDate`,`s`.`id` AS `shopId`,`pc`.`slug` AS `slug`,`dp`.`extId` AS `extId`,`ds`.`extSkuId` AS `extSkuId` from (((((((((`Product` `p` join `ProductVariant` `pv`) join `ProductBrand` `pb`) join `ProductStatus` `ps`) join `ShopHasProduct` `sp`) join `Shop` `s`) join `ProductCategory` `pc`) join `ProductHasProductCategory` `ppc`) left join `DirtyProduct` `dp` on(((`p`.`id` = `dp`.`productId`) and (`p`.`productVariantId` = `dp`.`productVariantId`) and (`sp`.`shopId` = `dp`.`shopId`)))) left join `DirtySku` `ds` on((`dp`.`id` = `ds`.`dirtyProductId`))) where ((`p`.`productVariantId` = `pv`.`id`) and (`p`.`productBrandId` = `pb`.`id`) and (((`p`.`id` = `sp`.`productId`) and (`p`.`productVariantId` = `sp`.`productVariantId`)) or (isnull(`sp`.`productId`) and isnull(`sp`.`productVariantId`))) and (`sp`.`shopId` = `s`.`id`) and (`ps`.`id` = `p`.`productStatusId`) and (`pc`.`id` = `ppc`.`productCategoryId`) and (((`p`.`id` = `ppc`.`productId`) and (`p`.`productVariantId` = `ppc`.`productVariantId`)) or (isnull(`ppc`.`productId`) and isnull(`ppc`.`productVariantId`))));

-- Dump della struttura di vista barbagalloshop.vBluesealProductNameList
DROP VIEW IF EXISTS `vBluesealProductNameList`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealProductNameList` AS select `pn`.`productId` AS `productId`,`pn`.`productVariantId` AS `productVariantId`,`pn`.`langId` AS `langId`,`l`.`lang` AS `lang`,`l`.`name` AS `langName`,`pn`.`name` AS `name`,count(`pn`.`productVariantId`) AS `conto`,sum(`ps`.`stockQty`) AS `quanti` from ((`ProductNameTranslation` `pn` join `ProductSku` `ps`) join `Lang` `l`) where ((`pn`.`langId` = `l`.`id`) and (`pn`.`productId` = `ps`.`productId`) and (`pn`.`productVariantId` = `ps`.`productVariantId`)) group by `pn`.`productId`,`pn`.`productVariantId` having (`quanti` > 0);

-- Dump della struttura di vista barbagalloshop.vBluesealTagList
DROP VIEW IF EXISTS `vBluesealTagList`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealTagList` AS select `Tag`.`id` AS `id`,`Tag`.`slug` AS `slug`,`SortingPriority`.`priority` AS `priority` from (`Tag` join `SortingPriority` on((`Tag`.`sortingPriorityId` = `SortingPriority`.`id`)));

-- Dump della struttura di vista barbagalloshop.vBluesealUsers
DROP VIEW IF EXISTS `vBluesealUsers`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vBluesealUsers` AS select `u`.`id` AS `id`,`ud`.`name` AS `name`,`ud`.`surname` AS `surname`,`u`.`email` AS `email`,if((`ud`.`gender` = 'F'),'Donna','Uomo') AS `sex`,if((`u`.`isActive` = 1),'Attivato','Disattivato') AS `status`,`u`.`creationDate` AS `creationDate` from (`User` `u` join `UserDetails` `ud`) where (`u`.`id` = `ud`.`userId`) order by `u`.`creationDate` desc;

-- Dump della struttura di vista barbagalloshop.vCategories
DROP VIEW IF EXISTS `vCategories`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vCategories` AS select `father`.`id` AS `fatherId`,`parent`.`id` AS `id`,(select count(`parent2`.`id`) from `ProductCategory` `parent2` where ((`parent`.`lft` > `parent2`.`lft`) and (`parent`.`rght` < `parent2`.`rght`))) AS `depth`,count(distinct `phpc`.`product`,`phpc`.`variant`) AS `visible` from (((`ProductCategory` `node` join `ProductCategory` `parent`) join `vProductSortingView` `phpc`) join `ProductCategory` `father`) where ((`node`.`lft` between `parent`.`lft` and `parent`.`rght`) and (`node`.`id` = `phpc`.`category`) and (`parent`.`lft` between `father`.`lft` and `father`.`rght`)) group by `parent`.`id` having ((`depth` between 1 and 3) and (`visible` > 0)) order by `parent`.`lft`;

-- Dump della struttura di vista barbagalloshop.vProductShopView
DROP VIEW IF EXISTS `vProductShopView`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vProductShopView` AS select `p`.`id` AS `id`,`p`.`productVariantId` AS `productVariantId`,`p`.`itemno` AS `itemno`,`p`.`creationDate` AS `creationDate`,`p`.`dummyPicture` AS `dummyPicture`,`p`.`productSeasonId` AS `productSeasonId`,`p`.`productBrandId` AS `productBrandId`,`p`.`sortingPriorityId` AS `sortingPriorityId`,`p`.`sizeGroupId` AS `sizeGroupId`,`p`.`externalId` AS `externalId`,`p`.`note` AS `note`,`p`.`sheetName` AS `sheetName`,`p`.`lastUpdate` AS `lastUpdate`,`p`.`status` AS `status`,`sp`.`shopId` AS `shopId` from (`Product` `p` left join `ShopHasProduct` `sp` on(((`p`.`id` = `sp`.`productId`) and (`p`.`productVariantId` = `sp`.`productVariantId`)))) where (isnull(`sp`.`productId`) or (`sp`.`productId` is not null));

-- Dump della struttura di vista barbagalloshop.vProductSortingView
DROP VIEW IF EXISTS `vProductSortingView`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vProductSortingView` AS select `Product`.`id` AS `product`,`Product`.`productVariantId` AS `variant`,`ProductSku`.`shopId` AS `shop`,`Tag`.`id` AS `tag`,min(`ProductSku`.`price`) AS `price`,`Product`.`sortingPriorityId` AS `productPriority`,`Tag`.`sortingPriorityId` AS `tagPriority`,`ProductBrand`.`id` AS `brand`,`ProductSku`.`productSizeId` AS `size`,(case when isnull(`ProductHasProductColorGroup`.`productColorGroupId`) then 1 else `ProductHasProductColorGroup`.`productColorGroupId` end) AS `color`,`ProductHasProductCategory`.`productCategoryId` AS `category`,`ProductCategory`.`lft` AS `lft`,max(`ProductSku`.`stockQty`) AS `maxQty`,`Product`.`creationDate` AS `creation` from (((((((((`Product` join `Tag`) join `ProductStatus`) join `ProductSku`) join `ProductHasTag`) join `ProductBrand`) join `ProductSize`) join `ProductCategory`) join `ProductHasProductCategory`) left join `ProductHasProductColorGroup` on(((`Product`.`id` = `ProductHasProductColorGroup`.`productId`) and (`Product`.`productVariantId` = `ProductHasProductColorGroup`.`productVariantId`)))) where ((`ProductHasTag`.`productId` = `Product`.`id`) and (`ProductHasTag`.`productVariantId` = `Product`.`productVariantId`) and (`Product`.`productStatusId` = `ProductStatus`.`id`) and (`ProductStatus`.`isVisible` = 1) and (`ProductHasTag`.`tagId` = `Tag`.`id`) and (`Product`.`id` = `ProductSku`.`productId`) and (`ProductSku`.`price` > 0) and (`Product`.`productVariantId` = `ProductSku`.`productVariantId`) and (`ProductBrand`.`id` = `Product`.`productBrandId`) and (`ProductSize`.`id` = `ProductSku`.`productSizeId`) and (`ProductHasProductCategory`.`productId` = `Product`.`id`) and (`ProductHasProductCategory`.`productVariantId` = `Product`.`productVariantId`) and (`ProductCategory`.`id` = `ProductHasProductCategory`.`productCategoryId`) and (`ProductCategory`.`id` <> 1)) group by `Product`.`id`,`Product`.`productVariantId`,`ProductHasProductCategory`.`productCategoryId`,`ProductSku`.`price`,`Tag`.`id` having ((`maxQty` > 0) and (`ProductSku`.`price` > 0)) order by `Tag`.`sortingPriorityId`,`Product`.`sortingPriorityId`;

-- Dump della struttura di vista barbagalloshop.vRepairNestedSet
DROP VIEW IF EXISTS `vRepairNestedSet`;
-- Rimozione temporanea di tabella e creazione della struttura finale della vista
CREATE VIEW `vRepairNestedSet` AS select `p`.`id` AS `pid`,`p`.`slug` AS `pname`,`c`.`id` AS `cid`,`c`.`slug` AS `cname` from (`TestNs` `c` left join `TestNs` `p` on((`p`.`lft` = (select max(`l`.`lft`) from `TestNs` `l` where ((`c`.`lft` > `l`.`lft`) and (`c`.`lft` < `l`.`rght`)))))) order by `p`.`lft`,`c`.`lft`;

