CREATE TABLE IF NOT EXISTS `blocked_users` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `uid` bigint(20) unsigned NOT NULL,
  `bid` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `chats` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `title` varchar(255) NOT NULL,
  `chat_desc` varchar(255) NOT NULL,
  `show_avatar` tinyint(1) unsigned NOT NULL,
  `header_bg` varchar(64) NOT NULL,
  `header_font` varchar(64) NOT NULL,
  `footer_bg` varchar(64) NOT NULL,
  `footer_font` varchar(64) NOT NULL,
  `images_enabled` tinyint(1) unsigned NOT NULL,
  `font_enabled` tinyint(1) unsigned NOT NULL,
  `size_enabled` tinyint(1) unsigned NOT NULL,
  `color_enabled` tinyint(1) unsigned NOT NULL,
  `bold_enabled` tinyint(1) unsigned NOT NULL,
  `italic_enabled` tinyint(1) unsigned NOT NULL,
  `emotes_enabled` tinyint(1) unsigned NOT NULL,
  `links_enabled` tinyint(1) unsigned NOT NULL,
  `youtube_enabled` tinyint(1) unsigned NOT NULL,
  `files_enabled` tinyint(1) unsigned NOT NULL,
  `polls_enabled` tinyint(1) unsigned NOT NULL,
  `bad_words` text NOT NULL,
  `password` varchar(255) NOT NULL,
  `last_message` varchar(64) DEFAULT NULL,
  `owner` varchar(64) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `chat_bans` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `username` varchar(64) NOT NULL,
  `cid` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `chat_mods` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `username` varchar(255) NOT NULL,
  `cid` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `emotes` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `img` varchar(255) NOT NULL,
  `e_cmd` varchar(255) NOT NULL,
  `img_name` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `friends` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `uid` bigint(20) unsigned NOT NULL,
  `fid` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `messages` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `message` text NOT NULL,
  `m_type` tinyint(1) unsigned NOT NULL,
  `submitted_by` varchar(64) NOT NULL,
  `time_submitted` varchar(32) NOT NULL,
  `cid` bigint(20) unsigned DEFAULT NULL,
  `recipient` varchar(64) DEFAULT NULL,
  `isRead` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `profile_img` varchar(64) NOT NULL DEFAULT 'default.png',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `polls` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `question` varchar(255) NOT NULL,
  `answers` text NOT NULL,
  `uid` text NOT NULL,
  `total_votes` int(11) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `poll_votes` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `pid` bigint(20) unsigned NOT NULL,
  `answer_index` tinyint(3) unsigned NOT NULL,
  `sid` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `settings` (
  `id` tinyint(1) unsigned NOT NULL AUTO_INCREMENT,
  `site_name` varchar(255) NOT NULL DEFAULT 'Owl Chat',
  `site_desc` text,
  `site_domain` varchar(255) DEFAULT NULL,
  `site_dir` varchar(255) DEFAULT NULL,
  `header_ad` text,
  `footer_ad` text,
  `sidebar_ad` text,
  `registration` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `max_upload_size` int(11) NOT NULL DEFAULT '1024',
  `file_uploads` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `create_polls` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `auto_clean_db` int(11) NOT NULL DEFAULT '168',
  `room_creation` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `guests_chat` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `font_family_btn` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `color_btn` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `bold_btn` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `italic_btn` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `emoticon_btn` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `images_btn` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `url_btn` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `youtube_btn` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `private_chat` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `last_cleaned` int(11) unsigned DEFAULT NULL,
  `bad_words` text,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `users` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `username` varchar(64) NOT NULL,
  `email` varchar(128) NOT NULL,
  `pass` varchar(255) NOT NULL,
  `login_token` varchar(128) DEFAULT NULL,
  `mem_level` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `location` varchar(128) DEFAULT NULL,
  `age` smallint(4) unsigned DEFAULT NULL,
  `gender` tinyint(1) unsigned NOT NULL DEFAULT '3',
  `about` text,
  `profile_img` varchar(64) NOT NULL DEFAULT 'default.png',
  `upl_dir` varchar(128) NOT NULL,
  `time_created` int(11) NOT NULL,
  `header_img` varchar(128) NOT NULL,
  `profile_status` varchar(80) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `users_online` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `uid` bigint(20) unsigned NOT NULL,
  `username` varchar(64) NOT NULL,
  `cid` bigint(20) NOT NULL,
  `time_online` bigint(16) NOT NULL,
  `profile_img` varchar(64) NOT NULL DEFAULT 'default.png',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `user_files` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `original_file_name` varchar(255) NOT NULL,
  `upl_dir` varchar(255) NOT NULL,
  `uid` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;