]> git.mxchange.org Git - friendica.git/blob - database.sql
Update "storage" console command
[friendica.git] / database.sql
1 -- ------------------------------------------
2 -- Friendica 2019.03-dev (The Tazmans Flax-lily)
3 -- DB_UPDATE_VERSION 1297
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         `queue_count` mediumint(9) NOT NULL DEFAULT '0' COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
645         `queue_done` mediumint(9) NOT NULL DEFAULT '0' COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
646          PRIMARY KEY(`iid`)
647 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
648
649 --
650 -- TABLE item-uri
651 --
652 CREATE TABLE IF NOT EXISTS `item-uri` (
653         `id` int unsigned NOT NULL auto_increment,
654         `uri` varbinary(255) NOT NULL COMMENT 'URI of an item',
655         `guid` varbinary(255) COMMENT 'A unique identifier for an item',
656          PRIMARY KEY(`id`),
657          UNIQUE INDEX `uri` (`uri`),
658          INDEX `guid` (`guid`)
659 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
660
661 --
662 -- TABLE locks
663 --
664 CREATE TABLE IF NOT EXISTS `locks` (
665         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
666         `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
667         `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
668         `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
669         `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
670          PRIMARY KEY(`id`),
671          INDEX `name_expires` (`name`,`expires`)
672 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
673
674 --
675 -- TABLE mail
676 --
677 CREATE TABLE IF NOT EXISTS `mail` (
678         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
679         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
680         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
681         `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
682         `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
683         `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
684         `contact-id` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact.id',
685         `convid` int unsigned NOT NULL DEFAULT 0 COMMENT 'conv.id',
686         `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
687         `body` mediumtext COMMENT '',
688         `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
689         `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
690         `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
691         `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
692         `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
693         `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
694         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
695          PRIMARY KEY(`id`),
696          INDEX `uid_seen` (`uid`,`seen`),
697          INDEX `convid` (`convid`),
698          INDEX `uri` (`uri`(64)),
699          INDEX `parent-uri` (`parent-uri`(64)),
700          INDEX `contactid` (`contact-id`(32))
701 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
702
703 --
704 -- TABLE mailacct
705 --
706 CREATE TABLE IF NOT EXISTS `mailacct` (
707         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
708         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
709         `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
710         `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
711         `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
712         `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
713         `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
714         `pass` text COMMENT '',
715         `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
716         `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
717         `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
718         `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
719         `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
720          PRIMARY KEY(`id`)
721 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
722
723 --
724 -- TABLE manage
725 --
726 CREATE TABLE IF NOT EXISTS `manage` (
727         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
728         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
729         `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
730          PRIMARY KEY(`id`),
731          UNIQUE INDEX `uid_mid` (`uid`,`mid`)
732 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
733
734 --
735 -- TABLE notify
736 --
737 CREATE TABLE IF NOT EXISTS `notify` (
738         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
739         `hash` varchar(64) NOT NULL DEFAULT '' COMMENT '',
740         `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
741         `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
742         `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
743         `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
744         `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
745         `msg` mediumtext COMMENT '',
746         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
747         `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
748         `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'item.id',
749         `parent` int unsigned NOT NULL DEFAULT 0 COMMENT '',
750         `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
751         `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
752         `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
753         `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
754         `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
755          PRIMARY KEY(`id`),
756          INDEX `hash_uid` (`hash`,`uid`),
757          INDEX `seen_uid_date` (`seen`,`uid`,`date`),
758          INDEX `uid_date` (`uid`,`date`),
759          INDEX `uid_type_link` (`uid`,`type`,`link`(190))
760 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
761
762 --
763 -- TABLE notify-threads
764 --
765 CREATE TABLE IF NOT EXISTS `notify-threads` (
766         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
767         `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
768         `master-parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
769         `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
770         `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
771          PRIMARY KEY(`id`)
772 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
773
774 --
775 -- TABLE oembed
776 --
777 CREATE TABLE IF NOT EXISTS `oembed` (
778         `url` varbinary(255) NOT NULL COMMENT 'page url',
779         `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
780         `content` mediumtext COMMENT 'OEmbed data of the page',
781         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
782          PRIMARY KEY(`url`,`maxwidth`),
783          INDEX `created` (`created`)
784 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
785
786 --
787 -- TABLE openwebauth-token
788 --
789 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
790         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
791         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
792         `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
793         `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
794         `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
795         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
796          PRIMARY KEY(`id`)
797 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
798
799 --
800 -- TABLE parsed_url
801 --
802 CREATE TABLE IF NOT EXISTS `parsed_url` (
803         `url` varbinary(255) NOT NULL COMMENT 'page url',
804         `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
805         `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
806         `content` mediumtext COMMENT 'page data',
807         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
808          PRIMARY KEY(`url`,`guessing`,`oembed`),
809          INDEX `created` (`created`)
810 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
811
812 --
813 -- TABLE participation
814 --
815 CREATE TABLE IF NOT EXISTS `participation` (
816         `iid` int unsigned NOT NULL COMMENT '',
817         `server` varchar(60) NOT NULL COMMENT '',
818         `cid` int unsigned NOT NULL COMMENT '',
819         `fid` int unsigned NOT NULL COMMENT '',
820          PRIMARY KEY(`iid`,`server`),
821          INDEX `cid` (`cid`),
822          INDEX `fid` (`fid`)
823 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Storage for participation messages from Diaspora';
824
825 --
826 -- TABLE pconfig
827 --
828 CREATE TABLE IF NOT EXISTS `pconfig` (
829         `id` int unsigned NOT NULL auto_increment COMMENT '',
830         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
831         `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
832         `k` varbinary(100) NOT NULL DEFAULT '' COMMENT '',
833         `v` mediumtext COMMENT '',
834          PRIMARY KEY(`id`),
835          UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`)
836 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
837
838 --
839 -- TABLE permissionset
840 --
841 CREATE TABLE IF NOT EXISTS `permissionset` (
842         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
843         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
844         `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
845         `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
846         `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
847         `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
848          PRIMARY KEY(`id`),
849          INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30))
850 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
851
852 --
853 -- TABLE photo
854 --
855 CREATE TABLE IF NOT EXISTS `photo` (
856         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
857         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
858         `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
859         `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
860         `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
861         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
862         `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
863         `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
864         `desc` text COMMENT '',
865         `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
866         `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
867         `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
868         `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
869         `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
870         `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
871         `data` mediumblob NOT NULL COMMENT '',
872         `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
873         `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
874         `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
875         `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
876         `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
877         `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
878         `backend-class` tinytext COMMENT 'Storage backend class',
879         `backend-ref` text COMMENT 'Storage backend data reference',
880          PRIMARY KEY(`id`),
881          INDEX `contactid` (`contact-id`),
882          INDEX `uid_contactid` (`uid`,`contact-id`),
883          INDEX `uid_profile` (`uid`,`profile`),
884          INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
885          INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
886          INDEX `resource-id` (`resource-id`)
887 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
888
889 --
890 -- TABLE poll
891 --
892 CREATE TABLE IF NOT EXISTS `poll` (
893         `id` int unsigned NOT NULL auto_increment COMMENT '',
894         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
895         `q0` text COMMENT '',
896         `q1` text COMMENT '',
897         `q2` text COMMENT '',
898         `q3` text COMMENT '',
899         `q4` text COMMENT '',
900         `q5` text COMMENT '',
901         `q6` text COMMENT '',
902         `q7` text COMMENT '',
903         `q8` text COMMENT '',
904         `q9` text COMMENT '',
905          PRIMARY KEY(`id`),
906          INDEX `uid` (`uid`)
907 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently unused table for storing poll results';
908
909 --
910 -- TABLE poll_result
911 --
912 CREATE TABLE IF NOT EXISTS `poll_result` (
913         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
914         `poll_id` int unsigned NOT NULL DEFAULT 0,
915         `choice` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
916          PRIMARY KEY(`id`),
917          INDEX `poll_id` (`poll_id`)
918 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='data for polls - currently unused';
919
920 --
921 -- TABLE process
922 --
923 CREATE TABLE IF NOT EXISTS `process` (
924         `pid` int unsigned NOT NULL COMMENT '',
925         `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
926         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
927          PRIMARY KEY(`pid`),
928          INDEX `command` (`command`)
929 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
930
931 --
932 -- TABLE profile
933 --
934 CREATE TABLE IF NOT EXISTS `profile` (
935         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
936         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
937         `profile-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name of the profile',
938         `is-default` boolean NOT NULL DEFAULT '0' COMMENT 'Mark this profile as default profile',
939         `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
940         `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
941         `pdesc` varchar(255) NOT NULL DEFAULT '' COMMENT 'Title or description',
942         `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
943         `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
944         `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
945         `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
946         `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
947         `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
948         `hometown` varchar(255) NOT NULL DEFAULT '' COMMENT '',
949         `gender` varchar(32) NOT NULL DEFAULT '' COMMENT '',
950         `marital` varchar(255) NOT NULL DEFAULT '' COMMENT '',
951         `with` text COMMENT '',
952         `howlong` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
953         `sexual` varchar(255) NOT NULL DEFAULT '' COMMENT '',
954         `politic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
955         `religion` varchar(255) NOT NULL DEFAULT '' COMMENT '',
956         `pub_keywords` text COMMENT '',
957         `prv_keywords` text COMMENT '',
958         `likes` text COMMENT '',
959         `dislikes` text COMMENT '',
960         `about` text COMMENT '',
961         `summary` varchar(255) NOT NULL DEFAULT '' COMMENT '',
962         `music` text COMMENT '',
963         `book` text COMMENT '',
964         `tv` text COMMENT '',
965         `film` text COMMENT '',
966         `interest` text COMMENT '',
967         `romance` text COMMENT '',
968         `work` text COMMENT '',
969         `education` text COMMENT '',
970         `contact` text COMMENT '',
971         `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
972         `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
973         `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
974         `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
975         `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
976         `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
977          PRIMARY KEY(`id`),
978          INDEX `uid_is-default` (`uid`,`is-default`),
979          FULLTEXT INDEX `pub_keywords` (`pub_keywords`)
980 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
981
982 --
983 -- TABLE profile_check
984 --
985 CREATE TABLE IF NOT EXISTS `profile_check` (
986         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
987         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
988         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
989         `dfrn_id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
990         `sec` varchar(255) NOT NULL DEFAULT '' COMMENT '',
991         `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
992          PRIMARY KEY(`id`)
993 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='DFRN remote auth use';
994
995 --
996 -- TABLE push_subscriber
997 --
998 CREATE TABLE IF NOT EXISTS `push_subscriber` (
999         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1000         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1001         `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1002         `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1003         `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1004         `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1005         `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1006         `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1007         `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1008         `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1009          PRIMARY KEY(`id`),
1010          INDEX `next_try` (`next_try`)
1011 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1012
1013 --
1014 -- TABLE queue
1015 --
1016 CREATE TABLE IF NOT EXISTS `queue` (
1017         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1018         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Message receiver',
1019         `network` char(4) NOT NULL DEFAULT '' COMMENT 'Receiver\'s network',
1020         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'Unique GUID of the message',
1021         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date, when the message was created',
1022         `last` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last trial',
1023         `next` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1024         `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1025         `content` mediumtext COMMENT '',
1026         `batch` boolean NOT NULL DEFAULT '0' COMMENT '',
1027          PRIMARY KEY(`id`),
1028          INDEX `last` (`last`),
1029          INDEX `next` (`next`)
1030 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Queue for messages that couldn\'t be delivered';
1031
1032 --
1033 -- TABLE register
1034 --
1035 CREATE TABLE IF NOT EXISTS `register` (
1036         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1037         `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1038         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1039         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1040         `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1041         `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1042         `note` text COMMENT '',
1043          PRIMARY KEY(`id`)
1044 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1045
1046 --
1047 -- TABLE search
1048 --
1049 CREATE TABLE IF NOT EXISTS `search` (
1050         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1051         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1052         `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1053          PRIMARY KEY(`id`),
1054          INDEX `uid` (`uid`)
1055 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1056
1057 --
1058 -- TABLE session
1059 --
1060 CREATE TABLE IF NOT EXISTS `session` (
1061         `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1062         `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1063         `data` text COMMENT '',
1064         `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1065          PRIMARY KEY(`id`),
1066          INDEX `sid` (`sid`(64)),
1067          INDEX `expire` (`expire`)
1068 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1069
1070 --
1071 -- TABLE sign
1072 --
1073 CREATE TABLE IF NOT EXISTS `sign` (
1074         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1075         `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'item.id',
1076         `signed_text` mediumtext COMMENT '',
1077         `signature` text COMMENT '',
1078         `signer` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1079          PRIMARY KEY(`id`),
1080          UNIQUE INDEX `iid` (`iid`)
1081 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora signatures';
1082
1083 --
1084 -- TABLE term
1085 --
1086 CREATE TABLE IF NOT EXISTS `term` (
1087         `tid` int unsigned NOT NULL auto_increment COMMENT '',
1088         `oid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1089         `otype` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1090         `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1091         `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1092         `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1093         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1094         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1095         `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1096         `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1097         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1098          PRIMARY KEY(`tid`),
1099          INDEX `oid_otype_type_term` (`oid`,`otype`,`type`,`term`(32)),
1100          INDEX `uid_otype_type_term_global_created` (`uid`,`otype`,`type`,`term`(32),`global`,`created`),
1101          INDEX `uid_otype_type_url` (`uid`,`otype`,`type`,`url`(64)),
1102          INDEX `guid` (`guid`(64))
1103 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='item taxonomy (categories, tags, etc.) table';
1104
1105 --
1106 -- TABLE thread
1107 --
1108 CREATE TABLE IF NOT EXISTS `thread` (
1109         `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'sequential ID',
1110         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1111         `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1112         `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1113         `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1114         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1115         `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1116         `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1117         `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1118         `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1119         `wall` boolean NOT NULL DEFAULT '0' COMMENT '',
1120         `private` boolean NOT NULL DEFAULT '0' COMMENT '',
1121         `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1122         `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
1123         `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1124         `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1125         `ignored` boolean NOT NULL DEFAULT '0' COMMENT '',
1126         `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
1127         `unseen` boolean NOT NULL DEFAULT '1' COMMENT '',
1128         `deleted` boolean NOT NULL DEFAULT '0' COMMENT '',
1129         `origin` boolean NOT NULL DEFAULT '0' COMMENT '',
1130         `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1131         `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1132         `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1133         `bookmark` boolean COMMENT '',
1134          PRIMARY KEY(`iid`),
1135          INDEX `uid_network_commented` (`uid`,`network`,`commented`),
1136          INDEX `uid_network_created` (`uid`,`network`,`created`),
1137          INDEX `uid_contactid_commented` (`uid`,`contact-id`,`commented`),
1138          INDEX `uid_contactid_created` (`uid`,`contact-id`,`created`),
1139          INDEX `contactid` (`contact-id`),
1140          INDEX `ownerid` (`owner-id`),
1141          INDEX `authorid` (`author-id`),
1142          INDEX `uid_created` (`uid`,`created`),
1143          INDEX `uid_commented` (`uid`,`commented`),
1144          INDEX `uid_wall_created` (`uid`,`wall`,`created`),
1145          INDEX `private_wall_origin_commented` (`private`,`wall`,`origin`,`commented`)
1146 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1147
1148 --
1149 -- TABLE tokens
1150 --
1151 CREATE TABLE IF NOT EXISTS `tokens` (
1152         `id` varchar(40) NOT NULL COMMENT '',
1153         `secret` text COMMENT '',
1154         `client_id` varchar(20) NOT NULL DEFAULT '',
1155         `expires` int NOT NULL DEFAULT 0 COMMENT '',
1156         `scope` varchar(200) NOT NULL DEFAULT '' COMMENT '',
1157         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1158          PRIMARY KEY(`id`)
1159 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
1160
1161 --
1162 -- TABLE user
1163 --
1164 CREATE TABLE IF NOT EXISTS `user` (
1165         `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1166         `parent-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'The parent user that has full control about this user',
1167         `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
1168         `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
1169         `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
1170         `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
1171         `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
1172         `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
1173         `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1174         `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
1175         `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
1176         `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
1177         `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
1178         `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
1179         `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
1180         `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
1181         `pubkey` text COMMENT 'RSA public key 4096 bit',
1182         `prvkey` text COMMENT 'RSA private key 4096 bit',
1183         `spubkey` text COMMENT '',
1184         `sprvkey` text COMMENT '',
1185         `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
1186         `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
1187         `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
1188         `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unkown viewers',
1189         `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
1190         `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
1191         `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
1192         `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
1193         `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
1194         `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1195         `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
1196         `pwdreset` varchar(255) COMMENT 'Password reset request token',
1197         `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
1198         `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
1199         `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1200         `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
1201         `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
1202         `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
1203         `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
1204         `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1205         `allow_cid` mediumtext COMMENT 'default permission for this user',
1206         `allow_gid` mediumtext COMMENT 'default permission for this user',
1207         `deny_cid` mediumtext COMMENT 'default permission for this user',
1208         `deny_gid` mediumtext COMMENT 'default permission for this user',
1209         `openidserver` text COMMENT '',
1210          PRIMARY KEY(`uid`),
1211          INDEX `nickname` (`nickname`(32))
1212 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
1213
1214 --
1215 -- TABLE userd
1216 --
1217 CREATE TABLE IF NOT EXISTS `userd` (
1218         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1219         `username` varchar(255) NOT NULL COMMENT '',
1220          PRIMARY KEY(`id`),
1221          INDEX `username` (`username`(32))
1222 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1223
1224 --
1225 -- TABLE user-contact
1226 --
1227 CREATE TABLE IF NOT EXISTS `user-contact` (
1228         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1229         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1230         `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1231         `ignored` boolean COMMENT 'Posts from this contact are ignored',
1232         `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1233          PRIMARY KEY(`uid`,`cid`)
1234 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1235
1236 --
1237 -- TABLE user-item
1238 --
1239 CREATE TABLE IF NOT EXISTS `user-item` (
1240         `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item id',
1241         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1242         `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide an item from the user',
1243         `ignored` boolean COMMENT 'Ignore this thread if set',
1244          PRIMARY KEY(`uid`,`iid`)
1245 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific item data';
1246
1247 --
1248 -- TABLE worker-ipc
1249 --
1250 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1251         `key` int NOT NULL COMMENT '',
1252         `jobs` boolean COMMENT 'Flag for outstanding jobs',
1253          PRIMARY KEY(`key`)
1254 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1255
1256 --
1257 -- TABLE workerqueue
1258 --
1259 CREATE TABLE IF NOT EXISTS `workerqueue` (
1260         `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
1261         `parameter` mediumblob COMMENT 'Task command',
1262         `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
1263         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
1264         `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
1265         `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
1266         `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1267         `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1268         `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
1269          PRIMARY KEY(`id`),
1270          INDEX `pid` (`pid`),
1271          INDEX `parameter` (`parameter`(64)),
1272          INDEX `priority_created_next_try` (`priority`,`created`,`next_try`),
1273          INDEX `done_priority_executed_next_try` (`done`,`priority`,`executed`,`next_try`),
1274          INDEX `done_executed_next_try` (`done`,`executed`,`next_try`),
1275          INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
1276          INDEX `done_next_try` (`done`,`next_try`)
1277 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
1278
1279 --
1280 -- TABLE storage
1281 --
1282 CREATE TABLE IF NOT EXISTS `storage` (
1283         `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1284         `data` longblob NOT NULL COMMENT 'file data',
1285          PRIMARY KEY(`id`)
1286 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1287
1288