]> git.mxchange.org Git - friendica.git/blob - database.sql
Add 'addon' folder as 'Friendica\Addon' namespace for autoload
[friendica.git] / database.sql
1 -- ------------------------------------------
2 -- Friendica 2019.03-dev (The Tazmans Flax-lily)
3 -- DB_UPDATE_VERSION 1295
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         `backend-class` tinytext COMMENT 'Storage backend class',
877         `backend-ref` text COMMENT 'Storage backend data reference',
878          PRIMARY KEY(`id`),
879          INDEX `contactid` (`contact-id`),
880          INDEX `uid_contactid` (`uid`,`contact-id`),
881          INDEX `uid_profile` (`uid`,`profile`),
882          INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
883          INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
884          INDEX `resource-id` (`resource-id`)
885 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
886
887 --
888 -- TABLE poll
889 --
890 CREATE TABLE IF NOT EXISTS `poll` (
891         `id` int unsigned NOT NULL auto_increment COMMENT '',
892         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
893         `q0` text COMMENT '',
894         `q1` text COMMENT '',
895         `q2` text COMMENT '',
896         `q3` text COMMENT '',
897         `q4` text COMMENT '',
898         `q5` text COMMENT '',
899         `q6` text COMMENT '',
900         `q7` text COMMENT '',
901         `q8` text COMMENT '',
902         `q9` text COMMENT '',
903          PRIMARY KEY(`id`),
904          INDEX `uid` (`uid`)
905 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently unused table for storing poll results';
906
907 --
908 -- TABLE poll_result
909 --
910 CREATE TABLE IF NOT EXISTS `poll_result` (
911         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
912         `poll_id` int unsigned NOT NULL DEFAULT 0,
913         `choice` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
914          PRIMARY KEY(`id`),
915          INDEX `poll_id` (`poll_id`)
916 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='data for polls - currently unused';
917
918 --
919 -- TABLE process
920 --
921 CREATE TABLE IF NOT EXISTS `process` (
922         `pid` int unsigned NOT NULL COMMENT '',
923         `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
924         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
925          PRIMARY KEY(`pid`),
926          INDEX `command` (`command`)
927 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
928
929 --
930 -- TABLE profile
931 --
932 CREATE TABLE IF NOT EXISTS `profile` (
933         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
934         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
935         `profile-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name of the profile',
936         `is-default` boolean NOT NULL DEFAULT '0' COMMENT 'Mark this profile as default profile',
937         `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
938         `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
939         `pdesc` varchar(255) NOT NULL DEFAULT '' COMMENT 'Title or description',
940         `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
941         `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
942         `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
943         `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
944         `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
945         `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
946         `hometown` varchar(255) NOT NULL DEFAULT '' COMMENT '',
947         `gender` varchar(32) NOT NULL DEFAULT '' COMMENT '',
948         `marital` varchar(255) NOT NULL DEFAULT '' COMMENT '',
949         `with` text COMMENT '',
950         `howlong` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
951         `sexual` varchar(255) NOT NULL DEFAULT '' COMMENT '',
952         `politic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
953         `religion` varchar(255) NOT NULL DEFAULT '' COMMENT '',
954         `pub_keywords` text COMMENT '',
955         `prv_keywords` text COMMENT '',
956         `likes` text COMMENT '',
957         `dislikes` text COMMENT '',
958         `about` text COMMENT '',
959         `summary` varchar(255) NOT NULL DEFAULT '' COMMENT '',
960         `music` text COMMENT '',
961         `book` text COMMENT '',
962         `tv` text COMMENT '',
963         `film` text COMMENT '',
964         `interest` text COMMENT '',
965         `romance` text COMMENT '',
966         `work` text COMMENT '',
967         `education` text COMMENT '',
968         `contact` text COMMENT '',
969         `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
970         `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
971         `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
972         `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
973         `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
974         `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
975          PRIMARY KEY(`id`),
976          INDEX `uid_is-default` (`uid`,`is-default`),
977          FULLTEXT INDEX `pub_keywords` (`pub_keywords`)
978 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
979
980 --
981 -- TABLE profile_check
982 --
983 CREATE TABLE IF NOT EXISTS `profile_check` (
984         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
985         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
986         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
987         `dfrn_id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
988         `sec` varchar(255) NOT NULL DEFAULT '' COMMENT '',
989         `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
990          PRIMARY KEY(`id`)
991 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='DFRN remote auth use';
992
993 --
994 -- TABLE push_subscriber
995 --
996 CREATE TABLE IF NOT EXISTS `push_subscriber` (
997         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
998         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
999         `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1000         `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1001         `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1002         `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1003         `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1004         `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1005         `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1006         `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1007          PRIMARY KEY(`id`),
1008          INDEX `next_try` (`next_try`)
1009 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1010
1011 --
1012 -- TABLE queue
1013 --
1014 CREATE TABLE IF NOT EXISTS `queue` (
1015         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1016         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Message receiver',
1017         `network` char(4) NOT NULL DEFAULT '' COMMENT 'Receiver\'s network',
1018         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'Unique GUID of the message',
1019         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date, when the message was created',
1020         `last` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last trial',
1021         `next` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1022         `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1023         `content` mediumtext COMMENT '',
1024         `batch` boolean NOT NULL DEFAULT '0' COMMENT '',
1025          PRIMARY KEY(`id`),
1026          INDEX `last` (`last`),
1027          INDEX `next` (`next`)
1028 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Queue for messages that couldn\'t be delivered';
1029
1030 --
1031 -- TABLE register
1032 --
1033 CREATE TABLE IF NOT EXISTS `register` (
1034         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1035         `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1036         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1037         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1038         `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1039         `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1040         `note` text COMMENT '',
1041          PRIMARY KEY(`id`)
1042 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1043
1044 --
1045 -- TABLE search
1046 --
1047 CREATE TABLE IF NOT EXISTS `search` (
1048         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1049         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1050         `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1051          PRIMARY KEY(`id`),
1052          INDEX `uid` (`uid`)
1053 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1054
1055 --
1056 -- TABLE session
1057 --
1058 CREATE TABLE IF NOT EXISTS `session` (
1059         `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1060         `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1061         `data` text COMMENT '',
1062         `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1063          PRIMARY KEY(`id`),
1064          INDEX `sid` (`sid`(64)),
1065          INDEX `expire` (`expire`)
1066 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1067
1068 --
1069 -- TABLE sign
1070 --
1071 CREATE TABLE IF NOT EXISTS `sign` (
1072         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1073         `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'item.id',
1074         `signed_text` mediumtext COMMENT '',
1075         `signature` text COMMENT '',
1076         `signer` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1077          PRIMARY KEY(`id`),
1078          UNIQUE INDEX `iid` (`iid`)
1079 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora signatures';
1080
1081 --
1082 -- TABLE term
1083 --
1084 CREATE TABLE IF NOT EXISTS `term` (
1085         `tid` int unsigned NOT NULL auto_increment COMMENT '',
1086         `oid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1087         `otype` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1088         `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1089         `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1090         `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1091         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1092         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1093         `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1094         `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1095         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1096          PRIMARY KEY(`tid`),
1097          INDEX `oid_otype_type_term` (`oid`,`otype`,`type`,`term`(32)),
1098          INDEX `uid_otype_type_term_global_created` (`uid`,`otype`,`type`,`term`(32),`global`,`created`),
1099          INDEX `uid_otype_type_url` (`uid`,`otype`,`type`,`url`(64)),
1100          INDEX `guid` (`guid`(64))
1101 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='item taxonomy (categories, tags, etc.) table';
1102
1103 --
1104 -- TABLE thread
1105 --
1106 CREATE TABLE IF NOT EXISTS `thread` (
1107         `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'sequential ID',
1108         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1109         `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1110         `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1111         `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1112         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1113         `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1114         `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1115         `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1116         `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1117         `wall` boolean NOT NULL DEFAULT '0' COMMENT '',
1118         `private` boolean NOT NULL DEFAULT '0' COMMENT '',
1119         `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1120         `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
1121         `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1122         `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1123         `ignored` boolean NOT NULL DEFAULT '0' COMMENT '',
1124         `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
1125         `unseen` boolean NOT NULL DEFAULT '1' COMMENT '',
1126         `deleted` boolean NOT NULL DEFAULT '0' COMMENT '',
1127         `origin` boolean NOT NULL DEFAULT '0' COMMENT '',
1128         `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1129         `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1130         `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1131         `bookmark` boolean COMMENT '',
1132          PRIMARY KEY(`iid`),
1133          INDEX `uid_network_commented` (`uid`,`network`,`commented`),
1134          INDEX `uid_network_created` (`uid`,`network`,`created`),
1135          INDEX `uid_contactid_commented` (`uid`,`contact-id`,`commented`),
1136          INDEX `uid_contactid_created` (`uid`,`contact-id`,`created`),
1137          INDEX `contactid` (`contact-id`),
1138          INDEX `ownerid` (`owner-id`),
1139          INDEX `authorid` (`author-id`),
1140          INDEX `uid_created` (`uid`,`created`),
1141          INDEX `uid_commented` (`uid`,`commented`),
1142          INDEX `uid_wall_created` (`uid`,`wall`,`created`),
1143          INDEX `private_wall_origin_commented` (`private`,`wall`,`origin`,`commented`)
1144 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1145
1146 --
1147 -- TABLE tokens
1148 --
1149 CREATE TABLE IF NOT EXISTS `tokens` (
1150         `id` varchar(40) NOT NULL COMMENT '',
1151         `secret` text COMMENT '',
1152         `client_id` varchar(20) NOT NULL DEFAULT '',
1153         `expires` int NOT NULL DEFAULT 0 COMMENT '',
1154         `scope` varchar(200) NOT NULL DEFAULT '' COMMENT '',
1155         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1156          PRIMARY KEY(`id`)
1157 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
1158
1159 --
1160 -- TABLE user
1161 --
1162 CREATE TABLE IF NOT EXISTS `user` (
1163         `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1164         `parent-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'The parent user that has full control about this user',
1165         `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
1166         `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
1167         `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
1168         `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
1169         `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
1170         `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
1171         `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1172         `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
1173         `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
1174         `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
1175         `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
1176         `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
1177         `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
1178         `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
1179         `pubkey` text COMMENT 'RSA public key 4096 bit',
1180         `prvkey` text COMMENT 'RSA private key 4096 bit',
1181         `spubkey` text COMMENT '',
1182         `sprvkey` text COMMENT '',
1183         `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
1184         `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
1185         `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
1186         `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unkown viewers',
1187         `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
1188         `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
1189         `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
1190         `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
1191         `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
1192         `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1193         `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
1194         `pwdreset` varchar(255) COMMENT 'Password reset request token',
1195         `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
1196         `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
1197         `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1198         `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
1199         `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
1200         `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
1201         `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
1202         `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1203         `allow_cid` mediumtext COMMENT 'default permission for this user',
1204         `allow_gid` mediumtext COMMENT 'default permission for this user',
1205         `deny_cid` mediumtext COMMENT 'default permission for this user',
1206         `deny_gid` mediumtext COMMENT 'default permission for this user',
1207         `openidserver` text COMMENT '',
1208          PRIMARY KEY(`uid`),
1209          INDEX `nickname` (`nickname`(32))
1210 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
1211
1212 --
1213 -- TABLE userd
1214 --
1215 CREATE TABLE IF NOT EXISTS `userd` (
1216         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1217         `username` varchar(255) NOT NULL COMMENT '',
1218          PRIMARY KEY(`id`),
1219          INDEX `username` (`username`(32))
1220 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1221
1222 --
1223 -- TABLE user-contact
1224 --
1225 CREATE TABLE IF NOT EXISTS `user-contact` (
1226         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1227         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1228         `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1229         `ignored` boolean COMMENT 'Posts from this contact are ignored',
1230         `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1231          PRIMARY KEY(`uid`,`cid`)
1232 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1233
1234 --
1235 -- TABLE user-item
1236 --
1237 CREATE TABLE IF NOT EXISTS `user-item` (
1238         `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item id',
1239         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1240         `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide an item from the user',
1241         `ignored` boolean COMMENT 'Ignore this thread if set',
1242          PRIMARY KEY(`uid`,`iid`)
1243 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific item data';
1244
1245 --
1246 -- TABLE worker-ipc
1247 --
1248 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1249         `key` int NOT NULL COMMENT '',
1250         `jobs` boolean COMMENT 'Flag for outstanding jobs',
1251          PRIMARY KEY(`key`)
1252 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1253
1254 --
1255 -- TABLE workerqueue
1256 --
1257 CREATE TABLE IF NOT EXISTS `workerqueue` (
1258         `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
1259         `parameter` mediumblob COMMENT 'Task command',
1260         `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
1261         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
1262         `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
1263         `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
1264         `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1265         `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1266         `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
1267          PRIMARY KEY(`id`),
1268          INDEX `pid` (`pid`),
1269          INDEX `parameter` (`parameter`(64)),
1270          INDEX `priority_created_next_try` (`priority`,`created`,`next_try`),
1271          INDEX `done_priority_executed_next_try` (`done`,`priority`,`executed`,`next_try`),
1272          INDEX `done_executed_next_try` (`done`,`executed`,`next_try`),
1273          INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
1274          INDEX `done_next_try` (`done`,`next_try`)
1275 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
1276
1277 --
1278 -- TABLE storage
1279 --
1280 CREATE TABLE IF NOT EXISTS `storage` (
1281         `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1282         `data` longblob NOT NULL COMMENT 'file data',
1283          PRIMARY KEY(`id`)
1284 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1285
1286