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