CREATE TABLE bans (
	id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
	username VARCHAR(200),
	ip VARCHAR(255),
	email VARCHAR(50),
	message VARCHAR(255),
	expire INT(10) UNSIGNED,
	PRIMARY KEY (id)
	) TYPE=MyISAM;

CREATE TABLE categories (
	id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
	cat_name VARCHAR(80) NOT NULL DEFAULT 'New Category',
	disp_position INT(10) NOT NULL DEFAULT 0,
	PRIMARY KEY (id)
	) TYPE=MyISAM;

CREATE TABLE censoring (
	id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
	search_for VARCHAR(60) NOT NULL DEFAULT '',
	replace_with VARCHAR(60) NOT NULL DEFAULT '',
	PRIMARY KEY (id)
	) TYPE=MyISAM;

CREATE TABLE config (
	conf_name VARCHAR(255) NOT NULL DEFAULT '',
	conf_value TEXT,
	PRIMARY KEY (conf_name)
	) TYPE=MyISAM;

CREATE TABLE forum_perms (
	group_id INT(10) NOT NULL DEFAULT 0,
	forum_id INT(10) NOT NULL DEFAULT 0,
	read_forum TINYINT(1) NOT NULL DEFAULT 1,
	post_replies TINYINT(1) NOT NULL DEFAULT 1,
	post_topics TINYINT(1) NOT NULL DEFAULT 1,
	PRIMARY KEY (group_id, forum_id)
	) TYPE=MyISAM;

CREATE TABLE forums (
	id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
	forum_name VARCHAR(80) NOT NULL DEFAULT 'New forum',
	forum_desc TEXT,
	redirect_url VARCHAR(100),
	moderators TEXT,
	num_topics MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0,
	num_posts MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0,
	last_post INT(10) UNSIGNED,
	last_post_id INT(10) UNSIGNED,
	last_poster VARCHAR(200),
	sort_by TINYINT(1) NOT NULL DEFAULT 0,
	disp_position INT(10) NOT NULL DEFAULT 0,
	cat_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
	PRIMARY KEY (id)
	) TYPE=MyISAM;

CREATE TABLE groups (
	g_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
	g_title VARCHAR(50) NOT NULL DEFAULT '',
	g_user_title VARCHAR(50),
	g_read_board TINYINT(1) NOT NULL DEFAULT 1,
	g_post_replies TINYINT(1) NOT NULL DEFAULT 1,
	g_post_topics TINYINT(1) NOT NULL DEFAULT 1,
	g_post_polls TINYINT(1) NOT NULL DEFAULT 1,
	g_edit_posts TINYINT(1) NOT NULL DEFAULT 1,
	g_delete_posts TINYINT(1) NOT NULL DEFAULT 1,
	g_delete_topics TINYINT(1) NOT NULL DEFAULT 1,
	g_set_title TINYINT(1) NOT NULL DEFAULT 1,
	g_search TINYINT(1) NOT NULL DEFAULT 1,
	g_search_users TINYINT(1) NOT NULL DEFAULT 1,
	g_edit_subjects_interval SMALLINT(6) NOT NULL DEFAULT 300,
	g_post_flood SMALLINT(6) NOT NULL DEFAULT 30,
	g_search_flood SMALLINT(6) NOT NULL DEFAULT 30,
	PRIMARY KEY (g_id)
	) TYPE=MyISAM;

CREATE TABLE online (
	user_id INT(10) UNSIGNED NOT NULL DEFAULT 1,
	ident VARCHAR(200) NOT NULL DEFAULT '',
	logged INT(10) UNSIGNED NOT NULL DEFAULT 0,
	idle TINYINT(1) NOT NULL DEFAULT 0
	) TYPE=HEAP;

CREATE TABLE posts (
	id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
	poster VARCHAR(200) NOT NULL DEFAULT '',
	poster_id INT(10) UNSIGNED NOT NULL DEFAULT 1,
	poster_ip VARCHAR(15),
	poster_email VARCHAR(50),
	message TEXT NOT NULL DEFAULT '',
	hide_smilies TINYINT(1) NOT NULL DEFAULT 0,
	posted INT(10) UNSIGNED NOT NULL DEFAULT 0,
	edited INT(10) UNSIGNED,
	edited_by VARCHAR(200),
	topic_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
	PRIMARY KEY (id)
	) TYPE=MyISAM;

CREATE TABLE ranks (
	id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
	rank VARCHAR(50) NOT NULL DEFAULT '',
	min_posts MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0,
	PRIMARY KEY (id)
	) TYPE=MyISAM;

CREATE TABLE reports (
	id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
	post_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
	topic_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
	forum_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
	reported_by INT(10) UNSIGNED NOT NULL DEFAULT 0,
	created INT(10) UNSIGNED NOT NULL DEFAULT 0,
	message TEXT NOT NULL DEFAULT '',
	zapped INT(10) UNSIGNED,
	zapped_by INT(10) UNSIGNED,
	PRIMARY KEY (id)
	) TYPE=MyISAM;

