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