punbb/schema.sql
author Dan
Thu, 12 Jul 2007 15:00:35 -0400
changeset 3 c0c445d4a13e
permissions -rw-r--r--
Got some basic security in there, admin panel works now, and most admin panel forms work (used regex mass search + replace)

-- Punano installation schema

CREATE TABLE {{TABLE_PREFIX}}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 {{TABLE_PREFIX}}config (
  conf_name VARCHAR(255) NOT NULL DEFAULT '',
  conf_value TEXT,
  PRIMARY KEY (conf_name)
) TYPE=MyISAM;

CREATE TABLE {{TABLE_PREFIX}}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 {{TABLE_PREFIX}}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 {{TABLE_PREFIX}}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 {{TABLE_PREFIX}}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 {{TABLE_PREFIX}}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,
  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 {{TABLE_PREFIX}}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 {{TABLE_PREFIX}}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,
  zapped INT(10) UNSIGNED,
  zapped_by INT(10) UNSIGNED,
  PRIMARY KEY (id)
) TYPE=MyISAM;

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

CREATE TABLE {{TABLE_PREFIX}}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 {{TABLE_PREFIX}}search_words (
  id MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,
  word VARCHAR(20) BINARY NOT NULL DEFAULT '',
  PRIMARY KEY (word),
  KEY {{TABLE_PREFIX}}search_words_id_idx (id)
) TYPE=MyISAM;

