SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";

CREATE TABLE IF NOT EXISTS `acl_action` (
  `id_acl_action` int(11) NOT NULL AUTO_INCREMENT,
  `id_acl_resource` int(11) NOT NULL,
  `acl_action_name` varchar(128) NOT NULL,
  `acl_action_alias` varchar(128) NOT NULL,
  PRIMARY KEY (`id_acl_action`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;

CREATE TABLE IF NOT EXISTS `acl_resource` (
  `id_acl_resource` int(11) NOT NULL AUTO_INCREMENT,
  `acl_resource_name` varchar(128) NOT NULL,
  `acl_resource_alias` varchar(128) NOT NULL,
  `active` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id_acl_resource`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;

CREATE TABLE IF NOT EXISTS `acl_role` (
  `id_acl_role` int(11) NOT NULL AUTO_INCREMENT,
  `acl_role_name` varchar(128) NOT NULL,
  `parent_id` int(11) NOT NULL DEFAULT '0',
  `active` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id_acl_role`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;

INSERT INTO `acl_role` (`id_acl_role`, `acl_role_name`, `parent_id`, `active`) VALUES
(1, 'administrator', 0, 1);

CREATE TABLE IF NOT EXISTS `acl_rule` (
  `id_acl_rule` int(11) NOT NULL AUTO_INCREMENT,
  `id_acl_role` int(11) NOT NULL,
  `id_acl_resource` int(11) NOT NULL,
  `id_acl_action` int(11) NOT NULL,
  PRIMARY KEY (`id_acl_rule`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;

CREATE TABLE IF NOT EXISTS `acl_user` (
  `id_acl_user` int(11) NOT NULL AUTO_INCREMENT,
  `login` varchar(128) DEFAULT NULL,
  `password` varchar(64) NOT NULL,
  `id_acl_role` int(11) NOT NULL DEFAULT '0',
  `photo` varchar(64) NOT NULL,
  `email` varchar(32) NOT NULL,
  `birth_date` date NOT NULL DEFAULT '1986-03-01',
  `registered` date NOT NULL,
  `confirmed` tinyint(1) DEFAULT '0',
  `id_lan` tinyint(4) DEFAULT '0',
  `last_logged` datetime NOT NULL,
  `active` tinyint(1) DEFAULT '0',
  PRIMARY KEY (`id_acl_user`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `admin_menu` (
  `id_admin_menu` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(256) DEFAULT NULL,
  `page` varchar(256) DEFAULT NULL,
  `image` varchar(64) DEFAULT NULL,
  `parent_id` int(11) DEFAULT '0',
  `view_order` tinyint(4) DEFAULT '100',
  `acl_resource` varchar(128) NOT NULL,
  `acl_action` varchar(128) NOT NULL,
  `active` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id_admin_menu`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;

CREATE TABLE IF NOT EXISTS `configuration` (
  `id_configuration` int(11) NOT NULL AUTO_INCREMENT,
  `id_acl_resource` int(11) NOT NULL,
  `data` text NOT NULL,
  PRIMARY KEY (`id_configuration`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;

CREATE TABLE IF NOT EXISTS `lan` (
  `id_lan` int(11) NOT NULL AUTO_INCREMENT,
  `short_name` varchar(3) NOT NULL,
  `name` varchar(25) NOT NULL,
  `active` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id_lan`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;

INSERT INTO `lan` (`id_lan`, `short_name`, `name`, `active`) VALUES
(1, 'en', 'English', 0),
(2, 'ru', 'Русский', 1),
(3, 'ua', 'Українська', 0);

CREATE TABLE IF NOT EXISTS `acl_user_translate` (
  `id_acl_user_translate` int(11) NOT NULL AUTO_INCREMENT,
  `id_acl_user` int(11) NOT NULL,
  `name` varchar(32) NOT NULL,
  `surname` varchar(32) NOT NULL,
  `about` text NOT NULL,
  `id_lan` int(1) NOT NULL,
  PRIMARY KEY (`id_acl_user_translate`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `rt_sessions` (
  `session_id` varchar(64) NOT NULL DEFAULT '0',
  `ip_address` varchar(16) NOT NULL DEFAULT '0',
  `user_agent` varchar(120) NOT NULL,
  `last_activity` int(10) unsigned NOT NULL DEFAULT '0',
  `user_data` text NOT NULL,
  PRIMARY KEY (`session_id`),
  KEY `last_activity` (`last_activity`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `ciext_observer` (
    `id_ciext_observer` int(11) NOT NULL AUTO_INCREMENT,
    `id_user` int(11) NOT NULL,
    `id_acl_resource` int(11) NOT NULL,
    `id_acl_action` int(11) NOT NULL,
    `ip` varchar(255) NOT NULL,
    `text` text NOT NULL,
    `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`id_ciext_observer`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;