1 -- ------------------------------------------
2 -- Friendica 2020.06-dev (Red Hot Poker)
3 -- DB_UPDATE_VERSION 1343
4 -- ------------------------------------------
8 -- TABLE 2fa_app_specific_password
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',
18 INDEX `uid_description` (`uid`,`description`(190))
19 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
22 -- TABLE 2fa_recovery_codes
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';
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',
44 UNIQUE INDEX `name` (`name`)
45 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registered addons';
50 CREATE TABLE IF NOT EXISTS `apcontact` (
51 `url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
52 `uuid` varchar(255) COMMENT '',
53 `type` varchar(20) NOT NULL COMMENT '',
54 `following` varchar(255) COMMENT '',
55 `followers` varchar(255) COMMENT '',
56 `inbox` varchar(255) NOT NULL COMMENT '',
57 `outbox` varchar(255) COMMENT '',
58 `sharedinbox` varchar(255) COMMENT '',
59 `manually-approve` boolean COMMENT '',
60 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
61 `name` varchar(255) COMMENT '',
62 `about` text COMMENT '',
63 `photo` varchar(255) COMMENT '',
64 `addr` varchar(255) COMMENT '',
65 `alias` varchar(255) COMMENT '',
66 `pubkey` text COMMENT '',
67 `baseurl` varchar(255) COMMENT 'baseurl of the ap contact',
68 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
69 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
70 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
71 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
72 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
74 INDEX `addr` (`addr`(32)),
75 INDEX `alias` (`alias`(190)),
76 INDEX `url` (`followers`(190))
77 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
82 CREATE TABLE IF NOT EXISTS `attach` (
83 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
84 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
85 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
86 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
87 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
88 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
89 `data` longblob NOT NULL COMMENT 'file data',
90 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
91 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
92 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
93 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
94 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
95 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
96 `backend-class` tinytext COMMENT 'Storage backend class',
97 `backend-ref` text COMMENT 'Storage backend data reference',
99 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
104 CREATE TABLE IF NOT EXISTS `auth_codes` (
105 `id` varchar(40) NOT NULL COMMENT '',
106 `client_id` varchar(20) NOT NULL DEFAULT '' COMMENT '',
107 `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
108 `expires` int NOT NULL DEFAULT 0 COMMENT '',
109 `scope` varchar(250) NOT NULL DEFAULT '' COMMENT '',
111 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
116 CREATE TABLE IF NOT EXISTS `cache` (
117 `k` varbinary(255) NOT NULL COMMENT 'cache key',
118 `v` mediumtext COMMENT 'cached serialized value',
119 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
120 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
122 INDEX `k_expires` (`k`,`expires`)
123 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
128 CREATE TABLE IF NOT EXISTS `challenge` (
129 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
130 `challenge` varchar(255) NOT NULL DEFAULT '' COMMENT '',
131 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
132 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
133 `type` varchar(255) NOT NULL DEFAULT '' COMMENT '',
134 `last_update` varchar(255) NOT NULL DEFAULT '' COMMENT '',
136 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
141 CREATE TABLE IF NOT EXISTS `clients` (
142 `client_id` varchar(20) NOT NULL COMMENT '',
143 `pw` varchar(20) NOT NULL DEFAULT '' COMMENT '',
144 `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
145 `name` text COMMENT '',
146 `icon` text COMMENT '',
147 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
148 PRIMARY KEY(`client_id`)
149 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
154 CREATE TABLE IF NOT EXISTS `config` (
155 `id` int unsigned NOT NULL auto_increment COMMENT '',
156 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
157 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
158 `v` mediumtext COMMENT '',
160 UNIQUE INDEX `cat_k` (`cat`,`k`)
161 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
166 CREATE TABLE IF NOT EXISTS `contact` (
167 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
168 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
169 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
170 `updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last contact update',
171 `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
172 `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
173 `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
174 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
175 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network of the contact',
176 `protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
177 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
178 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
179 `location` varchar(255) DEFAULT '' COMMENT '',
180 `about` text COMMENT '',
181 `keywords` text COMMENT 'public keywords (interests) of the contact',
182 `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
183 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
184 `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
185 `avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '',
186 `photo` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
187 `thumb` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
188 `micro` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
189 `site-pubkey` text COMMENT '',
190 `issued-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
191 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
192 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
193 `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
194 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
195 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
196 `pubkey` text COMMENT 'RSA public key 4096 bit',
197 `prvkey` text COMMENT 'RSA private key 4096 bit',
198 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
199 `request` varchar(255) COMMENT '',
200 `notify` varchar(255) COMMENT '',
201 `poll` varchar(255) COMMENT '',
202 `confirm` varchar(255) COMMENT '',
203 `poco` varchar(255) COMMENT '',
204 `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT '',
205 `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT '',
206 `usehub` boolean NOT NULL DEFAULT '0' COMMENT '',
207 `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
208 `hub-verify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
209 `last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
210 `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
211 `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
212 `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
213 `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
214 `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
215 `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
216 `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
217 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
218 `blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
219 `block_reason` text COMMENT 'Node-wide block reason',
220 `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
221 `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
222 `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum',
223 `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group',
224 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT '',
225 `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
226 `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
227 `pending` boolean NOT NULL DEFAULT '1' COMMENT '',
228 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
229 `rating` tinyint NOT NULL DEFAULT 0 COMMENT '',
230 `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
231 `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
232 `baseurl` varchar(255) DEFAULT '' COMMENT 'baseurl of the contact',
233 `reason` text COMMENT '',
234 `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT '',
235 `info` mediumtext COMMENT '',
236 `profile-id` int unsigned COMMENT 'Deprecated',
237 `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
238 `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
239 `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
240 `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
241 `ffi_keyword_blacklist` text COMMENT '',
243 INDEX `uid_name` (`uid`,`name`(190)),
244 INDEX `self_uid` (`self`,`uid`),
245 INDEX `alias_uid` (`alias`(32),`uid`),
246 INDEX `pending_uid` (`pending`,`uid`),
247 INDEX `blocked_uid` (`blocked`,`uid`),
248 INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
249 INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
250 INDEX `addr_uid` (`addr`(32),`uid`),
251 INDEX `nurl_uid` (`nurl`(32),`uid`),
252 INDEX `nick_uid` (`nick`(32),`uid`),
253 INDEX `dfrn-id` (`dfrn-id`(64)),
254 INDEX `issued-id` (`issued-id`(64))
255 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
258 -- TABLE contact-relation
260 CREATE TABLE IF NOT EXISTS `contact-relation` (
261 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
262 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
263 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
264 PRIMARY KEY(`cid`,`relation-cid`),
265 INDEX `relation-cid` (`relation-cid`)
266 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
271 CREATE TABLE IF NOT EXISTS `conv` (
272 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
273 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
274 `recips` text COMMENT 'sender_handle;recipient_handle',
275 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
276 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
277 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
278 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
279 `subject` text COMMENT 'subject of initial message',
282 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
285 -- TABLE conversation
287 CREATE TABLE IF NOT EXISTS `conversation` (
288 `item-uri` varbinary(255) NOT NULL COMMENT 'Original URI of the item - unrelated to the table with the same name',
289 `reply-to-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'URI to which this item is a reply',
290 `conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI',
291 `conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link',
292 `protocol` tinyint unsigned NOT NULL DEFAULT 255 COMMENT 'The protocol of the item',
293 `direction` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'How the message arrived here: 1=push, 2=pull',
294 `source` mediumtext COMMENT 'Original source',
295 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Receiving date',
296 PRIMARY KEY(`item-uri`),
297 INDEX `conversation-uri` (`conversation-uri`),
298 INDEX `received` (`received`)
299 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Raw data and structure information for messages';
302 -- TABLE diaspora-interaction
304 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
305 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
306 `interaction` mediumtext COMMENT 'The Diaspora interaction',
307 PRIMARY KEY(`uri-id`)
308 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
313 CREATE TABLE IF NOT EXISTS `event` (
314 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
315 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
316 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
317 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
318 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
319 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
320 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
321 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
322 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
323 `summary` text COMMENT 'short description or title of the event',
324 `desc` text COMMENT 'event description',
325 `location` text COMMENT 'event location',
326 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
327 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
328 `adjust` boolean NOT NULL DEFAULT '1' COMMENT 'adjust to timezone of the recipient (0 or 1)',
329 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
330 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
331 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
332 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
333 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
335 INDEX `uid_start` (`uid`,`start`)
336 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
341 CREATE TABLE IF NOT EXISTS `fcontact` (
342 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
343 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
344 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
345 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
346 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
347 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
348 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
349 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
350 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
351 `notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
352 `poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
353 `confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
354 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
355 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
356 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
357 `pubkey` text COMMENT '',
358 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
360 INDEX `addr` (`addr`(32)),
361 UNIQUE INDEX `url` (`url`(190))
362 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
367 CREATE TABLE IF NOT EXISTS `fsuggest` (
368 `id` int unsigned NOT NULL auto_increment COMMENT '',
369 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
370 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
371 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
372 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
373 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
374 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
375 `note` text COMMENT '',
376 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
378 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
383 CREATE TABLE IF NOT EXISTS `gcign` (
384 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
385 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Local User id',
386 `gcid` int unsigned NOT NULL DEFAULT 0 COMMENT 'gcontact.id of ignored contact',
389 INDEX `gcid` (`gcid`)
390 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contacts ignored by friend suggestions';
395 CREATE TABLE IF NOT EXISTS `gcontact` (
396 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
397 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
398 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
399 `url` varchar(255) NOT NULL DEFAULT '' COMMENT 'Link to the contacts profile page',
400 `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
401 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'Link to the profile photo',
402 `connect` varchar(255) NOT NULL DEFAULT '' COMMENT '',
403 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
404 `updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
405 `last_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
406 `last_failure` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
407 `last_discovery` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last contact discovery',
408 `archive_date` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
409 `archived` boolean NOT NULL DEFAULT '0' COMMENT '',
410 `location` varchar(255) NOT NULL DEFAULT '' COMMENT '',
411 `about` text COMMENT '',
412 `keywords` text COMMENT 'puplic keywords (interests)',
413 `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
414 `birthday` varchar(32) NOT NULL DEFAULT '0001-01-01' COMMENT '',
415 `community` boolean NOT NULL DEFAULT '0' COMMENT '1 if contact is forum account',
416 `contact-type` tinyint NOT NULL DEFAULT -1 COMMENT '',
417 `hide` boolean NOT NULL DEFAULT '0' COMMENT '1 = should be hidden from search',
418 `nsfw` boolean NOT NULL DEFAULT '0' COMMENT '1 = contact posts nsfw content',
419 `network` char(4) NOT NULL DEFAULT '' COMMENT 'social network protocol',
420 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
421 `notify` varchar(255) COMMENT '',
422 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
423 `generation` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
424 `server_url` varchar(255) NOT NULL DEFAULT '' COMMENT 'baseurl of the contacts server',
426 UNIQUE INDEX `nurl` (`nurl`(190)),
427 INDEX `name` (`name`(64)),
428 INDEX `nick` (`nick`(32)),
429 INDEX `addr` (`addr`(64)),
430 INDEX `hide_network_updated` (`hide`,`network`,`updated`),
431 INDEX `updated` (`updated`)
432 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='global contacts';
437 CREATE TABLE IF NOT EXISTS `gfollower` (
438 `gcid` int unsigned NOT NULL DEFAULT 0 COMMENT 'global contact',
439 `follower-gcid` int unsigned NOT NULL DEFAULT 0 COMMENT 'global contact of the follower',
440 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates that the connection has been deleted',
441 PRIMARY KEY(`gcid`,`follower-gcid`),
442 INDEX `follower-gcid` (`follower-gcid`)
443 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Followers of global contacts';
448 CREATE TABLE IF NOT EXISTS `glink` (
449 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
450 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
451 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
452 `gcid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
453 `zcid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
454 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
456 UNIQUE INDEX `cid_uid_gcid_zcid` (`cid`,`uid`,`gcid`,`zcid`),
457 INDEX `gcid` (`gcid`)
458 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='\'friends of friends\' linkages derived from poco';
463 CREATE TABLE IF NOT EXISTS `group` (
464 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
465 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
466 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
467 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
468 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
471 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
474 -- TABLE group_member
476 CREATE TABLE IF NOT EXISTS `group_member` (
477 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
478 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
479 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
481 INDEX `contactid` (`contact-id`),
482 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`)
483 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
488 CREATE TABLE IF NOT EXISTS `gserver` (
489 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
490 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
491 `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
492 `version` varchar(255) NOT NULL DEFAULT '' COMMENT '',
493 `site_name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
494 `info` text COMMENT '',
495 `register_policy` tinyint NOT NULL DEFAULT 0 COMMENT '',
496 `registered-users` int unsigned NOT NULL DEFAULT 0 COMMENT 'Number of registered users',
497 `directory-type` tinyint DEFAULT 0 COMMENT 'Type of directory service (Poco, Mastodon)',
498 `poco` varchar(255) NOT NULL DEFAULT '' COMMENT '',
499 `noscrape` varchar(255) NOT NULL DEFAULT '' COMMENT '',
500 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
501 `platform` varchar(255) NOT NULL DEFAULT '' COMMENT '',
502 `relay-subscribe` boolean NOT NULL DEFAULT '0' COMMENT 'Has the server subscribed to the relay system',
503 `relay-scope` varchar(10) NOT NULL DEFAULT '' COMMENT 'The scope of messages that the server wants to get',
504 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
505 `last_poco_query` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
506 `last_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
507 `last_failure` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
509 UNIQUE INDEX `nurl` (`nurl`(190))
510 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Global servers';
515 CREATE TABLE IF NOT EXISTS `gserver-tag` (
516 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
517 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
518 PRIMARY KEY(`gserver-id`,`tag`),
520 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
525 CREATE TABLE IF NOT EXISTS `hook` (
526 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
527 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
528 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
529 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
530 `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',
532 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
533 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
536 -- TABLE inbox-status
538 CREATE TABLE IF NOT EXISTS `inbox-status` (
539 `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
540 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
541 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
542 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
543 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
544 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
545 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
547 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
552 CREATE TABLE IF NOT EXISTS `intro` (
553 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
554 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
555 `fid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
556 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
557 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
558 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
559 `note` text COMMENT '',
560 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
561 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
562 `blocked` boolean NOT NULL DEFAULT '1' COMMENT '',
563 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
565 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
570 CREATE TABLE IF NOT EXISTS `item` (
571 `id` int unsigned NOT NULL auto_increment,
572 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this item',
573 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
574 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
575 `uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
576 `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',
577 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT 'uri of the parent to this item',
578 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
579 `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',
580 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
581 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
582 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
583 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last comment/reply to this item',
584 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
585 `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',
586 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
587 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
588 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
589 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
590 `icid` int unsigned COMMENT 'Id of the item-content table entry that contains the whole item content',
591 `iaid` int unsigned COMMENT 'Id of the item-activity table entry that contains the activity data',
592 `extid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
593 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
594 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
595 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
596 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
597 `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
598 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been deleted',
599 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
600 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
601 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
602 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
603 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
604 `starred` boolean NOT NULL DEFAULT '0' COMMENT 'item has been favourited',
605 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'item has not been seen',
606 `mention` boolean NOT NULL DEFAULT '0' COMMENT 'The owner of this item was mentioned in it',
607 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
608 `psid` int unsigned COMMENT 'ID of the permission set of this post',
609 `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',
610 `event-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Used to link to the event.id',
611 `attach` mediumtext COMMENT 'JSON structure representing attachments to this item',
612 `allow_cid` mediumtext COMMENT 'Deprecated',
613 `allow_gid` mediumtext COMMENT 'Deprecated',
614 `deny_cid` mediumtext COMMENT 'Deprecated',
615 `deny_gid` mediumtext COMMENT 'Deprecated',
616 `postopts` text COMMENT 'Deprecated',
617 `inform` mediumtext COMMENT 'Deprecated',
618 `type` varchar(20) COMMENT 'Deprecated',
619 `bookmark` boolean COMMENT 'Deprecated',
620 `file` mediumtext COMMENT 'Deprecated',
621 `location` varchar(255) COMMENT 'Deprecated',
622 `coord` varchar(255) COMMENT 'Deprecated',
623 `tag` mediumtext COMMENT 'Deprecated',
624 `plink` varchar(255) COMMENT 'Deprecated',
625 `title` varchar(255) COMMENT 'Deprecated',
626 `content-warning` varchar(255) COMMENT 'Deprecated',
627 `body` mediumtext COMMENT 'Deprecated',
628 `app` varchar(255) COMMENT 'Deprecated',
629 `verb` varchar(100) COMMENT 'Deprecated',
630 `object-type` varchar(100) COMMENT 'Deprecated',
631 `object` text COMMENT 'Deprecated',
632 `target-type` varchar(100) COMMENT 'Deprecated',
633 `target` text COMMENT 'Deprecated',
634 `author-name` varchar(255) COMMENT 'Deprecated',
635 `author-link` varchar(255) COMMENT 'Deprecated',
636 `author-avatar` varchar(255) COMMENT 'Deprecated',
637 `owner-name` varchar(255) COMMENT 'Deprecated',
638 `owner-link` varchar(255) COMMENT 'Deprecated',
639 `owner-avatar` varchar(255) COMMENT 'Deprecated',
640 `rendered-hash` varchar(32) COMMENT 'Deprecated',
641 `rendered-html` mediumtext COMMENT 'Deprecated',
643 INDEX `guid` (`guid`(191)),
644 INDEX `uri` (`uri`(191)),
645 INDEX `parent` (`parent`),
646 INDEX `parent-uri` (`parent-uri`(191)),
647 INDEX `extid` (`extid`(191)),
648 INDEX `uid_id` (`uid`,`id`),
649 INDEX `uid_contactid_id` (`uid`,`contact-id`,`id`),
650 INDEX `uid_received` (`uid`,`received`),
651 INDEX `uid_commented` (`uid`,`commented`),
652 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
653 INDEX `uid_network_received` (`uid`,`network`,`received`),
654 INDEX `uid_network_commented` (`uid`,`network`,`commented`),
655 INDEX `uid_thrparent` (`uid`,`thr-parent`(190)),
656 INDEX `uid_parenturi` (`uid`,`parent-uri`(190)),
657 INDEX `uid_contactid_received` (`uid`,`contact-id`,`received`),
658 INDEX `authorid_received` (`author-id`,`received`),
659 INDEX `ownerid` (`owner-id`),
660 INDEX `contact-id` (`contact-id`),
661 INDEX `uid_uri` (`uid`,`uri`(190)),
662 INDEX `resource-id` (`resource-id`),
663 INDEX `deleted_changed` (`deleted`,`changed`),
664 INDEX `uid_wall_changed` (`uid`,`wall`,`changed`),
665 INDEX `mention_uid_id` (`mention`,`uid`,`id`),
666 INDEX `uid_eventid` (`uid`,`event-id`),
667 INDEX `icid` (`icid`),
668 INDEX `iaid` (`iaid`),
669 INDEX `psid_wall` (`psid`,`wall`),
670 INDEX `uri-id` (`uri-id`)
671 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
674 -- TABLE item-activity
676 CREATE TABLE IF NOT EXISTS `item-activity` (
677 `id` int unsigned NOT NULL auto_increment,
678 `uri` varchar(255) COMMENT '',
679 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
680 `uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
681 `activity` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
683 UNIQUE INDEX `uri-hash` (`uri-hash`),
684 INDEX `uri` (`uri`(191)),
685 INDEX `uri-id` (`uri-id`)
686 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activities for items';
689 -- TABLE item-content
691 CREATE TABLE IF NOT EXISTS `item-content` (
692 `id` int unsigned NOT NULL auto_increment,
693 `uri` varchar(255) COMMENT '',
694 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
695 `uri-plink-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
696 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
697 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
698 `body` mediumtext COMMENT 'item body content',
699 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
700 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
701 `language` text COMMENT 'Language information about this post',
702 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
703 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
704 `rendered-html` mediumtext COMMENT 'item.body converted to html',
705 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
706 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
707 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
708 `target` text COMMENT 'JSON encoded target structure if used',
709 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
710 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams verb',
712 UNIQUE INDEX `uri-plink-hash` (`uri-plink-hash`),
713 INDEX `uri` (`uri`(191)),
714 INDEX `plink` (`plink`(191)),
715 INDEX `uri-id` (`uri-id`)
716 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
719 -- TABLE item-delivery-data
721 CREATE TABLE IF NOT EXISTS `item-delivery-data` (
722 `iid` int unsigned NOT NULL COMMENT 'Item id',
723 `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',
724 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
725 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
726 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
727 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
728 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
729 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
730 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
731 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
732 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
734 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
739 CREATE TABLE IF NOT EXISTS `item-uri` (
740 `id` int unsigned NOT NULL auto_increment,
741 `uri` varbinary(255) NOT NULL COMMENT 'URI of an item',
742 `guid` varbinary(255) COMMENT 'A unique identifier for an item',
744 UNIQUE INDEX `uri` (`uri`),
745 INDEX `guid` (`guid`)
746 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
751 CREATE TABLE IF NOT EXISTS `locks` (
752 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
753 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
754 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
755 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
756 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
758 INDEX `name_expires` (`name`,`expires`)
759 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
764 CREATE TABLE IF NOT EXISTS `mail` (
765 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
766 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
767 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
768 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
769 `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
770 `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
771 `contact-id` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact.id',
772 `convid` int unsigned NOT NULL DEFAULT 0 COMMENT 'conv.id',
773 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
774 `body` mediumtext COMMENT '',
775 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
776 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
777 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
778 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
779 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
780 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
781 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
783 INDEX `uid_seen` (`uid`,`seen`),
784 INDEX `convid` (`convid`),
785 INDEX `uri` (`uri`(64)),
786 INDEX `parent-uri` (`parent-uri`(64)),
787 INDEX `contactid` (`contact-id`(32))
788 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
793 CREATE TABLE IF NOT EXISTS `mailacct` (
794 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
795 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
796 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
797 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
798 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
799 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
800 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
801 `pass` text COMMENT '',
802 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
803 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
804 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
805 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
806 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
808 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
813 CREATE TABLE IF NOT EXISTS `manage` (
814 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
815 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
816 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
818 UNIQUE INDEX `uid_mid` (`uid`,`mid`)
819 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
824 CREATE TABLE IF NOT EXISTS `notify` (
825 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
826 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
827 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
828 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
829 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
830 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
831 `msg` mediumtext COMMENT '',
832 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
833 `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
834 `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'item.id',
835 `parent` int unsigned NOT NULL DEFAULT 0 COMMENT '',
836 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
837 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
838 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
839 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
840 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
842 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
843 INDEX `uid_date` (`uid`,`date`),
844 INDEX `uid_type_link` (`uid`,`type`,`link`(190))
845 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
848 -- TABLE notify-threads
850 CREATE TABLE IF NOT EXISTS `notify-threads` (
851 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
852 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
853 `master-parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
854 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
855 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
857 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
862 CREATE TABLE IF NOT EXISTS `oembed` (
863 `url` varbinary(255) NOT NULL COMMENT 'page url',
864 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
865 `content` mediumtext COMMENT 'OEmbed data of the page',
866 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
867 PRIMARY KEY(`url`,`maxwidth`),
868 INDEX `created` (`created`)
869 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
872 -- TABLE openwebauth-token
874 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
875 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
876 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
877 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
878 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
879 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
880 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
882 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
887 CREATE TABLE IF NOT EXISTS `parsed_url` (
888 `url` varbinary(255) NOT NULL COMMENT 'page url',
889 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
890 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
891 `content` mediumtext COMMENT 'page data',
892 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
893 PRIMARY KEY(`url`,`guessing`,`oembed`),
894 INDEX `created` (`created`)
895 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
898 -- TABLE participation
900 CREATE TABLE IF NOT EXISTS `participation` (
901 `iid` int unsigned NOT NULL COMMENT '',
902 `server` varchar(60) NOT NULL COMMENT '',
903 `cid` int unsigned NOT NULL COMMENT '',
904 `fid` int unsigned NOT NULL COMMENT '',
905 PRIMARY KEY(`iid`,`server`),
908 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Storage for participation messages from Diaspora';
913 CREATE TABLE IF NOT EXISTS `pconfig` (
914 `id` int unsigned NOT NULL auto_increment COMMENT '',
915 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
916 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
917 `k` varbinary(100) NOT NULL DEFAULT '' COMMENT '',
918 `v` mediumtext COMMENT '',
920 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`)
921 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
924 -- TABLE permissionset
926 CREATE TABLE IF NOT EXISTS `permissionset` (
927 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
928 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
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',
934 INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30))
935 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
940 CREATE TABLE IF NOT EXISTS `photo` (
941 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
942 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
943 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
944 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
945 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
946 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
947 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
948 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
949 `desc` text COMMENT '',
950 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
951 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
952 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
953 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
954 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
955 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
956 `data` mediumblob NOT NULL COMMENT '',
957 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
958 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
959 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
960 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
961 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
962 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
963 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
964 `backend-class` tinytext COMMENT 'Storage backend class',
965 `backend-ref` text COMMENT 'Storage backend data reference',
966 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
968 INDEX `contactid` (`contact-id`),
969 INDEX `uid_contactid` (`uid`,`contact-id`),
970 INDEX `uid_profile` (`uid`,`profile`),
971 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
972 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
973 INDEX `resource-id` (`resource-id`)
974 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
979 CREATE TABLE IF NOT EXISTS `poll` (
980 `id` int unsigned NOT NULL auto_increment COMMENT '',
981 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
982 `q0` text COMMENT '',
983 `q1` text COMMENT '',
984 `q2` text COMMENT '',
985 `q3` text COMMENT '',
986 `q4` text COMMENT '',
987 `q5` text COMMENT '',
988 `q6` text COMMENT '',
989 `q7` text COMMENT '',
990 `q8` text COMMENT '',
991 `q9` text COMMENT '',
994 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently unused table for storing poll results';
999 CREATE TABLE IF NOT EXISTS `poll_result` (
1000 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1001 `poll_id` int unsigned NOT NULL DEFAULT 0,
1002 `choice` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1004 INDEX `poll_id` (`poll_id`)
1005 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='data for polls - currently unused';
1010 CREATE TABLE IF NOT EXISTS `process` (
1011 `pid` int unsigned NOT NULL COMMENT '',
1012 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1013 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1015 INDEX `command` (`command`)
1016 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1021 CREATE TABLE IF NOT EXISTS `profile` (
1022 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1023 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1024 `profile-name` varchar(255) COMMENT 'Deprecated',
1025 `is-default` boolean COMMENT 'Deprecated',
1026 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1027 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1028 `pdesc` varchar(255) COMMENT 'Deprecated',
1029 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1030 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1031 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1032 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1033 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1034 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1035 `hometown` varchar(255) COMMENT 'Deprecated',
1036 `gender` varchar(32) COMMENT 'Deprecated',
1037 `marital` varchar(255) COMMENT 'Deprecated',
1038 `with` text COMMENT 'Deprecated',
1039 `howlong` datetime COMMENT 'Deprecated',
1040 `sexual` varchar(255) COMMENT 'Deprecated',
1041 `politic` varchar(255) COMMENT 'Deprecated',
1042 `religion` varchar(255) COMMENT 'Deprecated',
1043 `pub_keywords` text COMMENT '',
1044 `prv_keywords` text COMMENT '',
1045 `likes` text COMMENT 'Deprecated',
1046 `dislikes` text COMMENT 'Deprecated',
1047 `about` text COMMENT 'Profile description',
1048 `summary` varchar(255) COMMENT 'Deprecated',
1049 `music` text COMMENT 'Deprecated',
1050 `book` text COMMENT 'Deprecated',
1051 `tv` text COMMENT 'Deprecated',
1052 `film` text COMMENT 'Deprecated',
1053 `interest` text COMMENT 'Deprecated',
1054 `romance` text COMMENT 'Deprecated',
1055 `work` text COMMENT 'Deprecated',
1056 `education` text COMMENT 'Deprecated',
1057 `contact` text COMMENT 'Deprecated',
1058 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1059 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1060 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1061 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1062 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1063 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1065 INDEX `uid_is-default` (`uid`,`is-default`),
1066 FULLTEXT INDEX `pub_keywords` (`pub_keywords`)
1067 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1070 -- TABLE profile_check
1072 CREATE TABLE IF NOT EXISTS `profile_check` (
1073 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1074 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1075 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1076 `dfrn_id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1077 `sec` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1078 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1080 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='DFRN remote auth use';
1083 -- TABLE profile_field
1085 CREATE TABLE IF NOT EXISTS `profile_field` (
1086 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1087 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1088 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1089 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1090 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1091 `value` text COMMENT 'Value of the field',
1092 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1093 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1095 INDEX `uid` (`uid`),
1096 INDEX `order` (`order`),
1097 INDEX `psid` (`psid`)
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 `term` (
1160 `tid` int unsigned NOT NULL auto_increment COMMENT '',
1161 `oid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1162 `otype` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1163 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1164 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1165 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1166 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1167 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1168 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1169 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1170 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1172 INDEX `term_type` (`term`(64),`type`),
1173 INDEX `oid_otype_type_term` (`oid`,`otype`,`type`,`term`(32)),
1174 INDEX `uid_otype_type_term_global_created` (`uid`,`otype`,`type`,`term`(32),`global`,`created`),
1175 INDEX `uid_otype_type_url` (`uid`,`otype`,`type`,`url`(64)),
1176 INDEX `guid` (`guid`(64))
1177 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='item taxonomy (categories, tags, etc.) table';
1182 CREATE TABLE IF NOT EXISTS `tag` (
1183 `id` int unsigned NOT NULL auto_increment COMMENT '',
1184 `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
1185 `url` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1187 UNIQUE INDEX `type_name_url` (`name`,`url`),
1189 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
1194 CREATE TABLE IF NOT EXISTS `post-tag` (
1195 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1196 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1197 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1198 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1199 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1200 INDEX `uri-id` (`tid`),
1202 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1207 CREATE TABLE IF NOT EXISTS `thread` (
1208 `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'sequential ID',
1209 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1210 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1211 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1212 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1213 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1214 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1215 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1216 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1217 `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1218 `wall` boolean NOT NULL DEFAULT '0' COMMENT '',
1219 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1220 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1221 `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
1222 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1223 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1224 `ignored` boolean NOT NULL DEFAULT '0' COMMENT '',
1225 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
1226 `unseen` boolean NOT NULL DEFAULT '1' COMMENT '',
1227 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '',
1228 `origin` boolean NOT NULL DEFAULT '0' COMMENT '',
1229 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1230 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1231 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1232 `bookmark` boolean COMMENT '',
1234 INDEX `uid_network_commented` (`uid`,`network`,`commented`),
1235 INDEX `uid_network_received` (`uid`,`network`,`received`),
1236 INDEX `uid_contactid_commented` (`uid`,`contact-id`,`commented`),
1237 INDEX `uid_contactid_received` (`uid`,`contact-id`,`received`),
1238 INDEX `contactid` (`contact-id`),
1239 INDEX `ownerid` (`owner-id`),
1240 INDEX `authorid` (`author-id`),
1241 INDEX `uid_received` (`uid`,`received`),
1242 INDEX `uid_commented` (`uid`,`commented`),
1243 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1244 INDEX `private_wall_origin_commented` (`private`,`wall`,`origin`,`commented`)
1245 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1250 CREATE TABLE IF NOT EXISTS `tokens` (
1251 `id` varchar(40) NOT NULL COMMENT '',
1252 `secret` text COMMENT '',
1253 `client_id` varchar(20) NOT NULL DEFAULT '',
1254 `expires` int NOT NULL DEFAULT 0 COMMENT '',
1255 `scope` varchar(200) NOT NULL DEFAULT '' COMMENT '',
1256 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1258 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
1263 CREATE TABLE IF NOT EXISTS `user` (
1264 `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1265 `parent-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'The parent user that has full control about this user',
1266 `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
1267 `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
1268 `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
1269 `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
1270 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
1271 `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
1272 `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1273 `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
1274 `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
1275 `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
1276 `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
1277 `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
1278 `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
1279 `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
1280 `pubkey` text COMMENT 'RSA public key 4096 bit',
1281 `prvkey` text COMMENT 'RSA private key 4096 bit',
1282 `spubkey` text COMMENT '',
1283 `sprvkey` text COMMENT '',
1284 `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
1285 `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
1286 `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
1287 `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unkown viewers',
1288 `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
1289 `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
1290 `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
1291 `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
1292 `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
1293 `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1294 `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
1295 `pwdreset` varchar(255) COMMENT 'Password reset request token',
1296 `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
1297 `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
1298 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1299 `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
1300 `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
1301 `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
1302 `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
1303 `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1304 `allow_cid` mediumtext COMMENT 'default permission for this user',
1305 `allow_gid` mediumtext COMMENT 'default permission for this user',
1306 `deny_cid` mediumtext COMMENT 'default permission for this user',
1307 `deny_gid` mediumtext COMMENT 'default permission for this user',
1308 `openidserver` text COMMENT '',
1310 INDEX `nickname` (`nickname`(32))
1311 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
1316 CREATE TABLE IF NOT EXISTS `userd` (
1317 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1318 `username` varchar(255) NOT NULL COMMENT '',
1320 INDEX `username` (`username`(32))
1321 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1324 -- TABLE user-contact
1326 CREATE TABLE IF NOT EXISTS `user-contact` (
1327 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1328 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1329 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1330 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1331 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1332 PRIMARY KEY(`uid`,`cid`)
1333 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1338 CREATE TABLE IF NOT EXISTS `user-item` (
1339 `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item id',
1340 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1341 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide an item from the user',
1342 `ignored` boolean COMMENT 'Ignore this thread if set',
1343 `pinned` boolean COMMENT 'The item is pinned on the profile page',
1344 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1345 PRIMARY KEY(`uid`,`iid`),
1346 INDEX `uid_pinned` (`uid`,`pinned`),
1347 INDEX `iid_uid` (`iid`,`uid`)
1348 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific item data';
1353 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1354 `key` int NOT NULL COMMENT '',
1355 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1357 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1360 -- TABLE workerqueue
1362 CREATE TABLE IF NOT EXISTS `workerqueue` (
1363 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
1364 `parameter` mediumtext COMMENT 'Task command',
1365 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
1366 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
1367 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
1368 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
1369 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1370 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1371 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
1373 INDEX `done_parameter` (`done`,`parameter`(64)),
1374 INDEX `done_executed` (`done`,`executed`),
1375 INDEX `done_priority_created` (`done`,`priority`,`created`),
1376 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
1377 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
1378 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
1379 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
1384 CREATE TABLE IF NOT EXISTS `storage` (
1385 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1386 `data` longblob NOT NULL COMMENT 'file data',
1388 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1393 DROP VIEW IF EXISTS `tag-view`;
1394 CREATE VIEW `tag-view` AS SELECT
1395 `post-tag`.`uri-id` AS `uri-id`,
1396 `item-uri`.`uri` AS `uri`,
1397 `item-uri`.`guid` AS `guid`,
1398 `post-tag`.`type` AS `type`,
1399 `post-tag`.`tid` AS `tid`,
1400 `post-tag`.`cid` AS `cid`,
1401 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
1402 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
1404 INNER JOIN `item-uri` ON `item-uri`.id = `post-tag`.`uri-id`
1405 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
1406 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
1411 DROP VIEW IF EXISTS `owner-view`;
1412 CREATE VIEW `owner-view` AS SELECT
1413 `contact`.`id` AS `id`,
1414 `contact`.`uid` AS `uid`,
1415 `contact`.`created` AS `created`,
1416 `contact`.`updated` AS `updated`,
1417 `contact`.`self` AS `self`,
1418 `contact`.`remote_self` AS `remote_self`,
1419 `contact`.`rel` AS `rel`,
1420 `contact`.`duplex` AS `duplex`,
1421 `contact`.`network` AS `network`,
1422 `contact`.`protocol` AS `protocol`,
1423 `contact`.`name` AS `name`,
1424 `contact`.`nick` AS `nick`,
1425 `contact`.`location` AS `location`,
1426 `contact`.`about` AS `about`,
1427 `contact`.`keywords` AS `keywords`,
1428 `contact`.`gender` AS `gender`,
1429 `contact`.`xmpp` AS `xmpp`,
1430 `contact`.`attag` AS `attag`,
1431 `contact`.`avatar` AS `avatar`,
1432 `contact`.`photo` AS `photo`,
1433 `contact`.`thumb` AS `thumb`,
1434 `contact`.`micro` AS `micro`,
1435 `contact`.`site-pubkey` AS `site-pubkey`,
1436 `contact`.`issued-id` AS `issued-id`,
1437 `contact`.`dfrn-id` AS `dfrn-id`,
1438 `contact`.`url` AS `url`,
1439 `contact`.`nurl` AS `nurl`,
1440 `contact`.`addr` AS `addr`,
1441 `contact`.`alias` AS `alias`,
1442 `contact`.`pubkey` AS `pubkey`,
1443 `contact`.`prvkey` AS `prvkey`,
1444 `contact`.`batch` AS `batch`,
1445 `contact`.`request` AS `request`,
1446 `contact`.`notify` AS `notify`,
1447 `contact`.`poll` AS `poll`,
1448 `contact`.`confirm` AS `confirm`,
1449 `contact`.`poco` AS `poco`,
1450 `contact`.`aes_allow` AS `aes_allow`,
1451 `contact`.`ret-aes` AS `ret-aes`,
1452 `contact`.`usehub` AS `usehub`,
1453 `contact`.`subhub` AS `subhub`,
1454 `contact`.`hub-verify` AS `hub-verify`,
1455 `contact`.`last-update` AS `last-update`,
1456 `contact`.`success_update` AS `success_update`,
1457 `contact`.`failure_update` AS `failure_update`,
1458 `contact`.`name-date` AS `name-date`,
1459 `contact`.`uri-date` AS `uri-date`,
1460 `contact`.`avatar-date` AS `avatar-date`,
1461 `contact`.`avatar-date` AS `picdate`,
1462 `contact`.`term-date` AS `term-date`,
1463 `contact`.`last-item` AS `last-item`,
1464 `contact`.`priority` AS `priority`,
1465 `contact`.`blocked` AS `blocked`,
1466 `contact`.`block_reason` AS `block_reason`,
1467 `contact`.`readonly` AS `readonly`,
1468 `contact`.`writable` AS `writable`,
1469 `contact`.`forum` AS `forum`,
1470 `contact`.`prv` AS `prv`,
1471 `contact`.`contact-type` AS `contact-type`,
1472 `contact`.`hidden` AS `hidden`,
1473 `contact`.`archive` AS `archive`,
1474 `contact`.`pending` AS `pending`,
1475 `contact`.`deleted` AS `deleted`,
1476 `contact`.`rating` AS `rating`,
1477 `contact`.`unsearchable` AS `unsearchable`,
1478 `contact`.`sensitive` AS `sensitive`,
1479 `contact`.`baseurl` AS `baseurl`,
1480 `contact`.`reason` AS `reason`,
1481 `contact`.`closeness` AS `closeness`,
1482 `contact`.`info` AS `info`,
1483 `contact`.`profile-id` AS `profile-id`,
1484 `contact`.`bdyear` AS `bdyear`,
1485 `contact`.`bd` AS `bd`,
1486 `contact`.`notify_new_posts` AS `notify_new_posts`,
1487 `contact`.`fetch_further_information` AS `fetch_further_information`,
1488 `contact`.`ffi_keyword_blacklist` AS `ffi_keyword_blacklist`,
1489 `user`.`parent-uid` AS `parent-uid`,
1490 `user`.`guid` AS `guid`,
1491 `user`.`nickname` AS `nickname`,
1492 `user`.`email` AS `email`,
1493 `user`.`openid` AS `openid`,
1494 `user`.`timezone` AS `timezone`,
1495 `user`.`language` AS `language`,
1496 `user`.`register_date` AS `register_date`,
1497 `user`.`login_date` AS `login_date`,
1498 `user`.`default-location` AS `default-location`,
1499 `user`.`allow_location` AS `allow_location`,
1500 `user`.`theme` AS `theme`,
1501 `user`.`pubkey` AS `upubkey`,
1502 `user`.`prvkey` AS `uprvkey`,
1503 `user`.`sprvkey` AS `sprvkey`,
1504 `user`.`spubkey` AS `spubkey`,
1505 `user`.`verified` AS `verified`,
1506 `user`.`blockwall` AS `blockwall`,
1507 `user`.`hidewall` AS `hidewall`,
1508 `user`.`blocktags` AS `blocktags`,
1509 `user`.`unkmail` AS `unkmail`,
1510 `user`.`cntunkmail` AS `cntunkmail`,
1511 `user`.`notify-flags` AS `notify-flags`,
1512 `user`.`page-flags` AS `page-flags`,
1513 `user`.`account-type` AS `account-type`,
1514 `user`.`prvnets` AS `prvnets`,
1515 `user`.`maxreq` AS `maxreq`,
1516 `user`.`expire` AS `expire`,
1517 `user`.`account_removed` AS `account_removed`,
1518 `user`.`account_expired` AS `account_expired`,
1519 `user`.`account_expires_on` AS `account_expires_on`,
1520 `user`.`expire_notification_sent` AS `expire_notification_sent`,
1521 `user`.`def_gid` AS `def_gid`,
1522 `user`.`allow_cid` AS `allow_cid`,
1523 `user`.`allow_gid` AS `allow_gid`,
1524 `user`.`deny_cid` AS `deny_cid`,
1525 `user`.`deny_gid` AS `deny_gid`,
1526 `user`.`openidserver` AS `openidserver`,
1527 `profile`.`publish` AS `publish`,
1528 `profile`.`net-publish` AS `net-publish`,
1529 `profile`.`hide-friends` AS `hide-friends`,
1530 `profile`.`prv_keywords` AS `prv_keywords`,
1531 `profile`.`pub_keywords` AS `pub_keywords`,
1532 `profile`.`address` AS `address`,
1533 `profile`.`locality` AS `locality`,
1534 `profile`.`region` AS `region`,
1535 `profile`.`postal-code` AS `postal-code`,
1536 `profile`.`country-name` AS `country-name`,
1537 `profile`.`homepage` AS `homepage`,
1538 `profile`.`dob` AS `dob`
1540 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
1541 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
1544 -- VIEW pending-view
1546 DROP VIEW IF EXISTS `pending-view`;
1547 CREATE VIEW `pending-view` AS SELECT
1548 `register`.`id` AS `id`,
1549 `register`.`hash` AS `hash`,
1550 `register`.`created` AS `created`,
1551 `register`.`uid` AS `uid`,
1552 `register`.`password` AS `password`,
1553 `register`.`language` AS `language`,
1554 `register`.`note` AS `note`,
1555 `contact`.`self` AS `self`,
1556 `contact`.`name` AS `name`,
1557 `contact`.`url` AS `url`,
1558 `contact`.`micro` AS `micro`,
1559 `user`.`email` AS `email`,
1560 `contact`.`nick` AS `nick`
1562 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
1563 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
1566 -- VIEW tag-search-view
1568 DROP VIEW IF EXISTS `tag-search-view`;
1569 CREATE VIEW `tag-search-view` AS SELECT
1570 `post-tag`.`uri-id` AS `uri-id`,
1571 `item`.`id` AS `iid`,
1572 `item`.`uri` AS `uri`,
1573 `item`.`guid` AS `guid`,
1574 `item`.`uid` AS `uid`,
1575 `item`.`private` AS `private`,
1576 `item`.`wall` AS `wall`,
1577 `item`.`origin` AS `origin`,
1578 `item`.`gravity` AS `gravity`,
1579 `item`.`received` AS `received`,
1580 `tag`.`name` AS `name`
1582 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
1583 INNER JOIN `item` ON `item`.`uri-id` = `post-tag`.`uri-id`
1584 WHERE `post-tag`.`type` = 1;
1587 -- VIEW workerqueue-view
1589 DROP VIEW IF EXISTS `workerqueue-view`;
1590 CREATE VIEW `workerqueue-view` AS SELECT
1591 `process`.`pid` AS `pid`,
1592 `workerqueue`.`priority` AS `priority`
1594 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
1595 WHERE NOT `workerqueue`.`done`;