-- Adminer 4.0.3 MySQL dump

SET NAMES utf8;
SET foreign_key_checks = 0;
SET time_zone = '+01:00';
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';

DROP TABLE IF EXISTS `discussions`;
CREATE TABLE `discussions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `type` varchar(255) DEFAULT NULL,
  `object` char(40) NOT NULL,
  `title` varchar(255) NOT NULL,
  `show` tinyint(1) NOT NULL DEFAULT '1',
  `allow_posts` tinyint(1) NOT NULL DEFAULT '1',
  `approved_before_publish` tinyint(1) NOT NULL DEFAULT '0',
  `send_notify` tinyint(1) NOT NULL DEFAULT '1',
  `views` int(11) NOT NULL DEFAULT '0',
  `posts` int(11) NOT NULL DEFAULT '0',
  `created` datetime NOT NULL,
  `updated` datetime NOT NULL,
  `last_post_id` int(11) DEFAULT NULL,
  `last_post_user` varchar(255) DEFAULT NULL,
  `last_post_user_id` int(11) DEFAULT NULL,
  `last_post_created` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `module_object` (`type`,`object`),
  KEY `last_post_user_id` (`last_post_user_id`),
  CONSTRAINT `discussions_ibfk_2` FOREIGN KEY (`last_post_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


DROP TABLE IF EXISTS `discussions_monitor`;
CREATE TABLE `discussions_monitor` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `discussion` int(11) NOT NULL,
  `email` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email_discussion` (`email`,`discussion`),
  KEY `discussion` (`discussion`),
  CONSTRAINT `discussions_monitor_ibfk_1` FOREIGN KEY (`discussion`) REFERENCES `discussions` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


DROP TABLE IF EXISTS `discussions_posts`;
CREATE TABLE `discussions_posts` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `discussion` int(11) NOT NULL,
  `show` tinyint(1) NOT NULL DEFAULT '0',
  `hide_content` tinyint(1) NOT NULL DEFAULT '0',
  `parent` int(11) DEFAULT NULL,
  `name` varchar(255) NOT NULL,
  `url` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `user` int(11) DEFAULT NULL,
  `title` varchar(255) NOT NULL,
  `content` text NOT NULL,
  `original_content` text NOT NULL,
  `created` datetime NOT NULL,
  `edited` datetime NOT NULL,
  `user_ip` char(15) NOT NULL,
  `user_ua` text NOT NULL,
  PRIMARY KEY (`id`),
  KEY `parent` (`parent`),
  KEY `discussion` (`discussion`),
  KEY `user` (`user`),
  CONSTRAINT `discussions_posts_ibfk_3` FOREIGN KEY (`parent`) REFERENCES `discussions_posts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `discussions_posts_ibfk_4` FOREIGN KEY (`discussion`) REFERENCES `discussions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `discussions_posts_ibfk_5` FOREIGN KEY (`user`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


DROP TABLE IF EXISTS `discussions_viewed_posts`;
CREATE TABLE `discussions_viewed_posts` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `post` int(11) NOT NULL,
  `user` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `post_user` (`post`,`user`),
  KEY `user` (`user`),
  CONSTRAINT `discussions_viewed_posts_ibfk_1` FOREIGN KEY (`post`) REFERENCES `discussions_posts` (`id`) ON DELETE CASCADE,
  CONSTRAINT `discussions_viewed_posts_ibfk_2` FOREIGN KEY (`user`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


-- 2014-02-19 09:38:10
