PluginProbe
wpForo Forum / 2.0.9
wpForo Forum v2.0.9
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.0.9, at includes/install-sql.php

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