CREATE TABLE `groups1` (
  `ID` int(10) UNSIGNED NOT NULL,
  `PostDate` date DEFAULT NULL,
  `LastUpdate` datetime DEFAULT NULL,
  `Code` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ParentID` int(10) UNSIGNED NOT NULL DEFAULT '0',
  `Color` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `UploadID` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `Image` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `Visible` tinyint(1) UNSIGNED NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

ALTER TABLE `groups1`
  ADD PRIMARY KEY (`ID`),
  ADD KEY `ParentID` (`ParentID`);

ALTER TABLE `groups1`
  MODIFY `ID` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

INSERT INTO `groups1`
SELECT * FROM `groups` WHERE `ID` IN (SELECT `GroupID` FROM `product_groups`);

REPLACE INTO `groups1`
SELECT * FROM `groups` WHERE `ID` IN (SELECT DISTINCT `ParentID` FROM `groups1` WHERE `ParentID` > 0);



CREATE TABLE `group_texts1` (
  `GroupID` int(10) UNSIGNED NOT NULL,
  `Language` char(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'bg',
  `MenuLabel` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `Title` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `URLLabel` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

ALTER TABLE `group_texts1`
  ADD PRIMARY KEY (`GroupID`,`Language`) USING BTREE,
  ADD UNIQUE KEY `URLLabel` (`Language`,`URLLabel`) USING BTREE;

INSERT INTO `group_texts1`
SELECT * FROM `group_texts` WHERE `GroupID` IN (SELECT `ID` FROM `groups1`);