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