CREATE TABLE search_cache (
	id INT(10) UNSIGNED NOT NULL DEFAULT 0,
	ident VARCHAR(200) NOT NULL DEFAULT '',
	search_data TEXT NOT NULL DEFAULT '',
	PRIMARY KEY (id)
	) TYPE=MyISAM;

CREATE TABLE search_matches (
	post_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
	word_id MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0,
	subject_match TINYINT(1) NOT NULL DEFAULT 0
	) TYPE=MyISAM;

CREATE TABLE search_words (
	id MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,
	word VARCHAR(20) BINARY NOT NULL DEFAULT '',
	PRIMARY KEY (word),
	KEY search_words_id_idx (id)
	) TYPE=MyISAM;

CREATE TABLE subscriptions (
	user_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
	topic_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
	PRIMARY KEY (user_id, topic_id)
	) TYPE=MyISAM;

CREATE TABLE topics (
	id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
	poster VARCHAR(200) NOT NULL DEFAULT '',
	subject VARCHAR(255) NOT NULL DEFAULT '',
	posted INT(10) UNSIGNED NOT NULL DEFAULT 0,
	last_post INT(10) UNSIGNED NOT NULL DEFAULT 0,
	last_post_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
	last_poster VARCHAR(200),
	num_views MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0,
	num_replies MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0,
	closed TINYINT(1) NOT NULL DEFAULT 0,
	sticky TINYINT(1) NOT NULL DEFAULT 0,
	moved_to INT(10) UNSIGNED,
	forum_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
	PRIMARY KEY (id)
	) TYPE=MyISAM;

CREATE TABLE users (
	id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
	group_id INT(10) UNSIGNED NOT NULL DEFAULT 4,
	username VARCHAR(200) NOT NULL DEFAULT '',
	password VARCHAR(40) NOT NULL DEFAULT '',
	email VARCHAR(50) NOT NULL DEFAULT '',
	title VARCHAR(50),
	realname VARCHAR(40),
	url VARCHAR(100),
	jabber VARCHAR(75),
	icq VARCHAR(12),
	msn VARCHAR(50),
	aim VARCHAR(30),
	yahoo VARCHAR(30),
	location VARCHAR(30),
	use_avatar TINYINT(1) NOT NULL DEFAULT 0,
	signature TEXT,
	disp_topics TINYINT(3) UNSIGNED,
	disp_posts TINYINT(3) UNSIGNED,
	email_setting TINYINT(1) NOT NULL DEFAULT 1,
	save_pass TINYINT(1) NOT NULL DEFAULT 1,
	notify_with_post TINYINT(1) NOT NULL DEFAULT 0,
	show_smilies TINYINT(1) NOT NULL DEFAULT 1,
	show_img TINYINT(1) NOT NULL DEFAULT 1,
	show_img_sig TINYINT(1) NOT NULL DEFAULT 1,
	show_avatars TINYINT(1) NOT NULL DEFAULT 1,
	show_sig TINYINT(1) NOT NULL DEFAULT 1,
	timezone FLOAT NOT NULL DEFAULT 0,
	language VARCHAR(25) NOT NULL DEFAULT 'English',
	style VARCHAR(25) NOT NULL DEFAULT 'Oxygen',
	num_posts INT(10) UNSIGNED NOT NULL DEFAULT 0,
	last_post INT(10) UNSIGNED,
	registered INT(10) UNSIGNED NOT NULL DEFAULT 0,
	registration_ip VARCHAR(15) NOT NULL DEFAULT '0.0.0.0',
	last_visit INT(10) UNSIGNED NOT NULL DEFAULT 0,
	admin_note VARCHAR(30),
	activate_string VARCHAR(50),
	activate_key VARCHAR(8),
	PRIMARY KEY (id)
	) TYPE=MyISAM;

ALTER TABLE online ADD INDEX online_user_id_idx(user_id);
ALTER TABLE posts ADD INDEX posts_topic_id_idx(topic_id);
ALTER TABLE posts ADD INDEX posts_multi_idx(poster_id, topic_id);
ALTER TABLE reports ADD INDEX reports_zapped_idx(zapped);
ALTER TABLE search_matches ADD INDEX search_matches_word_id_idx(word_id);
ALTER TABLE search_matches ADD INDEX search_matches_post_id_idx(post_id);
ALTER TABLE topics ADD INDEX topics_forum_id_idx(forum_id);
ALTER TABLE topics ADD INDEX topics_moved_to_idx(moved_to);
ALTER TABLE users ADD INDEX users_registered_idx(registered);
ALTER TABLE search_cache ADD INDEX search_cache_ident_idx(ident(8));
ALTER TABLE users ADD INDEX users_username_idx(username(8));
