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