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