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