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