PluginProbe
wpForo Forum / 2.4.13
wpForo Forum v2.4.13
3.1.5 3.1.4 3.1.2 3.1.1 3.1.0 3.0.9 3.0.8 3.0.7 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.2 All 137 releases
wpforo / includes / install-sql.php

install-sql.php in wpForo Forum 2.4.13, at includes/install-sql.php

364 lines 16.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // Exit if accessed directly
3 if( ! defined( 'ABSPATH' ) ) exit;
4
5 if( ! function_exists( 'wpforo_get_install_sqls' ) ) {
6 function wpforo_get_install_sqls() {
7 $charset_collate = '';
8 if( ! empty( WPF()->db->charset ) ) $charset_collate = "DEFAULT CHARACTER SET " . WPF()->db->charset;
9 if( ! empty( WPF()->db->collate ) ) $charset_collate .= " COLLATE " . WPF()->db->collate;
10 $engine = version_compare( WPF()->db->db_version(), '5.6.4', '>=' ) ? 'InnoDB' : 'MyISAM';
11
12 return [
13 WPF()->tables->boards => "CREATE TABLE IF NOT EXISTS `" . WPF()->tables->boards . "`(
14 `boardid` INT UNSIGNED NOT NULL AUTO_INCREMENT,
15 `title` VARCHAR(100) NOT NULL,
16 `slug` VARCHAR(255) NOT NULL,
17 `pageid` BIGINT NOT NULL,
18 `modules` TEXT,
19 `locale` VARCHAR(10) DEFAULT '',
20 `is_standalone` TINYINT(1) NOT NULL DEFAULT 0,
21 `excld_urls` TEXT,
22 `status` TINYINT(1) NOT NULL DEFAULT 1,
23 `settings` TEXT,
24 PRIMARY KEY (`boardid`),
25 UNIQUE KEY `unique_slug` (`slug`(191)),
26 KEY `bulk_index` (`slug`(191), `locale`, `is_standalone`, `status`)
27 ) ENGINE=INNODB $charset_collate",
28 WPF()->tables->forums => "CREATE TABLE IF NOT EXISTS `" . WPF()->tables->forums . "`(
29 `forumid` INT UNSIGNED NOT NULL AUTO_INCREMENT,
30 `title` VARCHAR(255) NOT NULL,
31 `slug` VARCHAR(255) NOT NULL,
32 `description` LONGTEXT,
33 `parentid` INT UNSIGNED NOT NULL DEFAULT 0,
34 `icon` VARCHAR(255),
35 `cover` BIGINT UNSIGNED NOT NULL DEFAULT 0,
36 `cover_height` INT(4) UNSIGNED NOT NULL DEFAULT 150,
37 `last_topicid` INT UNSIGNED NOT NULL DEFAULT 0,
38 `last_postid` INT UNSIGNED NOT NULL DEFAULT 0,
39 `last_userid` VARCHAR(255) NOT NULL,
40 `last_post_date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
41 `topics` INT NOT NULL DEFAULT 0,
42 `posts` INT NOT NULL DEFAULT 0,
43 `permissions` TEXT,
44 `meta_key` TEXT,
45 `meta_desc` TEXT,
46 `status` tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
47 `is_cat` tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
48 `layout` tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
49 `order` INT UNSIGNED NOT NULL DEFAULT 0,
50 `color` VARCHAR(7) NOT NULL DEFAULT '',
51 PRIMARY KEY (`forumid`),
52 UNIQUE KEY `UNIQUE SLUG` (`slug`(191)),
53 KEY `order` (`order`),
54 KEY `status` (`status`),
55 KEY `parentid` (`parentid`),
56 KEY `last_postid` (`last_postid`),
57 KEY `last_userid` (`last_userid`(191)),
58 KEY `is_cat` (`is_cat`)
59 ) ENGINE=InnoDB $charset_collate",
60 WPF()->tables->topics => "CREATE TABLE IF NOT EXISTS `" . WPF()->tables->topics . "`(
61 `topicid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
62 `forumid` INT UNSIGNED NOT NULL,
63 `first_postid` BIGINT UNSIGNED NOT NULL DEFAULT 0,
64 `userid` INT UNSIGNED NOT NULL,
65 `title` VARCHAR(255) NOT NULL,
66 `slug` VARCHAR(255) NOT NULL,
67 `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
68 `modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
69 `last_post` BIGINT UNSIGNED NOT NULL DEFAULT 0,
70 `posts` INT NOT NULL DEFAULT 0,
71 `votes` INT NOT NULL DEFAULT 0,
72 `answers` INT NOT NULL DEFAULT 0,
73 `views` INT UNSIGNED NOT NULL DEFAULT 0,
74 `meta_key` TEXT,
75 `meta_desc` TEXT,
76 `type` TINYINT NOT NULL DEFAULT 0,
77 `solved` TINYINT(1) NOT NULL DEFAULT 0,
78 `closed` tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
79 `has_attach` tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
80 `private` tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
81 `status` tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
82 `name` VARCHAR(50) NOT NULL DEFAULT '',
83 `email` VARCHAR(50) NOT NULL DEFAULT '',
84 `prefix` VARCHAR(100) NOT NULL DEFAULT '',
85 `tags` TEXT,
86 PRIMARY KEY (`topicid`),
87 KEY `slug` (`slug`(191)),
88 FULLTEXT KEY `title` (`title`),
89 KEY `forumid` (`forumid`),
90 KEY `first_postid` (`first_postid`),
91 KEY `created` (`created`),
92 KEY `modified` (`modified`),
93 KEY `last_post` (`last_post`),
94 KEY `type` (`type`),
95 KEY `status` (`status`),
96 KEY `email` (`email`),
97 KEY `solved` (`solved`),
98 KEY `is_private` (`private`),
99 KEY `own_private` (`userid`,`private`),
100 KEY `forumid_status` (`forumid`,`status`),
101 KEY `forumid_status_private` (`forumid`,`status`,`private`),
102 KEY `prefix` (`prefix`)
103 ) ENGINE=$engine $charset_collate",
104 WPF()->tables->postmeta => "CREATE TABLE IF NOT EXISTS `" . WPF()->tables->postmeta . "`(
105 `metaid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
106 `postid` BIGINT UNSIGNED NOT NULL,
107 `metakey` VARCHAR(255) NOT NULL,
108 `metavalue` MEDIUMTEXT,
109 `forumid` INT UNSIGNED NOT NULL DEFAULT 0,
110 `topicid` BIGINT UNSIGNED NOT NULL DEFAULT 0,
111 `is_first_post` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
112 `status` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
113 `private` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
114 PRIMARY KEY (`metaid`),
115 KEY `postid_metakey` (`postid`, `metakey`(191)),
116 KEY `forumid` (`forumid`),
117 KEY `topicid` (`topicid`),
118 KEY `is_first_post` (`is_first_post`),
119 KEY `status` (`status`),
120 KEY `private` (`private`)
121 ) ENGINE=InnoDB $charset_collate",
122 WPF()->tables->posts => "CREATE TABLE IF NOT EXISTS `" . WPF()->tables->posts . "`(
123 `postid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
124 `parentid` BIGINT UNSIGNED NOT NULL DEFAULT 0,
125 `forumid` INT UNSIGNED NOT NULL,
126 `topicid` BIGINT UNSIGNED NOT NULL,
127 `userid` INT UNSIGNED NOT NULL,
128 `title` varchar(255),
129 `body` LONGTEXT,
130 `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
131 `modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
132 `likes` INT UNSIGNED NOT NULL DEFAULT 0,
133 `votes` INT NOT NULL DEFAULT 0,
134 `is_answer` tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
135 `is_first_post` tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
136 `status` tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
137 `name` VARCHAR(50) NOT NULL DEFAULT '',
138 `email` VARCHAR(50) NOT NULL DEFAULT '',
139 `private` tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
140 `root` BIGINT NULL DEFAULT NULL,
141 PRIMARY KEY (`postid`),
142 FULLTEXT KEY `title`(`title`(191)),
143 FULLTEXT KEY `body` (`body`),
144 FULLTEXT KEY `title_plus_body` (`title`,`body`),
145 KEY `topicid` (`topicid`),
146 KEY `forumid` (`forumid`),
147 KEY `userid` (`userid`),
148 KEY `created` (`created`),
149 KEY `parentid` (`parentid`),
150 KEY `is_answer` (`is_answer`),
151 KEY `is_first_post` (`is_first_post`),
152 KEY `status` (`status`),
153 KEY `email` (`email`),
154 KEY `is_private` (`private`),
155 KEY `root` (`root`),
156 KEY `forumid_status` (`forumid`,`status`),
157 KEY `topicid_status` (`topicid`,`status`),
158 KEY `topicid_solved` (`topicid`,`is_answer`),
159 KEY `topicid_parentid` (`topicid`,`parentid`),
160 KEY `forumid_status_private` (`forumid`, `status`, `private`),
161 KEY `forumid_answer_first` (`forumid`, `is_answer`, `is_first_post`)
162 ) ENGINE=$engine $charset_collate",
163 WPF()->tables->profiles => "CREATE TABLE IF NOT EXISTS `" . WPF()->tables->profiles . "` (
164 `userid` BIGINT UNSIGNED NOT NULL,
165 `title` VARCHAR(255) NOT NULL DEFAULT 'member',
166 `groupid` INT UNSIGNED NOT NULL,
167 `secondary_groupids` VARCHAR(255) NOT NULL DEFAULT '',
168 `avatar` VARCHAR(991) NOT NULL DEFAULT '',
169 `cover` VARCHAR(255) NOT NULL DEFAULT '',
170 `posts` INT UNSIGNED NOT NULL DEFAULT 0,
171 `topics` INT UNSIGNED NOT NULL DEFAULT 0,
172 `questions` INT UNSIGNED NOT NULL DEFAULT 0,
173 `answers` INT UNSIGNED NOT NULL DEFAULT 0,
174 `comments` INT UNSIGNED NOT NULL DEFAULT 0,
175 `reactions_in` TEXT,
176 `reactions_out` TEXT,
177 `points` INT NOT NULL DEFAULT 0,
178 `custom_points` INT NOT NULL DEFAULT 0,
179 `online_time` INT UNSIGNED NOT NULL DEFAULT 0,
180 `timezone` VARCHAR(255) NOT NULL DEFAULT '',
181 `location` VARCHAR(255) NOT NULL DEFAULT '',
182 `signature` TEXT,
183 `about` TEXT,
184 `occupation` TEXT,
185 `status` VARCHAR(8) NOT NULL DEFAULT 'active' COMMENT 'active, blocked, trashed, spamer',
186 `is_email_confirmed` TINYINT(1) NOT NULL DEFAULT 0,
187 `is_mention_muted` TINYINT(1) NOT NULL DEFAULT 0,
188 `fields` LONGTEXT,
189 PRIMARY KEY (`userid`),
190 KEY `groupid` (`groupid`),
191 KEY `online_time` (`online_time`),
192 KEY `posts` (`posts`),
193 KEY `status` (`status`),
194 KEY `is_email_confirmed` (`is_email_confirmed`)
195 ) ENGINE=InnoDB $charset_collate",
196 WPF()->tables->usergroups => "CREATE TABLE IF NOT EXISTS `" . WPF()->tables->usergroups . "`(
197 `groupid` INT UNSIGNED NOT NULL AUTO_INCREMENT,
198 `name` VARCHAR(255) NOT NULL,
199 `cans` LONGTEXT NOT NULL COMMENT 'board permissions',
200 `description` TEXT,
201 `utitle` VARCHAR(100) NOT NULL DEFAULT '',
202 `role` VARCHAR(50) NOT NULL DEFAULT '',
203 `access` VARCHAR(50) NOT NULL DEFAULT '',
204 `color` VARCHAR(7) NOT NULL DEFAULT '',
205 `visible` TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
206 `secondary` TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
207 `is_default` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
208 PRIMARY KEY (`groupid`),
209 KEY `visible` (`visible`),
210 KEY `secondary` (`secondary`),
211 UNIQUE KEY `UNIQUE_GROUP_NAME` (`name`(191))
212 ) ENGINE=MyISAM $charset_collate",
213 WPF()->tables->languages => "CREATE TABLE IF NOT EXISTS `" . WPF()->tables->languages . "`(
214 `langid` INT UNSIGNED NOT NULL AUTO_INCREMENT,
215 `name` VARCHAR(255) NOT NULL,
216 `status` TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
217 PRIMARY KEY (`langid`),
218 UNIQUE KEY `UNIQUE language name` (`name`(191))
219 ) ENGINE=MyISAM $charset_collate",
220 WPF()->tables->phrases => "CREATE TABLE IF NOT EXISTS `" . WPF()->tables->phrases . "` (
221 `phraseid` INT UNSIGNED NOT NULL AUTO_INCREMENT,
222 `langid` INT UNSIGNED NOT NULL,
223 `phrase_key` text NOT NULL,
224 `phrase_value` text NOT NULL,
225 `package` VARCHAR(255) NOT NULL DEFAULT 'wpforo',
226 PRIMARY KEY (`phraseid`),
227 KEY `langid` (`langid`),
228 KEY `phrase_key` (`phrase_key`(191)),
229 UNIQUE KEY lng_and_key_uniq (`langid`, `phrase_key`(191))
230 ) ENGINE=MyISAM $charset_collate",
231 WPF()->tables->accesses => "CREATE TABLE IF NOT EXISTS `" . WPF()->tables->accesses . "`(
232 `accessid` INT UNSIGNED NOT NULL AUTO_INCREMENT,
233 `access` VARCHAR(255) NOT NULL,
234 `title` VARCHAR(255) NOT NULL,
235 `cans` LONGTEXT NOT NULL COMMENT 'forum permissions',
236 PRIMARY KEY (`accessid`),
237 UNIQUE KEY ( `access`(191) )
238 ) ENGINE=MyISAM $charset_collate",
239 WPF()->tables->subscribes => "CREATE TABLE IF NOT EXISTS `" . WPF()->tables->subscribes . "` (
240 `subid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
241 `itemid` BIGINT UNSIGNED NOT NULL,
242 `type` VARCHAR(5) NOT NULL,
243 `confirmkey` varchar(32) NOT NULL,
244 `userid` BIGINT UNSIGNED NOT NULL,
245 `active` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
246 `user_name` VARCHAR(60) NOT NULL,
247 `user_email` VARCHAR(60) NOT NULL,
248 PRIMARY KEY (`subid`),
249 UNIQUE KEY `fld_group_unq` (`itemid`,`type`,`userid`,`user_email`(60)),
250 UNIQUE KEY `confirmkey` (`confirmkey`),
251 KEY `itemid_2` (`itemid`),
252 KEY `userid` (`userid`)
253 ) ENGINE=INNODB $charset_collate",
254 WPF()->tables->follows => "CREATE TABLE IF NOT EXISTS `" . WPF()->tables->follows . "` (
255 `followid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
256 `itemid` BIGINT UNSIGNED NOT NULL,
257 `itemtype` VARCHAR(5) NOT NULL DEFAULT 'user',
258 `confirmkey` VARCHAR(32) NOT NULL,
259 `userid` BIGINT UNSIGNED NOT NULL,
260 `active` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
261 `name` VARCHAR(60) NOT NULL,
262 `email` VARCHAR(60) NOT NULL,
263 PRIMARY KEY (`followid`),
264 UNIQUE KEY `fld_group_unq` (`itemid`,`itemtype`,`userid`,`email`(60)),
265 UNIQUE KEY `confirmkey` (`confirmkey`),
266 KEY `itemid` (`itemid`),
267 KEY `userid` (`userid`)
268 ) ENGINE=INNODB $charset_collate",
269 WPF()->tables->visits => "CREATE TABLE IF NOT EXISTS `" . WPF()->tables->visits . "` (
270 `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
271 `userid` BIGINT UNSIGNED NOT NULL,
272 `name` VARCHAR(60) NOT NULL,
273 `ip` VARCHAR(60) NOT NULL,
274 `time` INT UNSIGNED NOT NULL,
275 `forumid` INT UNSIGNED NOT NULL,
276 `topicid` BIGINT UNSIGNED NOT NULL,
277 PRIMARY KEY (`id`),
278 KEY `userid` (`userid`),
279 KEY `forumid` (`forumid`),
280 KEY `topicid` (`topicid`),
281 KEY `time` (`time`),
282 KEY `ip` (`ip`),
283 KEY `time_forumid` (`time`,`forumid`),
284 KEY `time_topicid` (`time`,`topicid`),
285 UNIQUE KEY `unique_tracking` (`userid`,`ip`,`forumid`,`topicid`)
286 ) ENGINE=INNODB $charset_collate",
287 WPF()->tables->activity => "CREATE TABLE IF NOT EXISTS `" . WPF()->tables->activity . "` (
288 `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
289 `type` VARCHAR(60) NOT NULL,
290 `itemid` BIGINT UNSIGNED NOT NULL,
291 `itemtype` VARCHAR(60) NOT NULL,
292 `itemid_second` BIGINT UNSIGNED NOT NULL DEFAULT 0,
293 `userid` BIGINT UNSIGNED NOT NULL DEFAULT 0,
294 `name` VARCHAR(60) NOT NULL DEFAULT '',
295 `email` VARCHAR(70) NOT NULL DEFAULT '',
296 `date` INT UNSIGNED NOT NULL DEFAULT 0,
297 `content` TEXT,
298 `permalink` VARCHAR(1024) NOT NULL DEFAULT '',
299 `new` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
300 PRIMARY KEY (`id`),
301 KEY `type` (`type`),
302 KEY `type_objid_objtype` (`type`,`itemid`,`itemtype`),
303 KEY `type_objid_objtype_userid` (`type`,`itemid`,`itemtype`,`userid`),
304 KEY `itemtype_userid_new` (`itemtype`,`userid`,`new`),
305 KEY `date` (`date`)
306 ) ENGINE=INNODB $charset_collate",
307 WPF()->tables->post_revisions => "CREATE TABLE IF NOT EXISTS `" . WPF()->tables->post_revisions . "` (
308 `revisionid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
309 `userid` BIGINT UNSIGNED NOT NULL DEFAULT 0,
310 `textareaid` VARCHAR(50) NOT NULL,
311 `postid` BIGINT UNSIGNED NOT NULL DEFAULT 0,
312 `body` LONGTEXT,
313 `created` INT UNSIGNED NOT NULL DEFAULT 0,
314 `version` SMALLINT NOT NULL DEFAULT 0,
315 `email` VARCHAR(50) NOT NULL DEFAULT '',
316 `url` TEXT,
317 PRIMARY KEY (`revisionid`),
318 KEY `userid_textareaid_postid_email` (`userid`, `textareaid`, `postid`, `email`, `url`(70))
319 ) ENGINE=INNODB $charset_collate",
320 WPF()->tables->tags => "CREATE TABLE IF NOT EXISTS `" . WPF()->tables->tags . "`(
321 `tagid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
322 `tag` VARCHAR(255) NOT NULL,
323 `prefix` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
324 `count` INT UNSIGNED NOT NULL DEFAULT 0,
325 PRIMARY KEY (`tagid`),
326 UNIQUE KEY `tag` (`tag`(190)),
327 KEY (`prefix`)
328 ) ENGINE=MyISAM $charset_collate",
329 WPF()->tables->logs => "CREATE TABLE IF NOT EXISTS `" . WPF()->tables->logs . "`(
330 `logid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
331 `sessionid` VARCHAR(255) NOT NULL,
332 `key` VARCHAR(255) NOT NULL,
333 `value` MEDIUMTEXT NOT NULL,
334 PRIMARY KEY (`logid`),
335 KEY `sessionid_key` (`sessionid`(20), `key`(160))
336 ) ENGINE=InnoDB $charset_collate",
337 WPF()->tables->reactions => "CREATE TABLE IF NOT EXISTS `" . WPF()->tables->reactions . "` (
338 `reactionid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
339 `userid` BIGINT UNSIGNED NOT NULL,
340 `postid` BIGINT UNSIGNED NOT NULL,
341 `post_userid` BIGINT UNSIGNED NOT NULL DEFAULT 0,
342 `reaction` TINYINT(4) NOT NULL DEFAULT 1,
343 `type` VARCHAR(50) NOT NULL DEFAULT 'up',
344 `name` VARCHAR(50) DEFAULT NULL,
345 `email` VARCHAR(100) DEFAULT NULL,
346 PRIMARY KEY (`reactionid`),
347 UNIQUE KEY `unique_reaction` (`userid`,`postid`,`type`,`email`),
348 KEY `performance` (`postid`,`post_userid`,`type`)
349 ) ENGINE=InnoDB $charset_collate",
350 WPF()->tables->bookmarks => "CREATE TABLE IF NOT EXISTS `" . WPF()->tables->bookmarks . "` (
351 `bookmarkid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
352 `userid` BIGINT UNSIGNED NOT NULL,
353 `boardid` INT UNSIGNED NOT NULL,
354 `postid` BIGINT UNSIGNED NOT NULL,
355 `created` INT UNSIGNED NOT NULL,
356 `status` TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
357 PRIMARY KEY (`bookmarkid`),
358 UNIQUE KEY `unique_bookmark` (`userid`,`boardid`,`postid`),
359 KEY `performance` (`userid`,`boardid`,`postid`,`status`)
360 ) ENGINE=InnoDB $charset_collate",
361 ];
362 }
363 }
364