1 -- ------------------------------------------
2 -- Friendica 2020.12-dev (Red Hot Poker)
3 -- DB_UPDATE_VERSION 1378
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 `user` (
40 `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
41 `parent-uid` mediumint unsigned COMMENT 'The parent user that has full control about this user',
42 `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
43 `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
44 `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
45 `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
46 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
47 `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
48 `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
49 `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
50 `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
51 `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
52 `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
53 `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
54 `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
55 `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
56 `pubkey` text COMMENT 'RSA public key 4096 bit',
57 `prvkey` text COMMENT 'RSA private key 4096 bit',
58 `spubkey` text COMMENT '',
59 `sprvkey` text COMMENT '',
60 `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
61 `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
62 `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
63 `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unkown viewers',
64 `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
65 `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
66 `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
67 `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
68 `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
69 `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
70 `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
71 `pwdreset` varchar(255) COMMENT 'Password reset request token',
72 `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
73 `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
74 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
75 `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
76 `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
77 `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
78 `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
79 `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
80 `allow_cid` mediumtext COMMENT 'default permission for this user',
81 `allow_gid` mediumtext COMMENT 'default permission for this user',
82 `deny_cid` mediumtext COMMENT 'default permission for this user',
83 `deny_gid` mediumtext COMMENT 'default permission for this user',
84 `openidserver` text COMMENT '',
86 INDEX `nickname` (`nickname`(32)),
87 INDEX `parent-uid` (`parent-uid`),
88 FOREIGN KEY (`parent-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
89 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
94 CREATE TABLE IF NOT EXISTS `contact` (
95 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
96 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
97 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
98 `updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last contact update',
99 `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
100 `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
101 `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
102 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
103 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network of the contact',
104 `protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
105 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
106 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
107 `location` varchar(255) DEFAULT '' COMMENT '',
108 `about` text COMMENT '',
109 `keywords` text COMMENT 'public keywords (interests) of the contact',
110 `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
111 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
112 `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
113 `avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '',
114 `photo` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
115 `thumb` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
116 `micro` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
117 `site-pubkey` text COMMENT '',
118 `issued-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
119 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
120 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
121 `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
122 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
123 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
124 `pubkey` text COMMENT 'RSA public key 4096 bit',
125 `prvkey` text COMMENT 'RSA private key 4096 bit',
126 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
127 `request` varchar(255) COMMENT '',
128 `notify` varchar(255) COMMENT '',
129 `poll` varchar(255) COMMENT '',
130 `confirm` varchar(255) COMMENT '',
131 `subscribe` varchar(255) COMMENT '',
132 `poco` varchar(255) COMMENT '',
133 `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT '',
134 `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT '',
135 `usehub` boolean NOT NULL DEFAULT '0' COMMENT '',
136 `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
137 `hub-verify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
138 `last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
139 `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
140 `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
141 `failed` boolean COMMENT 'Connection failed',
142 `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
143 `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
144 `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
145 `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
146 `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
147 `last-discovery` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last follower discovery',
148 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
149 `blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
150 `block_reason` text COMMENT 'Node-wide block reason',
151 `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
152 `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
153 `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum',
154 `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group',
155 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT '',
156 `manually-approve` boolean COMMENT '',
157 `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
158 `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
159 `pending` boolean NOT NULL DEFAULT '1' COMMENT '',
160 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
161 `rating` tinyint NOT NULL DEFAULT 0 COMMENT '',
162 `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
163 `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
164 `baseurl` varchar(255) DEFAULT '' COMMENT 'baseurl of the contact',
165 `gsid` int unsigned COMMENT 'Global Server ID',
166 `reason` text COMMENT '',
167 `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT '',
168 `info` mediumtext COMMENT '',
169 `profile-id` int unsigned COMMENT 'Deprecated',
170 `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
171 `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
172 `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
173 `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
174 `ffi_keyword_denylist` text COMMENT '',
176 INDEX `uid_name` (`uid`,`name`(190)),
177 INDEX `self_uid` (`self`,`uid`),
178 INDEX `alias_uid` (`alias`(128),`uid`),
179 INDEX `pending_uid` (`pending`,`uid`),
180 INDEX `blocked_uid` (`blocked`,`uid`),
181 INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
182 INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
183 INDEX `addr_uid` (`addr`(128),`uid`),
184 INDEX `nurl_uid` (`nurl`(128),`uid`),
185 INDEX `nick_uid` (`nick`(128),`uid`),
186 INDEX `attag_uid` (`attag`(96),`uid`),
187 INDEX `dfrn-id` (`dfrn-id`(64)),
188 INDEX `issued-id` (`issued-id`(64)),
189 INDEX `network_uid_lastupdate` (`network`,`uid`,`last-update`),
190 INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`),
191 INDEX `uid_lastitem` (`uid`,`last-item`),
192 INDEX `gsid` (`gsid`),
193 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
194 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
195 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
200 CREATE TABLE IF NOT EXISTS `item-uri` (
201 `id` int unsigned NOT NULL auto_increment,
202 `uri` varbinary(255) NOT NULL COMMENT 'URI of an item',
203 `guid` varbinary(255) COMMENT 'A unique identifier for an item',
205 UNIQUE INDEX `uri` (`uri`),
206 INDEX `guid` (`guid`)
207 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
212 CREATE TABLE IF NOT EXISTS `tag` (
213 `id` int unsigned NOT NULL auto_increment COMMENT '',
214 `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
215 `url` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
217 UNIQUE INDEX `type_name_url` (`name`,`url`),
219 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
224 CREATE TABLE IF NOT EXISTS `clients` (
225 `client_id` varchar(20) NOT NULL COMMENT '',
226 `pw` varchar(20) NOT NULL DEFAULT '' COMMENT '',
227 `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
228 `name` text COMMENT '',
229 `icon` text COMMENT '',
230 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
231 PRIMARY KEY(`client_id`),
233 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
234 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
237 -- TABLE permissionset
239 CREATE TABLE IF NOT EXISTS `permissionset` (
240 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
241 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
242 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
243 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
244 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
245 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
247 INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`uid`,`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30)),
248 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
249 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
254 CREATE TABLE IF NOT EXISTS `verb` (
255 `id` smallint unsigned NOT NULL auto_increment,
256 `name` varchar(100) NOT NULL DEFAULT '' COMMENT '',
258 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activity Verbs';
261 -- TABLE 2fa_app_specific_password
263 CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
264 `id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
265 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
266 `description` varchar(255) COMMENT 'Description of the usage of the password',
267 `hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
268 `generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
269 `last_used` datetime COMMENT 'Datetime the password was last used',
271 INDEX `uid_description` (`uid`,`description`(190)),
272 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
273 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
276 -- TABLE 2fa_recovery_codes
278 CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
279 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
280 `code` varchar(50) NOT NULL COMMENT 'Recovery code string',
281 `generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
282 `used` datetime COMMENT 'Datetime the code was used',
283 PRIMARY KEY(`uid`,`code`),
284 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
285 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
290 CREATE TABLE IF NOT EXISTS `addon` (
291 `id` int unsigned NOT NULL auto_increment COMMENT '',
292 `name` varchar(50) NOT NULL DEFAULT '' COMMENT 'addon base (file)name',
293 `version` varchar(50) NOT NULL DEFAULT '' COMMENT 'currently unused',
294 `installed` boolean NOT NULL DEFAULT '0' COMMENT 'currently always 1',
295 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'currently unused',
296 `timestamp` int unsigned NOT NULL DEFAULT 0 COMMENT 'file timestamp to check for reloads',
297 `plugin_admin` boolean NOT NULL DEFAULT '0' COMMENT '1 = has admin config, 0 = has no admin config',
299 UNIQUE INDEX `name` (`name`)
300 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registered addons';
305 CREATE TABLE IF NOT EXISTS `apcontact` (
306 `url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
307 `uuid` varchar(255) COMMENT '',
308 `type` varchar(20) NOT NULL COMMENT '',
309 `following` varchar(255) COMMENT '',
310 `followers` varchar(255) COMMENT '',
311 `inbox` varchar(255) NOT NULL COMMENT '',
312 `outbox` varchar(255) COMMENT '',
313 `sharedinbox` varchar(255) COMMENT '',
314 `manually-approve` boolean COMMENT '',
315 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
316 `name` varchar(255) COMMENT '',
317 `about` text COMMENT '',
318 `photo` varchar(255) COMMENT '',
319 `addr` varchar(255) COMMENT '',
320 `alias` varchar(255) COMMENT '',
321 `pubkey` text COMMENT '',
322 `subscribe` varchar(255) COMMENT '',
323 `baseurl` varchar(255) COMMENT 'baseurl of the ap contact',
324 `gsid` int unsigned COMMENT 'Global Server ID',
325 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
326 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
327 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
328 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
329 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
331 INDEX `addr` (`addr`(32)),
332 INDEX `alias` (`alias`(190)),
333 INDEX `followers` (`followers`(190)),
334 INDEX `baseurl` (`baseurl`(190)),
335 INDEX `gsid` (`gsid`),
336 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
337 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
342 CREATE TABLE IF NOT EXISTS `attach` (
343 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
344 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
345 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
346 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
347 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
348 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
349 `data` longblob NOT NULL COMMENT 'file data',
350 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
351 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
352 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
353 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
354 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
355 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
356 `backend-class` tinytext COMMENT 'Storage backend class',
357 `backend-ref` text COMMENT 'Storage backend data reference',
360 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
361 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
366 CREATE TABLE IF NOT EXISTS `auth_codes` (
367 `id` varchar(40) NOT NULL COMMENT '',
368 `client_id` varchar(20) NOT NULL DEFAULT '' COMMENT '',
369 `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
370 `expires` int NOT NULL DEFAULT 0 COMMENT '',
371 `scope` varchar(250) NOT NULL DEFAULT '' COMMENT '',
373 INDEX `client_id` (`client_id`),
374 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE
375 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
380 CREATE TABLE IF NOT EXISTS `cache` (
381 `k` varbinary(255) NOT NULL COMMENT 'cache key',
382 `v` mediumtext COMMENT 'cached serialized value',
383 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
384 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
386 INDEX `k_expires` (`k`,`expires`)
387 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
392 CREATE TABLE IF NOT EXISTS `challenge` (
393 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
394 `challenge` varchar(255) NOT NULL DEFAULT '' COMMENT '',
395 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
396 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
397 `type` varchar(255) NOT NULL DEFAULT '' COMMENT '',
398 `last_update` varchar(255) NOT NULL DEFAULT '' COMMENT '',
400 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
405 CREATE TABLE IF NOT EXISTS `config` (
406 `id` int unsigned NOT NULL auto_increment COMMENT '',
407 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
408 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
409 `v` mediumtext COMMENT '',
411 UNIQUE INDEX `cat_k` (`cat`,`k`)
412 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
415 -- TABLE contact-relation
417 CREATE TABLE IF NOT EXISTS `contact-relation` (
418 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
419 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
420 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
421 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
422 `follows` boolean NOT NULL DEFAULT '0' COMMENT '',
423 PRIMARY KEY(`cid`,`relation-cid`),
424 INDEX `relation-cid` (`relation-cid`),
425 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
426 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
427 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
432 CREATE TABLE IF NOT EXISTS `conv` (
433 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
434 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
435 `recips` text COMMENT 'sender_handle;recipient_handle',
436 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
437 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
438 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
439 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
440 `subject` text COMMENT 'subject of initial message',
443 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
444 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
447 -- TABLE conversation
449 CREATE TABLE IF NOT EXISTS `conversation` (
450 `item-uri` varbinary(255) NOT NULL COMMENT 'Original URI of the item - unrelated to the table with the same name',
451 `reply-to-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'URI to which this item is a reply',
452 `conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI',
453 `conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link',
454 `protocol` tinyint unsigned NOT NULL DEFAULT 255 COMMENT 'The protocol of the item',
455 `direction` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'How the message arrived here: 1=push, 2=pull',
456 `source` mediumtext COMMENT 'Original source',
457 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Receiving date',
458 PRIMARY KEY(`item-uri`),
459 INDEX `conversation-uri` (`conversation-uri`),
460 INDEX `received` (`received`)
461 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Raw data and structure information for messages';
464 -- TABLE diaspora-interaction
466 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
467 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
468 `interaction` mediumtext COMMENT 'The Diaspora interaction',
469 PRIMARY KEY(`uri-id`),
470 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
471 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
476 CREATE TABLE IF NOT EXISTS `event` (
477 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
478 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
479 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
480 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
481 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
482 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
483 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
484 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
485 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
486 `summary` text COMMENT 'short description or title of the event',
487 `desc` text COMMENT 'event description',
488 `location` text COMMENT 'event location',
489 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
490 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
491 `adjust` boolean NOT NULL DEFAULT '1' COMMENT 'adjust to timezone of the recipient (0 or 1)',
492 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
493 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
494 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
495 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
496 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
498 INDEX `uid_start` (`uid`,`start`),
500 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
501 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
502 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
507 CREATE TABLE IF NOT EXISTS `fcontact` (
508 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
509 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
510 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
511 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
512 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
513 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
514 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
515 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
516 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
517 `notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
518 `poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
519 `confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
520 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
521 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
522 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
523 `pubkey` text COMMENT '',
524 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
526 INDEX `addr` (`addr`(32)),
527 UNIQUE INDEX `url` (`url`(190))
528 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
533 CREATE TABLE IF NOT EXISTS `fsuggest` (
534 `id` int unsigned NOT NULL auto_increment COMMENT '',
535 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
536 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
537 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
538 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
539 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
540 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
541 `note` text COMMENT '',
542 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
546 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
547 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
548 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
553 CREATE TABLE IF NOT EXISTS `group` (
554 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
555 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
556 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
557 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
558 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
561 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
562 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
565 -- TABLE group_member
567 CREATE TABLE IF NOT EXISTS `group_member` (
568 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
569 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
570 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
572 INDEX `contactid` (`contact-id`),
573 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
574 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
575 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
576 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
581 CREATE TABLE IF NOT EXISTS `gserver-tag` (
582 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
583 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
584 PRIMARY KEY(`gserver-id`,`tag`),
586 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
587 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
592 CREATE TABLE IF NOT EXISTS `hook` (
593 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
594 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
595 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
596 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
597 `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',
599 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
600 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
605 CREATE TABLE IF NOT EXISTS `host` (
606 `id` tinyint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
607 `name` varchar(128) NOT NULL DEFAULT '' COMMENT 'The hostname',
609 UNIQUE INDEX `name` (`name`)
610 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Hostname';
613 -- TABLE inbox-status
615 CREATE TABLE IF NOT EXISTS `inbox-status` (
616 `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
617 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
618 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
619 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
620 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
621 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
622 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
624 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
629 CREATE TABLE IF NOT EXISTS `intro` (
630 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
631 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
632 `fid` int unsigned COMMENT '',
633 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
634 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
635 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
636 `note` text COMMENT '',
637 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
638 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
639 `blocked` boolean NOT NULL DEFAULT '1' COMMENT '',
640 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
642 INDEX `contact-id` (`contact-id`),
644 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
645 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
646 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
651 CREATE TABLE IF NOT EXISTS `item` (
652 `id` int unsigned NOT NULL auto_increment,
653 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this item',
654 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
655 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
656 `uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
657 `parent` int unsigned 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',
658 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT 'uri of the top-level parent to this item',
659 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the top-level parent uri',
660 `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',
661 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
662 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
663 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
664 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last comment/reply to this item',
665 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
666 `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',
667 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
668 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
669 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
670 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
671 `causer-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
672 `icid` int unsigned COMMENT 'Id of the item-content table entry that contains the whole item content',
673 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
674 `extid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
675 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
676 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
677 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
678 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
679 `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
680 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been deleted',
681 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
682 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
683 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
684 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
685 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
686 `starred` boolean NOT NULL DEFAULT '0' COMMENT 'item has been favourited',
687 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'item has not been seen',
688 `mention` boolean NOT NULL DEFAULT '0' COMMENT 'The owner of this item was mentioned in it',
689 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
690 `psid` int unsigned COMMENT 'ID of the permission set of this post',
691 `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',
692 `event-id` int unsigned COMMENT 'Used to link to the event.id',
693 `iaid` int unsigned COMMENT 'Deprecated',
694 `attach` mediumtext COMMENT 'Deprecated',
695 `allow_cid` mediumtext COMMENT 'Deprecated',
696 `allow_gid` mediumtext COMMENT 'Deprecated',
697 `deny_cid` mediumtext COMMENT 'Deprecated',
698 `deny_gid` mediumtext COMMENT 'Deprecated',
699 `postopts` text COMMENT 'Deprecated',
700 `inform` mediumtext COMMENT 'Deprecated',
701 `type` varchar(20) COMMENT 'Deprecated',
702 `bookmark` boolean COMMENT 'Deprecated',
703 `file` mediumtext COMMENT 'Deprecated',
704 `location` varchar(255) COMMENT 'Deprecated',
705 `coord` varchar(255) COMMENT 'Deprecated',
706 `tag` mediumtext COMMENT 'Deprecated',
707 `plink` varchar(255) COMMENT 'Deprecated',
708 `title` varchar(255) COMMENT 'Deprecated',
709 `content-warning` varchar(255) COMMENT 'Deprecated',
710 `body` mediumtext COMMENT 'Deprecated',
711 `app` varchar(255) COMMENT 'Deprecated',
712 `verb` varchar(100) COMMENT 'Deprecated',
713 `object-type` varchar(100) COMMENT 'Deprecated',
714 `object` text COMMENT 'Deprecated',
715 `target-type` varchar(100) COMMENT 'Deprecated',
716 `target` text COMMENT 'Deprecated',
717 `author-name` varchar(255) COMMENT 'Deprecated',
718 `author-link` varchar(255) COMMENT 'Deprecated',
719 `author-avatar` varchar(255) COMMENT 'Deprecated',
720 `owner-name` varchar(255) COMMENT 'Deprecated',
721 `owner-link` varchar(255) COMMENT 'Deprecated',
722 `owner-avatar` varchar(255) COMMENT 'Deprecated',
723 `rendered-hash` varchar(32) COMMENT 'Deprecated',
724 `rendered-html` mediumtext COMMENT 'Deprecated',
726 INDEX `guid` (`guid`(191)),
727 INDEX `uri` (`uri`(191)),
728 INDEX `parent` (`parent`),
729 INDEX `parent-uri` (`parent-uri`(191)),
730 INDEX `extid` (`extid`(191)),
731 INDEX `uid_id` (`uid`,`id`),
732 INDEX `uid_contactid_id` (`uid`,`contact-id`,`id`),
733 INDEX `uid_received` (`uid`,`received`),
734 INDEX `uid_commented` (`uid`,`commented`),
735 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
736 INDEX `uid_network_received` (`uid`,`network`,`received`),
737 INDEX `uid_network_commented` (`uid`,`network`,`commented`),
738 INDEX `uid_thrparent` (`uid`,`thr-parent`(190)),
739 INDEX `uid_parenturi` (`uid`,`parent-uri`(190)),
740 INDEX `uid_contactid_received` (`uid`,`contact-id`,`received`),
741 INDEX `authorid_received` (`author-id`,`received`),
742 INDEX `ownerid` (`owner-id`),
743 INDEX `contact-id` (`contact-id`),
744 INDEX `uid_uri` (`uid`,`uri`(190)),
745 INDEX `resource-id` (`resource-id`),
746 INDEX `deleted_changed` (`deleted`,`changed`),
747 INDEX `uid_wall_changed` (`uid`,`wall`,`changed`),
748 INDEX `uid_unseen_wall` (`uid`,`unseen`,`wall`),
749 INDEX `mention_uid_id` (`mention`,`uid`,`id`),
750 INDEX `uid_eventid` (`uid`,`event-id`),
751 INDEX `icid` (`icid`),
752 INDEX `iaid` (`iaid`),
754 INDEX `psid_wall` (`psid`,`wall`),
755 INDEX `uri-id` (`uri-id`),
756 INDEX `parent-uri-id` (`parent-uri-id`),
757 INDEX `thr-parent-id` (`thr-parent-id`),
758 INDEX `causer-id` (`causer-id`),
759 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
760 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
761 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
762 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
763 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
764 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
765 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
766 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
767 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
768 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
769 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
772 -- TABLE item-activity
774 CREATE TABLE IF NOT EXISTS `item-activity` (
775 `id` int unsigned NOT NULL auto_increment,
776 `uri` varchar(255) COMMENT '',
777 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
778 `uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
779 `activity` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
781 UNIQUE INDEX `uri-hash` (`uri-hash`),
782 INDEX `uri` (`uri`(191)),
783 INDEX `uri-id` (`uri-id`),
784 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
785 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activities for items';
788 -- TABLE item-content
790 CREATE TABLE IF NOT EXISTS `item-content` (
791 `id` int unsigned NOT NULL auto_increment,
792 `uri` varchar(255) COMMENT '',
793 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
794 `uri-plink-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
795 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
796 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
797 `body` mediumtext COMMENT 'item body content',
798 `raw-body` mediumtext COMMENT 'Body without embedded media links',
799 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
800 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
801 `language` text COMMENT 'Language information about this post',
802 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
803 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
804 `rendered-html` mediumtext COMMENT 'item.body converted to html',
805 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
806 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
807 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
808 `target` text COMMENT 'JSON encoded target structure if used',
809 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
810 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams verb',
812 UNIQUE INDEX `uri-plink-hash` (`uri-plink-hash`),
813 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
814 INDEX `uri` (`uri`(191)),
815 INDEX `plink` (`plink`(191)),
816 INDEX `uri-id` (`uri-id`),
817 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
818 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
823 CREATE TABLE IF NOT EXISTS `locks` (
824 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
825 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
826 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
827 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
828 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
830 INDEX `name_expires` (`name`,`expires`)
831 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
836 CREATE TABLE IF NOT EXISTS `mail` (
837 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
838 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
839 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
840 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
841 `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
842 `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
843 `contact-id` varchar(255) COMMENT 'contact.id',
844 `convid` int unsigned COMMENT 'conv.id',
845 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
846 `body` mediumtext COMMENT '',
847 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
848 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
849 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
850 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
851 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
852 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
853 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
855 INDEX `uid_seen` (`uid`,`seen`),
856 INDEX `convid` (`convid`),
857 INDEX `uri` (`uri`(64)),
858 INDEX `parent-uri` (`parent-uri`(64)),
859 INDEX `contactid` (`contact-id`(32)),
860 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
861 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
866 CREATE TABLE IF NOT EXISTS `mailacct` (
867 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
868 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
869 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
870 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
871 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
872 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
873 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
874 `pass` text COMMENT '',
875 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
876 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
877 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
878 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
879 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
882 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
883 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
888 CREATE TABLE IF NOT EXISTS `manage` (
889 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
890 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
891 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
893 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
895 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
896 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
897 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
902 CREATE TABLE IF NOT EXISTS `notify` (
903 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
904 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
905 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
906 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
907 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
908 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
909 `msg` mediumtext COMMENT '',
910 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
911 `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
912 `iid` int unsigned COMMENT 'item.id',
913 `parent` int unsigned COMMENT '',
914 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
915 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
916 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
917 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
918 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
919 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
920 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
922 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
923 INDEX `uid_date` (`uid`,`date`),
924 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
925 INDEX `uri-id` (`uri-id`),
926 INDEX `parent-uri-id` (`parent-uri-id`),
927 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
928 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
929 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
930 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
933 -- TABLE notify-threads
935 CREATE TABLE IF NOT EXISTS `notify-threads` (
936 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
937 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
938 `master-parent-item` int unsigned COMMENT '',
939 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
940 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
941 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
943 INDEX `master-parent-item` (`master-parent-item`),
944 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
945 INDEX `receiver-uid` (`receiver-uid`),
946 INDEX `notify-id` (`notify-id`),
947 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
948 FOREIGN KEY (`master-parent-item`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
949 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
950 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
951 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
956 CREATE TABLE IF NOT EXISTS `oembed` (
957 `url` varbinary(255) NOT NULL COMMENT 'page url',
958 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
959 `content` mediumtext COMMENT 'OEmbed data of the page',
960 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
961 PRIMARY KEY(`url`,`maxwidth`),
962 INDEX `created` (`created`)
963 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
966 -- TABLE openwebauth-token
968 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
969 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
970 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
971 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
972 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
973 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
974 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
977 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
978 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
983 CREATE TABLE IF NOT EXISTS `parsed_url` (
984 `url` varbinary(255) NOT NULL COMMENT 'page url',
985 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
986 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
987 `content` mediumtext COMMENT 'page data',
988 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
989 PRIMARY KEY(`url`,`guessing`,`oembed`),
990 INDEX `created` (`created`)
991 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
994 -- TABLE participation
996 CREATE TABLE IF NOT EXISTS `participation` (
997 `iid` int unsigned NOT NULL COMMENT '',
998 `server` varchar(60) NOT NULL COMMENT '',
999 `cid` int unsigned NOT NULL COMMENT '',
1000 `fid` int unsigned NOT NULL COMMENT '',
1001 PRIMARY KEY(`iid`,`server`),
1002 INDEX `cid` (`cid`),
1003 INDEX `fid` (`fid`),
1004 FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1005 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1006 FOREIGN KEY (`fid`) REFERENCES `fcontact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1007 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Storage for participation messages from Diaspora';
1012 CREATE TABLE IF NOT EXISTS `pconfig` (
1013 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
1014 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1015 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
1016 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
1017 `v` mediumtext COMMENT 'Value',
1019 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
1020 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1021 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
1026 CREATE TABLE IF NOT EXISTS `photo` (
1027 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1028 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1029 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1030 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
1031 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
1032 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
1033 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
1034 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1035 `desc` text COMMENT '',
1036 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
1037 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1038 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
1039 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1040 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1041 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1042 `data` mediumblob NOT NULL COMMENT '',
1043 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1044 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
1045 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
1046 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
1047 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
1048 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
1049 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
1050 `backend-class` tinytext COMMENT 'Storage backend class',
1051 `backend-ref` text COMMENT 'Storage backend data reference',
1052 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1054 INDEX `contactid` (`contact-id`),
1055 INDEX `uid_contactid` (`uid`,`contact-id`),
1056 INDEX `uid_profile` (`uid`,`profile`),
1057 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
1058 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
1059 INDEX `resource-id` (`resource-id`),
1060 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1061 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1062 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1065 -- TABLE post-category
1067 CREATE TABLE IF NOT EXISTS `post-category` (
1068 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1069 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1070 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1071 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1072 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1073 INDEX `uri-id` (`tid`),
1074 INDEX `uid` (`uid`),
1075 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1076 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1077 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1078 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1081 -- TABLE post-delivery-data
1083 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1084 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1085 `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',
1086 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1087 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1088 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1089 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1090 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1091 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1092 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1093 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1094 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1095 PRIMARY KEY(`uri-id`),
1096 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1097 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1102 CREATE TABLE IF NOT EXISTS `post-media` (
1103 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1104 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1105 `url` varbinary(511) NOT NULL COMMENT 'Media URL',
1106 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1107 `mimetype` varchar(60) COMMENT '',
1108 `height` smallint unsigned COMMENT 'Height of the media',
1109 `width` smallint unsigned COMMENT 'Width of the media',
1110 `size` int unsigned COMMENT 'Media size',
1111 `preview` varbinary(255) COMMENT 'Preview URL',
1112 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1113 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1114 `description` text COMMENT '',
1116 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1117 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1118 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1123 CREATE TABLE IF NOT EXISTS `post-tag` (
1124 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1125 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1126 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1127 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1128 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1129 INDEX `tid` (`tid`),
1130 INDEX `cid` (`cid`),
1131 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1132 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1133 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1134 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1139 CREATE TABLE IF NOT EXISTS `post-user` (
1140 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1141 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1142 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1143 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1144 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1145 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1146 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1147 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1148 PRIMARY KEY(`uid`,`uri-id`),
1149 INDEX `uri-id` (`uri-id`),
1150 INDEX `contact-id` (`contact-id`),
1151 INDEX `psid` (`psid`),
1152 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1153 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1154 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1155 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1156 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1161 CREATE TABLE IF NOT EXISTS `process` (
1162 `pid` int unsigned NOT NULL COMMENT '',
1163 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1164 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1166 INDEX `command` (`command`)
1167 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1172 CREATE TABLE IF NOT EXISTS `profile` (
1173 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1174 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1175 `profile-name` varchar(255) COMMENT 'Deprecated',
1176 `is-default` boolean COMMENT 'Deprecated',
1177 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1178 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1179 `pdesc` varchar(255) COMMENT 'Deprecated',
1180 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1181 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1182 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1183 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1184 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1185 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1186 `hometown` varchar(255) COMMENT 'Deprecated',
1187 `gender` varchar(32) COMMENT 'Deprecated',
1188 `marital` varchar(255) COMMENT 'Deprecated',
1189 `with` text COMMENT 'Deprecated',
1190 `howlong` datetime COMMENT 'Deprecated',
1191 `sexual` varchar(255) COMMENT 'Deprecated',
1192 `politic` varchar(255) COMMENT 'Deprecated',
1193 `religion` varchar(255) COMMENT 'Deprecated',
1194 `pub_keywords` text COMMENT '',
1195 `prv_keywords` text COMMENT '',
1196 `likes` text COMMENT 'Deprecated',
1197 `dislikes` text COMMENT 'Deprecated',
1198 `about` text COMMENT 'Profile description',
1199 `summary` varchar(255) COMMENT 'Deprecated',
1200 `music` text COMMENT 'Deprecated',
1201 `book` text COMMENT 'Deprecated',
1202 `tv` text COMMENT 'Deprecated',
1203 `film` text COMMENT 'Deprecated',
1204 `interest` text COMMENT 'Deprecated',
1205 `romance` text COMMENT 'Deprecated',
1206 `work` text COMMENT 'Deprecated',
1207 `education` text COMMENT 'Deprecated',
1208 `contact` text COMMENT 'Deprecated',
1209 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1210 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1211 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1212 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1213 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1214 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1216 INDEX `uid_is-default` (`uid`,`is-default`),
1217 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1218 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1219 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1222 -- TABLE profile_check
1224 CREATE TABLE IF NOT EXISTS `profile_check` (
1225 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1226 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1227 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1228 `dfrn_id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1229 `sec` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1230 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1232 INDEX `uid` (`uid`),
1233 INDEX `cid` (`cid`),
1234 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1235 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1236 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='DFRN remote auth use';
1239 -- TABLE profile_field
1241 CREATE TABLE IF NOT EXISTS `profile_field` (
1242 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1243 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1244 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1245 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1246 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1247 `value` text COMMENT 'Value of the field',
1248 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1249 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1251 INDEX `uid` (`uid`),
1252 INDEX `order` (`order`),
1253 INDEX `psid` (`psid`),
1254 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1255 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1256 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1259 -- TABLE push_subscriber
1261 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1262 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1263 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1264 `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1265 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1266 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1267 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1268 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1269 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1270 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1271 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1273 INDEX `next_try` (`next_try`),
1274 INDEX `uid` (`uid`),
1275 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1276 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1281 CREATE TABLE IF NOT EXISTS `register` (
1282 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1283 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1284 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1285 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1286 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1287 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1288 `note` text COMMENT '',
1290 INDEX `uid` (`uid`),
1291 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1292 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1297 CREATE TABLE IF NOT EXISTS `search` (
1298 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1299 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1300 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1302 INDEX `uid` (`uid`),
1303 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1304 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1309 CREATE TABLE IF NOT EXISTS `session` (
1310 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1311 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1312 `data` text COMMENT '',
1313 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1315 INDEX `sid` (`sid`(64)),
1316 INDEX `expire` (`expire`)
1317 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1322 CREATE TABLE IF NOT EXISTS `storage` (
1323 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1324 `data` longblob NOT NULL COMMENT 'file data',
1326 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1331 CREATE TABLE IF NOT EXISTS `thread` (
1332 `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'sequential ID',
1333 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
1334 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1335 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1336 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1337 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1338 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1339 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1340 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1341 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1342 `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1343 `wall` boolean NOT NULL DEFAULT '0' COMMENT '',
1344 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1345 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1346 `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
1347 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1348 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1349 `ignored` boolean NOT NULL DEFAULT '0' COMMENT '',
1350 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
1351 `unseen` boolean NOT NULL DEFAULT '1' COMMENT '',
1352 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '',
1353 `origin` boolean NOT NULL DEFAULT '0' COMMENT '',
1354 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1355 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1356 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1357 `bookmark` boolean COMMENT '',
1359 INDEX `uid_network_commented` (`uid`,`network`,`commented`),
1360 INDEX `uid_network_received` (`uid`,`network`,`received`),
1361 INDEX `uid_contactid_commented` (`uid`,`contact-id`,`commented`),
1362 INDEX `uid_contactid_received` (`uid`,`contact-id`,`received`),
1363 INDEX `contactid` (`contact-id`),
1364 INDEX `ownerid` (`owner-id`),
1365 INDEX `authorid` (`author-id`),
1366 INDEX `uid_received` (`uid`,`received`),
1367 INDEX `uid_commented` (`uid`,`commented`),
1368 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1369 INDEX `private_wall_origin_commented` (`private`,`wall`,`origin`,`commented`),
1370 INDEX `uri-id` (`uri-id`),
1371 FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1372 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1373 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1374 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1375 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1376 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1377 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1382 CREATE TABLE IF NOT EXISTS `tokens` (
1383 `id` varchar(40) NOT NULL COMMENT '',
1384 `secret` text COMMENT '',
1385 `client_id` varchar(20) NOT NULL DEFAULT '',
1386 `expires` int NOT NULL DEFAULT 0 COMMENT '',
1387 `scope` varchar(200) NOT NULL DEFAULT '' COMMENT '',
1388 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1390 INDEX `client_id` (`client_id`),
1391 INDEX `uid` (`uid`),
1392 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1393 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1394 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
1399 CREATE TABLE IF NOT EXISTS `userd` (
1400 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1401 `username` varchar(255) NOT NULL COMMENT '',
1403 INDEX `username` (`username`(32))
1404 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1407 -- TABLE user-contact
1409 CREATE TABLE IF NOT EXISTS `user-contact` (
1410 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1411 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1412 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1413 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1414 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1415 PRIMARY KEY(`uid`,`cid`),
1416 INDEX `cid` (`cid`),
1417 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1418 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1419 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1424 CREATE TABLE IF NOT EXISTS `user-item` (
1425 `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item id',
1426 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1427 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide an item from the user',
1428 `ignored` boolean COMMENT 'Ignore this thread if set',
1429 `pinned` boolean COMMENT 'The item is pinned on the profile page',
1430 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1431 PRIMARY KEY(`uid`,`iid`),
1432 INDEX `uid_pinned` (`uid`,`pinned`),
1433 INDEX `iid_uid` (`iid`,`uid`),
1434 FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1435 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1436 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific item data';
1441 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1442 `key` int NOT NULL COMMENT '',
1443 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1445 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1448 -- TABLE workerqueue
1450 CREATE TABLE IF NOT EXISTS `workerqueue` (
1451 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
1452 `parameter` mediumtext COMMENT 'Task command',
1453 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
1454 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
1455 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
1456 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
1457 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1458 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1459 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
1461 INDEX `done_parameter` (`done`,`parameter`(64)),
1462 INDEX `done_executed` (`done`,`executed`),
1463 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
1464 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
1465 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
1466 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
1467 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
1468 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
1471 -- VIEW category-view
1473 DROP VIEW IF EXISTS `category-view`;
1474 CREATE VIEW `category-view` AS SELECT
1475 `post-category`.`uri-id` AS `uri-id`,
1476 `post-category`.`uid` AS `uid`,
1477 `item-uri`.`uri` AS `uri`,
1478 `item-uri`.`guid` AS `guid`,
1479 `post-category`.`type` AS `type`,
1480 `post-category`.`tid` AS `tid`,
1481 `tag`.`name` AS `name`,
1482 `tag`.`url` AS `url`
1483 FROM `post-category`
1484 INNER JOIN `item-uri` ON `item-uri`.id = `post-category`.`uri-id`
1485 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
1490 DROP VIEW IF EXISTS `tag-view`;
1491 CREATE VIEW `tag-view` AS SELECT
1492 `post-tag`.`uri-id` AS `uri-id`,
1493 `item-uri`.`uri` AS `uri`,
1494 `item-uri`.`guid` AS `guid`,
1495 `post-tag`.`type` AS `type`,
1496 `post-tag`.`tid` AS `tid`,
1497 `post-tag`.`cid` AS `cid`,
1498 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
1499 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
1501 INNER JOIN `item-uri` ON `item-uri`.id = `post-tag`.`uri-id`
1502 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
1503 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
1506 -- VIEW network-item-view
1508 DROP VIEW IF EXISTS `network-item-view`;
1509 CREATE VIEW `network-item-view` AS SELECT
1510 `item`.`parent-uri-id` AS `uri-id`,
1511 `item`.`parent-uri` AS `uri`,
1512 `item`.`parent` AS `parent`,
1513 `item`.`received` AS `received`,
1514 `item`.`commented` AS `commented`,
1515 `item`.`created` AS `created`,
1516 `item`.`uid` AS `uid`,
1517 `item`.`starred` AS `starred`,
1518 `item`.`mention` AS `mention`,
1519 `item`.`network` AS `network`,
1520 `item`.`unseen` AS `unseen`,
1521 `item`.`gravity` AS `gravity`,
1522 `item`.`contact-id` AS `contact-id`,
1523 `ownercontact`.`contact-type` AS `contact-type`
1525 INNER JOIN `thread` ON `thread`.`iid` = `item`.`parent`
1526 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
1527 LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
1528 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
1529 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
1530 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
1531 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
1532 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
1533 AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
1534 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
1535 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
1538 -- VIEW network-thread-view
1540 DROP VIEW IF EXISTS `network-thread-view`;
1541 CREATE VIEW `network-thread-view` AS SELECT
1542 `item`.`uri-id` AS `uri-id`,
1543 `item`.`uri` AS `uri`,
1544 `item`.`parent-uri-id` AS `parent-uri-id`,
1545 `thread`.`iid` AS `parent`,
1546 `thread`.`received` AS `received`,
1547 `thread`.`commented` AS `commented`,
1548 `thread`.`created` AS `created`,
1549 `thread`.`uid` AS `uid`,
1550 `thread`.`starred` AS `starred`,
1551 `thread`.`mention` AS `mention`,
1552 `thread`.`network` AS `network`,
1553 `thread`.`contact-id` AS `contact-id`,
1554 `ownercontact`.`contact-type` AS `contact-type`
1556 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
1557 STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
1558 LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
1559 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
1560 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
1561 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
1562 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
1563 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
1564 AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
1565 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
1566 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
1571 DROP VIEW IF EXISTS `owner-view`;
1572 CREATE VIEW `owner-view` AS SELECT
1573 `contact`.`id` AS `id`,
1574 `contact`.`uid` AS `uid`,
1575 `contact`.`created` AS `created`,
1576 `contact`.`updated` AS `updated`,
1577 `contact`.`self` AS `self`,
1578 `contact`.`remote_self` AS `remote_self`,
1579 `contact`.`rel` AS `rel`,
1580 `contact`.`duplex` AS `duplex`,
1581 `contact`.`network` AS `network`,
1582 `contact`.`protocol` AS `protocol`,
1583 `contact`.`name` AS `name`,
1584 `contact`.`nick` AS `nick`,
1585 `contact`.`location` AS `location`,
1586 `contact`.`about` AS `about`,
1587 `contact`.`keywords` AS `keywords`,
1588 `contact`.`gender` AS `gender`,
1589 `contact`.`xmpp` AS `xmpp`,
1590 `contact`.`attag` AS `attag`,
1591 `contact`.`avatar` AS `avatar`,
1592 `contact`.`photo` AS `photo`,
1593 `contact`.`thumb` AS `thumb`,
1594 `contact`.`micro` AS `micro`,
1595 `contact`.`site-pubkey` AS `site-pubkey`,
1596 `contact`.`issued-id` AS `issued-id`,
1597 `contact`.`dfrn-id` AS `dfrn-id`,
1598 `contact`.`url` AS `url`,
1599 `contact`.`nurl` AS `nurl`,
1600 `contact`.`addr` AS `addr`,
1601 `contact`.`alias` AS `alias`,
1602 `contact`.`pubkey` AS `pubkey`,
1603 `contact`.`prvkey` AS `prvkey`,
1604 `contact`.`batch` AS `batch`,
1605 `contact`.`request` AS `request`,
1606 `contact`.`notify` AS `notify`,
1607 `contact`.`poll` AS `poll`,
1608 `contact`.`confirm` AS `confirm`,
1609 `contact`.`poco` AS `poco`,
1610 `contact`.`aes_allow` AS `aes_allow`,
1611 `contact`.`ret-aes` AS `ret-aes`,
1612 `contact`.`usehub` AS `usehub`,
1613 `contact`.`subhub` AS `subhub`,
1614 `contact`.`hub-verify` AS `hub-verify`,
1615 `contact`.`last-update` AS `last-update`,
1616 `contact`.`success_update` AS `success_update`,
1617 `contact`.`failure_update` AS `failure_update`,
1618 `contact`.`name-date` AS `name-date`,
1619 `contact`.`uri-date` AS `uri-date`,
1620 `contact`.`avatar-date` AS `avatar-date`,
1621 `contact`.`avatar-date` AS `picdate`,
1622 `contact`.`term-date` AS `term-date`,
1623 `contact`.`last-item` AS `last-item`,
1624 `contact`.`priority` AS `priority`,
1625 `user`.`blocked` AS `blocked`,
1626 `contact`.`block_reason` AS `block_reason`,
1627 `contact`.`readonly` AS `readonly`,
1628 `contact`.`writable` AS `writable`,
1629 `contact`.`forum` AS `forum`,
1630 `contact`.`prv` AS `prv`,
1631 `contact`.`contact-type` AS `contact-type`,
1632 `contact`.`manually-approve` AS `manually-approve`,
1633 `contact`.`hidden` AS `hidden`,
1634 `contact`.`archive` AS `archive`,
1635 `contact`.`pending` AS `pending`,
1636 `contact`.`deleted` AS `deleted`,
1637 `contact`.`unsearchable` AS `unsearchable`,
1638 `contact`.`sensitive` AS `sensitive`,
1639 `contact`.`baseurl` AS `baseurl`,
1640 `contact`.`reason` AS `reason`,
1641 `contact`.`closeness` AS `closeness`,
1642 `contact`.`info` AS `info`,
1643 `contact`.`profile-id` AS `profile-id`,
1644 `contact`.`bdyear` AS `bdyear`,
1645 `contact`.`bd` AS `bd`,
1646 `contact`.`notify_new_posts` AS `notify_new_posts`,
1647 `contact`.`fetch_further_information` AS `fetch_further_information`,
1648 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
1649 `user`.`parent-uid` AS `parent-uid`,
1650 `user`.`guid` AS `guid`,
1651 `user`.`nickname` AS `nickname`,
1652 `user`.`email` AS `email`,
1653 `user`.`openid` AS `openid`,
1654 `user`.`timezone` AS `timezone`,
1655 `user`.`language` AS `language`,
1656 `user`.`register_date` AS `register_date`,
1657 `user`.`login_date` AS `login_date`,
1658 `user`.`default-location` AS `default-location`,
1659 `user`.`allow_location` AS `allow_location`,
1660 `user`.`theme` AS `theme`,
1661 `user`.`pubkey` AS `upubkey`,
1662 `user`.`prvkey` AS `uprvkey`,
1663 `user`.`sprvkey` AS `sprvkey`,
1664 `user`.`spubkey` AS `spubkey`,
1665 `user`.`verified` AS `verified`,
1666 `user`.`blockwall` AS `blockwall`,
1667 `user`.`hidewall` AS `hidewall`,
1668 `user`.`blocktags` AS `blocktags`,
1669 `user`.`unkmail` AS `unkmail`,
1670 `user`.`cntunkmail` AS `cntunkmail`,
1671 `user`.`notify-flags` AS `notify-flags`,
1672 `user`.`page-flags` AS `page-flags`,
1673 `user`.`account-type` AS `account-type`,
1674 `user`.`prvnets` AS `prvnets`,
1675 `user`.`maxreq` AS `maxreq`,
1676 `user`.`expire` AS `expire`,
1677 `user`.`account_removed` AS `account_removed`,
1678 `user`.`account_expired` AS `account_expired`,
1679 `user`.`account_expires_on` AS `account_expires_on`,
1680 `user`.`expire_notification_sent` AS `expire_notification_sent`,
1681 `user`.`def_gid` AS `def_gid`,
1682 `user`.`allow_cid` AS `allow_cid`,
1683 `user`.`allow_gid` AS `allow_gid`,
1684 `user`.`deny_cid` AS `deny_cid`,
1685 `user`.`deny_gid` AS `deny_gid`,
1686 `user`.`openidserver` AS `openidserver`,
1687 `profile`.`publish` AS `publish`,
1688 `profile`.`net-publish` AS `net-publish`,
1689 `profile`.`hide-friends` AS `hide-friends`,
1690 `profile`.`prv_keywords` AS `prv_keywords`,
1691 `profile`.`pub_keywords` AS `pub_keywords`,
1692 `profile`.`address` AS `address`,
1693 `profile`.`locality` AS `locality`,
1694 `profile`.`region` AS `region`,
1695 `profile`.`postal-code` AS `postal-code`,
1696 `profile`.`country-name` AS `country-name`,
1697 `profile`.`homepage` AS `homepage`,
1698 `profile`.`dob` AS `dob`
1700 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
1701 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
1704 -- VIEW pending-view
1706 DROP VIEW IF EXISTS `pending-view`;
1707 CREATE VIEW `pending-view` AS SELECT
1708 `register`.`id` AS `id`,
1709 `register`.`hash` AS `hash`,
1710 `register`.`created` AS `created`,
1711 `register`.`uid` AS `uid`,
1712 `register`.`password` AS `password`,
1713 `register`.`language` AS `language`,
1714 `register`.`note` AS `note`,
1715 `contact`.`self` AS `self`,
1716 `contact`.`name` AS `name`,
1717 `contact`.`url` AS `url`,
1718 `contact`.`micro` AS `micro`,
1719 `user`.`email` AS `email`,
1720 `contact`.`nick` AS `nick`
1722 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
1723 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
1726 -- VIEW tag-search-view
1728 DROP VIEW IF EXISTS `tag-search-view`;
1729 CREATE VIEW `tag-search-view` AS SELECT
1730 `post-tag`.`uri-id` AS `uri-id`,
1731 `item`.`id` AS `iid`,
1732 `item`.`uri` AS `uri`,
1733 `item`.`guid` AS `guid`,
1734 `item`.`uid` AS `uid`,
1735 `item`.`private` AS `private`,
1736 `item`.`wall` AS `wall`,
1737 `item`.`origin` AS `origin`,
1738 `item`.`gravity` AS `gravity`,
1739 `item`.`received` AS `received`,
1740 `tag`.`name` AS `name`
1742 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
1743 INNER JOIN `item` ON `item`.`uri-id` = `post-tag`.`uri-id`
1744 WHERE `post-tag`.`type` = 1;
1747 -- VIEW workerqueue-view
1749 DROP VIEW IF EXISTS `workerqueue-view`;
1750 CREATE VIEW `workerqueue-view` AS SELECT
1751 `process`.`pid` AS `pid`,
1752 `workerqueue`.`priority` AS `priority`
1754 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
1755 WHERE NOT `workerqueue`.`done`;