CREATE TABLE IF NOT EXISTS `blog_posts` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `keyword` varchar(250) NOT NULL,
  `status` enum('Enabled','Disabled') NOT NULL DEFAULT 'Enabled',
  `published` datetime DEFAULT NULL,
  `created` datetime DEFAULT NULL,
  `updated` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `keyword` (`keyword`),
  KEY `status` (`status`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `blog_posts_i18n` (
  `id` int(11) NOT NULL,
  `title` varchar(500) NOT NULL,
  `image` varchar(500) NOT NULL,
  `abstract` text NOT NULL,
  `content` text NOT NULL,
  `metaTitle` varchar(500) NOT NULL,
  `metaDescr` varchar(500) NOT NULL,
  `metaKeywords` varchar(500) NOT NULL,
  `locale` varchar(5) NOT NULL DEFAULT 'en_US',
   KEY `id` (`id`),
   KEY `locale` (`locale`),
   FULLTEXT KEY `search` (`title`,`abstract`,`content`, `metaTitle`, `metaDescr`, `metaKeywords`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `blog_categories` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `keyword` varchar(250) NOT NULL,
  `status` enum('Enabled','Disabled') NOT NULL DEFAULT 'Enabled',
  PRIMARY KEY (`id`),
  KEY `keyword` (`keyword`),
    KEY `status` (`status`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `blog_categories_i18n` (
  `id` int(11) NOT NULL,
  `title` varchar(500) NOT NULL,
  `abstract` text NOT NULL,
  `locale` varchar(5) NOT NULL DEFAULT 'en_US',
   KEY `id` (`id`),
   KEY `locale` (`locale`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `blog_postsCategories` (
  `postId` int(11) NOT NULL,
  `categoryId` int(11) NOT NULL,
  KEY `postId` (`postId`),
  KEY `tagId` (`categoryId`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `blog_postsContributors` (
  `postId` int(11) NOT NULL,
  `contributorId` int(11) NOT NULL,
  KEY `postId` (`postId`),
  KEY `tagId` (`contributorId`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `blog_tags` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `keyword` varchar(250) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `keyword` (`keyword`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `blog_tags_i18n` (
  `id` int(11) NOT NULL,
  `title` varchar(500) NOT NULL,
  `content` text DEFAULT NULL,
  `locale` varchar(5) NOT NULL DEFAULT 'en_US',
   KEY `id` (`id`),
   KEY `locale` (`locale`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `blog_postsTags` (
  `postId` int(11) NOT NULL,
  `tagId` int(11) NOT NULL,
  KEY `postId` (`postId`),
  KEY `tagId` (`tagId`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `blog_links` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `position` int(11) NOT NULL,
  `url` varchar(500) NOT NULL,
  `status` enum('Enabled','Disabled') NOT NULL DEFAULT 'Enabled',
  PRIMARY KEY (`id`),
  KEY `position` (`position`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `blog_links_i18n` (
  `id` int(11) NOT NULL,
  `title` varchar(500) NOT NULL,
  `locale` varchar(5) NOT NULL DEFAULT 'en_US',
   KEY `id` (`id`),
   KEY `locale` (`locale`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

INSERT INTO `page_pages` ( `parentId`, `keyword`, `status`, `type`, `route`, `template`, `created`, `updated`) VALUES
(0, 'blog', 'Enabled', 'Module', 'blog', 'inner', NOW(), NOW());
INSERT INTO `page_pages_i18n` (`id`, `label`, `content`, `header`, `metaTitle`, `metaDescr`, `metaKeywords`, `locale`) VALUES 
(LAST_INSERT_ID(), 'Blog', 'Blog', 'Blog', 'Blog', 'Blog', 'Blog', 'en_US');
