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