-- CREATE TABLE "blog__item" -------------------------------
CREATE TABLE `blog__item` (
  `itemID` Int( 11 ) UNSIGNED AUTO_INCREMENT NOT NULL,
  `title` VarChar( 64 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `content` Text CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `lead` Text CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `slug` VarChar( 64 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `author` VarChar( 64 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `userID` Int( 11 ) UNSIGNED NULL,
  `readCount` Int( 11 ) UNSIGNED NOT NULL DEFAULT '0',
  `emphasized` Enum( 'yes', 'no' ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'no',
  `activeFrom` DateTime NULL,
  `activeTo` DateTime NULL,
  `type` Enum( 'blog', 'news' ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'blog',
  `status` Enum( 'active', 'inactive' ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'active',
  `createDate` DateTime NOT NULL,
  `modifyDate` DateTime NOT NULL,
  `ogImage` Int( 11 ) UNSIGNED NULL,
  `indexImage` Int( 11 ) UNSIGNED NULL,
  `commentsEnabled` Enum( 'yes', 'no' ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'yes',
  `metaDescription` VarChar( 155 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL,
  `metaKeywords` VarChar( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL,
  PRIMARY KEY ( `itemID` ),
  CONSTRAINT `unique_itemID` UNIQUE( `itemID` ),
  CONSTRAINT `unique_slug` UNIQUE( `slug` ) )
  CHARACTER SET = utf8
  COLLATE = utf8_general_ci
  ENGINE = InnoDB
  AUTO_INCREMENT = 1;
-- ---------------------------------------------------------

-- CREATE INDEX "index_type" -------------------------------
CREATE INDEX `index_type` USING BTREE ON `blog__item`( `type` );
-- ---------------------------------------------------------


-- CREATE INDEX "index_userID" ----------------------------
CREATE INDEX `index_userID` USING BTREE ON `blog__item`( `userID` );
-- ---------------------------------------------------------



-- CREATE TABLE "blog__item_has_sites" ---------------------
CREATE TABLE `blog__item_has_sites` (
  `itemID` Int( 11 ) UNSIGNED NOT NULL,
  `siteID` Int( 11 ) UNSIGNED NOT NULL,
  PRIMARY KEY ( `itemID`, `siteID` ) )
  CHARACTER SET = utf8
  COLLATE = utf8_general_ci
  ENGINE = InnoDB;
-- ---------------------------------------------------------

-- CREATE INDEX "index_itemID" ----------------------------
CREATE INDEX `index_itemID` USING BTREE ON `blog__item_has_sites`( `itemID` );
-- ---------------------------------------------------------

-- CREATE INDEX "index_siteID" -----------------------------
CREATE INDEX `index_siteID` USING BTREE ON `blog__item_has_sites`( `siteID` );
-- ---------------------------------------------------------



-- CREATE TABLE "blog__item_has_tags" ----------------------
CREATE TABLE `blog__item_has_tags` (
  `itemID` Int( 11 ) UNSIGNED NOT NULL,
  `name` VarChar( 32 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  PRIMARY KEY ( `itemID` ) )
  CHARACTER SET = utf8
  COLLATE = utf8_general_ci
  ENGINE = InnoDB;
-- ---------------------------------------------------------

-- CREATE INDEX "index_name" -------------------------------
CREATE INDEX `index_name` USING BTREE ON `blog__item_has_tags`( `name` );
-- ---------------------------------------------------------



-- INSERT INTO `cms__module` -------------------------------
INSERT INTO `cms__module`( `moduleID`,`name` ) VALUES ( 11, 'module.blog' );
-- ---------------------------------------------------------




-- INSERT INTO `cms__panel` -------------------------------
INSERT INTO `cms__panel`( `moduleID`,`name`,`exclusive`,`status`,`parameters` ) VALUES ( 11, 'panel.blog.browse', 'true', 'active', '{"itemLimit":10,"itemOrderBy":"activeFrom","itemOrderMode":"desc","pageRange":5,"route":"","itemRoute":"","tagRoute":"","useCache":true,"useSeo":false,"showFacebookSharing":false,"showFacebookComments":false,"facebookNumComments":5,"showAuthor":true,"useIndexImage":false,"tags":null,"tagFiltration":"or","facebookButtonLayout":"button","facebookAction":"like","facebookShowFaces":true,"facebookIncludeShare":true,"facebookSize":"small","mode":"blog"}');
INSERT INTO `cms__panel`( `moduleID`,`name`,`exclusive`,`status`,`parameters` ) VALUES ( 11, 'panel.blog.archive', 'false', 'active', '{"itemLimit":10,"useCache":true,"useSeo":false,"route":"","tags":null,"tagFiltration":"and","yearFrom":null,"yearTo":null}' );
INSERT INTO `cms__panel`( `moduleID`,`name`,`exclusive`,`status`,`parameters` ) VALUES ( 11, 'panel.blog.emphasized', 'false', 'active', '{"itemLimit":10,"itemOrderBy":"emphasized","itemOrderMode":"desc","pageRange":5,"route":"","itemRoute":"","tagRoute":"","useCache":true,"useSeo":false,"showFacebookSharing":false,"showFacebookComments":false,"facebookNumComments":5,"showAuthor":true,"useIndexImage":false,"tags":null,"tagFiltration":"or","facebookButtonLayout":"button","facebookAction":"like","facebookShowFaces":true,"facebookIncludeShare":true,"facebookSize":"small","mode":"blog"}' );
INSERT INTO `cms__panel`( `moduleID`,`name`,`exclusive`,`status`,`parameters` ) VALUES ( 11,'panel.blog.search', 'false', 'active', '{"route":"","useSeo":false,"searchMode":"simple"}' );
INSERT INTO `cms__panel`( `moduleID`,`name`,`exclusive`,`status`,`parameters` ) VALUES ( 11, 'panel.blog.tagCloud', 'false', 'active', '{"useCache":true,"useSeo":false,"route":null,"tags":null,"tagFiltration":null,"itemLimit":2,"showCount":true,"maxFontSize:24,"minFontSize":12}' );
INSERT INTO `cms__panel`( `moduleID`,`name`,`exclusive`,`status`,`parameters` ) VALUES ( 11, 'panel.blog.admin.item', 'true', 'active', NULL );

-- ---------------------------------------------------------



-- INSERT INTO `cms__resource` -------------------------------
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ( 'blog.browse.index', 11, NULL, NULL );
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ( 'blog.browse.view', 11, NULL, NULL );
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ( 'blog.archive.index', 11, NULL, NULL );
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ( 'blog.emphasized.index', 11, NULL, NULL );
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ( 'blog.search.index', 11, NULL, NULL );
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ( 'blog.tagCloud.index', 11, NULL, NULL );
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ( 'blog.admin.item.index', 11, NULL, NULL );
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ( 'blog.admin.item.create', 11, NULL, NULL );
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ( 'blog.admin.item.modify', 11, NULL, NULL );
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ( 'blog.admin.item.delete', 11, NULL, NULL );
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ( 'blog.admin.item.view', 11, NULL, NULL );
-- ---------------------------------------------------------