CREATE TABLE {{TABLE_PREFIX}}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 {{TABLE_PREFIX}}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 {{TABLE_PREFIX}}users (
  id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  group_id INT(10) UNSIGNED NOT NULL DEFAULT 4,
  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 {{TABLE_PREFIX}}online ADD UNIQUE INDEX {{TABLE_PREFIX}}online_user_id_ident_idx(user_id,ident);
ALTER TABLE {{TABLE_PREFIX}}online ADD INDEX {{TABLE_PREFIX}}online_user_id_idx(user_id);
ALTER TABLE {{TABLE_PREFIX}}posts ADD INDEX {{TABLE_PREFIX}}posts_topic_id_idx(topic_id);
ALTER TABLE {{TABLE_PREFIX}}posts ADD INDEX {{TABLE_PREFIX}}posts_multi_idx(poster_id, topic_id);
ALTER TABLE {{TABLE_PREFIX}}reports ADD INDEX {{TABLE_PREFIX}}reports_zapped_idx(zapped);
ALTER TABLE {{TABLE_PREFIX}}search_matches ADD INDEX {{TABLE_PREFIX}}search_matches_word_id_idx(word_id);
ALTER TABLE {{TABLE_PREFIX}}search_matches ADD INDEX {{TABLE_PREFIX}}search_matches_post_id_idx(post_id);
ALTER TABLE {{TABLE_PREFIX}}topics ADD INDEX {{TABLE_PREFIX}}topics_forum_id_idx(forum_id);
ALTER TABLE {{TABLE_PREFIX}}topics ADD INDEX {{TABLE_PREFIX}}topics_moved_to_idx(moved_to);
ALTER TABLE {{TABLE_PREFIX}}users ADD INDEX {{TABLE_PREFIX}}users_registered_idx(registered);
ALTER TABLE {{TABLE_PREFIX}}search_cache ADD INDEX {{TABLE_PREFIX}}search_cache_ident_idx(ident(8));

INSERT INTO {{TABLE_PREFIX}}groups (g_title, g_user_title, g_read_board, g_post_replies, g_post_topics, g_post_polls, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_edit_subjects_interval, g_post_flood, g_search_flood) VALUES('Administrators', 'Administrator', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0);
INSERT INTO {{TABLE_PREFIX}}groups (g_title, g_user_title, g_read_board, g_post_replies, g_post_topics, g_post_polls, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_edit_subjects_interval, g_post_flood, g_search_flood) VALUES('Moderators', 'Moderator', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0);
INSERT INTO {{TABLE_PREFIX}}groups (g_title, g_user_title, g_read_board, g_post_replies, g_post_topics, g_post_polls, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_edit_subjects_interval, g_post_flood, g_search_flood) VALUES('Guest', NULL, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0);
INSERT INTO {{TABLE_PREFIX}}groups (g_title, g_user_title, g_read_board, g_post_replies, g_post_topics, g_post_polls, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_edit_subjects_interval, g_post_flood, g_search_flood) VALUES('Members', NULL, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 300, 60, 30);

INSERT INTO {{TABLE_PREFIX}}users (id, group_id) VALUES(1, 3);

INSERT INTO {{TABLE_PREFIX}}config VALUES
  ('o_cur_version', '{{PUN_VERSION}}'),
  ('o_board_title', 'My PunBB forum'),
  ('o_board_desc', 'Unfortunately no one can be told what PunBB is - you have to see it for yourself.'),
  ('o_server_timezone', '0'),
  ('o_time_format', 'H:i:s'),
  ('o_date_format', 'Y-m-d'),
  ('o_timeout_visit', '600'),
  ('o_timeout_online', '300'),
  ('o_redirect_delay', '1'),
  ('o_show_version', '0'),
  ('o_show_user_info', '1'),
  ('o_show_post_count', '1'),
  ('o_smilies', '1'),
  ('o_smilies_sig', '1'),
  ('o_make_links', '1'),
  ('o_default_lang', 'English'),
  ('o_default_style', 'Oxygen'),
  ('o_default_user_group', '4'),
  ('o_topic_review', '15'),
  ('o_disp_topics_default', '30'),
  ('o_disp_posts_default', '25'),
  ('o_indent_num_spaces', '4'),
  ('o_quickpost', '1'),
  ('o_users_online', '1'),
  ('o_censoring', '0'),
  ('o_ranks', '1'),
  ('o_show_dot', '0'),
  ('o_quickjump', '1'),
  ('o_gzip', '0'),
  ('o_additional_navlinks', ''),
  ('o_report_method', '0'),
  ('o_regs_report', '0'),
  ('o_mailing_list', '{{ENANO_ADMIN_EMAIL}}'),
  ('o_avatars', '1'),
  ('o_avatars_dir', 'img/avatars'),
  ('o_avatars_width', '60'),
  ('o_avatars_height', '60'),
  ('o_avatars_size', '10240'),
  ('o_search_all_forums', '1'),
  ('o_base_url', ''),
  ('o_admin_email', '{{ENANO_ADMIN_EMAIL}}'),
  ('o_webmaster_email', '{{ENANO_ADMIN_EMAIL}}'),
  ('o_subscriptions', '1'),
  ('o_smtp_host', NULL),
  ('o_smtp_user', NULL),
  ('o_smtp_pass', NULL),
  ('o_regs_allow', '1'),
  ('o_regs_verify', '0'),
  ('o_announcement', '0'),
  ('o_announcement_message', 'Enter your announcement here.'),
  ('o_rules', '0'),
  ('o_rules_message', 'Enter your rules here.'),
  ('o_maintenance', '0'),
  ('o_maintenance_message', 'The forums are temporarily down for maintenance. Please try again in a few minutes.<br />\\n<br />\\n--Administrator'),
  ('p_mod_edit_users', '1'),
  ('p_mod_rename_users', '0'),
  ('p_mod_change_passwords', '0'),
  ('p_mod_ban_users', '0'),
  ('p_message_bbcode', '1'),
  ('p_message_img_tag', '1'),
  ('p_message_all_caps', '1'),
  ('p_subject_all_caps', '1'),
  ('p_sig_all_caps', '1'),
  ('p_sig_bbcode', '1'),
  ('p_sig_img_tag', '0'),
  ('p_sig_length', '400'),
  ('p_sig_lines', '4'),
  ('p_allow_banned_email', '1'),
  ('p_allow_dupe_email', '0'),
  ('p_force_guest_email', '1');
  
INSERT INTO {{TABLE_PREFIX}}categories (cat_name, disp_position) VALUES('Test category', 1);
INSERT INTO {{TABLE_PREFIX}}forums (forum_name, forum_desc, num_topics, num_posts, last_post, last_post_id, last_poster, disp_position, cat_id) VALUES('Test forum', 'This is just a test forum', 1, 1, UNIX_TIMESTAMP(), 1, 'PunBB', 1, 1);
INSERT INTO {{TABLE_PREFIX}}topics (poster, subject, posted, last_post, last_post_id, last_poster, forum_id) VALUES('PunBB', 'Test post', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), 1, 'PunBB', 1);
INSERT INTO {{TABLE_PREFIX}}posts (poster, poster_id, poster_ip, message, posted, topic_id) VALUES('PunBB', 2, '127.0.0.1', 'If you are looking at this (which I guess you are), the install of PunBB appears to have worked! Now log in and head over to the administration control panel to configure your forum.', UNIX_TIMESTAMP(), 1);
INSERT INTO {{TABLE_PREFIX}}ranks (rank, min_posts) VALUES('New member', 0), ('Member', 10);