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