CREATE TABLE `contentTemplate` (
  `id_template` int(11) NOT NULL AUTO_INCREMENT,
  `id_dd` int(11) DEFAULT NULL,
  `id_templatetype` int(11) NOT NULL,
  `templatename` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `template` text COLLATE utf8_unicode_ci DEFAULT NULL,
  `hidden` tinyint(4) NOT NULL DEFAULT 0,
  `displayorder` int(11) NOT NULL,
  `preview` text COLLATE utf8_unicode_ci DEFAULT NULL,
  `templatefile` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `ismastercopy` tinyint(4) NOT NULL DEFAULT 0,
  `id_template_copiedfrom` int(11) DEFAULT NULL,
  `id_design_copiedfrom` int(11) DEFAULT NULL,
  PRIMARY KEY (`id_template`),
  KEY `FK_contentTemplate_domain_id_dd` (`id_dd`),
  KEY `FK_contentTemplate_contentTemplateType_id_templatetype` (`id_templatetype`),
  CONSTRAINT `FK_contentTemplate_contentTemplateType_id_templatetype` FOREIGN KEY (`id_templatetype`) REFERENCES `contentTemplateType` (`id_templatetype`) ON UPDATE CASCADE,
  CONSTRAINT `FK_contentTemplate_domain_id_dd` FOREIGN KEY (`id_dd`) REFERENCES `domain` (`id_dd`) ON DELETE NO ACTION ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC;


CREATE TABLE `content` (
  `id_con` int(7) NOT NULL AUTO_INCREMENT,
  `id_dd` int(11) NOT NULL,
  `slug` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `id_status` int(11) NOT NULL DEFAULT 10,
  `id_contenttype` int(11) NOT NULL,
  `id_skeleton` int(11) DEFAULT NULL,
  `id_template` int(11) DEFAULT NULL,
  `subadmin` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `allowsearch` tinyint(4) NOT NULL DEFAULT 1,
  `pagetitle` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `metatitle` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL,
  `metakeywords` varchar(1500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `metadescription` varchar(1500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `dateadd` datetime NOT NULL DEFAULT current_timestamp(),
  `datemodify` datetime NOT NULL DEFAULT current_timestamp(),
  `notes` text COLLATE utf8_unicode_ci DEFAULT NULL,
  `userid` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `content_route` varchar(512) COLLATE utf8_unicode_ci DEFAULT NULL,
  `content_pagelink` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id_con`),
  UNIQUE KEY `UK_content2` (`id_dd`,`slug`),
  UNIQUE KEY `UK_content3` (`id_dd`,`content_route`),
  KEY `UK_content` (`id_dd`),
  KEY `FK_content_id_status` (`id_status`),
  KEY `FK_content_id_contenttype` (`id_contenttype`),
  KEY `FK_content_contentTemplate_id_template` (`id_template`),
  KEY `IDX_content` (`id_dd`,`content_pagelink`),
  KEY `FK_content_contentTemplate_id_skeleton` (`id_skeleton`),
  CONSTRAINT `FK_content_contentTemplate_id_skeleton` FOREIGN KEY (`id_skeleton`) REFERENCES `contentTemplate` (`id_template`) ON UPDATE CASCADE,
  CONSTRAINT `FK_content_contentTemplate_id_template` FOREIGN KEY (`id_template`) REFERENCES `contentTemplate` (`id_template`) ON DELETE NO ACTION ON UPDATE CASCADE,
  CONSTRAINT `FK_content_ddserver1_id_dd` FOREIGN KEY (`id_dd`) REFERENCES `domain` (`id_dd`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `FK_content_id_contenttype` FOREIGN KEY (`id_contenttype`) REFERENCES `contentType` (`id_contenttype`) ON UPDATE CASCADE,
  CONSTRAINT `FK_content_id_status` FOREIGN KEY (`id_status`) REFERENCES `status` (`id_status`) ON DELETE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=1206 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AVG_ROW_LENGTH=1365;

CREATE TABLE `contentItem` (
  `id_contentitem` int(7) NOT NULL AUTO_INCREMENT,
  `id_con` int(11) NOT NULL,
  `userid` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `content` mediumtext COLLATE utf8_unicode_ci DEFAULT NULL,
  `textonly` text COLLATE utf8_unicode_ci DEFAULT NULL,
  `datemodify` datetime NOT NULL DEFAULT current_timestamp(),
  `id_feature` int(11) DEFAULT NULL,
  `id_region` int(11) DEFAULT NULL,
  `id_block` int(11) DEFAULT NULL,
  `id_list` int(11) DEFAULT NULL,
  `extradata` text COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id_contentitem`),
  KEY `IDX_contentItem` (`id_con`),
  KEY `IDX_contentItem2` (`id_con`),
  KEY `FK_contentItem_contentPart_id_feature` (`id_feature`),
  KEY `FK_contentItem_contentBlock_id_block` (`id_block`),
  KEY `FK_contentItem_featureBoxList_id_list` (`id_list`),
  KEY `FK_contentItem_contentTemplateRegion_id_region` (`id_region`),
  KEY `IDX_contentItem3` (`id_con`,`id_region`),
  CONSTRAINT `FK_contentItem_contentBlock_id_block` FOREIGN KEY (`id_block`) REFERENCES `contentBlock` (`id_block`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `FK_contentItem_contentPart_id_feature` FOREIGN KEY (`id_feature`) REFERENCES `contentPart` (`id_feature`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `FK_contentItem_contentTemplateRegion_id_region` FOREIGN KEY (`id_region`) REFERENCES `contentTemplateRegion` (`id_region`) ON UPDATE CASCADE,
  CONSTRAINT `FK_contentItem_content_id_con` FOREIGN KEY (`id_con`) REFERENCES `content` (`id_con`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `FK_contentItem_featureBoxList_id_list` FOREIGN KEY (`id_list`) REFERENCES `featureBoxList` (`id_list`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `CK_contentItem` CHECK (`extradata` is null or json_valid(`extradata`))
) ENGINE=InnoDB AUTO_INCREMENT=2034 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AVG_ROW_LENGTH=1365 ROW_FORMAT=DYNAMIC;

