# This file is part of Igloo
#  
# Copyright (C) 2003, 2005 Barnraiser
# http://www.barnraiser.org/
# 
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2, or (at your option) any
# later version.
# 
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with program; see the file COPYING. If not, write to the Free
# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# 

# Table structure for table `igloo_abuse`
CREATE TABLE `igloo_abuse` (
  `abuse_id` int(11) NOT NULL auto_increment,
  `abuse_url` varchar(255) default NULL,
  `abuse_source` text,
  `reportee_user_id` int(11) default NULL,
  `assigned_user_id` int(11) default NULL,
  `abuse_note` text,
  `reportee_language_id` int(3) default NULL,
  `report_datetime` datetime default NULL,
  `report_status_id` int(11) default NULL,
  PRIMARY KEY  (`abuse_id`)
) TYPE=InnoDB CHARACTER SET utf8 COMMENT='record of all instances of reported abuse';


# Table structure for table `igloo_acs_permission`
CREATE TABLE `igloo_acs_permission` (
  `role_id` int(3) default NULL,
  `privilege_id` int(3) default NULL,
  `resource_id` int(3) default NULL
) TYPE=InnoDB CHARACTER SET utf8 COMMENT='access control system';


# Table structure for table `igloo_blog`
CREATE TABLE `igloo_blog` (
  `blog_id` int(11) NOT NULL auto_increment,
  `blog_title` varchar(255) default NULL,
  `blog_synopsis` varchar(255) default NULL,
  `blog_body` text,
  `language_id` int(3) default NULL,
  `blog_create_datetime` datetime default NULL,
  `blog_edit_datetime` datetime default NULL,
  `blog_allow_comments` int(1) default NULL,
  `file_id` int(11) default NULL,
  `user_id` int(11) default NULL,
  PRIMARY KEY  (`blog_id`)
) TYPE=InnoDB CHARACTER SET utf8;


# Table structure for table `igloo_bookmark`
CREATE TABLE `igloo_bookmark` (
  `item_id` int(11) default NULL,
  `rsp_item_type_id` int(3) default NULL,
  `bookmark_type` int(1) default NULL,
  `user_id` int(11) default NULL,
  `bookmark_lastview_datetime` datetime default NULL,
  `bookmark_alarm_datetime` datetime default NULL
) TYPE=InnoDB CHARACTER SET utf8;


# Table structure for table `igloo_channel`
CREATE TABLE `igloo_channel` (
  `channel_id` int(11) NOT NULL auto_increment,
  `channel_url` varchar(255) default NULL,
  `language_id` int(3) default NULL,
  `channel_title` varchar(255) default NULL,
  `channel_synopsis` varchar(255) default NULL,
  `user_id` int(11) default NULL,
  PRIMARY KEY  (`channel_id`)
) TYPE=InnoDB CHARACTER SET utf8;
    


# Table structure for table `igloo_comment`
CREATE TABLE `igloo_comment` (
  `comment_id` int(11) NOT NULL auto_increment,
  `comment_parent_id` int(11) default NULL,
  `item_id` int(11) default NULL,
  `rsp_item_type_id` int(3) default NULL,
  `comment_body` text,
  `comment_create_datetime` datetime default NULL,
  `user_id` int(11) default NULL,
  PRIMARY KEY  (`comment_id`)
) TYPE=InnoDB CHARACTER SET utf8;


# Table structure for table `igloo_file`
CREATE TABLE `igloo_file` (
  `file_id` int(11) NOT NULL auto_increment,
  `file_name` varchar(50) default NULL,
  `file_suffix` varchar(4) default NULL,
  `file_create_datetime` datetime default NULL,
  `file_title` varchar(255) default NULL,
  `file_size` int(11) default NULL,
  `user_id` int(11) default NULL,
  PRIMARY KEY  (`file_id`)
) TYPE=InnoDB CHARACTER SET utf8;


# Table structure for table `igloo_forum_subject`
CREATE TABLE `igloo_forum_subject` (
  `subject_id` int(11) NOT NULL auto_increment,
  `topic_id` int(11) default NULL,
  `subject_title` varchar(255) default NULL,
  `file_id` int(11) default NULL,
  `user_id` int(11) default NULL,
  `subject_hidden` int(1) default NULL,
  `subject_synopsis` varchar(255) default NULL,
  `subject_body` text,
  `subject_create_datetime` datetime default NULL,
  `subject_edit_datetime` datetime default NULL,
  `subject_locked` int(1) default NULL,
  `subject_sticky` int(1) default NULL,
  PRIMARY KEY  (`subject_id`)
) TYPE=InnoDB CHARACTER SET utf8;


