Issue 8371: Improvements for picture permissions
[friendica.git/.git] / database.sql
1 -- ------------------------------------------
2 -- Friendica 2020.03-dev (Dalmatian Bellflower)
3 -- DB_UPDATE_VERSION 1337
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         `last_discovery` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last contact discovery',
397         `archive_date` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
398         `archived` boolean NOT NULL DEFAULT '0' COMMENT '',
399         `location` varchar(255) NOT NULL DEFAULT '' COMMENT '',
400         `about` text COMMENT '',
401         `keywords` text COMMENT 'puplic keywords (interests)',
402         `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
403         `birthday` varchar(32) NOT NULL DEFAULT '0001-01-01' COMMENT '',
404         `community` boolean NOT NULL DEFAULT '0' COMMENT '1 if contact is forum account',
405         `contact-type` tinyint NOT NULL DEFAULT -1 COMMENT '',
406         `hide` boolean NOT NULL DEFAULT '0' COMMENT '1 = should be hidden from search',
407         `nsfw` boolean NOT NULL DEFAULT '0' COMMENT '1 = contact posts nsfw content',
408         `network` char(4) NOT NULL DEFAULT '' COMMENT 'social network protocol',
409         `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
410         `notify` varchar(255) COMMENT '',
411         `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
412         `generation` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
413         `server_url` varchar(255) NOT NULL DEFAULT '' COMMENT 'baseurl of the contacts server',
414          PRIMARY KEY(`id`),
415          UNIQUE INDEX `nurl` (`nurl`(190)),
416          INDEX `name` (`name`(64)),
417          INDEX `nick` (`nick`(32)),
418          INDEX `addr` (`addr`(64)),
419          INDEX `hide_network_updated` (`hide`,`network`,`updated`),
420          INDEX `updated` (`updated`)
421 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='global contacts';
422
423 --
424 -- TABLE gfollower
425 --
426 CREATE TABLE IF NOT EXISTS `gfollower` (
427         `gcid` int unsigned NOT NULL DEFAULT 0 COMMENT 'global contact',
428         `follower-gcid` int unsigned NOT NULL DEFAULT 0 COMMENT 'global contact of the follower',
429         `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates that the connection has been deleted',
430          PRIMARY KEY(`gcid`,`follower-gcid`),
431          INDEX `follower-gcid` (`follower-gcid`)
432 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Followers of global contacts';
433
434 --
435 -- TABLE glink
436 --
437 CREATE TABLE IF NOT EXISTS `glink` (
438         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
439         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
440         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
441         `gcid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
442         `zcid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
443         `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
444          PRIMARY KEY(`id`),
445          UNIQUE INDEX `cid_uid_gcid_zcid` (`cid`,`uid`,`gcid`,`zcid`),
446          INDEX `gcid` (`gcid`)
447 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='\'friends of friends\' linkages derived from poco';
448
449 --
450 -- TABLE group
451 --
452 CREATE TABLE IF NOT EXISTS `group` (
453         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
454         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
455         `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
456         `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
457         `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
458          PRIMARY KEY(`id`),
459          INDEX `uid` (`uid`)
460 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
461
462 --
463 -- TABLE group_member
464 --
465 CREATE TABLE IF NOT EXISTS `group_member` (
466         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
467         `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
468         `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
469          PRIMARY KEY(`id`),
470          INDEX `contactid` (`contact-id`),
471          UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`)
472 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
473
474 --
475 -- TABLE gserver
476 --
477 CREATE TABLE IF NOT EXISTS `gserver` (
478         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
479         `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
480         `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
481         `version` varchar(255) NOT NULL DEFAULT '' COMMENT '',
482         `site_name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
483         `info` text COMMENT '',
484         `register_policy` tinyint NOT NULL DEFAULT 0 COMMENT '',
485         `registered-users` int unsigned NOT NULL DEFAULT 0 COMMENT 'Number of registered users',
486         `directory-type` tinyint DEFAULT 0 COMMENT 'Type of directory service (Poco, Mastodon)',
487         `poco` varchar(255) NOT NULL DEFAULT '' COMMENT '',
488         `noscrape` varchar(255) NOT NULL DEFAULT '' COMMENT '',
489         `network` char(4) NOT NULL DEFAULT '' COMMENT '',
490         `platform` varchar(255) NOT NULL DEFAULT '' COMMENT '',
491         `relay-subscribe` boolean NOT NULL DEFAULT '0' COMMENT 'Has the server subscribed to the relay system',
492         `relay-scope` varchar(10) NOT NULL DEFAULT '' COMMENT 'The scope of messages that the server wants to get',
493         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
494         `last_poco_query` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
495         `last_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
496         `last_failure` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
497          PRIMARY KEY(`id`),
498          UNIQUE INDEX `nurl` (`nurl`(190))
499 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Global servers';
500
501 --
502 -- TABLE gserver-tag
503 --
504 CREATE TABLE IF NOT EXISTS `gserver-tag` (
505         `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
506         `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
507          PRIMARY KEY(`gserver-id`,`tag`),
508          INDEX `tag` (`tag`)
509 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
510
511 --
512 -- TABLE hook
513 --
514 CREATE TABLE IF NOT EXISTS `hook` (
515         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
516         `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
517         `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
518         `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
519         `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',
520          PRIMARY KEY(`id`),
521          UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
522 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
523
524 --
525 -- TABLE inbox-status
526 --
527 CREATE TABLE IF NOT EXISTS `inbox-status` (
528         `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
529         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
530         `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
531         `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
532         `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
533         `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
534         `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
535          PRIMARY KEY(`url`)
536 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
537
538 --
539 -- TABLE intro
540 --
541 CREATE TABLE IF NOT EXISTS `intro` (
542         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
543         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
544         `fid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
545         `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
546         `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
547         `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
548         `note` text COMMENT '',
549         `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
550         `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
551         `blocked` boolean NOT NULL DEFAULT '1' COMMENT '',
552         `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
553          PRIMARY KEY(`id`)
554 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
555
556 --
557 -- TABLE item
558 --
559 CREATE TABLE IF NOT EXISTS `item` (
560         `id` int unsigned NOT NULL auto_increment,
561         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this item',
562         `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
563         `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
564         `uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
565         `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',
566         `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT 'uri of the parent to this item',
567         `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
568         `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',
569         `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
570         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
571         `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
572         `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last comment/reply to this item',
573         `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
574         `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',
575         `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
576         `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
577         `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
578         `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
579         `icid` int unsigned COMMENT 'Id of the item-content table entry that contains the whole item content',
580         `iaid` int unsigned COMMENT 'Id of the item-activity table entry that contains the activity data',
581         `extid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
582         `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
583         `global` boolean NOT NULL DEFAULT '0' COMMENT '',
584         `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
585         `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
586         `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
587         `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been deleted',
588         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
589         `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
590         `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
591         `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
592         `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
593         `starred` boolean NOT NULL DEFAULT '0' COMMENT 'item has been favourited',
594         `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'item has not been seen',
595         `mention` boolean NOT NULL DEFAULT '0' COMMENT 'The owner of this item was mentioned in it',
596         `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
597         `psid` int unsigned COMMENT 'ID of the permission set of this post',
598         `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',
599         `event-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Used to link to the event.id',
600         `attach` mediumtext COMMENT 'JSON structure representing attachments to this item',
601         `allow_cid` mediumtext COMMENT 'Deprecated',
602         `allow_gid` mediumtext COMMENT 'Deprecated',
603         `deny_cid` mediumtext COMMENT 'Deprecated',
604         `deny_gid` mediumtext COMMENT 'Deprecated',
605         `postopts` text COMMENT 'Deprecated',
606         `inform` mediumtext COMMENT 'Deprecated',
607         `type` varchar(20) COMMENT 'Deprecated',
608         `bookmark` boolean COMMENT 'Deprecated',
609         `file` mediumtext COMMENT 'Deprecated',
610         `location` varchar(255) COMMENT 'Deprecated',
611         `coord` varchar(255) COMMENT 'Deprecated',
612         `tag` mediumtext COMMENT 'Deprecated',
613         `plink` varchar(255) COMMENT 'Deprecated',
614         `title` varchar(255) COMMENT 'Deprecated',
615         `content-warning` varchar(255) COMMENT 'Deprecated',
616         `body` mediumtext COMMENT 'Deprecated',
617         `app` varchar(255) COMMENT 'Deprecated',
618         `verb` varchar(100) COMMENT 'Deprecated',
619         `object-type` varchar(100) COMMENT 'Deprecated',
620         `object` text COMMENT 'Deprecated',
621         `target-type` varchar(100) COMMENT 'Deprecated',
622         `target` text COMMENT 'Deprecated',
623         `author-name` varchar(255) COMMENT 'Deprecated',
624         `author-link` varchar(255) COMMENT 'Deprecated',
625         `author-avatar` varchar(255) COMMENT 'Deprecated',
626         `owner-name` varchar(255) COMMENT 'Deprecated',
627         `owner-link` varchar(255) COMMENT 'Deprecated',
628         `owner-avatar` varchar(255) COMMENT 'Deprecated',
629         `rendered-hash` varchar(32) COMMENT 'Deprecated',
630         `rendered-html` mediumtext COMMENT 'Deprecated',
631          PRIMARY KEY(`id`),
632          INDEX `guid` (`guid`(191)),
633          INDEX `uri` (`uri`(191)),
634          INDEX `parent` (`parent`),
635          INDEX `parent-uri` (`parent-uri`(191)),
636          INDEX `extid` (`extid`(191)),
637          INDEX `uid_id` (`uid`,`id`),
638          INDEX `uid_contactid_id` (`uid`,`contact-id`,`id`),
639          INDEX `uid_received` (`uid`,`received`),
640          INDEX `uid_commented` (`uid`,`commented`),
641          INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
642          INDEX `uid_network_received` (`uid`,`network`,`received`),
643          INDEX `uid_network_commented` (`uid`,`network`,`commented`),
644          INDEX `uid_thrparent` (`uid`,`thr-parent`(190)),
645          INDEX `uid_parenturi` (`uid`,`parent-uri`(190)),
646          INDEX `uid_contactid_received` (`uid`,`contact-id`,`received`),
647          INDEX `authorid_received` (`author-id`,`received`),
648          INDEX `ownerid` (`owner-id`),
649          INDEX `contact-id` (`contact-id`),
650          INDEX `uid_uri` (`uid`,`uri`(190)),
651          INDEX `resource-id` (`resource-id`),
652          INDEX `deleted_changed` (`deleted`,`changed`),
653          INDEX `uid_wall_changed` (`uid`,`wall`,`changed`),
654          INDEX `mention_uid_id` (`mention`,`uid`,`id`),
655          INDEX `uid_eventid` (`uid`,`event-id`),
656          INDEX `icid` (`icid`),
657          INDEX `iaid` (`iaid`),
658          INDEX `psid_wall` (`psid`,`wall`)
659 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
660
661 --
662 -- TABLE item-activity
663 --
664 CREATE TABLE IF NOT EXISTS `item-activity` (
665         `id` int unsigned NOT NULL auto_increment,
666         `uri` varchar(255) COMMENT '',
667         `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
668         `uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
669         `activity` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
670          PRIMARY KEY(`id`),
671          UNIQUE INDEX `uri-hash` (`uri-hash`),
672          INDEX `uri` (`uri`(191)),
673          INDEX `uri-id` (`uri-id`)
674 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activities for items';
675
676 --
677 -- TABLE item-content
678 --
679 CREATE TABLE IF NOT EXISTS `item-content` (
680         `id` int unsigned NOT NULL auto_increment,
681         `uri` varchar(255) COMMENT '',
682         `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
683         `uri-plink-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
684         `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
685         `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
686         `body` mediumtext COMMENT 'item body content',
687         `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
688         `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
689         `language` text COMMENT 'Language information about this post',
690         `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
691         `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
692         `rendered-html` mediumtext COMMENT 'item.body converted to html',
693         `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
694         `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
695         `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
696         `target` text COMMENT 'JSON encoded target structure if used',
697         `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
698         `verb` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams verb',
699          PRIMARY KEY(`id`),
700          UNIQUE INDEX `uri-plink-hash` (`uri-plink-hash`),
701          INDEX `uri` (`uri`(191)),
702          INDEX `plink` (`plink`(191)),
703          INDEX `uri-id` (`uri-id`)
704 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
705
706 --
707 -- TABLE item-delivery-data
708 --
709 CREATE TABLE IF NOT EXISTS `item-delivery-data` (
710         `iid` int unsigned NOT NULL COMMENT 'Item id',
711         `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',
712         `inform` mediumtext COMMENT 'Additional receivers of the linked item',
713         `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
714         `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
715         `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
716         `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
717         `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
718         `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
719         `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
720         `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
721          PRIMARY KEY(`iid`)
722 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
723
724 --
725 -- TABLE item-uri
726 --
727 CREATE TABLE IF NOT EXISTS `item-uri` (
728         `id` int unsigned NOT NULL auto_increment,
729         `uri` varbinary(255) NOT NULL COMMENT 'URI of an item',
730         `guid` varbinary(255) COMMENT 'A unique identifier for an item',
731          PRIMARY KEY(`id`),
732          UNIQUE INDEX `uri` (`uri`),
733          INDEX `guid` (`guid`)
734 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
735
736 --
737 -- TABLE locks
738 --
739 CREATE TABLE IF NOT EXISTS `locks` (
740         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
741         `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
742         `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
743         `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
744         `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
745          PRIMARY KEY(`id`),
746          INDEX `name_expires` (`name`,`expires`)
747 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
748
749 --
750 -- TABLE mail
751 --
752 CREATE TABLE IF NOT EXISTS `mail` (
753         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
754         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
755         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
756         `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
757         `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
758         `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
759         `contact-id` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact.id',
760         `convid` int unsigned NOT NULL DEFAULT 0 COMMENT 'conv.id',
761         `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
762         `body` mediumtext COMMENT '',
763         `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
764         `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
765         `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
766         `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
767         `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
768         `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
769         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
770          PRIMARY KEY(`id`),
771          INDEX `uid_seen` (`uid`,`seen`),
772          INDEX `convid` (`convid`),
773          INDEX `uri` (`uri`(64)),
774          INDEX `parent-uri` (`parent-uri`(64)),
775          INDEX `contactid` (`contact-id`(32))
776 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
777
778 --
779 -- TABLE mailacct
780 --
781 CREATE TABLE IF NOT EXISTS `mailacct` (
782         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
783         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
784         `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
785         `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
786         `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
787         `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
788         `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
789         `pass` text COMMENT '',
790         `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
791         `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
792         `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
793         `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
794         `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
795          PRIMARY KEY(`id`)
796 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
797
798 --
799 -- TABLE manage
800 --
801 CREATE TABLE IF NOT EXISTS `manage` (
802         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
803         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
804         `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
805          PRIMARY KEY(`id`),
806          UNIQUE INDEX `uid_mid` (`uid`,`mid`)
807 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
808
809 --
810 -- TABLE notify
811 --
812 CREATE TABLE IF NOT EXISTS `notify` (
813         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
814         `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
815         `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
816         `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
817         `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
818         `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
819         `msg` mediumtext COMMENT '',
820         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
821         `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
822         `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'item.id',
823         `parent` int unsigned NOT NULL DEFAULT 0 COMMENT '',
824         `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
825         `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
826         `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
827         `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
828         `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
829          PRIMARY KEY(`id`),
830          INDEX `seen_uid_date` (`seen`,`uid`,`date`),
831          INDEX `uid_date` (`uid`,`date`),
832          INDEX `uid_type_link` (`uid`,`type`,`link`(190))
833 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
834
835 --
836 -- TABLE notify-threads
837 --
838 CREATE TABLE IF NOT EXISTS `notify-threads` (
839         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
840         `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
841         `master-parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
842         `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
843         `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
844          PRIMARY KEY(`id`)
845 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
846
847 --
848 -- TABLE oembed
849 --
850 CREATE TABLE IF NOT EXISTS `oembed` (
851         `url` varbinary(255) NOT NULL COMMENT 'page url',
852         `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
853         `content` mediumtext COMMENT 'OEmbed data of the page',
854         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
855          PRIMARY KEY(`url`,`maxwidth`),
856          INDEX `created` (`created`)
857 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
858
859 --
860 -- TABLE openwebauth-token
861 --
862 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
863         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
864         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
865         `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
866         `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
867         `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
868         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
869          PRIMARY KEY(`id`)
870 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
871
872 --
873 -- TABLE parsed_url
874 --
875 CREATE TABLE IF NOT EXISTS `parsed_url` (
876         `url` varbinary(255) NOT NULL COMMENT 'page url',
877         `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
878         `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
879         `content` mediumtext COMMENT 'page data',
880         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
881          PRIMARY KEY(`url`,`guessing`,`oembed`),
882          INDEX `created` (`created`)
883 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
884
885 --
886 -- TABLE participation
887 --
888 CREATE TABLE IF NOT EXISTS `participation` (
889         `iid` int unsigned NOT NULL COMMENT '',
890         `server` varchar(60) NOT NULL COMMENT '',
891         `cid` int unsigned NOT NULL COMMENT '',
892         `fid` int unsigned NOT NULL COMMENT '',
893          PRIMARY KEY(`iid`,`server`),
894          INDEX `cid` (`cid`),
895          INDEX `fid` (`fid`)
896 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Storage for participation messages from Diaspora';
897
898 --
899 -- TABLE pconfig
900 --
901 CREATE TABLE IF NOT EXISTS `pconfig` (
902         `id` int unsigned NOT NULL auto_increment COMMENT '',
903         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
904         `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
905         `k` varbinary(100) NOT NULL DEFAULT '' COMMENT '',
906         `v` mediumtext COMMENT '',
907          PRIMARY KEY(`id`),
908          UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`)
909 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
910
911 --
912 -- TABLE permissionset
913 --
914 CREATE TABLE IF NOT EXISTS `permissionset` (
915         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
916         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
917         `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
918         `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
919         `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
920         `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
921          PRIMARY KEY(`id`),
922          INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30))
923 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
924
925 --
926 -- TABLE photo
927 --
928 CREATE TABLE IF NOT EXISTS `photo` (
929         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
930         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
931         `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
932         `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
933         `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
934         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
935         `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
936         `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
937         `desc` text COMMENT '',
938         `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
939         `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
940         `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
941         `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
942         `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
943         `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
944         `data` mediumblob NOT NULL COMMENT '',
945         `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
946         `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
947         `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
948         `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
949         `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
950         `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
951         `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
952         `backend-class` tinytext COMMENT 'Storage backend class',
953         `backend-ref` text COMMENT 'Storage backend data reference',
954         `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
955          PRIMARY KEY(`id`),
956          INDEX `contactid` (`contact-id`),
957          INDEX `uid_contactid` (`uid`,`contact-id`),
958          INDEX `uid_profile` (`uid`,`profile`),
959          INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
960          INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
961          INDEX `resource-id` (`resource-id`)
962 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
963
964 --
965 -- TABLE poll
966 --
967 CREATE TABLE IF NOT EXISTS `poll` (
968         `id` int unsigned NOT NULL auto_increment COMMENT '',
969         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
970         `q0` text COMMENT '',
971         `q1` text COMMENT '',
972         `q2` text COMMENT '',
973         `q3` text COMMENT '',
974         `q4` text COMMENT '',
975         `q5` text COMMENT '',
976         `q6` text COMMENT '',
977         `q7` text COMMENT '',
978         `q8` text COMMENT '',
979         `q9` text COMMENT '',
980          PRIMARY KEY(`id`),
981          INDEX `uid` (`uid`)
982 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently unused table for storing poll results';
983
984 --
985 -- TABLE poll_result
986 --
987 CREATE TABLE IF NOT EXISTS `poll_result` (
988         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
989         `poll_id` int unsigned NOT NULL DEFAULT 0,
990         `choice` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
991          PRIMARY KEY(`id`),
992          INDEX `poll_id` (`poll_id`)
993 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='data for polls - currently unused';
994
995 --
996 -- TABLE process
997 --
998 CREATE TABLE IF NOT EXISTS `process` (
999         `pid` int unsigned NOT NULL COMMENT '',
1000         `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1001         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1002          PRIMARY KEY(`pid`),
1003          INDEX `command` (`command`)
1004 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1005
1006 --
1007 -- TABLE profile
1008 --
1009 CREATE TABLE IF NOT EXISTS `profile` (
1010         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1011         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1012         `profile-name` varchar(255) COMMENT 'Deprecated',
1013         `is-default` boolean COMMENT 'Deprecated',
1014         `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1015         `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1016         `pdesc` varchar(255) COMMENT 'Deprecated',
1017         `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1018         `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1019         `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1020         `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1021         `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1022         `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1023         `hometown` varchar(255) COMMENT 'Deprecated',
1024         `gender` varchar(32) COMMENT 'Deprecated',
1025         `marital` varchar(255) COMMENT 'Deprecated',
1026         `with` text COMMENT 'Deprecated',
1027         `howlong` datetime COMMENT 'Deprecated',
1028         `sexual` varchar(255) COMMENT 'Deprecated',
1029         `politic` varchar(255) COMMENT 'Deprecated',
1030         `religion` varchar(255) COMMENT 'Deprecated',
1031         `pub_keywords` text COMMENT '',
1032         `prv_keywords` text COMMENT '',
1033         `likes` text COMMENT 'Deprecated',
1034         `dislikes` text COMMENT 'Deprecated',
1035         `about` text COMMENT 'Profile description',
1036         `summary` varchar(255) COMMENT 'Deprecated',
1037         `music` text COMMENT 'Deprecated',
1038         `book` text COMMENT 'Deprecated',
1039         `tv` text COMMENT 'Deprecated',
1040         `film` text COMMENT 'Deprecated',
1041         `interest` text COMMENT 'Deprecated',
1042         `romance` text COMMENT 'Deprecated',
1043         `work` text COMMENT 'Deprecated',
1044         `education` text COMMENT 'Deprecated',
1045         `contact` text COMMENT 'Deprecated',
1046         `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1047         `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1048         `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1049         `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1050         `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1051         `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1052          PRIMARY KEY(`id`),
1053          INDEX `uid_is-default` (`uid`,`is-default`),
1054          FULLTEXT INDEX `pub_keywords` (`pub_keywords`)
1055 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1056
1057 --
1058 -- TABLE profile_check
1059 --
1060 CREATE TABLE IF NOT EXISTS `profile_check` (
1061         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1062         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1063         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1064         `dfrn_id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1065         `sec` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1066         `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1067          PRIMARY KEY(`id`)
1068 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='DFRN remote auth use';
1069
1070 --
1071 -- TABLE profile_field
1072 --
1073 CREATE TABLE IF NOT EXISTS `profile_field` (
1074         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1075         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1076         `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1077         `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1078         `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1079         `value` text COMMENT 'Value of the field',
1080         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1081         `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1082          PRIMARY KEY(`id`),
1083          INDEX `uid` (`uid`),
1084          INDEX `order` (`order`),
1085          INDEX `psid` (`psid`)
1086 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1087
1088 --
1089 -- TABLE push_subscriber
1090 --
1091 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1092         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1093         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1094         `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1095         `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1096         `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1097         `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1098         `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1099         `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1100         `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1101         `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1102          PRIMARY KEY(`id`),
1103          INDEX `next_try` (`next_try`)
1104 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1105
1106 --
1107 -- TABLE register
1108 --
1109 CREATE TABLE IF NOT EXISTS `register` (
1110         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1111         `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1112         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1113         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1114         `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1115         `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1116         `note` text COMMENT '',
1117          PRIMARY KEY(`id`)
1118 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1119
1120 --
1121 -- TABLE search
1122 --
1123 CREATE TABLE IF NOT EXISTS `search` (
1124         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1125         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1126         `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1127          PRIMARY KEY(`id`),
1128          INDEX `uid` (`uid`)
1129 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1130
1131 --
1132 -- TABLE session
1133 --
1134 CREATE TABLE IF NOT EXISTS `session` (
1135         `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1136         `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1137         `data` text COMMENT '',
1138         `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1139          PRIMARY KEY(`id`),
1140          INDEX `sid` (`sid`(64)),
1141          INDEX `expire` (`expire`)
1142 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1143
1144 --
1145 -- TABLE sign
1146 --
1147 CREATE TABLE IF NOT EXISTS `sign` (
1148         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1149         `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'item.id',
1150         `signed_text` mediumtext COMMENT '',
1151         `signature` text COMMENT '',
1152         `signer` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1153          PRIMARY KEY(`id`),
1154          UNIQUE INDEX `iid` (`iid`)
1155 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora signatures';
1156
1157 --
1158 -- TABLE term
1159 --
1160 CREATE TABLE IF NOT EXISTS `term` (
1161         `tid` int unsigned NOT NULL auto_increment COMMENT '',
1162         `oid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1163         `otype` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1164         `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1165         `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1166         `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1167         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1168         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1169         `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1170         `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1171         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1172          PRIMARY KEY(`tid`),
1173          INDEX `term_type` (`term`(64),`type`),
1174          INDEX `oid_otype_type_term` (`oid`,`otype`,`type`,`term`(32)),
1175          INDEX `uid_otype_type_term_global_created` (`uid`,`otype`,`type`,`term`(32),`global`,`created`),
1176          INDEX `uid_otype_type_url` (`uid`,`otype`,`type`,`url`(64)),
1177          INDEX `guid` (`guid`(64))
1178 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='item taxonomy (categories, tags, etc.) table';
1179
1180 --
1181 -- TABLE thread
1182 --
1183 CREATE TABLE IF NOT EXISTS `thread` (
1184         `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'sequential ID',
1185         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1186         `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1187         `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1188         `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1189         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1190         `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1191         `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1192         `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1193         `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1194         `wall` boolean NOT NULL DEFAULT '0' COMMENT '',
1195         `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1196         `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1197         `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
1198         `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1199         `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1200         `ignored` boolean NOT NULL DEFAULT '0' COMMENT '',
1201         `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
1202         `unseen` boolean NOT NULL DEFAULT '1' COMMENT '',
1203         `deleted` boolean NOT NULL DEFAULT '0' COMMENT '',
1204         `origin` boolean NOT NULL DEFAULT '0' COMMENT '',
1205         `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1206         `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1207         `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1208         `bookmark` boolean COMMENT '',
1209          PRIMARY KEY(`iid`),
1210          INDEX `uid_network_commented` (`uid`,`network`,`commented`),
1211          INDEX `uid_network_received` (`uid`,`network`,`received`),
1212          INDEX `uid_contactid_commented` (`uid`,`contact-id`,`commented`),
1213          INDEX `uid_contactid_received` (`uid`,`contact-id`,`received`),
1214          INDEX `contactid` (`contact-id`),
1215          INDEX `ownerid` (`owner-id`),
1216          INDEX `authorid` (`author-id`),
1217          INDEX `uid_received` (`uid`,`received`),
1218          INDEX `uid_commented` (`uid`,`commented`),
1219          INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1220          INDEX `private_wall_origin_commented` (`private`,`wall`,`origin`,`commented`)
1221 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1222
1223 --
1224 -- TABLE tokens
1225 --
1226 CREATE TABLE IF NOT EXISTS `tokens` (
1227         `id` varchar(40) NOT NULL COMMENT '',
1228         `secret` text COMMENT '',
1229         `client_id` varchar(20) NOT NULL DEFAULT '',
1230         `expires` int NOT NULL DEFAULT 0 COMMENT '',
1231         `scope` varchar(200) NOT NULL DEFAULT '' COMMENT '',
1232         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1233          PRIMARY KEY(`id`)
1234 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
1235
1236 --
1237 -- TABLE user
1238 --
1239 CREATE TABLE IF NOT EXISTS `user` (
1240         `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1241         `parent-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'The parent user that has full control about this user',
1242         `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
1243         `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
1244         `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
1245         `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
1246         `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
1247         `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
1248         `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1249         `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
1250         `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
1251         `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
1252         `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
1253         `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
1254         `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
1255         `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
1256         `pubkey` text COMMENT 'RSA public key 4096 bit',
1257         `prvkey` text COMMENT 'RSA private key 4096 bit',
1258         `spubkey` text COMMENT '',
1259         `sprvkey` text COMMENT '',
1260         `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
1261         `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
1262         `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
1263         `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unkown viewers',
1264         `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
1265         `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
1266         `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
1267         `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
1268         `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
1269         `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1270         `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
1271         `pwdreset` varchar(255) COMMENT 'Password reset request token',
1272         `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
1273         `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
1274         `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1275         `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
1276         `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
1277         `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
1278         `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
1279         `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1280         `allow_cid` mediumtext COMMENT 'default permission for this user',
1281         `allow_gid` mediumtext COMMENT 'default permission for this user',
1282         `deny_cid` mediumtext COMMENT 'default permission for this user',
1283         `deny_gid` mediumtext COMMENT 'default permission for this user',
1284         `openidserver` text COMMENT '',
1285          PRIMARY KEY(`uid`),
1286          INDEX `nickname` (`nickname`(32))
1287 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
1288
1289 --
1290 -- TABLE userd
1291 --
1292 CREATE TABLE IF NOT EXISTS `userd` (
1293         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1294         `username` varchar(255) NOT NULL COMMENT '',
1295          PRIMARY KEY(`id`),
1296          INDEX `username` (`username`(32))
1297 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1298
1299 --
1300 -- TABLE user-contact
1301 --
1302 CREATE TABLE IF NOT EXISTS `user-contact` (
1303         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1304         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1305         `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1306         `ignored` boolean COMMENT 'Posts from this contact are ignored',
1307         `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1308          PRIMARY KEY(`uid`,`cid`)
1309 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1310
1311 --
1312 -- TABLE user-item
1313 --
1314 CREATE TABLE IF NOT EXISTS `user-item` (
1315         `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item id',
1316         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1317         `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide an item from the user',
1318         `ignored` boolean COMMENT 'Ignore this thread if set',
1319         `pinned` boolean COMMENT 'The item is pinned on the profile page',
1320         `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1321          PRIMARY KEY(`uid`,`iid`),
1322          INDEX `uid_pinned` (`uid`,`pinned`),
1323          INDEX `iid_uid` (`iid`,`uid`)
1324 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific item data';
1325
1326 --
1327 -- TABLE worker-ipc
1328 --
1329 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1330         `key` int NOT NULL COMMENT '',
1331         `jobs` boolean COMMENT 'Flag for outstanding jobs',
1332          PRIMARY KEY(`key`)
1333 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1334
1335 --
1336 -- TABLE workerqueue
1337 --
1338 CREATE TABLE IF NOT EXISTS `workerqueue` (
1339         `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
1340         `parameter` mediumtext COMMENT 'Task command',
1341         `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
1342         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
1343         `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
1344         `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
1345         `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1346         `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1347         `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
1348          PRIMARY KEY(`id`),
1349          INDEX `done_parameter` (`done`,`parameter`(64)),
1350          INDEX `done_executed` (`done`,`executed`),
1351          INDEX `done_priority_created` (`done`,`priority`,`created`),
1352          INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
1353          INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
1354          INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
1355 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
1356
1357 --
1358 -- TABLE storage
1359 --
1360 CREATE TABLE IF NOT EXISTS `storage` (
1361         `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1362         `data` longblob NOT NULL COMMENT 'file data',
1363          PRIMARY KEY(`id`)
1364 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1365
1366