CREATE TABLE `domain` (
  `id_dd` int(11) NOT NULL AUTO_INCREMENT,
  `domain` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `id_status` int(11) NOT NULL,
  `id_contenteditortype` int(11) DEFAULT NULL,
  `id_plan` int(11) NOT NULL,
  `id_design` int(11) DEFAULT NULL,
  `id_emailaccounts` int(11) NOT NULL,
  `id_pagesetup` int(11) NOT NULL,
  `id_palette` int(11) DEFAULT NULL,
  `id_theme` int(11) DEFAULT NULL,
  `date` date DEFAULT NULL,
  `log` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `lockout` tinyint(4) NOT NULL DEFAULT 0,
  `server` int(11) DEFAULT NULL,
  `emailserver` int(11) DEFAULT NULL,
  `company` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL,
  `legalname` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL,
  `responsivemenutitle` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL,
  `lastlogin` datetime DEFAULT NULL,
  `istock` int(11) NOT NULL DEFAULT 0,
  `renewdate` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
  `defaultfromemail` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `defaulttoemail` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `slpwfromemail` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `slpwtoemail` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `returnpathemail` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `mcontact` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL,
  `memail` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL,
  `bcontact` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL,
  `bemail` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL,
  `contactdatemodify` datetime DEFAULT NULL,
  `wlstatus` tinyint(4) NOT NULL DEFAULT 0,
  `wlconame` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL,
  `wlwebsite` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL,
  `wlcopyright` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL,
  `domainreg` tinyint(4) NOT NULL DEFAULT 0,
  `rsemailcount` int(11) NOT NULL DEFAULT 0,
  `timezonename` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'America/New_York',
  `enablerssall` tinyint(4) NOT NULL DEFAULT 0,
  `rssmessage` text COLLATE utf8_unicode_ci DEFAULT NULL,
  `notes` text COLLATE utf8_unicode_ci DEFAULT NULL,
  `supportnotes` text COLLATE utf8_unicode_ci DEFAULT NULL,
  `accesslevels` text COLLATE utf8_unicode_ci DEFAULT NULL,
  `usecontactsetup` tinyint(4) NOT NULL DEFAULT 0,
  `slideenable` tinyint(4) NOT NULL DEFAULT 0,
  `slidesize` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
  `slidepause` int(11) DEFAULT NULL,
  `slidefade` int(11) DEFAULT NULL,
  `sliderandom` tinyint(4) NOT NULL DEFAULT 0,
  `slidesinglepage` tinyint(4) NOT NULL DEFAULT 0,
  `metatitle` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `metakeywords` varchar(1500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `metadescription` varchar(1500) COLLATE utf8_unicode_ci DEFAULT NULL,
  `dbtable` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `usercount` int(11) DEFAULT NULL,
  `darkbackground` tinyint(4) NOT NULL DEFAULT 0,
  `copyright_br` int(11) DEFAULT NULL,
  `copyright_keyword` int(11) DEFAULT NULL,
  `googlesiteverif` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `analytics` text COLLATE utf8_unicode_ci DEFAULT NULL,
  `history` text COLLATE utf8_unicode_ci DEFAULT NULL,
  `userstore` int(11) NOT NULL DEFAULT 10,
  `validatedns` tinyint(4) NOT NULL DEFAULT 0,
  `lastdnsdate` datetime DEFAULT NULL,
  `enableipblock` tinyint(4) NOT NULL DEFAULT 0,
  `enablessl` tinyint(4) NOT NULL DEFAULT 0,
  `enablesms` tinyint(4) NOT NULL DEFAULT 0,
  `enablehomepageboxes` tinyint(4) NOT NULL DEFAULT 0,
  `testsiteurl` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `purchasesingleemail` tinyint(4) NOT NULL DEFAULT 0,
  `additionalheader` text COLLATE utf8_unicode_ci DEFAULT NULL,
  `overrideheader` text COLLATE utf8_unicode_ci DEFAULT NULL,
  `enablerouting` tinyint(4) NOT NULL,
  `termsofservice` text COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id_dd`),
  UNIQUE KEY `domain` (`domain`),
  KEY `FK_domain_plan_id_plan` (`id_plan`),
  KEY `UK_domain` (`domain`),
  KEY `FK_domain_id_pagesetup` (`id_pagesetup`),
  KEY `FK_domain_id_status` (`id_status`),
  KEY `FK_domain_id_emailaccounts` (`id_emailaccounts`),
  KEY `FK_domain_contentEditorType_id_type` (`id_contenteditortype`),
  KEY `FK_domain_design_id_design` (`id_design`),
  CONSTRAINT `FK_domain_contentEditorType_id_type` FOREIGN KEY (`id_contenteditortype`) REFERENCES `contentEditorType` (`id_type`) ON UPDATE CASCADE,
  CONSTRAINT `FK_domain_design_id_design` FOREIGN KEY (`id_design`) REFERENCES `design` (`id_design`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_domain_id_emailaccounts` FOREIGN KEY (`id_emailaccounts`) REFERENCES `domainEmail` (`id_email`) ON DELETE NO ACTION,
  CONSTRAINT `FK_domain_id_pagesetup` FOREIGN KEY (`id_pagesetup`) REFERENCES `domainPageSetup` (`id_pagesetup`) ON DELETE NO ACTION,
  CONSTRAINT `FK_domain_id_status` FOREIGN KEY (`id_status`) REFERENCES `domainStatus` (`id_status`) ON DELETE NO ACTION,
  CONSTRAINT `FK_domain_plan_id_plan` FOREIGN KEY (`id_plan`) REFERENCES `plan` (`id_plan`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=4292 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AVG_ROW_LENGTH=956 ROW_FORMAT=DYNAMIC;

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 `contentTemplateRegion` (
  `id_region` int(11) NOT NULL AUTO_INCREMENT,
  `id_template` int(11) NOT NULL,
  `id_category` int(11) DEFAULT NULL,
  `default_id_feature` int(11) DEFAULT NULL,
  `defaultcontent` mediumtext COLLATE utf8_unicode_ci DEFAULT NULL,
  `default_id_block` int(11) DEFAULT NULL,
  `default_id_list` int(11) DEFAULT NULL,
  `default_extradata` text COLLATE utf8_unicode_ci DEFAULT NULL,
  `regionname` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `region` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `notes` varchar(1000) COLLATE utf8_unicode_ci DEFAULT NULL,
  `properties` text COLLATE utf8_unicode_ci DEFAULT NULL,
  `displayorder` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id_region`),
  UNIQUE KEY `UK_contentTemplateRegion` (`id_template`,`region`),
  KEY `FK_contentTemplateRegion_contentPartCategory_id_category` (`id_category`),
  KEY `FK_contentTemplateRegion_contentBlock_id_block` (`default_id_block`),
  KEY `FK_contentTemplateRegion_featureBoxList_id_list` (`default_id_list`),
  KEY `FK_contentTemplateRegion_contentPart_id_feature` (`default_id_feature`),
  CONSTRAINT `FK_contentTemplateRegion_contentBlock_id_block` FOREIGN KEY (`default_id_block`) REFERENCES `contentBlock` (`id_block`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `FK_contentTemplateRegion_contentPartCategory_id_category` FOREIGN KEY (`id_category`) REFERENCES `contentPartCategory` (`id_category`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `FK_contentTemplateRegion_contentPart_id_feature` FOREIGN KEY (`default_id_feature`) REFERENCES `contentPart` (`id_feature`) ON UPDATE CASCADE,
  CONSTRAINT `FK_contentTemplateRegion_contentTemplate_id_template` FOREIGN KEY (`id_template`) REFERENCES `contentTemplate` (`id_template`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `FK_contentTemplateRegion_featureBoxList_id_list` FOREIGN KEY (`default_id_list`) REFERENCES `featureBoxList` (`id_list`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `CK_contentTemplateRegion` CHECK (`properties` is null or json_valid(`properties`))
) ENGINE=InnoDB AUTO_INCREMENT=64 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AVG_ROW_LENGTH=4096 ROW_FORMAT=DYNAMIC;

  CREATE TABLE `contentPart` (
  `id_feature` int(11) NOT NULL,
  `id_featuretype` int(11) DEFAULT NULL,
  `id_featurenavtype` int(11) DEFAULT NULL,
  `id_feature_parent` int(11) DEFAULT NULL,
  `displayorder` int(11) NOT NULL,
  `maxuse` int(11) NOT NULL,
  `infocode` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `installpath` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `featuretext` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `featurelink` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `featureroute` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `aplink` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `id_matrix` int(11) DEFAULT NULL,
  `editortype` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `description` varchar(512) COLLATE utf8_unicode_ci DEFAULT NULL,
  `json_metadata` text COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id_feature`),
  UNIQUE KEY `UK_contentPart_id_feature` (`id_feature`),
  KEY `FK_contentPart_featureType_id_featuretype` (`id_featuretype`),
  KEY `FK_contentPart_id_matrix` (`id_matrix`),
  KEY `FK_id_featurenavtype` (`id_featurenavtype`),
  KEY `FK_contentPart_contentPart_id_feature` (`id_feature_parent`),
  CONSTRAINT `FK_contentPart_contentPart_id_feature` FOREIGN KEY (`id_feature_parent`) REFERENCES `contentPart` (`id_feature`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `FK_contentPart_featureType_id_featuretype` FOREIGN KEY (`id_featuretype`) REFERENCES `featureType` (`id_featuretype`) ON UPDATE CASCADE,
  CONSTRAINT `FK_contentPart_id_matrix` FOREIGN KEY (`id_matrix`) REFERENCES `featureMatrix` (`id_matrix`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `FK_id_featurenavtype` FOREIGN KEY (`id_featurenavtype`) REFERENCES `featureNavType` (`id_featurenavtype`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AVG_ROW_LENGTH=256 ROW_FORMAT=DYNAMIC COMMENT='FK_featureMatrix';

  CREATE TABLE `contentBlock` (
  `id_block` int(11) NOT NULL AUTO_INCREMENT,
  `id_dd` int(11) NOT NULL,
  `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  `contentblock` text COLLATE utf8_unicode_ci DEFAULT NULL,
  `id_status` int(11) NOT NULL DEFAULT 10,
  `notes` text COLLATE utf8_unicode_ci DEFAULT NULL,
  `datemodify` datetime DEFAULT current_timestamp(),
  `userid` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id_block`),
  KEY `FK_contentLayout_ddserver1_id_dd` (`id_dd`),
  CONSTRAINT `FK_contentLayout_ddserver1_id_dd` FOREIGN KEY (`id_dd`) REFERENCES `domain` (`id_dd`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AVG_ROW_LENGTH=1638;

  CREATE TABLE `featureBoxList` (
  `id_list` int(11) NOT NULL AUTO_INCREMENT,
  `id_dd` int(11) NOT NULL,
  `id_listtype` int(11) NOT NULL,
  `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `datemodify` datetime NOT NULL DEFAULT current_timestamp(),
  `firstboxopen` tinyint(4) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id_list`),
  KEY `FK_featureBoxList_domain_id_dd` (`id_dd`),
  KEY `FK_featureBoxList_featureBoxListType_id_listtype` (`id_listtype`),
  CONSTRAINT `FK_featureBoxList_domain_id_dd` FOREIGN KEY (`id_dd`) REFERENCES `domain` (`id_dd`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `FK_featureBoxList_featureBoxListType_id_listtype` FOREIGN KEY (`id_listtype`) REFERENCES `featureBoxListType` (`id_listtype`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=4141 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;


