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