CREATE TABLE IF NOT EXISTS `community_board` (
  `id` int(11) NOT NULL auto_increment,
  `id_comm` int(11) NOT NULL,
  `user` int(11) NOT NULL default '0',
  `time` int(11) NOT NULL,
  `msg` varchar(512) default NULL,
  PRIMARY KEY  (`id`),
  KEY `time` (`time`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `community_comm` (
  `id` int(11) NOT NULL auto_increment,
  `id_author` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `about` varchar(256) NOT NULL,
  `time_create` int(11) NOT NULL,
  `time_last_edit` int(11) NOT NULL,
  `slogan` varchar(100) NOT NULL,
  `rules` text,
  `status` set('1','2') default NULL,
  `id_razd` int(11) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `community_razd` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(100) NOT NULL,
  `opis` varchar(256) NOT NULL,
  `sort` int(11) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `community_user_incomm` (
  `id` int(11) NOT NULL auto_increment,
  `uid` int(11) NOT NULL,
  `cid` int(11) NOT NULL,
  `time` int(11) NOT NULL,
  `priv` int(11) NOT NULL,
  `postov` int(111) default '0',
  `them` int(111) default '0',
  `files` int(111) default '0',
  `activate` int(1) default '0',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `comm_ban` (
  `id` int(11) NOT NULL auto_increment,
  `time` int(11) NOT NULL,
  `id_user` int(11) NOT NULL,
  `id_ban` int(11) NOT NULL,
  `prich` varchar(1024) NOT NULL,
  `id_comm` int(11) NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `id_user` (`id_user`,`id_ban`),
  KEY `time` (`time`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `comm_forum_f` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(32) NOT NULL,
  `pos` int(11) NOT NULL,
  `opis` varchar(512) NOT NULL,
  `adm` set('0','1') NOT NULL default '0',
  `id_comm` int(11) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `comm_forum_files` (
  `id` int(11) NOT NULL auto_increment,
  `id_post` int(11) NOT NULL,
  `name` varchar(64) default NULL,
  `ras` varchar(32) NOT NULL,
  `size` int(11) NOT NULL,
  `type` varchar(32) NOT NULL,
  `count` int(11) NOT NULL default '0',
  `rating` int(11) NOT NULL default '0',
  `id_comm` int(11) NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `id_post` (`id_post`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `comm_forum_files_rating` (
  `id_file` int(11) NOT NULL,
  `id_user` int(11) NOT NULL,
  `rating` int(11) default '0',
  `id_comm` int(11) NOT NULL,
  KEY `id_file` (`id_file`),
  KEY `id_user` (`id_user`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `comm_forum_p` (
  `id` int(11) NOT NULL auto_increment,
  `id_forum` int(11) NOT NULL,
  `id_razdel` int(11) NOT NULL,
  `id_them` int(11) NOT NULL,
  `id_user` int(11) NOT NULL,
  `time` int(11) NOT NULL,
  `msg` varchar(10240) NOT NULL,
  `cit` int(11) default NULL,
  `id_comm` int(11) NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `id_forum` (`id_forum`,`id_razdel`,`id_them`),
  KEY `id_user` (`id_user`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `comm_forum_r` (
  `id` int(11) NOT NULL auto_increment,
  `id_forum` int(11) NOT NULL,
  `name` varchar(32) NOT NULL,
  `time` int(11) NOT NULL,
  `id_comm` int(11) NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `id_forum` (`id_forum`,`time`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `comm_forum_t` (
  `id` int(11) NOT NULL auto_increment,
  `id_forum` int(11) NOT NULL,
  `id_razdel` int(11) default NULL,
  `name` varchar(32) NOT NULL,
  `id_user` int(11) default NULL,
  `time_create` int(11) NOT NULL,
  `time` int(11) NOT NULL,
  `up` set('0','1') NOT NULL default '0',
  `close` set('0','1') NOT NULL default '0',
  `id_comm` int(11) NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `id_forum` (`id_forum`,`id_razdel`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `comm_forum_zakl` (
  `id_user` int(11) NOT NULL,
  `id_them` int(11) NOT NULL,
  `time` int(11) NOT NULL,
  `time_obn` int(11) NOT NULL,
  `id_comm` int(11) NOT NULL,
  KEY `id_user` (`id_user`,`id_them`,`time`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `comm_obmen_dir` (
  `id` int(11) NOT NULL auto_increment,
  `id_comm` int(11) NOT NULL,
  `num` int(11) default '0',
  `name` varchar(64) NOT NULL,
  `ras` varchar(128) NOT NULL,
  `maxfilesize` int(11) NOT NULL,
  `dir` varchar(512) NOT NULL default '/',
  `dir_osn` varchar(512) default '/',
  `upload` set('1','0') NOT NULL default '0',
  PRIMARY KEY  (`id`),
  KEY `num` (`num`),
  KEY `dir` (`dir`(333))
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `comm_obmen_files` (
  `id` int(11) NOT NULL auto_increment,
  `id_comm` int(11) NOT NULL,
  `id_user` int(11) NOT NULL,
  `id_dir` int(11) NOT NULL,
  `name` varchar(128) NOT NULL,
  `ras` varchar(36) NOT NULL,
  `type` varchar(64) NOT NULL,
  `time` int(11) NOT NULL,
  `time_last` int(11) NOT NULL,
  `size` int(11) NOT NULL,
  `k_loads` int(11) default '0',
  `opis` text NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `comm_obmen_komm` (
  `id` int(11) NOT NULL auto_increment,
  `id_comm` int(11) NOT NULL,
  `id_file` int(11) NOT NULL,
  `id_user` int(11) NOT NULL,
  `time` int(11) NOT NULL,
  `msg` varchar(1024) NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `id_file` (`id_file`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `comm_wall` (
  `id` int(6) NOT NULL auto_increment,
  `id_comm` int(11) NOT NULL,
  `who` int(6) NOT NULL,
  `time` int(11) NOT NULL,
  `message` text NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;