-- 
-- Table structure for table `banners`
-- 

CREATE TABLE `banners` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `client_id` int(11) NOT NULL,
  `image` varchar(100) NOT NULL,
  `url` varchar(255) NOT NULL,
  `position` enum('RIGHT','TOPOFFER') NOT NULL,
  `date_at` date NOT NULL,
  `date_to` date NOT NULL,
  `created_at` date NOT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '0',
  `viewed` int(11) NOT NULL,
  `clicked` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `client_id` (`client_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;

ALTER TABLE `banners` ADD `never_expires` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `is_active` ;

-- 
-- Dumping data for table `banners`
-- 


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

-- 
-- Table structure for table `client_details`
-- 

CREATE TABLE `client_details` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `client_id` bigint(20) unsigned NOT NULL,
  `files` mediumtext NOT NULL,
  `bank_account` bigint(20) DEFAULT NULL,
  `bank` tinyint(4) DEFAULT NULL,
  `ip` varchar(15) DEFAULT NULL,
  `is_user_blocked` tinyint(4) DEFAULT NULL,
  `user_blocked_at` datetime DEFAULT NULL,
  `user_blocked_by` int(11) DEFAULT NULL,
  `allow_advertize` tinyint(4) DEFAULT NULL,
  `document_type` enum('PASSPORT','ID_CARD','DRIVER_LICENSE') DEFAULT NULL,
  `document_issuer` varchar(255) NOT NULL,
  `document_number` varchar(25) DEFAULT NULL,
  `document_at` date DEFAULT NULL,
  `document_due_date` date DEFAULT NULL,
  `rating` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `client_id` (`client_id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COMMENT='Client details - work, home and other addresses, etc.' AUTO_INCREMENT=6 ;

-- 
-- Dumping data for table `client_details`
-- 

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

-- 
-- Table structure for table `clients`
-- 

CREATE TABLE `clients` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `first_name` varchar(255) DEFAULT NULL,
  `last_name` varchar(255) DEFAULT NULL,
  `city` varchar(100) NOT NULL,
  `street` varchar(100) NOT NULL,
  `house` char(5) NOT NULL,
  `email` varchar(255) NOT NULL,
  `web` varchar(100) NOT NULL,
  `logo` varchar(100) NOT NULL,
  `phone` char(20) NOT NULL,
  `company` varchar(255) NOT NULL,
  `company_register` varchar(20) NOT NULL,
  `company_description` varchar(255) NOT NULL,
  `client_language` char(3) NOT NULL,
  `is_temporary` tinyint(4) DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COMMENT='Clients which are either private persons or companies' AUTO_INCREMENT=7 ;

-- 
-- Dumping data for table `clients`
-- 

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

-- 
-- Table structure for table `emails`
-- 

CREATE TABLE `emails` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `table_name` varchar(255) NOT NULL,
  `table_id` int(11) NOT NULL,
  `client_email` varchar(255) DEFAULT NULL,
  `client_name` varchar(255) DEFAULT NULL,
  `from_name` varchar(255) NOT NULL,
  `from_email` varchar(255) NOT NULL,
  `subject` varchar(255) DEFAULT NULL,
  `content` longtext,
  `is_sent` tinyint(1) NOT NULL DEFAULT '0',
  `created_at` datetime NOT NULL,
  `sent_at` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `client_email` (`client_email`),
  KEY `client_name` (`client_name`),
  KEY `subject` (`subject`),
  KEY `is_sent` (`is_sent`),
  KEY `table_name` (`table_name`),
  KEY `table_id` (`table_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;

-- 
-- Dumping data for table `emails`
-- 


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

-- 
-- Table structure for table `files`
-- 

CREATE TABLE `files` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `related_id` int(11) NOT NULL,
  `table_name` varchar(150) NOT NULL,
  `file_type` enum('IMAGE','FILE') NOT NULL,
  `file_name` varchar(255) NOT NULL,
  `is_main` tinyint(1) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `related_id` (`related_id`),
  KEY `table_name` (`table_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

-- 
-- Dumping data for table `files`
-- 


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

-- 
-- Table structure for table `forum`
-- 

CREATE TABLE `forum` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `description` varchar(255) NOT NULL,
  `created_by` int(11) NOT NULL,
  `created_at` date NOT NULL,
  `updated_by` int(11) NOT NULL,
  `updated_at` date NOT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;

-- 
-- Dumping data for table `forum`
-- 

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

-- 
-- Table structure for table `forum_messages`
-- 

CREATE TABLE `forum_messages` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `forum_id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` longtext NOT NULL,
  `created_by` int(11) NOT NULL,
  `created_at` date NOT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '0',
  `queue` tinyint(1) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;

-- 
-- Dumping data for table `forum_messages`
-- 

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

-- 
-- Table structure for table `language`
-- 

CREATE TABLE `language` (
 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
 `name` longtext,
 `value` longtext,
 `language` char(10) DEFAULT NULL,
 `model` varchar(25) NOT NULL,
 `page` varchar(25) NOT NULL,
 `show_page` varchar(25) NOT NULL,
 `is_visible` tinyint(1) NOT NULL DEFAULT '1',
 PRIMARY KEY (`id`),
 KEY `language` (`language`),
 KEY `model` (`model`),
 KEY `page` (`page`),
 FULLTEXT KEY `name` (`name`)
) ENGINE=MyISAM AUTO_INCREMENT=1181 DEFAULT CHARSET=utf8;

-- 
-- Dumping data for table `language`
-- 

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

-- 
-- Table structure for table `language_menus`
-- 

CREATE TABLE `language_menus` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `key` char(5) NOT NULL,
  `language` varchar(100) NOT NULL,
  `domain` varchar(100) NOT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `queue` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;

-- 
-- Dumping data for table `language_menus`
-- 

INSERT INTO `language_menus` (`id`, `key`, `language`, `domain`, `is_active`, `queue`) VALUES (1, 'est', 'Estonian', 'www.projectpartner.ee', 1, 0),
(2, 'eng', 'English', 'www.projectpartner.ee', 0, 0),
(3, 'rus', 'Russian', 'www.projectpartner.ee', 0, 0);

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

-- 
-- Table structure for table `logs`
-- 

CREATE TABLE `logs` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `table_name` varchar(150) NOT NULL,
  `table_id` int(11) NOT NULL,
  `action` varchar(100) NOT NULL,
  `created_by` varchar(100) NOT NULL,
  `created_by_id` int(11) NOT NULL,
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `table_name` (`table_name`),
  KEY `table_id` (`table_id`),
  KEY `action` (`action`),
  KEY `created_by_id` (`created_by_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

-- 
-- Dumping data for table `logs`
-- 


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

-- 
-- Table structure for table `logs_get`
-- 

CREATE TABLE `logs_get` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `get` varchar(1000) NOT NULL,
  `post` longtext NOT NULL,
  `created_by` varchar(100) NOT NULL,
  `created_by_id` int(11) NOT NULL,
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `created_at` (`created_at`),
  KEY `created_by_id` (`created_by_id`),
  KEY `created_by` (`created_by`),
  KEY `get` (`get`(333))
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;

-- 
-- Dumping data for table `logs_get`
-- 

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

-- 
-- Table structure for table `logs_session`
-- 

CREATE TABLE `logs_session` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `action` varchar(100) NOT NULL,
  `created_by` varchar(100) NOT NULL,
  `created_by_id` int(11) NOT NULL,
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `created_at` (`created_at`),
  KEY `created_by` (`created_by`),
  KEY `created_by_id` (`created_by_id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;

-- 
-- Dumping data for table `logs_session`
-- 

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

-- 
-- Table structure for table `menus`
-- 

CREATE TABLE `menus` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `parent_id` int(10) unsigned NOT NULL,
  `related_id` int(11) NOT NULL,
  `template_id` int(10) unsigned NOT NULL,
  `model_id` int(11) NOT NULL,
  `name` varchar(45) DEFAULT NULL,
  `image` varchar(100) NOT NULL,
  `class` varchar(50) NOT NULL,
  `url` varchar(255) NOT NULL,
  `language` char(5) NOT NULL,
  `queue` int(11) NOT NULL DEFAULT '1',
  `is_public` tinyint(4) NOT NULL,
  `is_link` tinyint(1) NOT NULL DEFAULT '1',
  `position` varchar(100) NOT NULL,
  `short_name` varchar(100) NOT NULL,
  `is_enabled` tinyint(1) NOT NULL DEFAULT '1',
  `is_restricted` tinyint(1) NOT NULL,
  `to_next_menu` tinyint(1) NOT NULL,
  `show_sub_as_listing` tinyint(1) NOT NULL,
  `is_big` tinyint(1) NOT NULL,
  `active_at` date DEFAULT NULL,
  `un_active_at` date DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `parent_id` (`parent_id`),
  KEY `related_id` (`related_id`),
  KEY `template_id` (`template_id`),
  KEY `model_id` (`model_id`)
) ENGINE=InnoDB AUTO_INCREMENT=124 DEFAULT CHARSET=utf8 AUTO_INCREMENT=124 ;

ALTER TABLE `menus` ADD `redirect_url` VARCHAR( 255 ) NOT NULL AFTER `url` ;

-- 
-- Dumping data for table `menus`
-- 

INSERT INTO `menus` (`id`, `parent_id`, `related_id`, `template_id`, `model_id`, `name`, `image`, `class`, `url`, `redirect_url`, `language`, `queue`, `is_public`, `is_link`, `position`, `short_name`, `is_enabled`, `is_restricted`, `to_next_menu`, `show_sub_as_listing`, `is_big`, `active_at`, `un_active_at`) VALUES (1, 133, 0, 0, 3, 'model', '', '', '', 'model2/', 'est', 2, 0, 1, 'title', 'model2', 1, 1, 0, 0, 0, NULL, NULL),
(58, 133, 0, 0, 7, 'homepage settings', '', '', '', '', 'est', 3, 0, 1, '', 'header data', 1, 1, 0, 0, 0, NULL, NULL),
(59, 133, 0, 0, 13, 'users', '', '', '', '', 'est', 4, 0, 1, '', 'users', 1, 1, 0, 0, 0, NULL, NULL),
(65, 0, 0, 0, 19, 'content', '', '', '', '', 'est', 1, 0, 1, '', '', 1, 1, 0, 0, 0, NULL, NULL),
(83, 1, 0, 0, 48, 'database', '', '', '', '', 'est', 2, 0, 1, '', '', 1, 1, 0, 0, 0, NULL, NULL),
(91, 1, 0, 0, 74, 'queue', '', '', '', '', 'est', 2, 0, 1, '', '', 1, 1, 0, 0, 0, NULL, NULL),
(92, 0, 0, 0, 76, 'messages', '', '', '', '', 'est', 3, 0, 1, '', '', 1, 1, 0, 0, 0, NULL, NULL),
(93, 0, 0, 0, 79, 'language', '', '', '', '', 'est', 4, 0, 1, '', '', 1, 1, 0, 0, 0, NULL, NULL),
(94, 93, 0, 0, 80, 'menu', '', '', '', '', 'est', 1, 0, 1, '', '', 1, 1, 0, 0, 0, NULL, NULL),
(96, 0, 0, 0, 83, 'banners', '', '', '', '', 'est', 2, 0, 1, '', '', 1, 1, 0, 0, 0, NULL, NULL),
(106, 133, 0, 0, 108, 'roles', '', '', '', '', 'est', 5, 0, 1, '', '', 1, 1, 0, 0, 0, NULL, NULL),
(133, 0, 0, 0, 202, 'Tools', '', 'no-click', '', '', 'est', 6, 0, 1, '', '', 1, 1, 0, 0, 0, NULL, NULL),
(134, 1, 0, 0, 4, 'menu', '', '', '', '', 'est', 5, 0, 1, '', '', 1, 1, 0, 0, 0, NULL, NULL);




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

-- 
-- Table structure for table `permissions`
-- 

CREATE TABLE `permissions` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `role_id` int(10) unsigned NOT NULL,
  `table_name` varchar(255) NOT NULL,
  `table_id` int(10) unsigned NOT NULL DEFAULT '0',
  `created_at` datetime DEFAULT NULL,
  `allow_access` tinyint(4) DEFAULT '1',
  PRIMARY KEY (`id`),
  KEY `role_id` (`role_id`),
  KEY `table_name` (`table_name`),
  KEY `table_id` (`table_id`)
) ENGINE=InnoDB AUTO_INCREMENT=787 DEFAULT CHARSET=utf8 COMMENT='System permissions which are assigned to roles' AUTO_INCREMENT=787 ;

-- 
-- Dumping data for table `permissions`
-- 

INSERT INTO `permissions` (`id`, `role_id`, `table_name`, `table_id`, `created_at`, `allow_access`) VALUES (3, 2, 'templates', 3, '2012-07-26 14:23:52', 1),
(4, 2, 'templates', 4, '2012-07-26 14:23:52', 1),
(5, 2, 'templates', 5, '2012-07-26 14:23:52', 1),
(17, 2, 'templates', 48, '2012-07-26 14:23:52', 1),
(18, 2, 'templates', 74, '2012-07-26 14:23:52', 1),
(39, 2, 'templates', 100, '2012-08-02 10:01:36', 1),
(40, 5, 'templates', 100, '2012-08-02 10:01:36', 1),
(60, 2, 'templates', 83, '2012-08-04 14:28:49', 1),
(61, 5, 'templates', 83, '2012-08-04 14:28:49', 1),
(62, 1, 'templates', 82, '2012-08-04 14:29:01', 1),
(63, 2, 'templates', 82, '2012-08-04 14:29:01', 1),
(64, 4, 'templates', 82, '2012-08-04 14:29:01', 1),
(65, 5, 'templates', 82, '2012-08-04 14:29:01', 1),
(70, 2, 'templates', 85, '2012-08-04 14:29:13', 1),
(71, 5, 'templates', 85, '2012-08-04 14:29:13', 1),
(81, 2, 'templates', 110, '2012-08-08 10:24:30', 1),
(82, 5, 'templates', 110, '2012-08-08 10:24:30', 1),
(83, 2, 'templates', 111, '2012-08-08 10:27:47', 1),
(84, 5, 'templates', 111, '2012-08-08 10:27:47', 1),
(89, 1, 'templates', 10, '2012-08-08 11:48:49', 1),
(90, 2, 'templates', 10, '2012-08-08 11:48:49', 1),
(91, 4, 'templates', 10, '2012-08-08 11:48:49', 1),
(92, 5, 'templates', 10, '2012-08-08 11:48:49', 1),
(93, 1, 'templates', 11, '2012-08-08 11:48:49', 1),
(94, 2, 'templates', 11, '2012-08-08 11:48:49', 1),
(95, 4, 'templates', 11, '2012-08-08 11:48:49', 1),
(96, 5, 'templates', 11, '2012-08-08 11:48:49', 1),
(97, 1, 'templates', 12, '2012-08-08 11:48:49', 1),
(98, 2, 'templates', 12, '2012-08-08 11:48:49', 1),
(99, 4, 'templates', 12, '2012-08-08 11:48:49', 1),
(100, 5, 'templates', 12, '2012-08-08 11:48:49', 1),
(107, 2, 'templates', 79, '2012-08-08 11:50:27', 1),
(108, 5, 'templates', 79, '2012-08-08 11:50:27', 1),
(109, 1, 'templates', 1, '2012-08-08 11:51:02', 1),
(110, 2, 'templates', 1, '2012-08-08 11:51:02', 1),
(111, 5, 'templates', 1, '2012-08-08 11:51:02', 1),
(116, 2, 'templates', 8, '2012-08-08 11:51:41', 1),
(117, 5, 'templates', 8, '2012-08-08 11:51:41', 1),
(118, 2, 'templates', 19, '2012-08-08 12:29:55', 1),
(119, 5, 'templates', 19, '2012-08-08 12:29:55', 1),
(120, 2, 'templates', 22, '2012-08-08 12:30:01', 1),
(121, 5, 'templates', 22, '2012-08-08 12:30:01', 1),
(122, 2, 'templates', 80, '2012-08-08 12:30:26', 1),
(123, 5, 'templates', 80, '2012-08-08 12:30:26', 1),
(124, 2, 'templates', 76, '2012-08-08 12:30:55', 1),
(125, 5, 'templates', 76, '2012-08-08 12:30:55', 1),
(126, 2, 'templates', 77, '2012-08-08 12:30:55', 1),
(127, 5, 'templates', 77, '2012-08-08 12:30:55', 1),
(128, 2, 'templates', 102, '2012-08-08 12:30:55', 1),
(129, 5, 'templates', 102, '2012-08-08 12:30:55', 1),
(134, 2, 'templates', 13, '2012-08-08 12:31:23', 1),
(135, 5, 'templates', 13, '2012-08-08 12:31:23', 1),
(136, 2, 'templates', 108, '2012-08-08 12:31:23', 1),
(137, 5, 'templates', 108, '2012-08-08 12:31:23', 1),
(138, 2, 'templates', 109, '2012-08-08 12:31:23', 1),
(139, 5, 'templates', 109, '2012-08-08 12:31:23', 1),
(577, 1, 'templates', 2, '2012-08-12 15:55:33', 1),
(578, 2, 'templates', 2, '2012-08-12 15:55:33', 1),
(579, 4, 'templates', 2, '2012-08-12 15:55:33', 1),
(580, 5, 'templates', 2, '2012-08-12 15:55:33', 1),
(677, 1, 'templates', 46, '2012-08-13 20:58:05', 1),
(678, 2, 'templates', 46, '2012-08-13 20:58:05', 1),
(679, 4, 'templates', 46, '2012-08-13 20:58:05', 1),
(680, 5, 'templates', 46, '2012-08-13 20:58:05', 1),
(781, 1, 'templates', 21, '2012-10-21 19:20:04', 1),
(782, 2, 'templates', 21, '2012-10-21 19:20:04', 1),
(783, 4, 'templates', 21, '2012-10-21 19:20:04', 1),
(784, 5, 'templates', 21, '2012-10-21 19:20:04', 1),
(785, 2, 'templates', 7, '2012-10-21 21:01:34', 1),
(786, 5, 'templates', 7, '2012-10-21 21:01:34', 1),
(1215, 1, 'templates', 183, '2013-06-09 16:41:58', 1),
(1216, 2, 'templates', 183, '2013-06-09 16:41:58', 1),
(1217, 4, 'templates', 183, '2013-06-09 16:41:58', 1),
(1218, 5, 'templates', 183, '2013-06-09 16:41:58', 1),
(1219, 2, 'templates', 184, '2013-07-04 21:52:57', 1),
(1221, 2, 'templates', 1, '2014-07-31 17:45:35', 1),
(1222, 2, 'templates', 2, '2014-07-31 17:45:35', 1),
(1223, 2, 'templates', 3, '2014-07-31 17:45:35', 1),
(1224, 2, 'templates', 4, '2014-07-31 17:45:35', 1),
(1225, 2, 'templates', 5, '2014-07-31 17:45:35', 1),
(1227, 2, 'templates', 7, '2014-07-31 17:45:35', 1),
(1228, 2, 'templates', 8, '2014-07-31 17:45:35', 1),
(1229, 2, 'templates', 10, '2014-07-31 17:45:35', 1),
(1230, 2, 'templates', 11, '2014-07-31 17:45:35', 1),
(1231, 2, 'templates', 12, '2014-07-31 17:45:35', 1),
(1232, 2, 'templates', 13, '2014-07-31 17:45:35', 1),
(1233, 2, 'templates', 19, '2014-07-31 17:45:35', 1),
(1234, 2, 'templates', 21, '2014-07-31 17:45:35', 1),
(1235, 2, 'templates', 22, '2014-07-31 17:45:35', 1),
(1236, 2, 'templates', 46, '2014-07-31 17:45:35', 1),
(1237, 2, 'templates', 48, '2014-07-31 17:45:35', 1),
(1238, 2, 'templates', 74, '2014-07-31 17:45:35', 1),
(1239, 2, 'templates', 76, '2014-07-31 17:45:35', 1),
(1240, 2, 'templates', 77, '2014-07-31 17:45:35', 1),
(1241, 2, 'templates', 79, '2014-07-31 17:45:35', 1),
(1242, 2, 'templates', 80, '2014-07-31 17:45:35', 1),
(1243, 2, 'templates', 82, '2014-07-31 17:45:35', 1),
(1244, 2, 'templates', 83, '2014-07-31 17:45:35', 1),
(1246, 2, 'templates', 85, '2014-07-31 17:45:35', 1),
(1249, 2, 'templates', 100, '2014-07-31 17:45:35', 1),
(1250, 2, 'templates', 102, '2014-07-31 17:45:35', 1),
(1251, 2, 'templates', 108, '2014-07-31 17:45:35', 1),
(1252, 2, 'templates', 109, '2014-07-31 17:45:35', 1),
(1253, 2, 'templates', 110, '2014-07-31 17:45:35', 1),
(1254, 2, 'templates', 111, '2014-07-31 17:45:35', 1),
(1256, 2, 'templates', 183, '2014-07-31 17:45:35', 1),
(1257, 2, 'templates', 184, '2014-07-31 17:45:35', 1),
(1261, 2, 'templates', 202, '2014-07-31 17:45:35', 1),
(1262, 5, 'templates', 1, '2014-07-31 17:45:35', 1),
(1263, 5, 'templates', 2, '2014-07-31 17:45:35', 1),
(1264, 5, 'templates', 8, '2014-07-31 17:45:35', 1),
(1265, 5, 'templates', 13, '2014-07-31 17:45:35', 1),
(1266, 5, 'templates', 19, '2014-07-31 17:45:35', 1),
(1267, 5, 'templates', 21, '2014-07-31 17:45:35', 1),
(1268, 5, 'templates', 22, '2014-07-31 17:45:35', 1),
(1269, 5, 'templates', 46, '2014-07-31 17:45:35', 1),
(1270, 5, 'templates', 76, '2014-07-31 17:45:35', 1),
(1271, 5, 'templates', 77, '2014-07-31 17:45:35', 1),
(1272, 5, 'templates', 79, '2014-07-31 17:45:35', 1),
(1273, 5, 'templates', 80, '2014-07-31 17:45:35', 1),
(1274, 5, 'templates', 82, '2014-07-31 17:45:35', 1),
(1275, 5, 'templates', 83, '2014-07-31 17:45:35', 1),
(1277, 5, 'templates', 85, '2014-07-31 17:45:35', 1),
(1279, 5, 'templates', 100, '2014-07-31 17:45:35', 1),
(1280, 5, 'templates', 102, '2014-07-31 17:45:35', 1),
(1281, 5, 'templates', 108, '2014-07-31 17:45:35', 1),
(1282, 5, 'templates', 109, '2014-07-31 17:45:35', 1),
(1283, 5, 'templates', 110, '2014-07-31 17:45:35', 1),
(1284, 5, 'templates', 111, '2014-07-31 17:45:35', 1),
(1285, 5, 'templates', 183, '2014-07-31 17:45:35', 1),
(1286, 1, 'templates', 1, '2014-07-31 17:45:35', 1),
(1287, 1, 'templates', 2, '2014-07-31 17:45:35', 1),
(1288, 1, 'templates', 21, '2014-07-31 17:45:35', 1),
(1289, 1, 'templates', 46, '2014-07-31 17:45:35', 1),
(1290, 1, 'templates', 82, '2014-07-31 17:45:35', 1),
(1292, 4, 'templates', 2, '2014-07-31 17:45:35', 1),
(1293, 4, 'templates', 21, '2014-07-31 17:45:35', 1),
(1294, 4, 'templates', 46, '2014-07-31 17:45:35', 1),
(1295, 4, 'templates', 82, '2014-07-31 17:45:35', 1);


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

-- 
-- Table structure for table `redirect_link`
-- 

CREATE TABLE `redirect_link` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `redirect_id` int(11) NOT NULL,
  `canonical_url` varchar(1000) NOT NULL,
  `redirect_url` varchar(1000) NOT NULL,
  `from` varchar(100) NOT NULL,
  `is_indexed` tinyint(1) NOT NULL DEFAULT '0',
  `is_deleted` tinyint(1) NOT NULL DEFAULT '0',
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `canonical_url` (`canonical_url`(255)),
  KEY `redirect_url` (`redirect_url`(255))
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

-- 
-- Dumping data for table `redirect_link`
-- 


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

-- 
-- Table structure for table `roles`
-- 

CREATE TABLE `roles` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  `description` text,
  `is_enabled` tinyint(1) DEFAULT '1',
  `created_at` datetime DEFAULT NULL,
  `level` smallint(6) NOT NULL,
  `type` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COMMENT='Roles for system users' AUTO_INCREMENT=7 ;

-- 
-- Dumping data for table `roles`
-- 

INSERT INTO `roles` (`id`, `name`, `description`, `is_enabled`, `created_at`, `level`, `type`) VALUES (1, 'USER', 'mitte sisse logitud kasutaja grupp', 1, '2009-07-07 00:00:00', 1, 'USER'),
(2, 'SUPERADMIN', 'super administraator', 1, '2009-06-29 15:50:29', 10, 'SUPERADMIN'),
(4, 'CLIENT', 'sisse loginud kasutaja', 1, '2009-07-07 17:23:58', 2, 'CLIENT'),
(5, 'ADMIN', 'adminn', 1, '2010-04-22 19:11:25', 9, 'ADMIN');

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

-- 
-- Table structure for table `settings`
-- 

CREATE TABLE `settings` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `client_id` int(11) NOT NULL,
  `name` varchar(150) NOT NULL,
  `value` longtext NOT NULL,
  `language` char(3) NOT NULL,
  `created_at` date NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=110 DEFAULT CHARSET=utf8 AUTO_INCREMENT=110 ;

-- 
-- Dumping data for table `settings`
-- 

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

-- 
-- Table structure for table `templates`
-- 

CREATE TABLE `templates` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `parent_id` int(11) NOT NULL,
  `name` varchar(45) DEFAULT NULL,
  `page` varchar(45) DEFAULT NULL,
  `author` varchar(255) NOT NULL,
  `language` char(5) NOT NULL,
  `position` varchar(45) NOT NULL,
  `is_static` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `content` longtext,
  `type` enum('SMS','EMAIL','LETTER','PAGE','MODEL','PLUGIN','CORE') DEFAULT NULL,
  `version` decimal(2,1) NOT NULL,
  `is_first_page` smallint(1) NOT NULL DEFAULT '0',
  `subject` varchar(255) NOT NULL,
  `from_name` varchar(255) NOT NULL,
  `from_email` varchar(100) NOT NULL,
  `page_position` varchar(25) NOT NULL,
  `template` varchar(100) NOT NULL,
  `is_active` smallint(1) NOT NULL DEFAULT '1',
  `title` varchar(255) NOT NULL,
  `meta_description` longtext NOT NULL,
  `meta_keywords` longtext NOT NULL,
  `queue` int(11) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`),
  KEY `name` (`name`),
  KEY `filename` (`page`)
) ENGINE=InnoDB AUTO_INCREMENT=167 DEFAULT CHARSET=utf8 AUTO_INCREMENT=167 ;

ALTER TABLE `templates` ADD `from_phone` VARCHAR( 25 ) NOT NULL AFTER `from_email` ;
ALTER TABLE `templates` ADD `content_source` LONGTEXT NOT NULL AFTER `content` ;

-- 
-- Dumping data for table `templates`
-- 

INSERT INTO `templates` (`id`, `parent_id`, `name`, `page`, `author`, `language`, `position`, `is_static`, `content`, `content_source`, `type`, `version`, `is_first_page`, `subject`, `from_name`, `from_email`, `from_phone`, `page_position`, `template`, `is_active`, `title`, `meta_description`, `meta_keywords`, `queue`) VALUES (1, 0, 'login', 'login', '', 'est', 'login', 1, NULL, '', 'MODEL', 1.0, 0, '', '', '', '', 'admin', '', 1, '', '', '', 1),
(2, 0, 'login', 'login', '', 'est', 'header', 1, NULL, '', 'MODEL', 1.0, 0, '', '', '', '', 'public', '', 1, '', '', '', 1),
(3, 0, 'model', 'model', '', 'est', 'content', 0, NULL, '', 'MODEL', 1.1, 0, '', '', '', '', 'admin', '', 1, '', '', '', 1),
(4, 0, 'model', 'menu', '', 'est', 'content', 0, NULL, '', 'MODEL', 1.1, 0, '', '', '', '', 'admin', '', 1, '', '', '', 1),
(5, 0, 'model', 'edit', '', 'est', 'content', 0, NULL, '', 'MODEL', 1.1, 0, '', '', '', '', 'admin', '', 1, '', '', '', 1),
(7, 0, 'header_data', 'header_data', '', 'est', 'content', 0, NULL, '', 'MODEL', 1.0, 0, '', '', '', '', 'admin', '', 1, '', '', '', 1),
(8, 0, 'menu', 'adminmenu', '', 'est', 'header', 1, NULL, '', 'MODEL', 1.0, 0, '', '', '', '', 'admin,public', '', 1, '', '', '', 1),
(10, 0, 'header_data', 'title', '', 'est', 'title', 1, NULL, '', 'MODEL', 1.0, 0, '', '', '', '', 'admin,public', '', 1, '', '', '', 1),
(11, 0, 'header_data', 'meta_description', '', 'est', 'meta_description', 1, NULL, '', 'MODEL', 1.0, 0, '', '', '', '', 'admin,public', '', 1, '', '', '', 1),
(12, 0, 'header_data', 'meta_keywords', '', 'est', 'meta_keywords', 1, NULL, '', 'MODEL', 1.0, 0, '', '', '', '', 'admin,public', '', 1, '', '', '', 1),
(13, 0, 'users', 'users', '', 'est', 'content', 0, NULL, '', 'MODEL', 1.0, 0, '', '', '', '', 'admin', '', 1, '', '', '', 1),
(19, 0, 'content', 'content_list', '', 'est', 'content', 0, NULL, '', 'MODEL', 1.0, 0, '', '', '', '', 'admin', '', 1, '', '', '', 1),
(21, 0, 'menu', 'public_menu', '', 'est', 'all', 1, NULL, '', 'MODEL', 1.0, 0, '', '', '', '', 'public', '', 1, '', '', '', 3),
(22, 0, 'content', 'edit', '', 'est', 'content', 0, NULL, '', 'MODEL', 1.0, 0, '', '', '', '', 'admin', '', 1, '', '', '', 1),
(46, 0, 'pages', 'page', '', 'est', 'all', 1, NULL, '', 'MODEL', 1.1, 0, '', '', '', '', 'public', '', 1, '', '', '', 1),
(48, 0, 'model', 'database', '', 'est', 'content', 0, NULL, '', 'MODEL', 1.1, 0, '', '', '', '', 'admin', '', 1, '', '', '', 1),
(74, 0, 'model', 'queue', '', 'est', 'content', 0, NULL, '', 'MODEL', 1.1, 0, '', '', '', '', 'admin', '', 1, '', '', '', 1),
(76, 0, 'messages', 'messages', '', 'est', 'content', 0, NULL, '', 'MODEL', 1.0, 0, '', '', '', '', 'admin', '', 1, '', '', '', 1),
(77, 0, 'messages', 'edit', '', 'est', 'content', 0, NULL, '', 'MODEL', 1.0, 0, '', '', '', '', 'admin', '', 1, '', '', '', 1),
(79, 0, 'language', 'language', '', 'est', 'content', 0, NULL, '', 'MODEL', 1.0, 0, '', '', '', '', 'admin', '', 1, '', '', '', 1),
(80, 0, 'language', 'menu', '', 'est', 'content', 0, NULL, '', 'MODEL', 1.0, 0, '', '', '', '', 'admin', '', 1, '', '', '', 1),
(82, 0, 'banner', 'right_banner', '', 'est', 'right', 1, NULL, '', 'MODEL', 1.0, 0, '', '', '', '', 'public', '', 0, '', '', '', 3),
(83, 0, 'banner', 'manage_banner', '', 'est', 'content', 0, NULL, '', 'MODEL', 1.0, 0, '', '', '', '', 'admin', '', 1, '', '', '', 1),
(85, 0, 'banner', 'ajax_images', '', 'est', 'content', 0, NULL, '', 'MODEL', 1.0, 0, '', '', '', '', 'admin', '', 1, '', '', '', 1),
(100, 0, 'dashboard', 'dashboard', '', 'est', 'content', 0, NULL, '', 'MODEL', 1.0, 1, '', '', '', '', 'admin', '', 1, '', '', '', 1),
(102, 0, 'messages', 'dashboard', '', 'est', 'content', 0, NULL, '', 'MODEL', 1.0, 0, '', '', '', '', 'admin', '', 1, '', '', '', 1),
(108, 0, 'users', 'roles', '', 'est', 'content', 0, NULL, '', 'MODEL', 1.0, 0, '', '', '', '', 'admin', '', 1, '', '', '', 1),
(109, 0, 'users', 'dashboard', '', 'est', 'content', 0, NULL, '', 'MODEL', 1.0, 0, '', '', '', '', 'admin', '', 1, '', '', '', 1),
(110, 0, 'content', 'dashboard', '', 'est', 'content', 0, NULL, '', 'MODEL', 1.0, 0, '', '', '', '', 'admin', '', 1, '', '', '', 1),
(111, 0, 'banner', 'dashboard', '', 'est', 'content', 0, NULL, '', 'MODEL', 1.0, 0, '', '', '', '', 'admin', '', 1, '', '', '', 1),
(183, 0, 'menu', 'sitemap', '', 'est', 'content', 0, NULL, '', 'MODEL', 1.0, 0, '', '', '', '', 'public,select', '', 1, 'Sisukaart', '', '', 1),
(184, 0, 'model', 'export_db', '', 'est', 'content', 0, '', '', 'MODEL', 1.0, 0, '', '', '', '', 'admin', '', 1, '', '', '', 1),
(202, 0, 'tools', 'tools', '', 'al', 'content', 0, NULL, '', 'MODEL', 1.0, 0, '', '', '', '', 'admin', '', 1, '', '', '', 1);



CREATE TABLE `templates_history` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `parent_id` int(11) NOT NULL,
  `name` varchar(45) DEFAULT NULL,
  `page` varchar(45) DEFAULT NULL,
  `author` varchar(255) NOT NULL,
  `language` char(5) NOT NULL,
  `position` varchar(45) NOT NULL,
  `is_static` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `content` longtext,
  `type` enum('SMS','EMAIL','LETTER','PAGE','MODEL','PLUGIN','CORE') DEFAULT NULL,
  `version` decimal(2,1) NOT NULL,
  `is_first_page` smallint(1) NOT NULL DEFAULT '0',
  `subject` varchar(255) NOT NULL,
  `from_name` varchar(255) NOT NULL,
  `from_email` varchar(100) NOT NULL,
  `from_phone` varchar(25) NOT NULL,
  `page_position` varchar(25) NOT NULL,
  `template` varchar(100) NOT NULL,
  `is_active` smallint(1) NOT NULL DEFAULT '1',
  `title` varchar(255) NOT NULL,
  `meta_description` longtext NOT NULL,
  `meta_keywords` longtext NOT NULL,
  `queue` int(11) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`),
  KEY `name` (`name`),
  KEY `filename` (`page`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

ALTER TABLE `templates_history` ADD `template_id` INT NOT NULL AFTER `id` ;

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

-- 
-- Table structure for table `users`
-- 

CREATE TABLE `users` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `role_id` int(10) unsigned NOT NULL,
  `name` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `temp_password` varchar(255) NOT NULL,
  `type` varchar(15) NOT NULL,
  `is_enabled` tinyint(1) DEFAULT '1',
  `password_expires_at` date DEFAULT NULL,
  `account_expires_at` date DEFAULT NULL,
  `activation_hash` text NOT NULL,
  PRIMARY KEY (`id`),
  KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COMMENT='System users having access to the information system' AUTO_INCREMENT=7 ;

-- 
-- Dumping data for table `users`
-- 

CREATE TABLE `memory_page_generator` (
  `query` varchar(255) NOT NULL,
  `numrows` int(11) NOT NULL,
  `created_at` datetime NOT NULL,
  KEY `query` (`query`)
) ENGINE=MEMORY DEFAULT CHARSET=utf8;

CREATE TABLE `help` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(1000) NOT NULL,
  `value` longtext NOT NULL,
  `url` varchar(255) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `name` (`name`(255))
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;



ALTER TABLE `files` ADD `description` VARCHAR( 1000 ) NOT NULL AFTER `file_name` ;




CREATE TABLE `emails_list` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `table_name` varchar(255) NOT NULL,
  `table_id` int(11) NOT NULL,
  `email` varchar(255) NOT NULL,
  `from_web` tinyint(1) NOT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;




CREATE TABLE `newsletter` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `from_name` varchar(255) NOT NULL,
  `from_email` varchar(255) NOT NULL,
  `subject` varchar(255) NOT NULL,
  `content` longtext NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;



CREATE TABLE `elements` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `model` varchar(255) NOT NULL,
  `page` varchar(255) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `name` (`name`),
  KEY `model` (`model`),
  KEY `page` (`page`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;