/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

CREATE TABLE `news_article` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `site_id` int(11) NOT NULL,
  `site_user_id` int(11) NOT NULL,
  `news_article_category_id` int(11) NOT NULL,
  `image_id` int(11) NOT NULL,
  `created_date` datetime NOT NULL,
  `published_date` datetime DEFAULT NULL,
  `title` varchar(80) NOT NULL,
  `slug` varchar(80) NOT NULL,
  `content` mediumtext NOT NULL,
  `published` tinyint(1) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`),
  KEY `fk_news_article_news_article_category1_idx` (`news_article_category_id`),
  KEY `fk_news_article_image1_idx` (`image_id`),
  KEY `fk_news_article_site_user1_idx` (`site_user_id`),
  KEY `fk_news_article_site1_idx` (`site_id`),
  CONSTRAINT `fk_news_article_image1` FOREIGN KEY (`image_id`) REFERENCES `image` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_news_article_news_article_category1` FOREIGN KEY (`news_article_category_id`) REFERENCES `news_article_category` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_news_article_site1` FOREIGN KEY (`site_id`) REFERENCES `site` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_news_article_site_user1` FOREIGN KEY (`site_user_id`) REFERENCES `site_user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `news_article_category` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `site_id` int(11) NOT NULL,
  `title` varchar(25) NOT NULL,
  `slug` varchar(50) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_news_article_category_site1_idx` (`site_id`),
  KEY `idx_slug` (`slug`),
  CONSTRAINT `fk_news_article_category_site1` FOREIGN KEY (`site_id`) REFERENCES `site` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


SELECT `id` INTO @siteid FROM `site`;

LOCK TABLES `news_article_category` WRITE;
/*!40000 ALTER TABLE `news_article_category` DISABLE KEYS */;

INSERT INTO `news_article_category` (`site_id`, `title`, `slug`)
VALUES
  (@siteid,'Charity Events','charity-events'),
  (@siteid,'Christmas','christmas'),
  (@siteid,'Competitions','competitions'),
  (@siteid,'Family Events','family-events'),
  (@siteid,'Festivals','festivals'),
  (@siteid,'Local Business','local-business'),
  (@siteid,'Music Live','music-live'),
  (@siteid,'Non-Racing Events','non-racing-events'),
  (@siteid,'Partners & Sponsors','partners-and-sponsors'),
  (@siteid,'Racing','racing');

/*!40000 ALTER TABLE `news_article_category` ENABLE KEYS */;
UNLOCK TABLES;

/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;