# Table structure for table `igloo_forum_topic`
CREATE TABLE `igloo_forum_topic` (
  `topic_id` int(11) NOT NULL auto_increment,
  `topic_title` varchar(50) default NULL,
  `topic_synopsis` varchar(255) default NULL,
  `topic_hidden` int(1) default NULL,
  `topic_order` int(3) default NULL,
  `topic_create_datetime` datetime default NULL,
  `user_id` int(11) default NULL,
  PRIMARY KEY  (`topic_id`)
) TYPE=InnoDB CHARACTER SET utf8;


# Table structure for table `igloo_forum_topic_role`
CREATE TABLE `igloo_forum_topic_role` (
  `topic_id` int(11) default NULL,
  `role_id` int(11) default NULL
) TYPE=InnoDB CHARACTER SET utf8;


# Table structure for table `igloo_library`
CREATE TABLE `igloo_library` (
  `library_id` int(11) NOT NULL auto_increment,
  `library_page_name` varchar(100) default NULL,
  `library_default` int(1) default NULL,
  `library_title` varchar(255) default NULL,
  `library_synopsis` text,
  `library_body` text,
  `language_id` int(3) default NULL,
  `file_id` int(11) default NULL,
  `user_id` int(11) default NULL,
  `library_allow_comments` int(1) default NULL,
  `library_create_datetime` datetime default NULL,
  PRIMARY KEY  (`library_id`)
) TYPE=InnoDB CHARACTER SET utf8;

# Table structure for table `igloo_newsletter`
CREATE TABLE `igloo_newsletter` (
  `message_id` int(11) NOT NULL auto_increment,
  `from_user_id` int(11) default NULL,
  `to_type_id` int(11) default NULL,
  `message_subject` varchar(50) default NULL,
  `message_body` text,
  `message_create_datetime` datetime default NULL,
  `item_id` int(11) default NULL,
  `language_id` int(11) default NULL,
  `start_id` int(11) default NULL,
  `message_status` tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (`message_id`)
) TYPE=InnoDB CHARACTER SET utf8;

# Table structure for table `igloo_poll`
CREATE TABLE `igloo_poll` (
  `poll_id` int(11) NOT NULL auto_increment,
  `poll_question` varchar(255) default NULL,
  `poll_body` text,
  `poll_start_datetime` datetime default NULL,
  `poll_end_datetime` datetime default NULL,
  `poll_anon` int(1) default NULL,
  `user_id` int(11) default NULL,
  `poll_create_datetime` datetime default NULL,
  `poll_edit_datetime` datetime default NULL,
  `vote_required` int(1) default NULL,
  PRIMARY KEY  (`poll_id`)
) TYPE=InnoDB CHARACTER SET utf8;


# Table structure for table `igloo_poll_answer`
CREATE TABLE `igloo_poll_answer` (
  `answer_id` int(11) NOT NULL auto_increment,
  `user_id` int(11) default NULL,
  `poll_id` int(11) default NULL,
  `option_id` int(11) default NULL,
  `current_answer` int(1) default NULL,
  `answer_create_datetime` datetime default NULL,
  PRIMARY KEY  (`answer_id`)
) TYPE=InnoDB CHARACTER SET utf8;


# Table structure for table `igloo_poll_option`
CREATE TABLE `igloo_poll_option` (
  `option_id` int(11) NOT NULL auto_increment,
  `poll_id` int(11) default NULL,
  `option_body` varchar(255) default NULL,
  `option_create_datetime` datetime default NULL,
  `option_edit_datetime` datetime default NULL,
  `user_id` int(11) default NULL,
  PRIMARY KEY  (`option_id`)
) TYPE=InnoDB CHARACTER SET utf8;


# Table structure for table `igloo_rsp`
CREATE TABLE `igloo_rsp` (
  `item_id` int(11) default NULL,
  `item_name` VARCHAR(50) default NULL,
  `rsp_item_type_id` int(2) default NULL,
  `rsp_publish_datetime` datetime default NULL,
  `status_id` int(1) default NULL,
  `level_id` int(1) default NULL,
  `degree_id` int(1) default NULL,
  `language_id` int(3) default NULL,
  `rsp_sticky` int(1) default NULL
) TYPE=InnoDB CHARACTER SET utf8 COMMENT='really simple publishing system';


