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