punbb/schema.sql
changeset 6 5e1f1e916419
parent 5 e3d7322305bf
child 7 98bbc533541c
equal deleted inserted replaced
5:e3d7322305bf 6:5e1f1e916419
     1 -- Punano installation schema
       
     2 
       
     3 CREATE TABLE {{TABLE_PREFIX}}categories (
       
     4   id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
       
     5   cat_name VARCHAR(80) NOT NULL DEFAULT 'New Category',
       
     6   disp_position INT(10) NOT NULL DEFAULT 0,
       
     7   PRIMARY KEY (id)
       
     8 ) TYPE=MyISAM;
       
     9 
       
    10 CREATE TABLE {{TABLE_PREFIX}}config (
       
    11   conf_name VARCHAR(255) NOT NULL DEFAULT '',
       
    12   conf_value TEXT,
       
    13   PRIMARY KEY (conf_name)
       
    14 ) TYPE=MyISAM;
       
    15 
       
    16 CREATE TABLE {{TABLE_PREFIX}}forum_perms (
       
    17   group_id INT(10) NOT NULL DEFAULT 0,
       
    18   forum_id INT(10) NOT NULL DEFAULT 0,
       
    19   read_forum TINYINT(1) NOT NULL DEFAULT 1,
       
    20   post_replies TINYINT(1) NOT NULL DEFAULT 1,
       
    21   post_topics TINYINT(1) NOT NULL DEFAULT 1,
       
    22   PRIMARY KEY (group_id, forum_id)
       
    23 ) TYPE=MyISAM;
       
    24 
       
    25 CREATE TABLE {{TABLE_PREFIX}}forums (
       
    26   id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
       
    27   forum_name VARCHAR(80) NOT NULL DEFAULT 'New forum',
       
    28   forum_desc TEXT,
       
    29   redirect_url VARCHAR(100),
       
    30   moderators TEXT,
       
    31   num_topics MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0,
       
    32   num_posts MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0,
       
    33   last_post INT(10) UNSIGNED,
       
    34   last_post_id INT(10) UNSIGNED,
       
    35   last_poster VARCHAR(200),
       
    36   sort_by TINYINT(1) NOT NULL DEFAULT 0,
       
    37   disp_position INT(10) NOT NULL DEFAULT 0,
       
    38   cat_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
       
    39   PRIMARY KEY (id)
       
    40 ) TYPE=MyISAM;
       
    41 
       
    42 CREATE TABLE {{TABLE_PREFIX}}groups (
       
    43   g_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
       
    44   g_title VARCHAR(50) NOT NULL DEFAULT '',
       
    45   g_user_title VARCHAR(50),
       
    46   g_read_board TINYINT(1) NOT NULL DEFAULT 1,
       
    47   g_post_replies TINYINT(1) NOT NULL DEFAULT 1,
       
    48   g_post_topics TINYINT(1) NOT NULL DEFAULT 1,
       
    49   g_post_polls TINYINT(1) NOT NULL DEFAULT 1,
       
    50   g_edit_posts TINYINT(1) NOT NULL DEFAULT 1,
       
    51   g_delete_posts TINYINT(1) NOT NULL DEFAULT 1,
       
    52   g_delete_topics TINYINT(1) NOT NULL DEFAULT 1,
       
    53   g_set_title TINYINT(1) NOT NULL DEFAULT 1,
       
    54   g_search TINYINT(1) NOT NULL DEFAULT 1,
       
    55   g_search_users TINYINT(1) NOT NULL DEFAULT 1,
       
    56   g_edit_subjects_interval SMALLINT(6) NOT NULL DEFAULT 300,
       
    57   g_post_flood SMALLINT(6) NOT NULL DEFAULT 30,
       
    58   g_search_flood SMALLINT(6) NOT NULL DEFAULT 30,
       
    59   PRIMARY KEY (g_id)
       
    60 ) TYPE=MyISAM;
       
    61 
       
    62 CREATE TABLE {{TABLE_PREFIX}}online (
       
    63   user_id INT(10) UNSIGNED NOT NULL DEFAULT 1,
       
    64   ident VARCHAR(200) NOT NULL DEFAULT '',
       
    65   logged INT(10) UNSIGNED NOT NULL DEFAULT 0,
       
    66   idle TINYINT(1) NOT NULL DEFAULT 0
       
    67 ) TYPE=HEAP;
       
    68 
       
    69 CREATE TABLE {{TABLE_PREFIX}}posts (
       
    70   id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
       
    71   poster VARCHAR(200) NOT NULL DEFAULT '',
       
    72   poster_id INT(10) UNSIGNED NOT NULL DEFAULT 1,
       
    73   poster_ip VARCHAR(15),
       
    74   poster_email VARCHAR(50),
       
    75   message TEXT,
       
    76   hide_smilies TINYINT(1) NOT NULL DEFAULT 0,
       
    77   posted INT(10) UNSIGNED NOT NULL DEFAULT 0,
       
    78   edited INT(10) UNSIGNED,
       
    79   edited_by VARCHAR(200),
       
    80   topic_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
       
    81   PRIMARY KEY (id)
       
    82 ) TYPE=MyISAM;
       
    83 
       
    84 CREATE TABLE {{TABLE_PREFIX}}ranks (
       
    85   id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
       
    86   rank VARCHAR(50) NOT NULL DEFAULT '',
       
    87   min_posts MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0,
       
    88   PRIMARY KEY (id)
       
    89 ) TYPE=MyISAM;
       
    90 
       
    91 CREATE TABLE {{TABLE_PREFIX}}reports (
       
    92   id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
       
    93   post_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
       
    94   topic_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
       
    95   forum_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
       
    96   reported_by INT(10) UNSIGNED NOT NULL DEFAULT 0,
       
    97   created INT(10) UNSIGNED NOT NULL DEFAULT 0,
       
    98   message TEXT,
       
    99   zapped INT(10) UNSIGNED,
       
   100   zapped_by INT(10) UNSIGNED,
       
   101   PRIMARY KEY (id)
       
   102 ) TYPE=MyISAM;
       
   103 
       
   104 CREATE TABLE {{TABLE_PREFIX}}search_cache (
       
   105   id INT(10) UNSIGNED NOT NULL DEFAULT 0,
       
   106   ident VARCHAR(200) NOT NULL DEFAULT '',
       
   107   search_data TEXT,
       
   108   PRIMARY KEY (id)
       
   109 ) TYPE=MyISAM;
       
   110 
       
   111 CREATE TABLE {{TABLE_PREFIX}}search_matches (
       
   112   post_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
       
   113   word_id MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0,
       
   114   subject_match TINYINT(1) NOT NULL DEFAULT 0
       
   115 ) TYPE=MyISAM;
       
   116 
       
   117 CREATE TABLE {{TABLE_PREFIX}}search_words (
       
   118   id MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,
       
   119   word VARCHAR(20) BINARY NOT NULL DEFAULT '',
       
   120   PRIMARY KEY (word),
       
   121   KEY {{TABLE_PREFIX}}search_words_id_idx (id)
       
   122 ) TYPE=MyISAM;
       
   123 
       
   124 CREATE TABLE {{TABLE_PREFIX}}subscriptions (
       
   125   user_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
       
   126   topic_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
       
   127   PRIMARY KEY (user_id, topic_id)
       
   128 ) TYPE=MyISAM;
       
   129 
       
   130 CREATE TABLE {{TABLE_PREFIX}}topics (
       
   131   id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
       
   132   poster VARCHAR(200) NOT NULL DEFAULT '',
       
   133   subject VARCHAR(255) NOT NULL DEFAULT '',
       
   134   posted INT(10) UNSIGNED NOT NULL DEFAULT 0,
       
   135   last_post INT(10) UNSIGNED NOT NULL DEFAULT 0,
       
   136   last_post_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
       
   137   last_poster VARCHAR(200),
       
   138   num_views MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0,
       
   139   num_replies MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0,
       
   140   closed TINYINT(1) NOT NULL DEFAULT 0,
       
   141   sticky TINYINT(1) NOT NULL DEFAULT 0,
       
   142   moved_to INT(10) UNSIGNED,
       
   143   forum_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
       
   144   PRIMARY KEY (id)
       
   145 ) TYPE=MyISAM;
       
   146 
       
   147 CREATE TABLE {{TABLE_PREFIX}}users (
       
   148   id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
       
   149   group_id INT(10) UNSIGNED NOT NULL DEFAULT 4,
       
   150   title VARCHAR(50),
       
   151   realname VARCHAR(40),
       
   152   url VARCHAR(100),
       
   153   jabber VARCHAR(75),
       
   154   icq VARCHAR(12),
       
   155   msn VARCHAR(50),
       
   156   aim VARCHAR(30),
       
   157   yahoo VARCHAR(30),
       
   158   location VARCHAR(30),
       
   159   use_avatar TINYINT(1) NOT NULL DEFAULT 0,
       
   160   signature TEXT,
       
   161   disp_topics TINYINT(3) UNSIGNED,
       
   162   disp_posts TINYINT(3) UNSIGNED,
       
   163   email_setting TINYINT(1) NOT NULL DEFAULT 1,
       
   164   save_pass TINYINT(1) NOT NULL DEFAULT 1,
       
   165   notify_with_post TINYINT(1) NOT NULL DEFAULT 0,
       
   166   show_smilies TINYINT(1) NOT NULL DEFAULT 1,
       
   167   show_img TINYINT(1) NOT NULL DEFAULT 1,
       
   168   show_img_sig TINYINT(1) NOT NULL DEFAULT 1,
       
   169   show_avatars TINYINT(1) NOT NULL DEFAULT 1,
       
   170   show_sig TINYINT(1) NOT NULL DEFAULT 1,
       
   171   timezone FLOAT NOT NULL DEFAULT 0,
       
   172   language VARCHAR(25) NOT NULL DEFAULT 'English',
       
   173   style VARCHAR(25) NOT NULL DEFAULT 'Oxygen',
       
   174   num_posts INT(10) UNSIGNED NOT NULL DEFAULT 0,
       
   175   last_post INT(10) UNSIGNED,
       
   176   registered INT(10) UNSIGNED NOT NULL DEFAULT 0,
       
   177   registration_ip VARCHAR(15) NOT NULL DEFAULT '0.0.0.0',
       
   178   last_visit INT(10) UNSIGNED NOT NULL DEFAULT 0,
       
   179   admin_note VARCHAR(30),
       
   180   activate_string VARCHAR(50),
       
   181   activate_key VARCHAR(8),
       
   182   PRIMARY KEY (id)
       
   183 ) TYPE=MyISAM;
       
   184 
       
   185 ALTER TABLE {{TABLE_PREFIX}}online ADD UNIQUE INDEX {{TABLE_PREFIX}}online_user_id_ident_idx(user_id,ident);
       
   186 ALTER TABLE {{TABLE_PREFIX}}online ADD INDEX {{TABLE_PREFIX}}online_user_id_idx(user_id);
       
   187 ALTER TABLE {{TABLE_PREFIX}}posts ADD INDEX {{TABLE_PREFIX}}posts_topic_id_idx(topic_id);
       
   188 ALTER TABLE {{TABLE_PREFIX}}posts ADD INDEX {{TABLE_PREFIX}}posts_multi_idx(poster_id, topic_id);
       
   189 ALTER TABLE {{TABLE_PREFIX}}reports ADD INDEX {{TABLE_PREFIX}}reports_zapped_idx(zapped);
       
   190 ALTER TABLE {{TABLE_PREFIX}}search_matches ADD INDEX {{TABLE_PREFIX}}search_matches_word_id_idx(word_id);
       
   191 ALTER TABLE {{TABLE_PREFIX}}search_matches ADD INDEX {{TABLE_PREFIX}}search_matches_post_id_idx(post_id);
       
   192 ALTER TABLE {{TABLE_PREFIX}}topics ADD INDEX {{TABLE_PREFIX}}topics_forum_id_idx(forum_id);
       
   193 ALTER TABLE {{TABLE_PREFIX}}topics ADD INDEX {{TABLE_PREFIX}}topics_moved_to_idx(moved_to);
       
   194 ALTER TABLE {{TABLE_PREFIX}}users ADD INDEX {{TABLE_PREFIX}}users_registered_idx(registered);
       
   195 ALTER TABLE {{TABLE_PREFIX}}search_cache ADD INDEX {{TABLE_PREFIX}}search_cache_ident_idx(ident(8));
       
   196 
       
   197 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);
       
   198 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);
       
   199 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);
       
   200 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);
       
   201 
       
   202 INSERT INTO {{TABLE_PREFIX}}users (id, group_id) VALUES(1, 3);
       
   203 
       
   204 INSERT INTO {{TABLE_PREFIX}}config VALUES
       
   205   ('o_cur_version', '{{PUN_VERSION}}'),
       
   206   ('o_board_title', 'My PunBB forum'),
       
   207   ('o_board_desc', 'Unfortunately no one can be told what PunBB is - you have to see it for yourself.'),
       
   208   ('o_server_timezone', '0'),
       
   209   ('o_time_format', 'H:i:s'),
       
   210   ('o_date_format', 'Y-m-d'),
       
   211   ('o_timeout_visit', '600'),
       
   212   ('o_timeout_online', '300'),
       
   213   ('o_redirect_delay', '1'),
       
   214   ('o_show_version', '0'),
       
   215   ('o_show_user_info', '1'),
       
   216   ('o_show_post_count', '1'),
       
   217   ('o_smilies', '1'),
       
   218   ('o_smilies_sig', '1'),
       
   219   ('o_make_links', '1'),
       
   220   ('o_default_lang', 'English'),
       
   221   ('o_default_style', 'Oxygen'),
       
   222   ('o_default_user_group', '4'),
       
   223   ('o_topic_review', '15'),
       
   224   ('o_disp_topics_default', '30'),
       
   225   ('o_disp_posts_default', '25'),
       
   226   ('o_indent_num_spaces', '4'),
       
   227   ('o_quickpost', '1'),
       
   228   ('o_users_online', '1'),
       
   229   ('o_censoring', '0'),
       
   230   ('o_ranks', '1'),
       
   231   ('o_show_dot', '0'),
       
   232   ('o_quickjump', '1'),
       
   233   ('o_gzip', '0'),
       
   234   ('o_additional_navlinks', ''),
       
   235   ('o_report_method', '0'),
       
   236   ('o_regs_report', '0'),
       
   237   ('o_mailing_list', '{{ENANO_ADMIN_EMAIL}}'),
       
   238   ('o_avatars', '1'),
       
   239   ('o_avatars_dir', 'img/avatars'),
       
   240   ('o_avatars_width', '60'),
       
   241   ('o_avatars_height', '60'),
       
   242   ('o_avatars_size', '10240'),
       
   243   ('o_search_all_forums', '1'),
       
   244   ('o_base_url', ''),
       
   245   ('o_admin_email', '{{ENANO_ADMIN_EMAIL}}'),
       
   246   ('o_webmaster_email', '{{ENANO_ADMIN_EMAIL}}'),
       
   247   ('o_subscriptions', '1'),
       
   248   ('o_smtp_host', NULL),
       
   249   ('o_smtp_user', NULL),
       
   250   ('o_smtp_pass', NULL),
       
   251   ('o_regs_allow', '1'),
       
   252   ('o_regs_verify', '0'),
       
   253   ('o_announcement', '0'),
       
   254   ('o_announcement_message', 'Enter your announcement here.'),
       
   255   ('o_rules', '0'),
       
   256   ('o_rules_message', 'Enter your rules here.'),
       
   257   ('o_maintenance', '0'),
       
   258   ('o_maintenance_message', 'The forums are temporarily down for maintenance. Please try again in a few minutes.<br />\\n<br />\\n--Administrator'),
       
   259   ('p_mod_edit_users', '1'),
       
   260   ('p_mod_rename_users', '0'),
       
   261   ('p_mod_change_passwords', '0'),
       
   262   ('p_mod_ban_users', '0'),
       
   263   ('p_message_bbcode', '1'),
       
   264   ('p_message_img_tag', '1'),
       
   265   ('p_message_all_caps', '1'),
       
   266   ('p_subject_all_caps', '1'),
       
   267   ('p_sig_all_caps', '1'),
       
   268   ('p_sig_bbcode', '1'),
       
   269   ('p_sig_img_tag', '0'),
       
   270   ('p_sig_length', '400'),
       
   271   ('p_sig_lines', '4'),
       
   272   ('p_allow_banned_email', '1'),
       
   273   ('p_allow_dupe_email', '0'),
       
   274   ('p_force_guest_email', '1');
       
   275   
       
   276 INSERT INTO {{TABLE_PREFIX}}categories (cat_name, disp_position) VALUES('Test category', 1);
       
   277 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);
       
   278 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);
       
   279 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);
       
   280 INSERT INTO {{TABLE_PREFIX}}ranks (rank, min_posts) VALUES('New member', 0), ('Member', 10);
       
   281