1 -- ------------------------------------------
2 -- Friendica 2020.09-dev (Red Hot Poker)
3 -- DB_UPDATE_VERSION 1359
4 -- ------------------------------------------
10 CREATE TABLE IF NOT EXISTS `gserver` (
11 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
12 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
13 `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
14 `version` varchar(255) NOT NULL DEFAULT '' COMMENT '',
15 `site_name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
16 `info` text COMMENT '',
17 `register_policy` tinyint NOT NULL DEFAULT 0 COMMENT '',
18 `registered-users` int unsigned NOT NULL DEFAULT 0 COMMENT 'Number of registered users',
19 `directory-type` tinyint DEFAULT 0 COMMENT 'Type of directory service (Poco, Mastodon)',
20 `poco` varchar(255) NOT NULL DEFAULT '' COMMENT '',
21 `noscrape` varchar(255) NOT NULL DEFAULT '' COMMENT '',
22 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
23 `platform` varchar(255) NOT NULL DEFAULT '' COMMENT '',
24 `relay-subscribe` boolean NOT NULL DEFAULT '0' COMMENT 'Has the server subscribed to the relay system',
25 `relay-scope` varchar(10) NOT NULL DEFAULT '' COMMENT 'The scope of messages that the server wants to get',
26 `detection-method` tinyint unsigned COMMENT 'Method that had been used to detect that server',
27 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
28 `last_poco_query` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
29 `last_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
30 `last_failure` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
31 `failed` boolean COMMENT 'Connection failed',
33 UNIQUE INDEX `nurl` (`nurl`(190))
34 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Global servers';
39 CREATE TABLE IF NOT EXISTS `clients` (
40 `client_id` varchar(20) NOT NULL COMMENT '',
41 `pw` varchar(20) NOT NULL DEFAULT '' COMMENT '',
42 `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
43 `name` text COMMENT '',
44 `icon` text COMMENT '',
45 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
46 PRIMARY KEY(`client_id`)
47 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
52 CREATE TABLE IF NOT EXISTS `contact` (
53 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
54 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
55 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
56 `updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last contact update',
57 `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
58 `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
59 `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
60 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
61 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network of the contact',
62 `protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
63 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
64 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
65 `location` varchar(255) DEFAULT '' COMMENT '',
66 `about` text COMMENT '',
67 `keywords` text COMMENT 'public keywords (interests) of the contact',
68 `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
69 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
70 `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
71 `avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '',
72 `photo` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
73 `thumb` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
74 `micro` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
75 `site-pubkey` text COMMENT '',
76 `issued-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
77 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
78 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
79 `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
80 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
81 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
82 `pubkey` text COMMENT 'RSA public key 4096 bit',
83 `prvkey` text COMMENT 'RSA private key 4096 bit',
84 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
85 `request` varchar(255) COMMENT '',
86 `notify` varchar(255) COMMENT '',
87 `poll` varchar(255) COMMENT '',
88 `confirm` varchar(255) COMMENT '',
89 `subscribe` varchar(255) COMMENT '',
90 `poco` varchar(255) COMMENT '',
91 `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT '',
92 `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT '',
93 `usehub` boolean NOT NULL DEFAULT '0' COMMENT '',
94 `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
95 `hub-verify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
96 `last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
97 `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
98 `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
99 `failed` boolean COMMENT 'Connection failed',
100 `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
101 `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
102 `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
103 `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
104 `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
105 `last-discovery` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last follower discovery',
106 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
107 `blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
108 `block_reason` text COMMENT 'Node-wide block reason',
109 `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
110 `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
111 `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum',
112 `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group',
113 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT '',
114 `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
115 `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
116 `pending` boolean NOT NULL DEFAULT '1' COMMENT '',
117 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
118 `rating` tinyint NOT NULL DEFAULT 0 COMMENT '',
119 `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
120 `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
121 `baseurl` varchar(255) DEFAULT '' COMMENT 'baseurl of the contact',
122 `gsid` int unsigned COMMENT 'Global Server ID',
123 `reason` text COMMENT '',
124 `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT '',
125 `info` mediumtext COMMENT '',
126 `profile-id` int unsigned COMMENT 'Deprecated',
127 `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
128 `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
129 `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
130 `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
131 `ffi_keyword_denylist` text COMMENT '',
133 INDEX `uid_name` (`uid`,`name`(190)),
134 INDEX `self_uid` (`self`,`uid`),
135 INDEX `alias_uid` (`alias`(32),`uid`),
136 INDEX `pending_uid` (`pending`,`uid`),
137 INDEX `blocked_uid` (`blocked`,`uid`),
138 INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
139 INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
140 INDEX `addr_uid` (`addr`(32),`uid`),
141 INDEX `nurl_uid` (`nurl`(32),`uid`),
142 INDEX `nick_uid` (`nick`(32),`uid`),
143 INDEX `attag_uid` (`attag`(32),`uid`),
144 INDEX `dfrn-id` (`dfrn-id`(64)),
145 INDEX `issued-id` (`issued-id`(64)),
146 INDEX `network_uid_lastupdate` (`network`,`uid`,`last-update`),
147 INDEX `uid_lastitem` (`uid`,`last-item`),
148 INDEX `gsid` (`gsid`),
149 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
150 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
155 CREATE TABLE IF NOT EXISTS `item-uri` (
156 `id` int unsigned NOT NULL auto_increment,
157 `uri` varbinary(255) NOT NULL COMMENT 'URI of an item',
158 `guid` varbinary(255) COMMENT 'A unique identifier for an item',
160 UNIQUE INDEX `uri` (`uri`),
161 INDEX `guid` (`guid`)
162 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
165 -- TABLE permissionset
167 CREATE TABLE IF NOT EXISTS `permissionset` (
168 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
169 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
170 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
171 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
172 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
173 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
175 INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30))
176 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
181 CREATE TABLE IF NOT EXISTS `tag` (
182 `id` int unsigned NOT NULL auto_increment COMMENT '',
183 `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
184 `url` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
186 UNIQUE INDEX `type_name_url` (`name`,`url`),
188 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
191 -- TABLE 2fa_app_specific_password
193 CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
194 `id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
195 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
196 `description` varchar(255) COMMENT 'Description of the usage of the password',
197 `hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
198 `generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
199 `last_used` datetime COMMENT 'Datetime the password was last used',
201 INDEX `uid_description` (`uid`,`description`(190))
202 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
205 -- TABLE 2fa_recovery_codes
207 CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
208 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
209 `code` varchar(50) NOT NULL COMMENT 'Recovery code string',
210 `generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
211 `used` datetime COMMENT 'Datetime the code was used',
212 PRIMARY KEY(`uid`,`code`)
213 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
218 CREATE TABLE IF NOT EXISTS `addon` (
219 `id` int unsigned NOT NULL auto_increment COMMENT '',
220 `name` varchar(50) NOT NULL DEFAULT '' COMMENT 'addon base (file)name',
221 `version` varchar(50) NOT NULL DEFAULT '' COMMENT 'currently unused',
222 `installed` boolean NOT NULL DEFAULT '0' COMMENT 'currently always 1',
223 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'currently unused',
224 `timestamp` int unsigned NOT NULL DEFAULT 0 COMMENT 'file timestamp to check for reloads',
225 `plugin_admin` boolean NOT NULL DEFAULT '0' COMMENT '1 = has admin config, 0 = has no admin config',
227 UNIQUE INDEX `name` (`name`)
228 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registered addons';
233 CREATE TABLE IF NOT EXISTS `apcontact` (
234 `url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
235 `uuid` varchar(255) COMMENT '',
236 `type` varchar(20) NOT NULL COMMENT '',
237 `following` varchar(255) COMMENT '',
238 `followers` varchar(255) COMMENT '',
239 `inbox` varchar(255) NOT NULL COMMENT '',
240 `outbox` varchar(255) COMMENT '',
241 `sharedinbox` varchar(255) COMMENT '',
242 `manually-approve` boolean COMMENT '',
243 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
244 `name` varchar(255) COMMENT '',
245 `about` text COMMENT '',
246 `photo` varchar(255) COMMENT '',
247 `addr` varchar(255) COMMENT '',
248 `alias` varchar(255) COMMENT '',
249 `pubkey` text COMMENT '',
250 `subscribe` varchar(255) COMMENT '',
251 `baseurl` varchar(255) COMMENT 'baseurl of the ap contact',
252 `gsid` int unsigned COMMENT 'Global Server ID',
253 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
254 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
255 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
256 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
257 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
259 INDEX `addr` (`addr`(32)),
260 INDEX `alias` (`alias`(190)),
261 INDEX `followers` (`followers`(190)),
262 INDEX `baseurl` (`baseurl`(190)),
263 INDEX `gsid` (`gsid`),
264 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
265 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
270 CREATE TABLE IF NOT EXISTS `attach` (
271 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
272 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
273 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
274 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
275 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
276 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
277 `data` longblob NOT NULL COMMENT 'file data',
278 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
279 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
280 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
281 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
282 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
283 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
284 `backend-class` tinytext COMMENT 'Storage backend class',
285 `backend-ref` text COMMENT 'Storage backend data reference',
287 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
292 CREATE TABLE IF NOT EXISTS `auth_codes` (
293 `id` varchar(40) NOT NULL COMMENT '',
294 `client_id` varchar(20) NOT NULL DEFAULT '' COMMENT '',
295 `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
296 `expires` int NOT NULL DEFAULT 0 COMMENT '',
297 `scope` varchar(250) NOT NULL DEFAULT '' COMMENT '',
299 INDEX `client_id` (`client_id`),
300 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE
301 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
306 CREATE TABLE IF NOT EXISTS `cache` (
307 `k` varbinary(255) NOT NULL COMMENT 'cache key',
308 `v` mediumtext COMMENT 'cached serialized value',
309 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
310 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
312 INDEX `k_expires` (`k`,`expires`)
313 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
318 CREATE TABLE IF NOT EXISTS `challenge` (
319 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
320 `challenge` varchar(255) NOT NULL DEFAULT '' COMMENT '',
321 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
322 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
323 `type` varchar(255) NOT NULL DEFAULT '' COMMENT '',
324 `last_update` varchar(255) NOT NULL DEFAULT '' COMMENT '',
326 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
331 CREATE TABLE IF NOT EXISTS `config` (
332 `id` int unsigned NOT NULL auto_increment COMMENT '',
333 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
334 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
335 `v` mediumtext COMMENT '',
337 UNIQUE INDEX `cat_k` (`cat`,`k`)
338 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
341 -- TABLE contact-relation
343 CREATE TABLE IF NOT EXISTS `contact-relation` (
344 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
345 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
346 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
347 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
348 `follows` boolean NOT NULL DEFAULT '0' COMMENT '',
349 PRIMARY KEY(`cid`,`relation-cid`),
350 INDEX `relation-cid` (`relation-cid`),
351 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
352 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
353 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
358 CREATE TABLE IF NOT EXISTS `conv` (
359 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
360 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
361 `recips` text COMMENT 'sender_handle;recipient_handle',
362 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
363 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
364 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
365 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
366 `subject` text COMMENT 'subject of initial message',
369 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
372 -- TABLE conversation
374 CREATE TABLE IF NOT EXISTS `conversation` (
375 `item-uri` varbinary(255) NOT NULL COMMENT 'Original URI of the item - unrelated to the table with the same name',
376 `reply-to-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'URI to which this item is a reply',
377 `conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI',
378 `conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link',
379 `protocol` tinyint unsigned NOT NULL DEFAULT 255 COMMENT 'The protocol of the item',
380 `direction` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'How the message arrived here: 1=push, 2=pull',
381 `source` mediumtext COMMENT 'Original source',
382 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Receiving date',
383 PRIMARY KEY(`item-uri`),
384 INDEX `conversation-uri` (`conversation-uri`),
385 INDEX `received` (`received`)
386 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Raw data and structure information for messages';
389 -- TABLE diaspora-interaction
391 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
392 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
393 `interaction` mediumtext COMMENT 'The Diaspora interaction',
394 PRIMARY KEY(`uri-id`),
395 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
396 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
401 CREATE TABLE IF NOT EXISTS `event` (
402 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
403 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
404 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
405 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
406 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
407 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
408 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
409 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
410 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
411 `summary` text COMMENT 'short description or title of the event',
412 `desc` text COMMENT 'event description',
413 `location` text COMMENT 'event location',
414 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
415 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
416 `adjust` boolean NOT NULL DEFAULT '1' COMMENT 'adjust to timezone of the recipient (0 or 1)',
417 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
418 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
419 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
420 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
421 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
423 INDEX `uid_start` (`uid`,`start`)
424 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
429 CREATE TABLE IF NOT EXISTS `fcontact` (
430 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
431 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
432 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
433 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
434 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
435 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
436 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
437 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
438 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
439 `notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
440 `poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
441 `confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
442 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
443 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
444 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
445 `pubkey` text COMMENT '',
446 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
448 INDEX `addr` (`addr`(32)),
449 UNIQUE INDEX `url` (`url`(190))
450 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
455 CREATE TABLE IF NOT EXISTS `fsuggest` (
456 `id` int unsigned NOT NULL auto_increment COMMENT '',
457 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
458 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
459 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
460 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
461 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
462 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
463 `note` text COMMENT '',
464 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
466 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
471 CREATE TABLE IF NOT EXISTS `group` (
472 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
473 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
474 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
475 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
476 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
479 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
482 -- TABLE group_member
484 CREATE TABLE IF NOT EXISTS `group_member` (
485 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
486 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
487 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
489 INDEX `contactid` (`contact-id`),
490 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`)
491 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
496 CREATE TABLE IF NOT EXISTS `gserver-tag` (
497 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
498 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
499 PRIMARY KEY(`gserver-id`,`tag`),
501 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
506 CREATE TABLE IF NOT EXISTS `hook` (
507 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
508 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
509 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
510 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
511 `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',
513 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
514 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
517 -- TABLE inbox-status
519 CREATE TABLE IF NOT EXISTS `inbox-status` (
520 `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
521 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
522 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
523 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
524 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
525 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
526 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
528 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
533 CREATE TABLE IF NOT EXISTS `intro` (
534 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
535 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
536 `fid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
537 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
538 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
539 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
540 `note` text COMMENT '',
541 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
542 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
543 `blocked` boolean NOT NULL DEFAULT '1' COMMENT '',
544 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
546 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
551 CREATE TABLE IF NOT EXISTS `item` (
552 `id` int unsigned NOT NULL auto_increment,
553 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this item',
554 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
555 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
556 `uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
557 `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',
558 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT 'uri of the parent to this item',
559 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
560 `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',
561 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
562 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
563 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
564 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last comment/reply to this item',
565 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
566 `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',
567 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
568 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
569 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
570 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
571 `icid` int unsigned COMMENT 'Id of the item-content table entry that contains the whole item content',
572 `iaid` int unsigned COMMENT 'Id of the item-activity table entry that contains the activity data',
573 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
574 `extid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
575 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
576 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
577 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
578 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
579 `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
580 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been deleted',
581 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
582 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
583 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
584 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
585 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
586 `starred` boolean NOT NULL DEFAULT '0' COMMENT 'item has been favourited',
587 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'item has not been seen',
588 `mention` boolean NOT NULL DEFAULT '0' COMMENT 'The owner of this item was mentioned in it',
589 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
590 `psid` int unsigned COMMENT 'ID of the permission set of this post',
591 `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',
592 `event-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Used to link to the event.id',
593 `attach` mediumtext COMMENT 'JSON structure representing attachments to this item',
594 `allow_cid` mediumtext COMMENT 'Deprecated',
595 `allow_gid` mediumtext COMMENT 'Deprecated',
596 `deny_cid` mediumtext COMMENT 'Deprecated',
597 `deny_gid` mediumtext COMMENT 'Deprecated',
598 `postopts` text COMMENT 'Deprecated',
599 `inform` mediumtext COMMENT 'Deprecated',
600 `type` varchar(20) COMMENT 'Deprecated',
601 `bookmark` boolean COMMENT 'Deprecated',
602 `file` mediumtext COMMENT 'Deprecated',
603 `location` varchar(255) COMMENT 'Deprecated',
604 `coord` varchar(255) COMMENT 'Deprecated',
605 `tag` mediumtext COMMENT 'Deprecated',
606 `plink` varchar(255) COMMENT 'Deprecated',
607 `title` varchar(255) COMMENT 'Deprecated',
608 `content-warning` varchar(255) COMMENT 'Deprecated',
609 `body` mediumtext COMMENT 'Deprecated',
610 `app` varchar(255) COMMENT 'Deprecated',
611 `verb` varchar(100) COMMENT 'Deprecated',
612 `object-type` varchar(100) COMMENT 'Deprecated',
613 `object` text COMMENT 'Deprecated',
614 `target-type` varchar(100) COMMENT 'Deprecated',
615 `target` text COMMENT 'Deprecated',
616 `author-name` varchar(255) COMMENT 'Deprecated',
617 `author-link` varchar(255) COMMENT 'Deprecated',
618 `author-avatar` varchar(255) COMMENT 'Deprecated',
619 `owner-name` varchar(255) COMMENT 'Deprecated',
620 `owner-link` varchar(255) COMMENT 'Deprecated',
621 `owner-avatar` varchar(255) COMMENT 'Deprecated',
622 `rendered-hash` varchar(32) COMMENT 'Deprecated',
623 `rendered-html` mediumtext COMMENT 'Deprecated',
625 INDEX `guid` (`guid`(191)),
626 INDEX `uri` (`uri`(191)),
627 INDEX `parent` (`parent`),
628 INDEX `parent-uri` (`parent-uri`(191)),
629 INDEX `extid` (`extid`(191)),
630 INDEX `uid_id` (`uid`,`id`),
631 INDEX `uid_contactid_id` (`uid`,`contact-id`,`id`),
632 INDEX `uid_received` (`uid`,`received`),
633 INDEX `uid_commented` (`uid`,`commented`),
634 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
635 INDEX `uid_network_received` (`uid`,`network`,`received`),
636 INDEX `uid_network_commented` (`uid`,`network`,`commented`),
637 INDEX `uid_thrparent` (`uid`,`thr-parent`(190)),
638 INDEX `uid_parenturi` (`uid`,`parent-uri`(190)),
639 INDEX `uid_contactid_received` (`uid`,`contact-id`,`received`),
640 INDEX `authorid_received` (`author-id`,`received`),
641 INDEX `ownerid` (`owner-id`),
642 INDEX `contact-id` (`contact-id`),
643 INDEX `uid_uri` (`uid`,`uri`(190)),
644 INDEX `resource-id` (`resource-id`),
645 INDEX `deleted_changed` (`deleted`,`changed`),
646 INDEX `uid_wall_changed` (`uid`,`wall`,`changed`),
647 INDEX `mention_uid_id` (`mention`,`uid`,`id`),
648 INDEX `uid_eventid` (`uid`,`event-id`),
649 INDEX `icid` (`icid`),
650 INDEX `iaid` (`iaid`),
651 INDEX `psid_wall` (`psid`,`wall`),
652 INDEX `uri-id` (`uri-id`),
653 INDEX `parent-uri-id` (`parent-uri-id`),
654 INDEX `thr-parent-id` (`thr-parent-id`),
655 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
656 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
657 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
658 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
659 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
662 -- TABLE item-activity
664 CREATE TABLE IF NOT EXISTS `item-activity` (
665 `id` int unsigned NOT NULL auto_increment,
666 `uri` varchar(255) COMMENT '',
667 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
668 `uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
669 `activity` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
671 UNIQUE INDEX `uri-hash` (`uri-hash`),
672 INDEX `uri` (`uri`(191)),
673 INDEX `uri-id` (`uri-id`),
674 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
675 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activities for items';
678 -- TABLE item-content
680 CREATE TABLE IF NOT EXISTS `item-content` (
681 `id` int unsigned NOT NULL auto_increment,
682 `uri` varchar(255) COMMENT '',
683 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
684 `uri-plink-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
685 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
686 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
687 `body` mediumtext COMMENT 'item body content',
688 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
689 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
690 `language` text COMMENT 'Language information about this post',
691 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
692 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
693 `rendered-html` mediumtext COMMENT 'item.body converted to html',
694 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
695 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
696 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
697 `target` text COMMENT 'JSON encoded target structure if used',
698 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
699 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams verb',
701 UNIQUE INDEX `uri-plink-hash` (`uri-plink-hash`),
702 INDEX `uri` (`uri`(191)),
703 INDEX `plink` (`plink`(191)),
704 INDEX `uri-id` (`uri-id`),
705 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
706 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
711 CREATE TABLE IF NOT EXISTS `locks` (
712 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
713 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
714 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
715 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
716 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
718 INDEX `name_expires` (`name`,`expires`)
719 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
724 CREATE TABLE IF NOT EXISTS `mail` (
725 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
726 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
727 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
728 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
729 `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
730 `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
731 `contact-id` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact.id',
732 `convid` int unsigned NOT NULL DEFAULT 0 COMMENT 'conv.id',
733 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
734 `body` mediumtext COMMENT '',
735 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
736 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
737 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
738 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
739 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
740 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
741 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
743 INDEX `uid_seen` (`uid`,`seen`),
744 INDEX `convid` (`convid`),
745 INDEX `uri` (`uri`(64)),
746 INDEX `parent-uri` (`parent-uri`(64)),
747 INDEX `contactid` (`contact-id`(32))
748 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
753 CREATE TABLE IF NOT EXISTS `mailacct` (
754 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
755 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
756 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
757 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
758 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
759 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
760 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
761 `pass` text COMMENT '',
762 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
763 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
764 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
765 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
766 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
768 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
773 CREATE TABLE IF NOT EXISTS `manage` (
774 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
775 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
776 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
778 UNIQUE INDEX `uid_mid` (`uid`,`mid`)
779 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
784 CREATE TABLE IF NOT EXISTS `notify` (
785 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
786 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
787 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
788 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
789 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
790 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
791 `msg` mediumtext COMMENT '',
792 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
793 `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
794 `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'item.id',
795 `parent` int unsigned NOT NULL DEFAULT 0 COMMENT '',
796 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
797 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
798 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
799 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
800 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
801 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
802 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
804 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
805 INDEX `uid_date` (`uid`,`date`),
806 INDEX `uid_type_link` (`uid`,`type`,`link`(190))
807 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
810 -- TABLE notify-threads
812 CREATE TABLE IF NOT EXISTS `notify-threads` (
813 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
814 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
815 `master-parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
816 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
817 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
818 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
820 INDEX `master-parent-uri-id` (`master-parent-uri-id`)
821 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
826 CREATE TABLE IF NOT EXISTS `oembed` (
827 `url` varbinary(255) NOT NULL COMMENT 'page url',
828 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
829 `content` mediumtext COMMENT 'OEmbed data of the page',
830 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
831 PRIMARY KEY(`url`,`maxwidth`),
832 INDEX `created` (`created`)
833 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
836 -- TABLE openwebauth-token
838 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
839 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
840 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
841 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
842 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
843 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
844 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
846 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
851 CREATE TABLE IF NOT EXISTS `parsed_url` (
852 `url` varbinary(255) NOT NULL COMMENT 'page url',
853 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
854 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
855 `content` mediumtext COMMENT 'page data',
856 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
857 PRIMARY KEY(`url`,`guessing`,`oembed`),
858 INDEX `created` (`created`)
859 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
862 -- TABLE participation
864 CREATE TABLE IF NOT EXISTS `participation` (
865 `iid` int unsigned NOT NULL COMMENT '',
866 `server` varchar(60) NOT NULL COMMENT '',
867 `cid` int unsigned NOT NULL COMMENT '',
868 `fid` int unsigned NOT NULL COMMENT '',
869 PRIMARY KEY(`iid`,`server`),
872 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Storage for participation messages from Diaspora';
877 CREATE TABLE IF NOT EXISTS `pconfig` (
878 `id` int unsigned NOT NULL auto_increment COMMENT '',
879 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
880 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
881 `k` varbinary(100) NOT NULL DEFAULT '' COMMENT '',
882 `v` mediumtext COMMENT '',
884 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`)
885 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
890 CREATE TABLE IF NOT EXISTS `photo` (
891 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
892 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
893 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
894 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
895 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
896 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
897 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
898 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
899 `desc` text COMMENT '',
900 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
901 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
902 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
903 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
904 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
905 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
906 `data` mediumblob NOT NULL COMMENT '',
907 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
908 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
909 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
910 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
911 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
912 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
913 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
914 `backend-class` tinytext COMMENT 'Storage backend class',
915 `backend-ref` text COMMENT 'Storage backend data reference',
916 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
918 INDEX `contactid` (`contact-id`),
919 INDEX `uid_contactid` (`uid`,`contact-id`),
920 INDEX `uid_profile` (`uid`,`profile`),
921 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
922 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
923 INDEX `resource-id` (`resource-id`)
924 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
929 CREATE TABLE IF NOT EXISTS `poll` (
930 `id` int unsigned NOT NULL auto_increment COMMENT '',
931 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
932 `q0` text COMMENT '',
933 `q1` text COMMENT '',
934 `q2` text COMMENT '',
935 `q3` text COMMENT '',
936 `q4` text COMMENT '',
937 `q5` text COMMENT '',
938 `q6` text COMMENT '',
939 `q7` text COMMENT '',
940 `q8` text COMMENT '',
941 `q9` text COMMENT '',
944 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently unused table for storing poll results';
949 CREATE TABLE IF NOT EXISTS `poll_result` (
950 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
951 `poll_id` int unsigned NOT NULL DEFAULT 0,
952 `choice` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
954 INDEX `poll_id` (`poll_id`)
955 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='data for polls - currently unused';
958 -- TABLE post-category
960 CREATE TABLE IF NOT EXISTS `post-category` (
961 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
962 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
963 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
964 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
965 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
966 INDEX `uri-id` (`tid`),
967 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
968 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
969 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
972 -- TABLE post-delivery-data
974 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
975 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
976 `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',
977 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
978 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
979 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
980 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
981 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
982 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
983 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
984 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
985 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
986 PRIMARY KEY(`uri-id`),
987 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
988 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
993 CREATE TABLE IF NOT EXISTS `post-tag` (
994 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
995 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
996 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
997 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
998 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1000 INDEX `cid` (`cid`),
1001 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1002 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1003 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1004 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1009 CREATE TABLE IF NOT EXISTS `process` (
1010 `pid` int unsigned NOT NULL COMMENT '',
1011 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1012 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1014 INDEX `command` (`command`)
1015 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1020 CREATE TABLE IF NOT EXISTS `profile` (
1021 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1022 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1023 `profile-name` varchar(255) COMMENT 'Deprecated',
1024 `is-default` boolean COMMENT 'Deprecated',
1025 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1026 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1027 `pdesc` varchar(255) COMMENT 'Deprecated',
1028 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1029 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1030 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1031 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1032 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1033 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1034 `hometown` varchar(255) COMMENT 'Deprecated',
1035 `gender` varchar(32) COMMENT 'Deprecated',
1036 `marital` varchar(255) COMMENT 'Deprecated',
1037 `with` text COMMENT 'Deprecated',
1038 `howlong` datetime COMMENT 'Deprecated',
1039 `sexual` varchar(255) COMMENT 'Deprecated',
1040 `politic` varchar(255) COMMENT 'Deprecated',
1041 `religion` varchar(255) COMMENT 'Deprecated',
1042 `pub_keywords` text COMMENT '',
1043 `prv_keywords` text COMMENT '',
1044 `likes` text COMMENT 'Deprecated',
1045 `dislikes` text COMMENT 'Deprecated',
1046 `about` text COMMENT 'Profile description',
1047 `summary` varchar(255) COMMENT 'Deprecated',
1048 `music` text COMMENT 'Deprecated',
1049 `book` text COMMENT 'Deprecated',
1050 `tv` text COMMENT 'Deprecated',
1051 `film` text COMMENT 'Deprecated',
1052 `interest` text COMMENT 'Deprecated',
1053 `romance` text COMMENT 'Deprecated',
1054 `work` text COMMENT 'Deprecated',
1055 `education` text COMMENT 'Deprecated',
1056 `contact` text COMMENT 'Deprecated',
1057 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1058 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1059 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1060 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1061 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1062 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1064 INDEX `uid_is-default` (`uid`,`is-default`),
1065 FULLTEXT INDEX `pub_keywords` (`pub_keywords`)
1066 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1069 -- TABLE profile_check
1071 CREATE TABLE IF NOT EXISTS `profile_check` (
1072 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1073 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1074 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1075 `dfrn_id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1076 `sec` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1077 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1079 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='DFRN remote auth use';
1082 -- TABLE profile_field
1084 CREATE TABLE IF NOT EXISTS `profile_field` (
1085 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1086 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1087 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1088 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1089 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1090 `value` text COMMENT 'Value of the field',
1091 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1092 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1094 INDEX `uid` (`uid`),
1095 INDEX `order` (`order`),
1096 INDEX `psid` (`psid`),
1097 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1098 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1101 -- TABLE push_subscriber
1103 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1104 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1105 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1106 `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1107 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1108 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1109 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1110 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1111 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1112 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1113 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1115 INDEX `next_try` (`next_try`)
1116 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1121 CREATE TABLE IF NOT EXISTS `register` (
1122 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1123 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1124 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1125 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1126 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1127 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1128 `note` text COMMENT '',
1130 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1135 CREATE TABLE IF NOT EXISTS `search` (
1136 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1137 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1138 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1141 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1146 CREATE TABLE IF NOT EXISTS `session` (
1147 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1148 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1149 `data` text COMMENT '',
1150 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1152 INDEX `sid` (`sid`(64)),
1153 INDEX `expire` (`expire`)
1154 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1159 CREATE TABLE IF NOT EXISTS `storage` (
1160 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1161 `data` longblob NOT NULL COMMENT 'file data',
1163 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1168 CREATE TABLE IF NOT EXISTS `thread` (
1169 `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'sequential ID',
1170 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
1171 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1172 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1173 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1174 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1175 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1176 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1177 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1178 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1179 `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1180 `wall` boolean NOT NULL DEFAULT '0' COMMENT '',
1181 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1182 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1183 `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
1184 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1185 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1186 `ignored` boolean NOT NULL DEFAULT '0' COMMENT '',
1187 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
1188 `unseen` boolean NOT NULL DEFAULT '1' COMMENT '',
1189 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '',
1190 `origin` boolean NOT NULL DEFAULT '0' COMMENT '',
1191 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1192 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1193 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1194 `bookmark` boolean COMMENT '',
1196 INDEX `uid_network_commented` (`uid`,`network`,`commented`),
1197 INDEX `uid_network_received` (`uid`,`network`,`received`),
1198 INDEX `uid_contactid_commented` (`uid`,`contact-id`,`commented`),
1199 INDEX `uid_contactid_received` (`uid`,`contact-id`,`received`),
1200 INDEX `contactid` (`contact-id`),
1201 INDEX `ownerid` (`owner-id`),
1202 INDEX `authorid` (`author-id`),
1203 INDEX `uid_received` (`uid`,`received`),
1204 INDEX `uid_commented` (`uid`,`commented`),
1205 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1206 INDEX `private_wall_origin_commented` (`private`,`wall`,`origin`,`commented`),
1207 INDEX `uri-id` (`uri-id`),
1208 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1209 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1214 CREATE TABLE IF NOT EXISTS `tokens` (
1215 `id` varchar(40) NOT NULL COMMENT '',
1216 `secret` text COMMENT '',
1217 `client_id` varchar(20) NOT NULL DEFAULT '',
1218 `expires` int NOT NULL DEFAULT 0 COMMENT '',
1219 `scope` varchar(200) NOT NULL DEFAULT '' COMMENT '',
1220 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1222 INDEX `client_id` (`client_id`),
1223 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE
1224 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
1229 CREATE TABLE IF NOT EXISTS `user` (
1230 `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1231 `parent-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'The parent user that has full control about this user',
1232 `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
1233 `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
1234 `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
1235 `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
1236 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
1237 `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
1238 `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1239 `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
1240 `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
1241 `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
1242 `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
1243 `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
1244 `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
1245 `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
1246 `pubkey` text COMMENT 'RSA public key 4096 bit',
1247 `prvkey` text COMMENT 'RSA private key 4096 bit',
1248 `spubkey` text COMMENT '',
1249 `sprvkey` text COMMENT '',
1250 `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
1251 `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
1252 `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
1253 `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unkown viewers',
1254 `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
1255 `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
1256 `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
1257 `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
1258 `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
1259 `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1260 `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
1261 `pwdreset` varchar(255) COMMENT 'Password reset request token',
1262 `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
1263 `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
1264 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1265 `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
1266 `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
1267 `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
1268 `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
1269 `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1270 `allow_cid` mediumtext COMMENT 'default permission for this user',
1271 `allow_gid` mediumtext COMMENT 'default permission for this user',
1272 `deny_cid` mediumtext COMMENT 'default permission for this user',
1273 `deny_gid` mediumtext COMMENT 'default permission for this user',
1274 `openidserver` text COMMENT '',
1276 INDEX `nickname` (`nickname`(32))
1277 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
1282 CREATE TABLE IF NOT EXISTS `userd` (
1283 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1284 `username` varchar(255) NOT NULL COMMENT '',
1286 INDEX `username` (`username`(32))
1287 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1290 -- TABLE user-contact
1292 CREATE TABLE IF NOT EXISTS `user-contact` (
1293 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1294 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1295 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1296 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1297 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1298 PRIMARY KEY(`uid`,`cid`)
1299 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1304 CREATE TABLE IF NOT EXISTS `user-item` (
1305 `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item id',
1306 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1307 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide an item from the user',
1308 `ignored` boolean COMMENT 'Ignore this thread if set',
1309 `pinned` boolean COMMENT 'The item is pinned on the profile page',
1310 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1311 PRIMARY KEY(`uid`,`iid`),
1312 INDEX `uid_pinned` (`uid`,`pinned`),
1313 INDEX `iid_uid` (`iid`,`uid`)
1314 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific item data';
1319 CREATE TABLE IF NOT EXISTS `verb` (
1320 `id` smallint unsigned NOT NULL auto_increment,
1321 `name` varchar(100) NOT NULL DEFAULT '' COMMENT '',
1323 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activity Verbs';
1328 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1329 `key` int NOT NULL COMMENT '',
1330 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1332 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1335 -- TABLE workerqueue
1337 CREATE TABLE IF NOT EXISTS `workerqueue` (
1338 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
1339 `parameter` mediumtext COMMENT 'Task command',
1340 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
1341 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
1342 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
1343 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
1344 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1345 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1346 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
1348 INDEX `done_parameter` (`done`,`parameter`(64)),
1349 INDEX `done_executed` (`done`,`executed`),
1350 INDEX `done_priority_created` (`done`,`priority`,`created`),
1351 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
1352 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
1353 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
1354 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
1357 -- VIEW category-view
1359 DROP VIEW IF EXISTS `category-view`;
1360 CREATE VIEW `category-view` AS SELECT
1361 `post-category`.`uri-id` AS `uri-id`,
1362 `post-category`.`uid` AS `uid`,
1363 `item-uri`.`uri` AS `uri`,
1364 `item-uri`.`guid` AS `guid`,
1365 `post-category`.`type` AS `type`,
1366 `post-category`.`tid` AS `tid`,
1367 `tag`.`name` AS `name`,
1368 `tag`.`url` AS `url`
1369 FROM `post-category`
1370 INNER JOIN `item-uri` ON `item-uri`.id = `post-category`.`uri-id`
1371 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
1376 DROP VIEW IF EXISTS `tag-view`;
1377 CREATE VIEW `tag-view` AS SELECT
1378 `post-tag`.`uri-id` AS `uri-id`,
1379 `item-uri`.`uri` AS `uri`,
1380 `item-uri`.`guid` AS `guid`,
1381 `post-tag`.`type` AS `type`,
1382 `post-tag`.`tid` AS `tid`,
1383 `post-tag`.`cid` AS `cid`,
1384 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
1385 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
1387 INNER JOIN `item-uri` ON `item-uri`.id = `post-tag`.`uri-id`
1388 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
1389 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
1394 DROP VIEW IF EXISTS `owner-view`;
1395 CREATE VIEW `owner-view` AS SELECT
1396 `contact`.`id` AS `id`,
1397 `contact`.`uid` AS `uid`,
1398 `contact`.`created` AS `created`,
1399 `contact`.`updated` AS `updated`,
1400 `contact`.`self` AS `self`,
1401 `contact`.`remote_self` AS `remote_self`,
1402 `contact`.`rel` AS `rel`,
1403 `contact`.`duplex` AS `duplex`,
1404 `contact`.`network` AS `network`,
1405 `contact`.`protocol` AS `protocol`,
1406 `contact`.`name` AS `name`,
1407 `contact`.`nick` AS `nick`,
1408 `contact`.`location` AS `location`,
1409 `contact`.`about` AS `about`,
1410 `contact`.`keywords` AS `keywords`,
1411 `contact`.`gender` AS `gender`,
1412 `contact`.`xmpp` AS `xmpp`,
1413 `contact`.`attag` AS `attag`,
1414 `contact`.`avatar` AS `avatar`,
1415 `contact`.`photo` AS `photo`,
1416 `contact`.`thumb` AS `thumb`,
1417 `contact`.`micro` AS `micro`,
1418 `contact`.`site-pubkey` AS `site-pubkey`,
1419 `contact`.`issued-id` AS `issued-id`,
1420 `contact`.`dfrn-id` AS `dfrn-id`,
1421 `contact`.`url` AS `url`,
1422 `contact`.`nurl` AS `nurl`,
1423 `contact`.`addr` AS `addr`,
1424 `contact`.`alias` AS `alias`,
1425 `contact`.`pubkey` AS `pubkey`,
1426 `contact`.`prvkey` AS `prvkey`,
1427 `contact`.`batch` AS `batch`,
1428 `contact`.`request` AS `request`,
1429 `contact`.`notify` AS `notify`,
1430 `contact`.`poll` AS `poll`,
1431 `contact`.`confirm` AS `confirm`,
1432 `contact`.`poco` AS `poco`,
1433 `contact`.`aes_allow` AS `aes_allow`,
1434 `contact`.`ret-aes` AS `ret-aes`,
1435 `contact`.`usehub` AS `usehub`,
1436 `contact`.`subhub` AS `subhub`,
1437 `contact`.`hub-verify` AS `hub-verify`,
1438 `contact`.`last-update` AS `last-update`,
1439 `contact`.`success_update` AS `success_update`,
1440 `contact`.`failure_update` AS `failure_update`,
1441 `contact`.`name-date` AS `name-date`,
1442 `contact`.`uri-date` AS `uri-date`,
1443 `contact`.`avatar-date` AS `avatar-date`,
1444 `contact`.`avatar-date` AS `picdate`,
1445 `contact`.`term-date` AS `term-date`,
1446 `contact`.`last-item` AS `last-item`,
1447 `contact`.`priority` AS `priority`,
1448 `contact`.`blocked` AS `blocked`,
1449 `contact`.`block_reason` AS `block_reason`,
1450 `contact`.`readonly` AS `readonly`,
1451 `contact`.`writable` AS `writable`,
1452 `contact`.`forum` AS `forum`,
1453 `contact`.`prv` AS `prv`,
1454 `contact`.`contact-type` AS `contact-type`,
1455 `contact`.`hidden` AS `hidden`,
1456 `contact`.`archive` AS `archive`,
1457 `contact`.`pending` AS `pending`,
1458 `contact`.`deleted` AS `deleted`,
1459 `contact`.`rating` AS `rating`,
1460 `contact`.`unsearchable` AS `unsearchable`,
1461 `contact`.`sensitive` AS `sensitive`,
1462 `contact`.`baseurl` AS `baseurl`,
1463 `contact`.`reason` AS `reason`,
1464 `contact`.`closeness` AS `closeness`,
1465 `contact`.`info` AS `info`,
1466 `contact`.`profile-id` AS `profile-id`,
1467 `contact`.`bdyear` AS `bdyear`,
1468 `contact`.`bd` AS `bd`,
1469 `contact`.`notify_new_posts` AS `notify_new_posts`,
1470 `contact`.`fetch_further_information` AS `fetch_further_information`,
1471 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
1472 `user`.`parent-uid` AS `parent-uid`,
1473 `user`.`guid` AS `guid`,
1474 `user`.`nickname` AS `nickname`,
1475 `user`.`email` AS `email`,
1476 `user`.`openid` AS `openid`,
1477 `user`.`timezone` AS `timezone`,
1478 `user`.`language` AS `language`,
1479 `user`.`register_date` AS `register_date`,
1480 `user`.`login_date` AS `login_date`,
1481 `user`.`default-location` AS `default-location`,
1482 `user`.`allow_location` AS `allow_location`,
1483 `user`.`theme` AS `theme`,
1484 `user`.`pubkey` AS `upubkey`,
1485 `user`.`prvkey` AS `uprvkey`,
1486 `user`.`sprvkey` AS `sprvkey`,
1487 `user`.`spubkey` AS `spubkey`,
1488 `user`.`verified` AS `verified`,
1489 `user`.`blockwall` AS `blockwall`,
1490 `user`.`hidewall` AS `hidewall`,
1491 `user`.`blocktags` AS `blocktags`,
1492 `user`.`unkmail` AS `unkmail`,
1493 `user`.`cntunkmail` AS `cntunkmail`,
1494 `user`.`notify-flags` AS `notify-flags`,
1495 `user`.`page-flags` AS `page-flags`,
1496 `user`.`account-type` AS `account-type`,
1497 `user`.`prvnets` AS `prvnets`,
1498 `user`.`maxreq` AS `maxreq`,
1499 `user`.`expire` AS `expire`,
1500 `user`.`account_removed` AS `account_removed`,
1501 `user`.`account_expired` AS `account_expired`,
1502 `user`.`account_expires_on` AS `account_expires_on`,
1503 `user`.`expire_notification_sent` AS `expire_notification_sent`,
1504 `user`.`def_gid` AS `def_gid`,
1505 `user`.`allow_cid` AS `allow_cid`,
1506 `user`.`allow_gid` AS `allow_gid`,
1507 `user`.`deny_cid` AS `deny_cid`,
1508 `user`.`deny_gid` AS `deny_gid`,
1509 `user`.`openidserver` AS `openidserver`,
1510 `profile`.`publish` AS `publish`,
1511 `profile`.`net-publish` AS `net-publish`,
1512 `profile`.`hide-friends` AS `hide-friends`,
1513 `profile`.`prv_keywords` AS `prv_keywords`,
1514 `profile`.`pub_keywords` AS `pub_keywords`,
1515 `profile`.`address` AS `address`,
1516 `profile`.`locality` AS `locality`,
1517 `profile`.`region` AS `region`,
1518 `profile`.`postal-code` AS `postal-code`,
1519 `profile`.`country-name` AS `country-name`,
1520 `profile`.`homepage` AS `homepage`,
1521 `profile`.`dob` AS `dob`
1523 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
1524 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
1527 -- VIEW pending-view
1529 DROP VIEW IF EXISTS `pending-view`;
1530 CREATE VIEW `pending-view` AS SELECT
1531 `register`.`id` AS `id`,
1532 `register`.`hash` AS `hash`,
1533 `register`.`created` AS `created`,
1534 `register`.`uid` AS `uid`,
1535 `register`.`password` AS `password`,
1536 `register`.`language` AS `language`,
1537 `register`.`note` AS `note`,
1538 `contact`.`self` AS `self`,
1539 `contact`.`name` AS `name`,
1540 `contact`.`url` AS `url`,
1541 `contact`.`micro` AS `micro`,
1542 `user`.`email` AS `email`,
1543 `contact`.`nick` AS `nick`
1545 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
1546 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
1549 -- VIEW tag-search-view
1551 DROP VIEW IF EXISTS `tag-search-view`;
1552 CREATE VIEW `tag-search-view` AS SELECT
1553 `post-tag`.`uri-id` AS `uri-id`,
1554 `item`.`id` AS `iid`,
1555 `item`.`uri` AS `uri`,
1556 `item`.`guid` AS `guid`,
1557 `item`.`uid` AS `uid`,
1558 `item`.`private` AS `private`,
1559 `item`.`wall` AS `wall`,
1560 `item`.`origin` AS `origin`,
1561 `item`.`gravity` AS `gravity`,
1562 `item`.`received` AS `received`,
1563 `tag`.`name` AS `name`
1565 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
1566 INNER JOIN `item` ON `item`.`uri-id` = `post-tag`.`uri-id`
1567 WHERE `post-tag`.`type` = 1;
1570 -- VIEW workerqueue-view
1572 DROP VIEW IF EXISTS `workerqueue-view`;
1573 CREATE VIEW `workerqueue-view` AS SELECT
1574 `process`.`pid` AS `pid`,
1575 `workerqueue`.`priority` AS `priority`
1577 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
1578 WHERE NOT `workerqueue`.`done`;