# Table structure for table `igloo_schedule`
CREATE TABLE `igloo_schedule` (
  `schedule_id` int(11) NOT NULL auto_increment,
  `schedule_type_id` int(3) default NULL,
  `schedule_create_datetime` datetime default NULL,
  `schedule_start_datetime` datetime default NULL,
  `schedule_end_datetime` datetime default NULL,
  `schedule_title` varchar(255) default NULL,
  `schedule_synopsis` text,
  `schedule_body` text,
  `schedule_location` varchar(255) default NULL,
  `schedule_occurence` int(11) default NULL,
  `schedule_repeat_until` date default NULL ,
  `file_id` int(11) default NULL,
  `user_id` int(11) default NULL,
  `schedule_category_id` int(11) default NULL,
  `status_id` int(11) default NULL,
  `schedule_priority_id` int(3) default NULL,
  `schedule_p_complete` int(3) default NULL,
  `schedule_complete` int(1) default NULL,
  `schedule_allocation` int(11) default NULL,
  `schedule_allow_comments` INT(1) default NULL,
  `language_id` INT(3) default NULL,
  PRIMARY KEY  (`schedule_id`)
) TYPE=InnoDB CHARACTER SET utf8;


# Table structure for table `igloo_schedule_allocation`
CREATE TABLE `igloo_schedule_allocation` (
  `schedule_id` int(11) default NULL,
  `user_id` int(11) default NULL,
  `schedule_allocation_create_datetime` datetime default NULL,
  `status_id` int(2) default NULL
) TYPE=InnoDB CHARACTER SET utf8;


# Table structure for table `igloo_shoutbox`
CREATE TABLE `igloo_shoutbox` (
  `shoutbox_id` int(11) NOT NULL auto_increment,
  `user_id` int(11) default NULL,
  `shoutbox_body` varchar(200) default NULL,
  `shoutbox_create_datetime` datetime default NULL,
  PRIMARY KEY  (`shoutbox_id`)
) TYPE=InnoDB CHARACTER SET utf8;


# Table structure for table `igloo_sn`
CREATE TABLE `igloo_sn` (
  `user_id` int(11) default NULL,
  `degree_id` int(3) default NULL,
  `sn_total` int(11) default NULL,
  `sn_update_datetime` datetime default NULL,
  `sn_cron_update_request` int(1) default NULL
) TYPE=InnoDB CHARACTER SET utf8;


# Table structure for table `igloo_statistic`
CREATE TABLE `igloo_statistic` (
  `statistic_type_id` int(3) default NULL,
  `total` int(11) default NULL,
  `user_id` int(11) default NULL
) TYPE=InnoDB CHARACTER SET utf8;


# Table structure for table `igloo_tag`
CREATE TABLE `igloo_tag` (
  `item_id` int(11) default NULL,
  `item_name` varchar(50) default NULL,
  `rsp_item_type_id` int(3) default NULL,
  `tag_body` varchar(50) default NULL,
  `user_id` int(11) default NULL
) TYPE=InnoDB CHARACTER SET utf8;


# Table structure for table `igloo_template`
CREATE TABLE `igloo_template` (
  `template_id` int(11) NOT NULL auto_increment,
  `template_title` varchar(50) default NULL,
  PRIMARY KEY  (`template_id`)
) TYPE=InnoDB CHARACTER SET utf8;


# Table structure for table `igloo_user`
CREATE TABLE `igloo_user` (
  `user_id` int(11) NOT NULL auto_increment,
  `user_number` varchar(50) default NULL,
  `user_firstname` varchar(100) default NULL,
  `user_surname` varchar(100) default NULL,
  `user_email` varchar(100) NOT NULL default '',
  `user_hometown` varchar(100) default NULL,
  `user_dob` date default NULL,
  `user_gender` int(1) default NULL,
  `language_id` int(3) default NULL,
  `template_id` int(3) default NULL,
  `user_homepage` varchar(50) default NULL,
  `status_id` int(3) default NULL,
  `role_id` int(11) default NULL,
  `user_password` varchar(32) NOT NULL default '',  
  `user_feed_password` varchar(6) default NULL,
  `user_create_datetime` datetime default NULL,
  `active_time` timestamp(14) NOT NULL,
  `user_file_allocation` int(11) default NULL,
  PRIMARY KEY  (`user_id`)
) TYPE=InnoDB CHARACTER SET utf8;


