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