]> git.mxchange.org Git - friendica.git/blob - database.sql
Merge remote-tracking branch 'upstream/develop' into develop
[friendica.git] / database.sql
1 -- ------------------------------------------
2 -- Friendica 2018.12-dev (The Tazmans Flax-lily)
3 -- DB_UPDATE_VERSION 1290
4 -- ------------------------------------------
5
6
7 --
8 -- TABLE addon
9 --
10 CREATE TABLE IF NOT EXISTS `addon` (
11         `id` int unsigned NOT NULL auto_increment COMMENT '',
12         `name` varchar(50) NOT NULL DEFAULT '' COMMENT 'addon base (file)name',
13         `version` varchar(50) NOT NULL DEFAULT '' COMMENT 'currently unused',
14         `installed` boolean NOT NULL DEFAULT '0' COMMENT 'currently always 1',
15         `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'currently unused',
16         `timestamp` int unsigned NOT NULL DEFAULT 0 COMMENT 'file timestamp to check for reloads',
17         `plugin_admin` boolean NOT NULL DEFAULT '0' COMMENT '1 = has admin config, 0 = has no admin config',
18          PRIMARY KEY(`id`),
19          UNIQUE INDEX `name` (`name`)
20 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registered addons';
21
22 --
23 -- TABLE apcontact
24 --
25 CREATE TABLE IF NOT EXISTS `apcontact` (
26         `url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
27         `uuid` varchar(255) COMMENT '',
28         `type` varchar(20) NOT NULL COMMENT '',
29         `following` varchar(255) COMMENT '',
30         `followers` varchar(255) COMMENT '',
31         `inbox` varchar(255) NOT NULL COMMENT '',
32         `outbox` varchar(255) COMMENT '',
33         `sharedinbox` varchar(255) COMMENT '',
34         `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
35         `name` varchar(255) COMMENT '',
36         `about` text COMMENT '',
37         `photo` varchar(255) COMMENT '',
38         `addr` varchar(255) COMMENT '',
39         `alias` varchar(255) COMMENT '',
40         `pubkey` text COMMENT '',
41         `baseurl` varchar(255) COMMENT 'baseurl of the ap contact',
42         `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
43          PRIMARY KEY(`url`),
44          INDEX `addr` (`addr`(32)),
45          INDEX `alias` (`alias`(190)),
46          INDEX `url` (`followers`(190))
47 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
48
49 --
50 -- TABLE attach
51 --
52 CREATE TABLE IF NOT EXISTS `attach` (
53         `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
54         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
55         `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
56         `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
57         `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
58         `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
59         `data` longblob NOT NULL COMMENT 'file data',
60         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
61         `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
62         `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
63         `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
64         `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
65         `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
66          PRIMARY KEY(`id`)
67 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
68
69 --
70 -- TABLE auth_codes
71 --
72 CREATE TABLE IF NOT EXISTS `auth_codes` (
73         `id` varchar(40) NOT NULL COMMENT '',
74         `client_id` varchar(20) NOT NULL DEFAULT '' COMMENT '',
75         `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
76         `expires` int NOT NULL DEFAULT 0 COMMENT '',
77         `scope` varchar(250) NOT NULL DEFAULT '' COMMENT '',
78          PRIMARY KEY(`id`)
79 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
80
81 --
82 -- TABLE cache
83 --
84 CREATE TABLE IF NOT EXISTS `cache` (
85         `k` varbinary(255) NOT NULL COMMENT 'cache key',
86         `v` mediumtext COMMENT 'cached serialized value',
87         `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
88         `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
89          PRIMARY KEY(`k`),
90          INDEX `k_expires` (`k`,`expires`)
91 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
92
93 --
94 -- TABLE challenge
95 --
96 CREATE TABLE IF NOT EXISTS `challenge` (
97         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
98         `challenge` varchar(255) NOT NULL DEFAULT '' COMMENT '',
99         `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
100         `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
101         `type` varchar(255) NOT NULL DEFAULT '' COMMENT '',
102         `last_update` varchar(255) NOT NULL DEFAULT '' COMMENT '',
103          PRIMARY KEY(`id`)
104 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
105
106 --
107 -- TABLE clients
108 --
109 CREATE TABLE IF NOT EXISTS `clients` (
110         `client_id` varchar(20) NOT NULL COMMENT '',
111         `pw` varchar(20) NOT NULL DEFAULT '' COMMENT '',
112         `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
113         `name` text COMMENT '',
114         `icon` text COMMENT '',
115         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
116          PRIMARY KEY(`client_id`)
117 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
118
119 --
120 -- TABLE config
121 --
122 CREATE TABLE IF NOT EXISTS `config` (
123         `id` int unsigned NOT NULL auto_increment COMMENT '',
124         `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
125         `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
126         `v` mediumtext COMMENT '',
127          PRIMARY KEY(`id`),
128          UNIQUE INDEX `cat_k` (`cat`,`k`)
129 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
130
131 --
132 -- TABLE contact
133 --
134 CREATE TABLE IF NOT EXISTS `contact` (
135         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
136         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
137         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
138         `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
139         `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
140         `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
141         `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
142         `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network protocol of the contact',
143         `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
144         `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
145         `location` varchar(255) NOT NULL DEFAULT '' COMMENT '',
146         `about` text COMMENT '',
147         `keywords` text COMMENT 'public keywords (interests) of the contact',
148         `gender` varchar(32) NOT NULL DEFAULT '' COMMENT '',
149         `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
150         `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
151         `avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '',
152         `photo` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
153         `thumb` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
154         `micro` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
155         `site-pubkey` text COMMENT '',
156         `issued-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
157         `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
158         `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
159         `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
160         `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
161         `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
162         `pubkey` text COMMENT 'RSA public key 4096 bit',
163         `prvkey` text COMMENT 'RSA private key 4096 bit',
164         `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
165         `request` varchar(255) COMMENT '',
166         `notify` varchar(255) COMMENT '',
167         `poll` varchar(255) COMMENT '',
168         `confirm` varchar(255) COMMENT '',
169         `poco` varchar(255) COMMENT '',
170         `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT '',
171         `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT '',
172         `usehub` boolean NOT NULL DEFAULT '0' COMMENT '',
173         `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
174         `hub-verify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
175         `last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
176         `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
177         `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
178         `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
179         `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
180         `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
181         `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
182         `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
183         `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
184         `blocked` boolean NOT NULL DEFAULT '1' COMMENT '',
185         `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
186         `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
187         `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum',
188         `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group',
189         `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT '',
190         `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
191         `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
192         `pending` boolean NOT NULL DEFAULT '1' COMMENT '',
193         `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
194         `rating` tinyint NOT NULL DEFAULT 0 COMMENT '',
195         `reason` text COMMENT '',
196         `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT '',
197         `info` mediumtext COMMENT '',
198         `profile-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
199         `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
200         `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
201         `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
202         `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
203         `ffi_keyword_blacklist` text COMMENT '',
204          PRIMARY KEY(`id`),
205          INDEX `uid_name` (`uid`,`name`(190)),
206          INDEX `self_uid` (`self`,`uid`),
207          INDEX `alias_uid` (`alias`(32),`uid`),
208          INDEX `pending_uid` (`pending`,`uid`),
209          INDEX `blocked_uid` (`blocked`,`uid`),
210          INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
211          INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
212          INDEX `addr_uid` (`addr`(32),`uid`),
213          INDEX `nurl_uid` (`nurl`(32),`uid`),
214          INDEX `nick_uid` (`nick`(32),`uid`),
215          INDEX `dfrn-id` (`dfrn-id`(64)),
216          INDEX `issued-id` (`issued-id`(64))
217 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
218
219 --
220 -- TABLE conv
221 --
222 CREATE TABLE IF NOT EXISTS `conv` (
223         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
224         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
225         `recips` text COMMENT 'sender_handle;recipient_handle',
226         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
227         `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
228         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
229         `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
230         `subject` text COMMENT 'subject of initial message',
231          PRIMARY KEY(`id`),
232          INDEX `uid` (`uid`)
233 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
234
235 --
236 -- TABLE conversation
237 --
238 CREATE TABLE IF NOT EXISTS `conversation` (
239         `item-uri` varbinary(255) NOT NULL COMMENT 'Original URI of the item - unrelated to the table with the same name',
240         `reply-to-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'URI to which this item is a reply',
241         `conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI',
242         `conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link',
243         `protocol` tinyint unsigned NOT NULL DEFAULT 255 COMMENT 'The protocol of the item',
244         `source` mediumtext COMMENT 'Original source',
245         `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Receiving date',
246          PRIMARY KEY(`item-uri`),
247          INDEX `conversation-uri` (`conversation-uri`),
248          INDEX `received` (`received`)
249 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Raw data and structure information for messages';
250
251 --
252 -- TABLE diaspora-interaction
253 --
254 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
255         `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
256         `interaction` mediumtext COMMENT 'The Diaspora interaction',
257          PRIMARY KEY(`uri-id`)
258 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
259
260 --
261 -- TABLE event
262 --
263 CREATE TABLE IF NOT EXISTS `event` (
264         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
265         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
266         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
267         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
268         `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
269         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
270         `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
271         `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
272         `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
273         `summary` text COMMENT 'short description or title of the event',
274         `desc` text COMMENT 'event description',
275         `location` text COMMENT 'event location',
276         `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
277         `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
278         `adjust` boolean NOT NULL DEFAULT '1' COMMENT 'adjust to timezone of the recipient (0 or 1)',
279         `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
280         `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
281         `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
282         `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
283         `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
284          PRIMARY KEY(`id`),
285          INDEX `uid_start` (`uid`,`start`)
286 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
287
288 --
289 -- TABLE fcontact
290 --
291 CREATE TABLE IF NOT EXISTS `fcontact` (
292         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
293         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
294         `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
295         `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
296         `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
297         `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
298         `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
299         `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
300         `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
301         `notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
302         `poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
303         `confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
304         `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
305         `network` char(4) NOT NULL DEFAULT '' COMMENT '',
306         `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
307         `pubkey` text COMMENT '',
308         `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
309          PRIMARY KEY(`id`),
310          INDEX `addr` (`addr`(32)),
311          UNIQUE INDEX `url` (`url`(190))
312 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
313
314 --
315 -- TABLE fsuggest
316 --
317 CREATE TABLE IF NOT EXISTS `fsuggest` (
318         `id` int unsigned NOT NULL auto_increment COMMENT '',
319         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
320         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
321         `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
322         `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
323         `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
324         `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
325         `note` text COMMENT '',
326         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
327          PRIMARY KEY(`id`)
328 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
329
330 --
331 -- TABLE gcign
332 --
333 CREATE TABLE IF NOT EXISTS `gcign` (
334         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
335         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Local User id',
336         `gcid` int unsigned NOT NULL DEFAULT 0 COMMENT 'gcontact.id of ignored contact',
337          PRIMARY KEY(`id`),
338          INDEX `uid` (`uid`),
339          INDEX `gcid` (`gcid`)
340 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contacts ignored by friend suggestions';
341
342 --
343 -- TABLE gcontact
344 --
345 CREATE TABLE IF NOT EXISTS `gcontact` (
346         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
347         `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
348         `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
349         `url` varchar(255) NOT NULL DEFAULT '' COMMENT 'Link to the contacts profile page',
350         `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
351         `photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'Link to the profile photo',
352         `connect` varchar(255) NOT NULL DEFAULT '' COMMENT '',
353         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
354         `updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
355         `last_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
356         `last_failure` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
357         `location` varchar(255) NOT NULL DEFAULT '' COMMENT '',
358         `about` text COMMENT '',
359         `keywords` text COMMENT 'puplic keywords (interests)',
360         `gender` varchar(32) NOT NULL DEFAULT '' COMMENT '',
361         `birthday` varchar(32) NOT NULL DEFAULT '0001-01-01' COMMENT '',
362         `community` boolean NOT NULL DEFAULT '0' COMMENT '1 if contact is forum account',
363         `contact-type` tinyint NOT NULL DEFAULT -1 COMMENT '',
364         `hide` boolean NOT NULL DEFAULT '0' COMMENT '1 = should be hidden from search',
365         `nsfw` boolean NOT NULL DEFAULT '0' COMMENT '1 = contact posts nsfw content',
366         `network` char(4) NOT NULL DEFAULT '' COMMENT 'social network protocol',
367         `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
368         `notify` varchar(255) COMMENT '',
369         `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
370         `generation` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
371         `server_url` varchar(255) NOT NULL DEFAULT '' COMMENT 'baseurl of the contacts server',
372          PRIMARY KEY(`id`),
373          UNIQUE INDEX `nurl` (`nurl`(190)),
374          INDEX `name` (`name`(64)),
375          INDEX `nick` (`nick`(32)),
376          INDEX `addr` (`addr`(64)),
377          INDEX `hide_network_updated` (`hide`,`network`,`updated`),
378          INDEX `updated` (`updated`)
379 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='global contacts';
380
381 --
382 -- TABLE glink
383 --
384 CREATE TABLE IF NOT EXISTS `glink` (
385         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
386         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
387         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
388         `gcid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
389         `zcid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
390         `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
391          PRIMARY KEY(`id`),
392          UNIQUE INDEX `cid_uid_gcid_zcid` (`cid`,`uid`,`gcid`,`zcid`),
393          INDEX `gcid` (`gcid`)
394 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='\'friends of friends\' linkages derived from poco';
395
396 --
397 -- TABLE group
398 --
399 CREATE TABLE IF NOT EXISTS `group` (
400         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
401         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
402         `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
403         `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
404         `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
405          PRIMARY KEY(`id`),
406          INDEX `uid` (`uid`)
407 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
408
409 --
410 -- TABLE group_member
411 --
412 CREATE TABLE IF NOT EXISTS `group_member` (
413         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
414         `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
415         `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
416          PRIMARY KEY(`id`),
417          INDEX `contactid` (`contact-id`),
418          UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`)
419 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
420
421 --
422 -- TABLE gserver
423 --
424 CREATE TABLE IF NOT EXISTS `gserver` (
425         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
426         `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
427         `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
428         `version` varchar(255) NOT NULL DEFAULT '' COMMENT '',
429         `site_name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
430         `info` text COMMENT '',
431         `register_policy` tinyint NOT NULL DEFAULT 0 COMMENT '',
432         `registered-users` int unsigned NOT NULL DEFAULT 0 COMMENT 'Number of registered users',
433         `poco` varchar(255) NOT NULL DEFAULT '' COMMENT '',
434         `noscrape` varchar(255) NOT NULL DEFAULT '' COMMENT '',
435         `network` char(4) NOT NULL DEFAULT '' COMMENT '',
436         `platform` varchar(255) NOT NULL DEFAULT '' COMMENT '',
437         `relay-subscribe` boolean NOT NULL DEFAULT '0' COMMENT 'Has the server subscribed to the relay system',
438         `relay-scope` varchar(10) NOT NULL DEFAULT '' COMMENT 'The scope of messages that the server wants to get',
439         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
440         `last_poco_query` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
441         `last_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
442         `last_failure` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
443          PRIMARY KEY(`id`),
444          UNIQUE INDEX `nurl` (`nurl`(190))
445 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Global servers';
446
447 --
448 -- TABLE gserver-tag
449 --
450 CREATE TABLE IF NOT EXISTS `gserver-tag` (
451         `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
452         `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
453          PRIMARY KEY(`gserver-id`,`tag`),
454          INDEX `tag` (`tag`)
455 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
456
457 --
458 -- TABLE hook
459 --
460 CREATE TABLE IF NOT EXISTS `hook` (
461         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
462         `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
463         `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
464         `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
465         `priority` smallint unsigned NOT NULL DEFAULT 0 COMMENT 'not yet implemented - can be used to sort conflicts in hook handling by calling handlers in priority order',
466          PRIMARY KEY(`id`),
467          UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
468 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
469
470 --
471 -- TABLE intro
472 --
473 CREATE TABLE IF NOT EXISTS `intro` (
474         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
475         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
476         `fid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
477         `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
478         `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
479         `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
480         `note` text COMMENT '',
481         `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
482         `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
483         `blocked` boolean NOT NULL DEFAULT '1' COMMENT '',
484         `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
485          PRIMARY KEY(`id`)
486 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
487
488 --
489 -- TABLE item
490 --
491 CREATE TABLE IF NOT EXISTS `item` (
492         `id` int unsigned NOT NULL auto_increment,
493         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this item',
494         `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
495         `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
496         `uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
497         `parent` int unsigned NOT NULL DEFAULT 0 COMMENT 'item.id of the parent to this item if it is a reply of some form; otherwise this must be set to the id of this item',
498         `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT 'uri of the parent to this item',
499         `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
500         `thr-parent` varchar(255) NOT NULL DEFAULT '' COMMENT 'If the parent of this item is not the top-level item in the conversation, the uri of the immediate parent; otherwise set to parent-uri',
501         `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
502         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
503         `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
504         `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last comment/reply to this item',
505         `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
506         `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date that something in the conversation changed, indicating clients should fetch the conversation again',
507         `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
508         `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
509         `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
510         `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
511         `icid` int unsigned COMMENT 'Id of the item-content table entry that contains the whole item content',
512         `iaid` int unsigned COMMENT 'Id of the item-activity table entry that contains the activity data',
513         `extid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
514         `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
515         `global` boolean NOT NULL DEFAULT '0' COMMENT '',
516         `private` boolean NOT NULL DEFAULT '0' COMMENT 'distribution is restricted',
517         `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
518         `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
519         `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been deleted',
520         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
521         `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
522         `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
523         `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
524         `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
525         `starred` boolean NOT NULL DEFAULT '0' COMMENT 'item has been favourited',
526         `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'item has not been seen',
527         `mention` boolean NOT NULL DEFAULT '0' COMMENT 'The owner of this item was mentioned in it',
528         `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
529         `psid` int unsigned COMMENT 'ID of the permission set of this post',
530         `resource-id` varchar(32) NOT NULL DEFAULT '' COMMENT 'Used to link other tables to items, it identifies the linked resource (e.g. photo) and if set must also set resource_type',
531         `event-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Used to link to the event.id',
532         `attach` mediumtext COMMENT 'JSON structure representing attachments to this item',
533         `allow_cid` mediumtext COMMENT 'Deprecated',
534         `allow_gid` mediumtext COMMENT 'Deprecated',
535         `deny_cid` mediumtext COMMENT 'Deprecated',
536         `deny_gid` mediumtext COMMENT 'Deprecated',
537         `postopts` text COMMENT 'Deprecated',
538         `inform` mediumtext COMMENT 'Deprecated',
539         `type` varchar(20) COMMENT 'Deprecated',
540         `bookmark` boolean COMMENT 'Deprecated',
541         `file` mediumtext COMMENT 'Deprecated',
542         `location` varchar(255) COMMENT 'Deprecated',
543         `coord` varchar(255) COMMENT 'Deprecated',
544         `tag` mediumtext COMMENT 'Deprecated',
545         `plink` varchar(255) COMMENT 'Deprecated',
546         `title` varchar(255) COMMENT 'Deprecated',
547         `content-warning` varchar(255) COMMENT 'Deprecated',
548         `body` mediumtext COMMENT 'Deprecated',
549         `app` varchar(255) COMMENT 'Deprecated',
550         `verb` varchar(100) COMMENT 'Deprecated',
551         `object-type` varchar(100) COMMENT 'Deprecated',
552         `object` text COMMENT 'Deprecated',
553         `target-type` varchar(100) COMMENT 'Deprecated',
554         `target` text COMMENT 'Deprecated',
555         `author-name` varchar(255) COMMENT 'Deprecated',
556         `author-link` varchar(255) COMMENT 'Deprecated',
557         `author-avatar` varchar(255) COMMENT 'Deprecated',
558         `owner-name` varchar(255) COMMENT 'Deprecated',
559         `owner-link` varchar(255) COMMENT 'Deprecated',
560         `owner-avatar` varchar(255) COMMENT 'Deprecated',
561         `rendered-hash` varchar(32) COMMENT 'Deprecated',
562         `rendered-html` mediumtext COMMENT 'Deprecated',
563          PRIMARY KEY(`id`),
564          INDEX `guid` (`guid`(191)),
565          INDEX `uri` (`uri`(191)),
566          INDEX `parent` (`parent`),
567          INDEX `parent-uri` (`parent-uri`(191)),
568          INDEX `extid` (`extid`(191)),
569          INDEX `uid_id` (`uid`,`id`),
570          INDEX `uid_contactid_id` (`uid`,`contact-id`,`id`),
571          INDEX `uid_created` (`uid`,`created`),
572          INDEX `uid_commented` (`uid`,`commented`),
573          INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
574          INDEX `uid_network_received` (`uid`,`network`,`received`),
575          INDEX `uid_network_commented` (`uid`,`network`,`commented`),
576          INDEX `uid_thrparent` (`uid`,`thr-parent`(190)),
577          INDEX `uid_parenturi` (`uid`,`parent-uri`(190)),
578          INDEX `uid_contactid_created` (`uid`,`contact-id`,`created`),
579          INDEX `authorid_created` (`author-id`,`created`),
580          INDEX `ownerid` (`owner-id`),
581          INDEX `uid_uri` (`uid`,`uri`(190)),
582          INDEX `resource-id` (`resource-id`),
583          INDEX `deleted_changed` (`deleted`,`changed`),
584          INDEX `uid_wall_changed` (`uid`,`wall`,`changed`),
585          INDEX `uid_eventid` (`uid`,`event-id`),
586          INDEX `icid` (`icid`),
587          INDEX `iaid` (`iaid`),
588          INDEX `psid_wall` (`psid`,`wall`)
589 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
590
591 --
592 -- TABLE item-activity
593 --
594 CREATE TABLE IF NOT EXISTS `item-activity` (
595         `id` int unsigned NOT NULL auto_increment,
596         `uri` varchar(255) COMMENT '',
597         `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
598         `uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
599         `activity` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
600          PRIMARY KEY(`id`),
601          UNIQUE INDEX `uri-hash` (`uri-hash`),
602          INDEX `uri` (`uri`(191)),
603          INDEX `uri-id` (`uri-id`)
604 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activities for items';
605
606 --
607 -- TABLE item-content
608 --
609 CREATE TABLE IF NOT EXISTS `item-content` (
610         `id` int unsigned NOT NULL auto_increment,
611         `uri` varchar(255) COMMENT '',
612         `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
613         `uri-plink-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
614         `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
615         `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
616         `body` mediumtext COMMENT 'item body content',
617         `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
618         `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
619         `language` text COMMENT 'Language information about this post',
620         `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
621         `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
622         `rendered-html` mediumtext COMMENT 'item.body converted to html',
623         `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
624         `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
625         `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
626         `target` text COMMENT 'JSON encoded target structure if used',
627         `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
628         `verb` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams verb',
629          PRIMARY KEY(`id`),
630          UNIQUE INDEX `uri-plink-hash` (`uri-plink-hash`),
631          INDEX `uri` (`uri`(191)),
632          INDEX `uri-id` (`uri-id`)
633 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
634
635 --
636 -- TABLE item-delivery-data
637 --
638 CREATE TABLE IF NOT EXISTS `item-delivery-data` (
639         `iid` int unsigned NOT NULL COMMENT 'Item id',
640         `postopts` text COMMENT 'External post connectors add their network name to this comma-separated string to identify that they should be delivered to these networks during delivery',
641         `inform` mediumtext COMMENT 'Additional receivers of the linked item',
642          PRIMARY KEY(`iid`)
643 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
644
645 --
646 -- TABLE item-uri
647 --
648 CREATE TABLE IF NOT EXISTS `item-uri` (
649         `id` int unsigned NOT NULL auto_increment,
650         `uri` varbinary(255) NOT NULL COMMENT 'URI of an item',
651         `guid` varbinary(255) COMMENT 'A unique identifier for an item',
652          PRIMARY KEY(`id`),
653          UNIQUE INDEX `uri` (`uri`),
654          INDEX `guid` (`guid`)
655 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
656
657 --
658 -- TABLE locks
659 --
660 CREATE TABLE IF NOT EXISTS `locks` (
661         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
662         `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
663         `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
664         `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
665         `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
666          PRIMARY KEY(`id`),
667          INDEX `name_expires` (`name`,`expires`)
668 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
669
670 --
671 -- TABLE mail
672 --
673 CREATE TABLE IF NOT EXISTS `mail` (
674         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
675         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
676         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
677         `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
678         `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
679         `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
680         `contact-id` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact.id',
681         `convid` int unsigned NOT NULL DEFAULT 0 COMMENT 'conv.id',
682         `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
683         `body` mediumtext COMMENT '',
684         `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
685         `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
686         `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
687         `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
688         `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
689         `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
690         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
691          PRIMARY KEY(`id`),
692          INDEX `uid_seen` (`uid`,`seen`),
693          INDEX `convid` (`convid`),
694          INDEX `uri` (`uri`(64)),
695          INDEX `parent-uri` (`parent-uri`(64)),
696          INDEX `contactid` (`contact-id`(32))
697 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
698
699 --
700 -- TABLE mailacct
701 --
702 CREATE TABLE IF NOT EXISTS `mailacct` (
703         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
704         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
705         `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
706         `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
707         `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
708         `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
709         `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
710         `pass` text COMMENT '',
711         `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
712         `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
713         `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
714         `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
715         `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
716          PRIMARY KEY(`id`)
717 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
718
719 --
720 -- TABLE manage
721 --
722 CREATE TABLE IF NOT EXISTS `manage` (
723         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
724         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
725         `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
726          PRIMARY KEY(`id`),
727          UNIQUE INDEX `uid_mid` (`uid`,`mid`)
728 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
729
730 --
731 -- TABLE notify
732 --
733 CREATE TABLE IF NOT EXISTS `notify` (
734         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
735         `hash` varchar(64) NOT NULL DEFAULT '' COMMENT '',
736         `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
737         `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
738         `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
739         `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
740         `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
741         `msg` mediumtext COMMENT '',
742         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
743         `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
744         `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'item.id',
745         `parent` int unsigned NOT NULL DEFAULT 0 COMMENT '',
746         `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
747         `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
748         `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
749         `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
750         `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
751          PRIMARY KEY(`id`),
752          INDEX `hash_uid` (`hash`,`uid`),
753          INDEX `seen_uid_date` (`seen`,`uid`,`date`),
754          INDEX `uid_date` (`uid`,`date`),
755          INDEX `uid_type_link` (`uid`,`type`,`link`(190))
756 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
757
758 --
759 -- TABLE notify-threads
760 --
761 CREATE TABLE IF NOT EXISTS `notify-threads` (
762         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
763         `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
764         `master-parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
765         `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
766         `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
767          PRIMARY KEY(`id`)
768 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
769
770 --
771 -- TABLE oembed
772 --
773 CREATE TABLE IF NOT EXISTS `oembed` (
774         `url` varbinary(255) NOT NULL COMMENT 'page url',
775         `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
776         `content` mediumtext COMMENT 'OEmbed data of the page',
777         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
778          PRIMARY KEY(`url`,`maxwidth`),
779          INDEX `created` (`created`)
780 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
781
782 --
783 -- TABLE openwebauth-token
784 --
785 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
786         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
787         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
788         `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
789         `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
790         `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
791         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
792          PRIMARY KEY(`id`)
793 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
794
795 --
796 -- TABLE parsed_url
797 --
798 CREATE TABLE IF NOT EXISTS `parsed_url` (
799         `url` varbinary(255) NOT NULL COMMENT 'page url',
800         `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
801         `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
802         `content` mediumtext COMMENT 'page data',
803         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
804          PRIMARY KEY(`url`,`guessing`,`oembed`),
805          INDEX `created` (`created`)
806 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
807
808 --
809 -- TABLE participation
810 --
811 CREATE TABLE IF NOT EXISTS `participation` (
812         `iid` int unsigned NOT NULL COMMENT '',
813         `server` varchar(60) NOT NULL COMMENT '',
814         `cid` int unsigned NOT NULL COMMENT '',
815         `fid` int unsigned NOT NULL COMMENT '',
816          PRIMARY KEY(`iid`,`server`)
817 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Storage for participation messages from Diaspora';
818
819 --
820 -- TABLE pconfig
821 --
822 CREATE TABLE IF NOT EXISTS `pconfig` (
823         `id` int unsigned NOT NULL auto_increment COMMENT '',
824         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
825         `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
826         `k` varbinary(100) NOT NULL DEFAULT '' COMMENT '',
827         `v` mediumtext COMMENT '',
828          PRIMARY KEY(`id`),
829          UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`)
830 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
831
832 --
833 -- TABLE permissionset
834 --
835 CREATE TABLE IF NOT EXISTS `permissionset` (
836         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
837         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
838         `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
839         `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
840         `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
841         `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
842          PRIMARY KEY(`id`),
843          INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30))
844 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
845
846 --
847 -- TABLE photo
848 --
849 CREATE TABLE IF NOT EXISTS `photo` (
850         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
851         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
852         `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
853         `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
854         `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
855         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
856         `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
857         `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
858         `desc` text COMMENT '',
859         `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
860         `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
861         `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
862         `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
863         `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
864         `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
865         `data` mediumblob NOT NULL COMMENT '',
866         `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
867         `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
868         `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
869         `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
870         `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
871         `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
872          PRIMARY KEY(`id`),
873          INDEX `contactid` (`contact-id`),
874          INDEX `uid_contactid` (`uid`,`contact-id`),
875          INDEX `uid_profile` (`uid`,`profile`),
876          INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
877          INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
878          INDEX `resource-id` (`resource-id`)
879 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
880
881 --
882 -- TABLE poll
883 --
884 CREATE TABLE IF NOT EXISTS `poll` (
885         `id` int unsigned NOT NULL auto_increment COMMENT '',
886         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
887         `q0` text COMMENT '',
888         `q1` text COMMENT '',
889         `q2` text COMMENT '',
890         `q3` text COMMENT '',
891         `q4` text COMMENT '',
892         `q5` text COMMENT '',
893         `q6` text COMMENT '',
894         `q7` text COMMENT '',
895         `q8` text COMMENT '',
896         `q9` text COMMENT '',
897          PRIMARY KEY(`id`),
898          INDEX `uid` (`uid`)
899 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently unused table for storing poll results';
900
901 --
902 -- TABLE poll_result
903 --
904 CREATE TABLE IF NOT EXISTS `poll_result` (
905         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
906         `poll_id` int unsigned NOT NULL DEFAULT 0,
907         `choice` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
908          PRIMARY KEY(`id`),
909          INDEX `poll_id` (`poll_id`)
910 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='data for polls - currently unused';
911
912 --
913 -- TABLE process
914 --
915 CREATE TABLE IF NOT EXISTS `process` (
916         `pid` int unsigned NOT NULL COMMENT '',
917         `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
918         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
919          PRIMARY KEY(`pid`),
920          INDEX `command` (`command`)
921 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
922
923 --
924 -- TABLE profile
925 --
926 CREATE TABLE IF NOT EXISTS `profile` (
927         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
928         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
929         `profile-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name of the profile',
930         `is-default` boolean NOT NULL DEFAULT '0' COMMENT 'Mark this profile as default profile',
931         `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
932         `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
933         `pdesc` varchar(255) NOT NULL DEFAULT '' COMMENT 'Title or description',
934         `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
935         `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
936         `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
937         `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
938         `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
939         `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
940         `hometown` varchar(255) NOT NULL DEFAULT '' COMMENT '',
941         `gender` varchar(32) NOT NULL DEFAULT '' COMMENT '',
942         `marital` varchar(255) NOT NULL DEFAULT '' COMMENT '',
943         `with` text COMMENT '',
944         `howlong` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
945         `sexual` varchar(255) NOT NULL DEFAULT '' COMMENT '',
946         `politic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
947         `religion` varchar(255) NOT NULL DEFAULT '' COMMENT '',
948         `pub_keywords` text COMMENT '',
949         `prv_keywords` text COMMENT '',
950         `likes` text COMMENT '',
951         `dislikes` text COMMENT '',
952         `about` text COMMENT '',
953         `summary` varchar(255) NOT NULL DEFAULT '' COMMENT '',
954         `music` text COMMENT '',
955         `book` text COMMENT '',
956         `tv` text COMMENT '',
957         `film` text COMMENT '',
958         `interest` text COMMENT '',
959         `romance` text COMMENT '',
960         `work` text COMMENT '',
961         `education` text COMMENT '',
962         `contact` text COMMENT '',
963         `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
964         `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
965         `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
966         `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
967         `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
968         `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
969          PRIMARY KEY(`id`),
970          INDEX `uid_is-default` (`uid`,`is-default`)
971 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
972
973 --
974 -- TABLE profile_check
975 --
976 CREATE TABLE IF NOT EXISTS `profile_check` (
977         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
978         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
979         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
980         `dfrn_id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
981         `sec` varchar(255) NOT NULL DEFAULT '' COMMENT '',
982         `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
983          PRIMARY KEY(`id`)
984 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='DFRN remote auth use';
985
986 --
987 -- TABLE push_subscriber
988 --
989 CREATE TABLE IF NOT EXISTS `push_subscriber` (
990         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
991         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
992         `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
993         `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
994         `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
995         `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
996         `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
997         `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
998         `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
999         `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1000          PRIMARY KEY(`id`),
1001          INDEX `next_try` (`next_try`)
1002 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1003
1004 --
1005 -- TABLE queue
1006 --
1007 CREATE TABLE IF NOT EXISTS `queue` (
1008         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1009         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Message receiver',
1010         `network` char(4) NOT NULL DEFAULT '' COMMENT 'Receiver\'s network',
1011         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'Unique GUID of the message',
1012         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date, when the message was created',
1013         `last` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last trial',
1014         `next` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1015         `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1016         `content` mediumtext COMMENT '',
1017         `batch` boolean NOT NULL DEFAULT '0' COMMENT '',
1018          PRIMARY KEY(`id`),
1019          INDEX `last` (`last`),
1020          INDEX `next` (`next`)
1021 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Queue for messages that couldn\'t be delivered';
1022
1023 --
1024 -- TABLE register
1025 --
1026 CREATE TABLE IF NOT EXISTS `register` (
1027         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1028         `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1029         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1030         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1031         `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1032         `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1033         `note` text COMMENT '',
1034          PRIMARY KEY(`id`)
1035 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1036
1037 --
1038 -- TABLE search
1039 --
1040 CREATE TABLE IF NOT EXISTS `search` (
1041         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1042         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1043         `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1044          PRIMARY KEY(`id`),
1045          INDEX `uid` (`uid`)
1046 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1047
1048 --
1049 -- TABLE session
1050 --
1051 CREATE TABLE IF NOT EXISTS `session` (
1052         `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1053         `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1054         `data` text COMMENT '',
1055         `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1056          PRIMARY KEY(`id`),
1057          INDEX `sid` (`sid`(64)),
1058          INDEX `expire` (`expire`)
1059 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1060
1061 --
1062 -- TABLE sign
1063 --
1064 CREATE TABLE IF NOT EXISTS `sign` (
1065         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1066         `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'item.id',
1067         `signed_text` mediumtext COMMENT '',
1068         `signature` text COMMENT '',
1069         `signer` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1070          PRIMARY KEY(`id`),
1071          UNIQUE INDEX `iid` (`iid`)
1072 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora signatures';
1073
1074 --
1075 -- TABLE term
1076 --
1077 CREATE TABLE IF NOT EXISTS `term` (
1078         `tid` int unsigned NOT NULL auto_increment COMMENT '',
1079         `oid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1080         `otype` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1081         `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1082         `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1083         `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1084         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1085         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1086         `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1087         `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1088         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1089          PRIMARY KEY(`tid`),
1090          INDEX `oid_otype_type_term` (`oid`,`otype`,`type`,`term`(32)),
1091          INDEX `uid_otype_type_term_global_created` (`uid`,`otype`,`type`,`term`(32),`global`,`created`),
1092          INDEX `uid_otype_type_url` (`uid`,`otype`,`type`,`url`(64)),
1093          INDEX `guid` (`guid`(64))
1094 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='item taxonomy (categories, tags, etc.) table';
1095
1096 --
1097 -- TABLE thread
1098 --
1099 CREATE TABLE IF NOT EXISTS `thread` (
1100         `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'sequential ID',
1101         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1102         `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1103         `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1104         `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1105         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1106         `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1107         `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1108         `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1109         `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1110         `wall` boolean NOT NULL DEFAULT '0' COMMENT '',
1111         `private` boolean NOT NULL DEFAULT '0' COMMENT '',
1112         `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1113         `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
1114         `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1115         `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1116         `ignored` boolean NOT NULL DEFAULT '0' COMMENT '',
1117         `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
1118         `unseen` boolean NOT NULL DEFAULT '1' COMMENT '',
1119         `deleted` boolean NOT NULL DEFAULT '0' COMMENT '',
1120         `origin` boolean NOT NULL DEFAULT '0' COMMENT '',
1121         `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1122         `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1123         `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1124         `bookmark` boolean COMMENT '',
1125          PRIMARY KEY(`iid`),
1126          INDEX `uid_network_commented` (`uid`,`network`,`commented`),
1127          INDEX `uid_network_created` (`uid`,`network`,`created`),
1128          INDEX `uid_contactid_commented` (`uid`,`contact-id`,`commented`),
1129          INDEX `uid_contactid_created` (`uid`,`contact-id`,`created`),
1130          INDEX `contactid` (`contact-id`),
1131          INDEX `ownerid` (`owner-id`),
1132          INDEX `authorid` (`author-id`),
1133          INDEX `uid_created` (`uid`,`created`),
1134          INDEX `uid_commented` (`uid`,`commented`),
1135          INDEX `uid_wall_created` (`uid`,`wall`,`created`),
1136          INDEX `private_wall_origin_commented` (`private`,`wall`,`origin`,`commented`)
1137 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1138
1139 --
1140 -- TABLE tokens
1141 --
1142 CREATE TABLE IF NOT EXISTS `tokens` (
1143         `id` varchar(40) NOT NULL COMMENT '',
1144         `secret` text COMMENT '',
1145         `client_id` varchar(20) NOT NULL DEFAULT '',
1146         `expires` int NOT NULL DEFAULT 0 COMMENT '',
1147         `scope` varchar(200) NOT NULL DEFAULT '' COMMENT '',
1148         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1149          PRIMARY KEY(`id`)
1150 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
1151
1152 --
1153 -- TABLE user
1154 --
1155 CREATE TABLE IF NOT EXISTS `user` (
1156         `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1157         `parent-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'The parent user that has full control about this user',
1158         `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
1159         `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
1160         `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
1161         `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
1162         `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
1163         `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
1164         `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1165         `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
1166         `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
1167         `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
1168         `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
1169         `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
1170         `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
1171         `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
1172         `pubkey` text COMMENT 'RSA public key 4096 bit',
1173         `prvkey` text COMMENT 'RSA private key 4096 bit',
1174         `spubkey` text COMMENT '',
1175         `sprvkey` text COMMENT '',
1176         `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
1177         `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
1178         `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
1179         `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unkown viewers',
1180         `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
1181         `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
1182         `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
1183         `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
1184         `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
1185         `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1186         `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
1187         `pwdreset` varchar(255) COMMENT 'Password reset request token',
1188         `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
1189         `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
1190         `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1191         `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
1192         `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
1193         `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
1194         `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
1195         `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1196         `allow_cid` mediumtext COMMENT 'default permission for this user',
1197         `allow_gid` mediumtext COMMENT 'default permission for this user',
1198         `deny_cid` mediumtext COMMENT 'default permission for this user',
1199         `deny_gid` mediumtext COMMENT 'default permission for this user',
1200         `openidserver` text COMMENT '',
1201          PRIMARY KEY(`uid`),
1202          INDEX `nickname` (`nickname`(32))
1203 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
1204
1205 --
1206 -- TABLE userd
1207 --
1208 CREATE TABLE IF NOT EXISTS `userd` (
1209         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1210         `username` varchar(255) NOT NULL COMMENT '',
1211          PRIMARY KEY(`id`),
1212          INDEX `username` (`username`(32))
1213 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1214
1215 --
1216 -- TABLE user-contact
1217 --
1218 CREATE TABLE IF NOT EXISTS `user-contact` (
1219         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1220         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1221         `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1222         `ignored` boolean COMMENT 'Posts from this contact are ignored',
1223         `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1224          PRIMARY KEY(`uid`,`cid`)
1225 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1226
1227 --
1228 -- TABLE user-item
1229 --
1230 CREATE TABLE IF NOT EXISTS `user-item` (
1231         `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item id',
1232         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1233         `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide an item from the user',
1234         `ignored` boolean COMMENT 'Ignore this thread if set',
1235          PRIMARY KEY(`uid`,`iid`)
1236 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific item data';
1237
1238 --
1239 -- TABLE worker-ipc
1240 --
1241 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1242         `key` int NOT NULL COMMENT '',
1243         `jobs` boolean COMMENT 'Flag for outstanding jobs',
1244          PRIMARY KEY(`key`)
1245 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1246
1247 --
1248 -- TABLE workerqueue
1249 --
1250 CREATE TABLE IF NOT EXISTS `workerqueue` (
1251         `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
1252         `parameter` mediumblob COMMENT 'Task command',
1253         `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
1254         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
1255         `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
1256         `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
1257         `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1258         `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1259         `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
1260          PRIMARY KEY(`id`),
1261          INDEX `pid` (`pid`),
1262          INDEX `parameter` (`parameter`(64)),
1263          INDEX `priority_created_next_try` (`priority`,`created`,`next_try`),
1264          INDEX `done_priority_executed_next_try` (`done`,`priority`,`executed`,`next_try`),
1265          INDEX `done_executed_next_try` (`done`,`executed`,`next_try`),
1266          INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
1267          INDEX `done_next_try` (`done`,`next_try`)
1268 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
1269
1270