# Table structure for table `igloo_user_blocked`
CREATE TABLE `igloo_user_blocked` (
  `user_id_blocker` int(11) default NULL,
  `user_id_blocked` int(11) default NULL,
  `block_datetime` datetime default NULL,
  `block_description` varchar(200) default NULL
) TYPE=InnoDB CHARACTER SET utf8;


# Table structure for table `igloo_user_invited`
CREATE TABLE `igloo_user_invited` (
  `invited_email` varchar(100) default NULL,
  `user_id` int(11) default NULL,
  `invite_create_datetime` datetime default NULL
) TYPE=InnoDB CHARACTER SET utf8;


# Table structure for table `igloo_user_language`
CREATE TABLE `igloo_user_language` (
  `user_id` int(11) default NULL,
  `language_id` int(3) default NULL
) TYPE=InnoDB CHARACTER SET utf8;


# Table structure for table `igloo_user_message`
CREATE TABLE `igloo_user_message` (
  `message_id` int(11) NOT NULL auto_increment,
  `owner_user_id` int(11) default NULL,
  `from_user_id` int(11) default NULL,
  `to_user_id` int(11) default NULL,
  `message_status` int(3) default NULL,
  `message_box` int(3) default NULL,
  `message_subject` varchar(50) default NULL,
  `message_body` text,
  `message_create_datetime` datetime default NULL,
  `message_type` int(3) default NULL,
  PRIMARY KEY  (`message_id`)
) TYPE=InnoDB CHARACTER SET utf8;


# Table structure for table `igloo_user_preference`
CREATE TABLE `igloo_user_preference` (
  `user_id` INT( 11 ) ,
  `user_preference_id` INT( 3 )
) TYPE=InnoDB CHARACTER SET utf8;


# Table structure for table `igloo_user_profile`
CREATE TABLE `igloo_user_profile` (
  `profile_id` int(11) NOT NULL auto_increment,
  `user_id` int(11) default NULL,
  `profile_true_self` int(1) default NULL,
  `profile_default` int(1) default NULL,
  `profile_name` varchar(50) default NULL,
  `profile_summary` text,
  `profile_gender` int(1) default NULL,
  `profile_nic` varchar(50) default NULL,
  `profile_hometown` varchar(50) default NULL,
  `profile_create_datetime` datetime default NULL,
  `profile_allow_msg` int(1) default NULL,
  `file_id` int(11) default NULL,
  `profile_text1` varchar(100) default NULL,
  `profile_text2` varchar(100) default NULL,
  `profile_text3` varchar(100) default NULL,
  `profile_text4` varchar(100) default NULL,
  `profile_text5` varchar(100) default NULL,
  `profile_text6` varchar(100) default NULL,
  `profile_text7` varchar(100) default NULL,
  `profile_text8` varchar(100) default NULL,
  `profile_text9` varchar(100) default NULL,
  `profile_text10` varchar(100) default NULL,
  PRIMARY KEY  (`profile_id`)
) TYPE=InnoDB CHARACTER SET utf8;


# Table structure for table `igloo_user_relation`
CREATE TABLE `igloo_user_relation` (
  `user_id` int(11) default NULL,
  `user_id_relation` int(11) default NULL,
  `relation_create_datetime` datetime default NULL,
  `relation_type_id` int(3) default NULL,
  `relation_show_true_self` int(1) default NULL,
  `relation_show_network` int(1) default NULL
) TYPE=InnoDB CHARACTER SET utf8;


# Table structure for table `igloo_user_session`
CREATE TABLE `igloo_user_session` (
  `session_id` int(11) NOT NULL auto_increment,
  `user_id` int(11) default NULL,
  `session_md5` varchar(32) default NULL,
  `session_lastused` timestamp(14) NOT NULL,
  `session_firstused` timestamp(14) NOT NULL,
  `session_ip` varchar(15) default NULL,
  PRIMARY KEY  (`session_id`)
) TYPE=InnoDB CHARACTER SET utf8;

# INSERT DEFAULTS -----------------------------------------

INSERT INTO `igloo_template` VALUES (1, 'barnraiser_01');