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