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 `pages`;
CREATE TABLE `pages` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `created` datetime NOT NULL,
  `updated` datetime NOT NULL,
  `mainphoto` int(11) DEFAULT NULL,
  `maingallery` int(11) DEFAULT NULL,
  `parent` int(11) DEFAULT NULL,
  `order` int(11) NOT NULL,
  `lft` int(11) DEFAULT NULL,
  `rgt` int(11) DEFAULT NULL,
  `level` int(11) DEFAULT NULL,
  `showlink` tinyint(1) DEFAULT NULL,
  `main` tinyint(1) DEFAULT NULL,
  `index` tinyint(1) DEFAULT NULL,
  `template` varchar(255) NOT NULL,
  `modify_lock` tinyint(1) NOT NULL DEFAULT '0',
  `route` varchar(255) DEFAULT NULL,
  `show_on_mainpage` tinyint(4) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `route` (`route`),
  KEY `parent` (`parent`),
  KEY `mainphoto` (`mainphoto`),
  KEY `maingallery` (`maingallery`),
  CONSTRAINT `pages_ibfk_2` FOREIGN KEY (`parent`) REFERENCES `pages` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `pages_ibfk_5` FOREIGN KEY (`mainphoto`) REFERENCES `photos` (`id`) ON DELETE SET NULL,
  CONSTRAINT `pages_ibfk_6` FOREIGN KEY (`maingallery`) REFERENCES `galleries` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


DROP TABLE IF EXISTS `pages_contents`;
CREATE TABLE `pages_contents` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `page` int(11) NOT NULL,
  `language` int(11) NOT NULL,
  `title` varchar(255) NOT NULL,
  `perex` text NOT NULL,
  `content` text NOT NULL,
  `url` varchar(255) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `language_page` (`language`,`page`),
  UNIQUE KEY `language_url` (`language`,`url`),
  KEY `page` (`page`),
  CONSTRAINT `pages_contents_ibfk_1` FOREIGN KEY (`page`) REFERENCES `pages` (`id`) ON DELETE CASCADE,
  CONSTRAINT `pages_contents_ibfk_2` FOREIGN KEY (`language`) REFERENCES `languages` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- 2013-12-19 18:15:36
