1 -- ------------------------------------------
2 -- Friendica 2021.03-dev (Red Hot Poker)
3 -- DB_UPDATE_VERSION 1392
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 `protocol` tinyint unsigned COMMENT 'The protocol of the server',
24 `platform` varchar(255) NOT NULL DEFAULT '' COMMENT '',
25 `relay-subscribe` boolean NOT NULL DEFAULT '0' COMMENT 'Has the server subscribed to the relay system',
26 `relay-scope` varchar(10) NOT NULL DEFAULT '' COMMENT 'The scope of messages that the server wants to get',
27 `detection-method` tinyint unsigned COMMENT 'Method that had been used to detect that server',
28 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
29 `last_poco_query` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
30 `last_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Last successful connection request',
31 `last_failure` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Last failed connection request',
32 `failed` boolean COMMENT 'Connection failed',
33 `next_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Next connection request',
35 UNIQUE INDEX `nurl` (`nurl`(190)),
36 INDEX `next_contact` (`next_contact`)
37 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Global servers';
42 CREATE TABLE IF NOT EXISTS `user` (
43 `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
44 `parent-uid` mediumint unsigned COMMENT 'The parent user that has full control about this user',
45 `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
46 `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
47 `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
48 `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
49 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
50 `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
51 `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
52 `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
53 `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
54 `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
55 `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
56 `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
57 `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
58 `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
59 `pubkey` text COMMENT 'RSA public key 4096 bit',
60 `prvkey` text COMMENT 'RSA private key 4096 bit',
61 `spubkey` text COMMENT '',
62 `sprvkey` text COMMENT '',
63 `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
64 `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
65 `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
66 `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unkown viewers',
67 `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
68 `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
69 `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
70 `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
71 `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
72 `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
73 `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
74 `pwdreset` varchar(255) COMMENT 'Password reset request token',
75 `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
76 `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
77 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
78 `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
79 `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
80 `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
81 `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
82 `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
83 `allow_cid` mediumtext COMMENT 'default permission for this user',
84 `allow_gid` mediumtext COMMENT 'default permission for this user',
85 `deny_cid` mediumtext COMMENT 'default permission for this user',
86 `deny_gid` mediumtext COMMENT 'default permission for this user',
87 `openidserver` text COMMENT '',
89 INDEX `nickname` (`nickname`(32)),
90 INDEX `parent-uid` (`parent-uid`),
91 FOREIGN KEY (`parent-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
92 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
97 CREATE TABLE IF NOT EXISTS `contact` (
98 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
99 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
100 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
101 `updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last contact update',
102 `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
103 `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
104 `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
105 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
106 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network of the contact',
107 `protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
108 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
109 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
110 `location` varchar(255) DEFAULT '' COMMENT '',
111 `about` text COMMENT '',
112 `keywords` text COMMENT 'public keywords (interests) of the contact',
113 `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
114 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
115 `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
116 `avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '',
117 `photo` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
118 `thumb` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
119 `micro` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
120 `site-pubkey` text COMMENT '',
121 `issued-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
122 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
123 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
124 `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
125 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
126 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
127 `pubkey` text COMMENT 'RSA public key 4096 bit',
128 `prvkey` text COMMENT 'RSA private key 4096 bit',
129 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
130 `request` varchar(255) COMMENT '',
131 `notify` varchar(255) COMMENT '',
132 `poll` varchar(255) COMMENT '',
133 `confirm` varchar(255) COMMENT '',
134 `subscribe` varchar(255) COMMENT '',
135 `poco` varchar(255) COMMENT '',
136 `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT '',
137 `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT '',
138 `usehub` boolean NOT NULL DEFAULT '0' COMMENT '',
139 `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
140 `hub-verify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
141 `last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
142 `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
143 `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
144 `failed` boolean COMMENT 'Connection failed',
145 `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
146 `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
147 `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
148 `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
149 `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
150 `last-discovery` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last follower discovery',
151 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
152 `blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
153 `block_reason` text COMMENT 'Node-wide block reason',
154 `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
155 `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
156 `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum',
157 `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group',
158 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT '',
159 `manually-approve` boolean COMMENT '',
160 `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
161 `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
162 `pending` boolean NOT NULL DEFAULT '1' COMMENT '',
163 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
164 `rating` tinyint NOT NULL DEFAULT 0 COMMENT '',
165 `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
166 `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
167 `baseurl` varchar(255) DEFAULT '' COMMENT 'baseurl of the contact',
168 `gsid` int unsigned COMMENT 'Global Server ID',
169 `reason` text COMMENT '',
170 `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT '',
171 `info` mediumtext COMMENT '',
172 `profile-id` int unsigned COMMENT 'Deprecated',
173 `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
174 `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
175 `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
176 `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
177 `ffi_keyword_denylist` text COMMENT '',
179 INDEX `uid_name` (`uid`,`name`(190)),
180 INDEX `self_uid` (`self`,`uid`),
181 INDEX `alias_uid` (`alias`(128),`uid`),
182 INDEX `pending_uid` (`pending`,`uid`),
183 INDEX `blocked_uid` (`blocked`,`uid`),
184 INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
185 INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
186 INDEX `addr_uid` (`addr`(128),`uid`),
187 INDEX `nurl_uid` (`nurl`(128),`uid`),
188 INDEX `nick_uid` (`nick`(128),`uid`),
189 INDEX `attag_uid` (`attag`(96),`uid`),
190 INDEX `dfrn-id` (`dfrn-id`(64)),
191 INDEX `issued-id` (`issued-id`(64)),
192 INDEX `network_uid_lastupdate` (`network`,`uid`,`last-update`),
193 INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`),
194 INDEX `uid_lastitem` (`uid`,`last-item`),
195 INDEX `gsid` (`gsid`),
196 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
197 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
198 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
203 CREATE TABLE IF NOT EXISTS `item-uri` (
204 `id` int unsigned NOT NULL auto_increment,
205 `uri` varbinary(255) NOT NULL COMMENT 'URI of an item',
206 `guid` varbinary(255) COMMENT 'A unique identifier for an item',
208 UNIQUE INDEX `uri` (`uri`),
209 INDEX `guid` (`guid`)
210 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
215 CREATE TABLE IF NOT EXISTS `tag` (
216 `id` int unsigned NOT NULL auto_increment COMMENT '',
217 `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
218 `url` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
220 UNIQUE INDEX `type_name_url` (`name`,`url`),
222 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
227 CREATE TABLE IF NOT EXISTS `clients` (
228 `client_id` varchar(20) NOT NULL COMMENT '',
229 `pw` varchar(20) NOT NULL DEFAULT '' COMMENT '',
230 `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
231 `name` text COMMENT '',
232 `icon` text COMMENT '',
233 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
234 PRIMARY KEY(`client_id`),
236 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
237 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
240 -- TABLE permissionset
242 CREATE TABLE IF NOT EXISTS `permissionset` (
243 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
244 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
245 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
246 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
247 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
248 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
250 INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`uid`,`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30)),
251 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
252 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
257 CREATE TABLE IF NOT EXISTS `verb` (
258 `id` smallint unsigned NOT NULL auto_increment,
259 `name` varchar(100) NOT NULL DEFAULT '' COMMENT '',
261 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activity Verbs';
264 -- TABLE 2fa_app_specific_password
266 CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
267 `id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
268 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
269 `description` varchar(255) COMMENT 'Description of the usage of the password',
270 `hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
271 `generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
272 `last_used` datetime COMMENT 'Datetime the password was last used',
274 INDEX `uid_description` (`uid`,`description`(190)),
275 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
276 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
279 -- TABLE 2fa_recovery_codes
281 CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
282 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
283 `code` varchar(50) NOT NULL COMMENT 'Recovery code string',
284 `generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
285 `used` datetime COMMENT 'Datetime the code was used',
286 PRIMARY KEY(`uid`,`code`),
287 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
288 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
293 CREATE TABLE IF NOT EXISTS `addon` (
294 `id` int unsigned NOT NULL auto_increment COMMENT '',
295 `name` varchar(50) NOT NULL DEFAULT '' COMMENT 'addon base (file)name',
296 `version` varchar(50) NOT NULL DEFAULT '' COMMENT 'currently unused',
297 `installed` boolean NOT NULL DEFAULT '0' COMMENT 'currently always 1',
298 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'currently unused',
299 `timestamp` int unsigned NOT NULL DEFAULT 0 COMMENT 'file timestamp to check for reloads',
300 `plugin_admin` boolean NOT NULL DEFAULT '0' COMMENT '1 = has admin config, 0 = has no admin config',
302 UNIQUE INDEX `name` (`name`)
303 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registered addons';
308 CREATE TABLE IF NOT EXISTS `apcontact` (
309 `url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
310 `uuid` varchar(255) COMMENT '',
311 `type` varchar(20) NOT NULL COMMENT '',
312 `following` varchar(255) COMMENT '',
313 `followers` varchar(255) COMMENT '',
314 `inbox` varchar(255) NOT NULL COMMENT '',
315 `outbox` varchar(255) COMMENT '',
316 `sharedinbox` varchar(255) COMMENT '',
317 `manually-approve` boolean COMMENT '',
318 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
319 `name` varchar(255) COMMENT '',
320 `about` text COMMENT '',
321 `photo` varchar(255) COMMENT '',
322 `addr` varchar(255) COMMENT '',
323 `alias` varchar(255) COMMENT '',
324 `pubkey` text COMMENT '',
325 `subscribe` varchar(255) COMMENT '',
326 `baseurl` varchar(255) COMMENT 'baseurl of the ap contact',
327 `gsid` int unsigned COMMENT 'Global Server ID',
328 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
329 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
330 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
331 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
332 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
334 INDEX `addr` (`addr`(32)),
335 INDEX `alias` (`alias`(190)),
336 INDEX `followers` (`followers`(190)),
337 INDEX `baseurl` (`baseurl`(190)),
338 INDEX `sharedinbox` (`sharedinbox`(190)),
339 INDEX `gsid` (`gsid`),
340 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
341 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
346 CREATE TABLE IF NOT EXISTS `attach` (
347 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
348 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
349 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
350 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
351 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
352 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
353 `data` longblob NOT NULL COMMENT 'file data',
354 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
355 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
356 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
357 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
358 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
359 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
360 `backend-class` tinytext COMMENT 'Storage backend class',
361 `backend-ref` text COMMENT 'Storage backend data reference',
364 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
365 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
370 CREATE TABLE IF NOT EXISTS `auth_codes` (
371 `id` varchar(40) NOT NULL COMMENT '',
372 `client_id` varchar(20) NOT NULL DEFAULT '' COMMENT '',
373 `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
374 `expires` int NOT NULL DEFAULT 0 COMMENT '',
375 `scope` varchar(250) NOT NULL DEFAULT '' COMMENT '',
377 INDEX `client_id` (`client_id`),
378 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE
379 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
384 CREATE TABLE IF NOT EXISTS `cache` (
385 `k` varbinary(255) NOT NULL COMMENT 'cache key',
386 `v` mediumtext COMMENT 'cached serialized value',
387 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
388 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
390 INDEX `k_expires` (`k`,`expires`)
391 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
396 CREATE TABLE IF NOT EXISTS `challenge` (
397 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
398 `challenge` varchar(255) NOT NULL DEFAULT '' COMMENT '',
399 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
400 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
401 `type` varchar(255) NOT NULL DEFAULT '' COMMENT '',
402 `last_update` varchar(255) NOT NULL DEFAULT '' COMMENT '',
404 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
409 CREATE TABLE IF NOT EXISTS `config` (
410 `id` int unsigned NOT NULL auto_increment COMMENT '',
411 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
412 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
413 `v` mediumtext COMMENT '',
415 UNIQUE INDEX `cat_k` (`cat`,`k`)
416 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
419 -- TABLE contact-relation
421 CREATE TABLE IF NOT EXISTS `contact-relation` (
422 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
423 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
424 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
425 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
426 `follows` boolean NOT NULL DEFAULT '0' COMMENT '',
427 PRIMARY KEY(`cid`,`relation-cid`),
428 INDEX `relation-cid` (`relation-cid`),
429 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
430 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
431 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
436 CREATE TABLE IF NOT EXISTS `conv` (
437 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
438 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
439 `recips` text COMMENT 'sender_handle;recipient_handle',
440 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
441 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
442 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
443 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
444 `subject` text COMMENT 'subject of initial message',
447 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
448 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
451 -- TABLE conversation
453 CREATE TABLE IF NOT EXISTS `conversation` (
454 `item-uri` varbinary(255) NOT NULL COMMENT 'Original URI of the item - unrelated to the table with the same name',
455 `reply-to-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'URI to which this item is a reply',
456 `conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI',
457 `conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link',
458 `protocol` tinyint unsigned NOT NULL DEFAULT 255 COMMENT 'The protocol of the item',
459 `direction` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'How the message arrived here: 1=push, 2=pull',
460 `source` mediumtext COMMENT 'Original source',
461 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Receiving date',
462 PRIMARY KEY(`item-uri`),
463 INDEX `conversation-uri` (`conversation-uri`),
464 INDEX `received` (`received`)
465 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Raw data and structure information for messages';
468 -- TABLE delayed-post
470 CREATE TABLE IF NOT EXISTS `delayed-post` (
471 `id` int unsigned NOT NULL auto_increment,
472 `uri` varchar(255) COMMENT 'URI of the post that will be distributed later',
473 `uid` mediumint unsigned COMMENT 'Owner User id',
474 `delayed` datetime COMMENT 'delay time',
476 UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
477 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
478 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
481 -- TABLE diaspora-interaction
483 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
484 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
485 `interaction` mediumtext COMMENT 'The Diaspora interaction',
486 PRIMARY KEY(`uri-id`),
487 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
488 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
493 CREATE TABLE IF NOT EXISTS `event` (
494 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
495 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
496 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
497 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
498 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
499 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
500 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
501 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
502 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
503 `summary` text COMMENT 'short description or title of the event',
504 `desc` text COMMENT 'event description',
505 `location` text COMMENT 'event location',
506 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
507 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
508 `adjust` boolean NOT NULL DEFAULT '1' COMMENT 'adjust to timezone of the recipient (0 or 1)',
509 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
510 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
511 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
512 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
513 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
515 INDEX `uid_start` (`uid`,`start`),
517 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
518 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
519 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
524 CREATE TABLE IF NOT EXISTS `fcontact` (
525 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
526 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
527 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
528 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
529 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
530 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
531 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
532 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
533 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
534 `notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
535 `poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
536 `confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
537 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
538 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
539 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
540 `pubkey` text COMMENT '',
541 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
543 INDEX `addr` (`addr`(32)),
544 UNIQUE INDEX `url` (`url`(190))
545 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
550 CREATE TABLE IF NOT EXISTS `fsuggest` (
551 `id` int unsigned NOT NULL auto_increment COMMENT '',
552 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
553 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
554 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
555 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
556 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
557 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
558 `note` text COMMENT '',
559 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
563 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
564 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
565 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
570 CREATE TABLE IF NOT EXISTS `group` (
571 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
572 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
573 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
574 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
575 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
578 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
579 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
582 -- TABLE group_member
584 CREATE TABLE IF NOT EXISTS `group_member` (
585 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
586 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
587 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
589 INDEX `contactid` (`contact-id`),
590 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
591 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
592 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
593 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
598 CREATE TABLE IF NOT EXISTS `gserver-tag` (
599 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
600 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
601 PRIMARY KEY(`gserver-id`,`tag`),
603 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
604 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
609 CREATE TABLE IF NOT EXISTS `hook` (
610 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
611 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
612 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
613 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
614 `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',
616 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
617 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
622 CREATE TABLE IF NOT EXISTS `host` (
623 `id` tinyint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
624 `name` varchar(128) NOT NULL DEFAULT '' COMMENT 'The hostname',
626 UNIQUE INDEX `name` (`name`)
627 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Hostname';
630 -- TABLE inbox-status
632 CREATE TABLE IF NOT EXISTS `inbox-status` (
633 `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
634 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
635 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
636 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
637 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
638 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
639 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
641 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
646 CREATE TABLE IF NOT EXISTS `intro` (
647 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
648 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
649 `fid` int unsigned COMMENT '',
650 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
651 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
652 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
653 `note` text COMMENT '',
654 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
655 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
656 `blocked` boolean NOT NULL DEFAULT '1' COMMENT '',
657 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
659 INDEX `contact-id` (`contact-id`),
661 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
662 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
663 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
668 CREATE TABLE IF NOT EXISTS `item` (
669 `id` int unsigned NOT NULL auto_increment,
670 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this item',
671 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
672 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
673 `uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
674 `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',
675 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT 'uri of the top-level parent to this item',
676 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the top-level parent uri',
677 `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',
678 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
679 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
680 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
681 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last comment/reply to this item',
682 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
683 `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',
684 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
685 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
686 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
687 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
688 `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',
689 `icid` int unsigned COMMENT 'Id of the item-content table entry that contains the whole item content',
690 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
691 `extid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
692 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
693 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
694 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
695 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
696 `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
697 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been deleted',
698 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
699 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
700 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
701 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
702 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
703 `starred` boolean NOT NULL DEFAULT '0' COMMENT 'item has been favourited',
704 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'item has not been seen',
705 `mention` boolean NOT NULL DEFAULT '0' COMMENT 'The owner of this item was mentioned in it',
706 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
707 `psid` int unsigned COMMENT 'ID of the permission set of this post',
708 `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',
709 `event-id` int unsigned COMMENT 'Used to link to the event.id',
710 `iaid` int unsigned COMMENT 'Deprecated',
711 `attach` mediumtext COMMENT 'Deprecated',
712 `allow_cid` mediumtext COMMENT 'Deprecated',
713 `allow_gid` mediumtext COMMENT 'Deprecated',
714 `deny_cid` mediumtext COMMENT 'Deprecated',
715 `deny_gid` mediumtext COMMENT 'Deprecated',
716 `postopts` text COMMENT 'Deprecated',
717 `inform` mediumtext COMMENT 'Deprecated',
718 `type` varchar(20) COMMENT 'Deprecated',
719 `bookmark` boolean COMMENT 'Deprecated',
720 `file` mediumtext COMMENT 'Deprecated',
721 `location` varchar(255) COMMENT 'Deprecated',
722 `coord` varchar(255) COMMENT 'Deprecated',
723 `tag` mediumtext COMMENT 'Deprecated',
724 `plink` varchar(255) COMMENT 'Deprecated',
725 `title` varchar(255) COMMENT 'Deprecated',
726 `content-warning` varchar(255) COMMENT 'Deprecated',
727 `body` mediumtext COMMENT 'Deprecated',
728 `app` varchar(255) COMMENT 'Deprecated',
729 `verb` varchar(100) COMMENT 'Deprecated',
730 `object-type` varchar(100) COMMENT 'Deprecated',
731 `object` text COMMENT 'Deprecated',
732 `target-type` varchar(100) COMMENT 'Deprecated',
733 `target` text COMMENT 'Deprecated',
734 `author-name` varchar(255) COMMENT 'Deprecated',
735 `author-link` varchar(255) COMMENT 'Deprecated',
736 `author-avatar` varchar(255) COMMENT 'Deprecated',
737 `owner-name` varchar(255) COMMENT 'Deprecated',
738 `owner-link` varchar(255) COMMENT 'Deprecated',
739 `owner-avatar` varchar(255) COMMENT 'Deprecated',
740 `rendered-hash` varchar(32) COMMENT 'Deprecated',
741 `rendered-html` mediumtext COMMENT 'Deprecated',
743 INDEX `guid` (`guid`(191)),
744 INDEX `uri` (`uri`(191)),
745 INDEX `parent` (`parent`),
746 INDEX `parent-uri` (`parent-uri`(191)),
747 INDEX `extid` (`extid`(191)),
748 INDEX `uid_id` (`uid`,`id`),
749 INDEX `uid_contactid_id` (`uid`,`contact-id`,`id`),
750 INDEX `uid_received` (`uid`,`received`),
751 INDEX `uid_commented` (`uid`,`commented`),
752 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
753 INDEX `uid_network_received` (`uid`,`network`,`received`),
754 INDEX `uid_network_commented` (`uid`,`network`,`commented`),
755 INDEX `uid_thrparent` (`uid`,`thr-parent`(190)),
756 INDEX `uid_parenturi` (`uid`,`parent-uri`(190)),
757 INDEX `uid_contactid_received` (`uid`,`contact-id`,`received`),
758 INDEX `authorid_received` (`author-id`,`received`),
759 INDEX `ownerid` (`owner-id`),
760 INDEX `contact-id` (`contact-id`),
761 INDEX `uid_uri` (`uid`,`uri`(190)),
762 INDEX `resource-id` (`resource-id`),
763 INDEX `deleted_changed` (`deleted`,`changed`),
764 INDEX `uid_wall_changed` (`uid`,`wall`,`changed`),
765 INDEX `uid_unseen_wall` (`uid`,`unseen`,`wall`),
766 INDEX `mention_uid_id` (`mention`,`uid`,`id`),
767 INDEX `uid_eventid` (`uid`,`event-id`),
768 INDEX `icid` (`icid`),
769 INDEX `iaid` (`iaid`),
771 INDEX `psid_wall` (`psid`,`wall`),
772 INDEX `uri-id` (`uri-id`),
773 INDEX `parent-uri-id` (`parent-uri-id`),
774 INDEX `thr-parent-id` (`thr-parent-id`),
775 INDEX `causer-id` (`causer-id`),
776 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
777 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
778 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
779 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
780 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
781 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
782 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
783 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
784 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
785 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
786 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
789 -- TABLE item-activity
791 CREATE TABLE IF NOT EXISTS `item-activity` (
792 `id` int unsigned NOT NULL auto_increment,
793 `uri` varchar(255) COMMENT '',
794 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
795 `uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
796 `activity` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
798 UNIQUE INDEX `uri-hash` (`uri-hash`),
799 INDEX `uri` (`uri`(191)),
800 INDEX `uri-id` (`uri-id`),
801 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
802 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activities for items';
805 -- TABLE item-content
807 CREATE TABLE IF NOT EXISTS `item-content` (
808 `id` int unsigned NOT NULL auto_increment,
809 `uri` varchar(255) COMMENT '',
810 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
811 `uri-plink-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
812 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
813 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
814 `body` mediumtext COMMENT 'item body content',
815 `raw-body` mediumtext COMMENT 'Body without embedded media links',
816 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
817 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
818 `language` text COMMENT 'Language information about this post',
819 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
820 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
821 `rendered-html` mediumtext COMMENT 'item.body converted to html',
822 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
823 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
824 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
825 `target` text COMMENT 'JSON encoded target structure if used',
826 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
827 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams verb',
829 UNIQUE INDEX `uri-plink-hash` (`uri-plink-hash`),
830 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
831 INDEX `uri` (`uri`(191)),
832 INDEX `plink` (`plink`(191)),
833 INDEX `uri-id` (`uri-id`),
834 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
835 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
840 CREATE TABLE IF NOT EXISTS `locks` (
841 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
842 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
843 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
844 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
845 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
847 INDEX `name_expires` (`name`,`expires`)
848 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
853 CREATE TABLE IF NOT EXISTS `mail` (
854 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
855 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
856 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
857 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
858 `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
859 `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
860 `contact-id` varchar(255) COMMENT 'contact.id',
861 `convid` int unsigned COMMENT 'conv.id',
862 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
863 `body` mediumtext COMMENT '',
864 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
865 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
866 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
867 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
868 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
869 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
870 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
872 INDEX `uid_seen` (`uid`,`seen`),
873 INDEX `convid` (`convid`),
874 INDEX `uri` (`uri`(64)),
875 INDEX `parent-uri` (`parent-uri`(64)),
876 INDEX `contactid` (`contact-id`(32)),
877 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
878 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
883 CREATE TABLE IF NOT EXISTS `mailacct` (
884 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
885 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
886 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
887 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
888 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
889 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
890 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
891 `pass` text COMMENT '',
892 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
893 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
894 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
895 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
896 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
899 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
900 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
905 CREATE TABLE IF NOT EXISTS `manage` (
906 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
907 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
908 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
910 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
912 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
913 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
914 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
919 CREATE TABLE IF NOT EXISTS `notify` (
920 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
921 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
922 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
923 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
924 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
925 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
926 `msg` mediumtext COMMENT '',
927 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
928 `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
929 `iid` int unsigned COMMENT 'item.id',
930 `parent` int unsigned COMMENT '',
931 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
932 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
933 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
934 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
935 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
936 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
937 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
939 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
940 INDEX `uid_date` (`uid`,`date`),
941 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
942 INDEX `uri-id` (`uri-id`),
943 INDEX `parent-uri-id` (`parent-uri-id`),
944 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
945 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
946 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
947 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
950 -- TABLE notify-threads
952 CREATE TABLE IF NOT EXISTS `notify-threads` (
953 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
954 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
955 `master-parent-item` int unsigned COMMENT '',
956 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
957 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
958 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
960 INDEX `master-parent-item` (`master-parent-item`),
961 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
962 INDEX `receiver-uid` (`receiver-uid`),
963 INDEX `notify-id` (`notify-id`),
964 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
965 FOREIGN KEY (`master-parent-item`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
966 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
967 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
968 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
973 CREATE TABLE IF NOT EXISTS `oembed` (
974 `url` varbinary(255) NOT NULL COMMENT 'page url',
975 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
976 `content` mediumtext COMMENT 'OEmbed data of the page',
977 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
978 PRIMARY KEY(`url`,`maxwidth`),
979 INDEX `created` (`created`)
980 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
983 -- TABLE openwebauth-token
985 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
986 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
987 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
988 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
989 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
990 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
991 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
994 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
995 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
1000 CREATE TABLE IF NOT EXISTS `parsed_url` (
1001 `url` varbinary(255) NOT NULL COMMENT 'page url',
1002 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
1003 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
1004 `content` mediumtext COMMENT 'page data',
1005 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1006 PRIMARY KEY(`url`,`guessing`,`oembed`),
1007 INDEX `created` (`created`)
1008 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
1011 -- TABLE participation
1013 CREATE TABLE IF NOT EXISTS `participation` (
1014 `iid` int unsigned NOT NULL COMMENT '',
1015 `server` varchar(60) NOT NULL COMMENT '',
1016 `cid` int unsigned NOT NULL COMMENT '',
1017 `fid` int unsigned NOT NULL COMMENT '',
1018 PRIMARY KEY(`iid`,`server`),
1019 INDEX `cid` (`cid`),
1020 INDEX `fid` (`fid`),
1021 FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1022 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1023 FOREIGN KEY (`fid`) REFERENCES `fcontact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1024 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Storage for participation messages from Diaspora';
1029 CREATE TABLE IF NOT EXISTS `pconfig` (
1030 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
1031 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1032 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
1033 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
1034 `v` mediumtext COMMENT 'Value',
1036 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
1037 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1038 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
1043 CREATE TABLE IF NOT EXISTS `photo` (
1044 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1045 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1046 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1047 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
1048 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
1049 `hash` char(32) COMMENT 'hash value of the photo',
1050 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
1051 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
1052 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1053 `desc` text COMMENT '',
1054 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
1055 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1056 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
1057 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1058 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1059 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1060 `data` mediumblob NOT NULL COMMENT '',
1061 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1062 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
1063 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
1064 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
1065 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
1066 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
1067 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
1068 `backend-class` tinytext COMMENT 'Storage backend class',
1069 `backend-ref` text COMMENT 'Storage backend data reference',
1070 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1072 INDEX `contactid` (`contact-id`),
1073 INDEX `uid_contactid` (`uid`,`contact-id`),
1074 INDEX `uid_profile` (`uid`,`profile`),
1075 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
1076 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
1077 INDEX `resource-id` (`resource-id`),
1078 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1079 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1080 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1083 -- TABLE post-category
1085 CREATE TABLE IF NOT EXISTS `post-category` (
1086 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1087 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1088 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1089 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1090 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1091 INDEX `uri-id` (`tid`),
1092 INDEX `uid` (`uid`),
1093 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1094 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1095 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1096 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1099 -- TABLE post-delivery-data
1101 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1102 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1103 `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',
1104 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1105 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1106 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1107 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1108 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1109 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1110 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1111 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1112 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1113 PRIMARY KEY(`uri-id`),
1114 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1115 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1120 CREATE TABLE IF NOT EXISTS `post-media` (
1121 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1122 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1123 `url` varbinary(511) NOT NULL COMMENT 'Media URL',
1124 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1125 `mimetype` varchar(60) COMMENT '',
1126 `height` smallint unsigned COMMENT 'Height of the media',
1127 `width` smallint unsigned COMMENT 'Width of the media',
1128 `size` int unsigned COMMENT 'Media size',
1129 `preview` varbinary(255) COMMENT 'Preview URL',
1130 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1131 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1132 `description` text COMMENT '',
1134 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1135 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1136 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1141 CREATE TABLE IF NOT EXISTS `post-tag` (
1142 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1143 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1144 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1145 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1146 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1147 INDEX `tid` (`tid`),
1148 INDEX `cid` (`cid`),
1149 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1150 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1151 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1152 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1157 CREATE TABLE IF NOT EXISTS `post-user` (
1158 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1159 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1160 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1161 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1162 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1163 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1164 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1165 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1166 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1167 PRIMARY KEY(`uid`,`uri-id`),
1168 INDEX `uri-id` (`uri-id`),
1169 INDEX `contact-id` (`contact-id`),
1170 INDEX `psid` (`psid`),
1171 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1172 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1173 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1174 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1175 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1180 CREATE TABLE IF NOT EXISTS `process` (
1181 `pid` int unsigned NOT NULL COMMENT '',
1182 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1183 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1185 INDEX `command` (`command`)
1186 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1191 CREATE TABLE IF NOT EXISTS `profile` (
1192 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1193 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1194 `profile-name` varchar(255) COMMENT 'Deprecated',
1195 `is-default` boolean COMMENT 'Deprecated',
1196 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1197 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1198 `pdesc` varchar(255) COMMENT 'Deprecated',
1199 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1200 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1201 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1202 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1203 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1204 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1205 `hometown` varchar(255) COMMENT 'Deprecated',
1206 `gender` varchar(32) COMMENT 'Deprecated',
1207 `marital` varchar(255) COMMENT 'Deprecated',
1208 `with` text COMMENT 'Deprecated',
1209 `howlong` datetime COMMENT 'Deprecated',
1210 `sexual` varchar(255) COMMENT 'Deprecated',
1211 `politic` varchar(255) COMMENT 'Deprecated',
1212 `religion` varchar(255) COMMENT 'Deprecated',
1213 `pub_keywords` text COMMENT '',
1214 `prv_keywords` text COMMENT '',
1215 `likes` text COMMENT 'Deprecated',
1216 `dislikes` text COMMENT 'Deprecated',
1217 `about` text COMMENT 'Profile description',
1218 `summary` varchar(255) COMMENT 'Deprecated',
1219 `music` text COMMENT 'Deprecated',
1220 `book` text COMMENT 'Deprecated',
1221 `tv` text COMMENT 'Deprecated',
1222 `film` text COMMENT 'Deprecated',
1223 `interest` text COMMENT 'Deprecated',
1224 `romance` text COMMENT 'Deprecated',
1225 `work` text COMMENT 'Deprecated',
1226 `education` text COMMENT 'Deprecated',
1227 `contact` text COMMENT 'Deprecated',
1228 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1229 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1230 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1231 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1232 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1233 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1235 INDEX `uid_is-default` (`uid`,`is-default`),
1236 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1237 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1238 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1241 -- TABLE profile_check
1243 CREATE TABLE IF NOT EXISTS `profile_check` (
1244 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1245 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1246 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1247 `dfrn_id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1248 `sec` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1249 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1251 INDEX `uid` (`uid`),
1252 INDEX `cid` (`cid`),
1253 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1254 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1255 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='DFRN remote auth use';
1258 -- TABLE profile_field
1260 CREATE TABLE IF NOT EXISTS `profile_field` (
1261 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1262 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1263 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1264 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1265 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1266 `value` text COMMENT 'Value of the field',
1267 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1268 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1270 INDEX `uid` (`uid`),
1271 INDEX `order` (`order`),
1272 INDEX `psid` (`psid`),
1273 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1274 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1275 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1278 -- TABLE push_subscriber
1280 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1281 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1282 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1283 `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1284 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1285 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1286 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1287 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1288 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1289 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1290 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1292 INDEX `next_try` (`next_try`),
1293 INDEX `uid` (`uid`),
1294 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1295 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1300 CREATE TABLE IF NOT EXISTS `register` (
1301 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1302 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1303 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1304 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1305 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1306 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1307 `note` text COMMENT '',
1309 INDEX `uid` (`uid`),
1310 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1311 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1316 CREATE TABLE IF NOT EXISTS `search` (
1317 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1318 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1319 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1321 INDEX `uid` (`uid`),
1322 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1323 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1328 CREATE TABLE IF NOT EXISTS `session` (
1329 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1330 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1331 `data` text COMMENT '',
1332 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1334 INDEX `sid` (`sid`(64)),
1335 INDEX `expire` (`expire`)
1336 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1341 CREATE TABLE IF NOT EXISTS `storage` (
1342 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1343 `data` longblob NOT NULL COMMENT 'file data',
1345 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1350 CREATE TABLE IF NOT EXISTS `thread` (
1351 `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'sequential ID',
1352 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
1353 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1354 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1355 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1356 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1357 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1358 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1359 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1360 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1361 `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1362 `wall` boolean NOT NULL DEFAULT '0' COMMENT '',
1363 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1364 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1365 `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
1366 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1367 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1368 `ignored` boolean NOT NULL DEFAULT '0' COMMENT '',
1369 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
1370 `unseen` boolean NOT NULL DEFAULT '1' COMMENT '',
1371 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '',
1372 `origin` boolean NOT NULL DEFAULT '0' COMMENT '',
1373 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1374 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1375 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1376 `bookmark` boolean COMMENT '',
1378 INDEX `uid_network_commented` (`uid`,`network`,`commented`),
1379 INDEX `uid_network_received` (`uid`,`network`,`received`),
1380 INDEX `uid_contactid_commented` (`uid`,`contact-id`,`commented`),
1381 INDEX `uid_contactid_received` (`uid`,`contact-id`,`received`),
1382 INDEX `contactid` (`contact-id`),
1383 INDEX `ownerid` (`owner-id`),
1384 INDEX `authorid` (`author-id`),
1385 INDEX `uid_received` (`uid`,`received`),
1386 INDEX `uid_commented` (`uid`,`commented`),
1387 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1388 INDEX `private_wall_origin_commented` (`private`,`wall`,`origin`,`commented`),
1389 INDEX `uri-id` (`uri-id`),
1390 FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1391 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1392 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1393 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1394 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1395 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1396 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1401 CREATE TABLE IF NOT EXISTS `tokens` (
1402 `id` varchar(40) NOT NULL COMMENT '',
1403 `secret` text COMMENT '',
1404 `client_id` varchar(20) NOT NULL DEFAULT '',
1405 `expires` int NOT NULL DEFAULT 0 COMMENT '',
1406 `scope` varchar(200) NOT NULL DEFAULT '' COMMENT '',
1407 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1409 INDEX `client_id` (`client_id`),
1410 INDEX `uid` (`uid`),
1411 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1412 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1413 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
1418 CREATE TABLE IF NOT EXISTS `userd` (
1419 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1420 `username` varchar(255) NOT NULL COMMENT '',
1422 INDEX `username` (`username`(32))
1423 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1426 -- TABLE user-contact
1428 CREATE TABLE IF NOT EXISTS `user-contact` (
1429 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1430 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1431 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1432 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1433 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1434 PRIMARY KEY(`uid`,`cid`),
1435 INDEX `cid` (`cid`),
1436 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1437 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1438 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1443 CREATE TABLE IF NOT EXISTS `user-item` (
1444 `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item id',
1445 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1446 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide an item from the user',
1447 `ignored` boolean COMMENT 'Ignore this thread if set',
1448 `pinned` boolean COMMENT 'The item is pinned on the profile page',
1449 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1450 PRIMARY KEY(`uid`,`iid`),
1451 INDEX `uid_pinned` (`uid`,`pinned`),
1452 INDEX `iid_uid` (`iid`,`uid`),
1453 FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1454 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1455 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific item data';
1460 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1461 `key` int NOT NULL COMMENT '',
1462 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1464 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1467 -- TABLE workerqueue
1469 CREATE TABLE IF NOT EXISTS `workerqueue` (
1470 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
1471 `command` varchar(100) COMMENT 'Task command',
1472 `parameter` mediumtext COMMENT 'Task parameter',
1473 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
1474 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
1475 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
1476 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
1477 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1478 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1479 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
1481 INDEX `command` (`command`),
1482 INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
1483 INDEX `done_executed` (`done`,`executed`),
1484 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
1485 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
1486 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
1487 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
1488 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
1489 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
1494 DROP VIEW IF EXISTS `post-view`;
1495 CREATE VIEW `post-view` AS SELECT
1496 `item`.`id` AS `id`,
1497 `item`.`id` AS `item_id`,
1498 `item`.`uid` AS `uid`,
1499 `item`.`uid` AS `internal-uid`,
1500 `item`.`parent` AS `parent`,
1501 `item`.`uri` AS `uri`,
1502 `item`.`uri-id` AS `uri-id`,
1503 `item`.`uri-id` AS `internal-uri-id`,
1504 `item`.`parent-uri` AS `parent-uri`,
1505 `item`.`parent-uri-id` AS `parent-uri-id`,
1506 `item`.`thr-parent` AS `thr-parent`,
1507 `item`.`thr-parent-id` AS `thr-parent-id`,
1508 `item`.`guid` AS `guid`,
1509 `item`.`type` AS `type`,
1510 `item`.`wall` AS `wall`,
1511 `item`.`gravity` AS `gravity`,
1512 `item`.`extid` AS `extid`,
1513 `item`.`created` AS `created`,
1514 `item`.`edited` AS `edited`,
1515 `item`.`commented` AS `commented`,
1516 `item`.`received` AS `received`,
1517 `item`.`changed` AS `changed`,
1518 `item`.`resource-id` AS `resource-id`,
1519 `item`.`post-type` AS `post-type`,
1520 `item`.`private` AS `private`,
1521 `item`.`pubmail` AS `pubmail`,
1522 `item`.`moderated` AS `moderated`,
1523 `item`.`visible` AS `visible`,
1524 `item`.`starred` AS `starred`,
1525 `item`.`bookmark` AS `bookmark`,
1526 `item`.`unseen` AS `unseen`,
1527 `item`.`deleted` AS `deleted`,
1528 `item`.`origin` AS `origin`,
1529 `item`.`forum_mode` AS `forum_mode`,
1530 `item`.`mention` AS `mention`,
1531 `item`.`global` AS `global`,
1532 `item`.`network` AS `network`,
1533 `item`.`icid` AS `icid`,
1534 `item`.`vid` AS `vid`,
1535 `item`.`psid` AS `psid`,
1536 `item`.`attach` AS `attach`,
1537 (SELECT COUNT(*) FROM `post-category` WHERE `post-category`.`uri-id` = `item`.`uri-id`) AS `internal-file-count`,
1539 IF (`item`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1540 `item-content`.`title` AS `title`,
1541 `item-content`.`content-warning` AS `content-warning`,
1542 `item-content`.`raw-body` AS `raw-body`,
1543 `item-content`.`body` AS `body`,
1544 `item-content`.`rendered-hash` AS `rendered-hash`,
1545 `item-content`.`rendered-html` AS `rendered-html`,
1546 `item-content`.`language` AS `language`,
1547 `item-content`.`plink` AS `plink`,
1548 `item-content`.`location` AS `location`,
1549 `item-content`.`coord` AS `coord`,
1550 `item-content`.`app` AS `app`,
1551 `item-content`.`object-type` AS `object-type`,
1552 `item-content`.`object` AS `object`,
1553 `item-content`.`target-type` AS `target-type`,
1554 `item-content`.`target` AS `target`,
1555 `item`.`contact-id` AS `contact-id`,
1556 `contact`.`url` AS `contact-link`,
1557 `contact`.`addr` AS `contact-addr`,
1558 `contact`.`name` AS `contact-name`,
1559 `contact`.`nick` AS `contact-nick`,
1560 `contact`.`thumb` AS `contact-avatar`,
1561 `contact`.`network` AS `contact-network`,
1562 `contact`.`blocked` AS `contact-blocked`,
1563 `contact`.`hidden` AS `contact-hidden`,
1564 `contact`.`readonly` AS `contact-readonly`,
1565 `contact`.`archive` AS `contact-archive`,
1566 `contact`.`pending` AS `contact-pending`,
1567 `contact`.`rel` AS `contact-rel`,
1568 `contact`.`uid` AS `contact-uid`,
1569 `contact`.`contact-type` AS `contact-contact-type`,
1570 IF (`item`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1571 `contact`.`self` AS `self`,
1572 `contact`.`id` AS `cid`,
1573 `contact`.`alias` AS `alias`,
1574 `contact`.`photo` AS `photo`,
1575 `contact`.`name-date` AS `name-date`,
1576 `contact`.`uri-date` AS `uri-date`,
1577 `contact`.`avatar-date` AS `avatar-date`,
1578 `contact`.`thumb` AS `thumb`,
1579 `contact`.`dfrn-id` AS `dfrn-id`,
1580 `item`.`author-id` AS `author-id`,
1581 `author`.`url` AS `author-link`,
1582 `author`.`addr` AS `author-addr`,
1583 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1584 `author`.`nick` AS `author-nick`,
1585 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1586 `author`.`network` AS `author-network`,
1587 `author`.`blocked` AS `author-blocked`,
1588 `author`.`hidden` AS `author-hidden`,
1589 `item`.`owner-id` AS `owner-id`,
1590 `owner`.`url` AS `owner-link`,
1591 `owner`.`addr` AS `owner-addr`,
1592 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1593 `owner`.`nick` AS `owner-nick`,
1594 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1595 `owner`.`network` AS `owner-network`,
1596 `owner`.`blocked` AS `owner-blocked`,
1597 `owner`.`hidden` AS `owner-hidden`,
1598 `item`.`causer-id` AS `causer-id`,
1599 `causer`.`url` AS `causer-link`,
1600 `causer`.`addr` AS `causer-addr`,
1601 `causer`.`name` AS `causer-name`,
1602 `causer`.`nick` AS `causer-nick`,
1603 `causer`.`thumb` AS `causer-avatar`,
1604 `causer`.`network` AS `causer-network`,
1605 `causer`.`blocked` AS `causer-blocked`,
1606 `causer`.`hidden` AS `causer-hidden`,
1607 `causer`.`contact-type` AS `causer-contact-type`,
1608 `post-delivery-data`.`postopts` AS `postopts`,
1609 `post-delivery-data`.`inform` AS `inform`,
1610 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1611 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1612 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1613 IF (`item`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1614 IF (`item`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1615 IF (`item`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1616 IF (`item`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1617 `item`.`event-id` AS `event-id`,
1618 `event`.`created` AS `event-created`,
1619 `event`.`edited` AS `event-edited`,
1620 `event`.`start` AS `event-start`,
1621 `event`.`finish` AS `event-finish`,
1622 `event`.`summary` AS `event-summary`,
1623 `event`.`desc` AS `event-desc`,
1624 `event`.`location` AS `event-location`,
1625 `event`.`type` AS `event-type`,
1626 `event`.`nofinish` AS `event-nofinish`,
1627 `event`.`adjust` AS `event-adjust`,
1628 `event`.`ignore` AS `event-ignore`,
1629 `diaspora-interaction`.`interaction` AS `signed_text`,
1630 `parent-item`.`guid` AS `parent-guid`,
1631 `parent-item`.`network` AS `parent-network`,
1632 `parent-item`.`author-id` AS `parent-author-id`,
1633 `parent-item-author`.`url` AS `parent-author-link`,
1634 `parent-item-author`.`name` AS `parent-author-name`,
1635 `parent-item-author`.`network` AS `parent-author-network`
1637 STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
1638 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `item`.`author-id`
1639 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `item`.`owner-id`
1640 STRAIGHT_JOIN `contact` AS `causer` ON `causer`.`id` = `item`.`causer-id`
1641 LEFT JOIN `verb` ON `verb`.`id` = `item`.`vid`
1642 LEFT JOIN `event` ON `event`.`id` = `item`.`event-id`
1643 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `item`.`uri-id`
1644 LEFT JOIN `item-content` ON `item-content`.`uri-id` = `item`.`uri-id`
1645 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `item`.`uri-id` AND `item`.`origin`
1646 LEFT JOIN `permissionset` ON `permissionset`.`id` = `item`.`psid`
1647 STRAIGHT_JOIN `item` AS `parent-item` ON `parent-item`.`uri-id` = `item`.`parent-uri-id` AND `parent-item`.`uid` = `item`.`uid`
1648 STRAIGHT_JOIN `contact` AS `parent-item-author` ON `parent-item-author`.`id` = `parent-item`.`author-id`;
1651 -- VIEW post-thread-view
1653 DROP VIEW IF EXISTS `post-thread-view`;
1654 CREATE VIEW `post-thread-view` AS SELECT
1655 `item`.`id` AS `id`,
1656 `thread`.`iid` AS `iid`,
1657 `item`.`id` AS `item_id`,
1658 `thread`.`uid` AS `uid`,
1659 `item`.`uid` AS `internal-uid`,
1660 `item`.`parent` AS `parent`,
1661 `item`.`uri` AS `uri`,
1662 `item`.`uri-id` AS `uri-id`,
1663 `item`.`uri-id` AS `internal-uri-id`,
1664 `item`.`parent-uri` AS `parent-uri`,
1665 `item`.`parent-uri-id` AS `parent-uri-id`,
1666 `item`.`thr-parent` AS `thr-parent`,
1667 `item`.`thr-parent-id` AS `thr-parent-id`,
1668 `item`.`guid` AS `guid`,
1669 `item`.`type` AS `type`,
1670 `thread`.`wall` AS `wall`,
1671 `item`.`gravity` AS `gravity`,
1672 `item`.`extid` AS `extid`,
1673 `thread`.`created` AS `created`,
1674 `item`.`edited` AS `edited`,
1675 `thread`.`commented` AS `commented`,
1676 `thread`.`received` AS `received`,
1677 `thread`.`changed` AS `changed`,
1678 `item`.`resource-id` AS `resource-id`,
1679 `thread`.`post-type` AS `post-type`,
1680 `thread`.`private` AS `private`,
1681 `thread`.`pubmail` AS `pubmail`,
1682 `thread`.`moderated` AS `moderated`,
1683 `thread`.`ignored` AS `ignored`,
1684 `thread`.`visible` AS `visible`,
1685 `thread`.`starred` AS `starred`,
1686 `item`.`bookmark` AS `bookmark`,
1687 `item`.`unseen` AS `unseen`,
1688 `thread`.`deleted` AS `deleted`,
1689 `thread`.`origin` AS `origin`,
1690 `thread`.`forum_mode` AS `forum_mode`,
1691 `thread`.`mention` AS `mention`,
1692 `item`.`global` AS `global`,
1693 `thread`.`network` AS `network`,
1694 `item`.`icid` AS `icid`,
1695 `item`.`vid` AS `vid`,
1696 `item`.`psid` AS `psid`,
1697 `item`.`attach` AS `attach`,
1698 (SELECT COUNT(*) FROM `post-category` WHERE `post-category`.`uri-id` = `item`.`uri-id`) AS `internal-file-count`,
1700 IF (`item`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1701 `item-content`.`title` AS `title`,
1702 `item-content`.`content-warning` AS `content-warning`,
1703 `item-content`.`raw-body` AS `raw-body`,
1704 `item-content`.`body` AS `body`,
1705 `item-content`.`rendered-hash` AS `rendered-hash`,
1706 `item-content`.`rendered-html` AS `rendered-html`,
1707 `item-content`.`language` AS `language`,
1708 `item-content`.`plink` AS `plink`,
1709 `item-content`.`location` AS `location`,
1710 `item-content`.`coord` AS `coord`,
1711 `item-content`.`app` AS `app`,
1712 `item-content`.`object-type` AS `object-type`,
1713 `item-content`.`object` AS `object`,
1714 `item-content`.`target-type` AS `target-type`,
1715 `item-content`.`target` AS `target`,
1716 `thread`.`contact-id` AS `contact-id`,
1717 `contact`.`url` AS `contact-link`,
1718 `contact`.`addr` AS `contact-addr`,
1719 `contact`.`name` AS `contact-name`,
1720 `contact`.`nick` AS `contact-nick`,
1721 `contact`.`thumb` AS `contact-avatar`,
1722 `contact`.`network` AS `contact-network`,
1723 `contact`.`blocked` AS `contact-blocked`,
1724 `contact`.`hidden` AS `contact-hidden`,
1725 `contact`.`readonly` AS `contact-readonly`,
1726 `contact`.`archive` AS `contact-archive`,
1727 `contact`.`pending` AS `contact-pending`,
1728 `contact`.`rel` AS `contact-rel`,
1729 `contact`.`uid` AS `contact-uid`,
1730 `contact`.`contact-type` AS `contact-contact-type`,
1731 IF (`item`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1732 `contact`.`self` AS `self`,
1733 `contact`.`id` AS `cid`,
1734 `contact`.`alias` AS `alias`,
1735 `contact`.`photo` AS `photo`,
1736 `contact`.`name-date` AS `name-date`,
1737 `contact`.`uri-date` AS `uri-date`,
1738 `contact`.`avatar-date` AS `avatar-date`,
1739 `contact`.`thumb` AS `thumb`,
1740 `contact`.`dfrn-id` AS `dfrn-id`,
1741 `thread`.`author-id` AS `author-id`,
1742 `author`.`url` AS `author-link`,
1743 `author`.`addr` AS `author-addr`,
1744 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1745 `author`.`nick` AS `author-nick`,
1746 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1747 `author`.`network` AS `author-network`,
1748 `author`.`blocked` AS `author-blocked`,
1749 `author`.`hidden` AS `author-hidden`,
1750 `thread`.`owner-id` AS `owner-id`,
1751 `owner`.`url` AS `owner-link`,
1752 `owner`.`addr` AS `owner-addr`,
1753 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1754 `owner`.`nick` AS `owner-nick`,
1755 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1756 `owner`.`network` AS `owner-network`,
1757 `owner`.`blocked` AS `owner-blocked`,
1758 `owner`.`hidden` AS `owner-hidden`,
1759 `item`.`causer-id` AS `causer-id`,
1760 `causer`.`url` AS `causer-link`,
1761 `causer`.`addr` AS `causer-addr`,
1762 `causer`.`name` AS `causer-name`,
1763 `causer`.`nick` AS `causer-nick`,
1764 `causer`.`thumb` AS `causer-avatar`,
1765 `causer`.`network` AS `causer-network`,
1766 `causer`.`blocked` AS `causer-blocked`,
1767 `causer`.`hidden` AS `causer-hidden`,
1768 `causer`.`contact-type` AS `causer-contact-type`,
1769 `post-delivery-data`.`postopts` AS `postopts`,
1770 `post-delivery-data`.`inform` AS `inform`,
1771 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1772 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1773 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1774 IF (`item`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1775 IF (`item`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1776 IF (`item`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1777 IF (`item`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1778 `item`.`event-id` AS `event-id`,
1779 `event`.`created` AS `event-created`,
1780 `event`.`edited` AS `event-edited`,
1781 `event`.`start` AS `event-start`,
1782 `event`.`finish` AS `event-finish`,
1783 `event`.`summary` AS `event-summary`,
1784 `event`.`desc` AS `event-desc`,
1785 `event`.`location` AS `event-location`,
1786 `event`.`type` AS `event-type`,
1787 `event`.`nofinish` AS `event-nofinish`,
1788 `event`.`adjust` AS `event-adjust`,
1789 `event`.`ignore` AS `event-ignore`,
1790 `diaspora-interaction`.`interaction` AS `signed_text`,
1791 `parent-item`.`guid` AS `parent-guid`,
1792 `parent-item`.`network` AS `parent-network`,
1793 `parent-item`.`author-id` AS `parent-author-id`,
1794 `parent-item-author`.`url` AS `parent-author-link`,
1795 `parent-item-author`.`name` AS `parent-author-name`,
1796 `parent-item-author`.`network` AS `parent-author-network`
1798 STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
1799 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
1800 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `thread`.`author-id`
1801 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `thread`.`owner-id`
1802 STRAIGHT_JOIN `contact` AS `causer` ON `causer`.`id` = `item`.`causer-id`
1803 LEFT JOIN `verb` ON `verb`.`id` = `item`.`vid`
1804 LEFT JOIN `event` ON `event`.`id` = `item`.`event-id`
1805 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `thread`.`uri-id`
1806 LEFT JOIN `item-content` ON `item-content`.`uri-id` = `thread`.`uri-id`
1807 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `thread`.`uri-id` AND `thread`.`origin`
1808 LEFT JOIN `permissionset` ON `permissionset`.`id` = `item`.`psid`
1809 STRAIGHT_JOIN `item` AS `parent-item` ON `parent-item`.`id` = `item`.`parent`
1810 STRAIGHT_JOIN `contact` AS `parent-item-author` ON `parent-item-author`.`id` = `parent-item`.`author-id`;
1813 -- VIEW category-view
1815 DROP VIEW IF EXISTS `category-view`;
1816 CREATE VIEW `category-view` AS SELECT
1817 `post-category`.`uri-id` AS `uri-id`,
1818 `post-category`.`uid` AS `uid`,
1819 `item-uri`.`uri` AS `uri`,
1820 `item-uri`.`guid` AS `guid`,
1821 `post-category`.`type` AS `type`,
1822 `post-category`.`tid` AS `tid`,
1823 `tag`.`name` AS `name`,
1824 `tag`.`url` AS `url`
1825 FROM `post-category`
1826 INNER JOIN `item-uri` ON `item-uri`.id = `post-category`.`uri-id`
1827 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
1832 DROP VIEW IF EXISTS `tag-view`;
1833 CREATE VIEW `tag-view` AS SELECT
1834 `post-tag`.`uri-id` AS `uri-id`,
1835 `item-uri`.`uri` AS `uri`,
1836 `item-uri`.`guid` AS `guid`,
1837 `post-tag`.`type` AS `type`,
1838 `post-tag`.`tid` AS `tid`,
1839 `post-tag`.`cid` AS `cid`,
1840 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
1841 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
1843 INNER JOIN `item-uri` ON `item-uri`.id = `post-tag`.`uri-id`
1844 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
1845 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
1848 -- VIEW network-item-view
1850 DROP VIEW IF EXISTS `network-item-view`;
1851 CREATE VIEW `network-item-view` AS SELECT
1852 `item`.`parent-uri-id` AS `uri-id`,
1853 `item`.`parent-uri` AS `uri`,
1854 `item`.`parent` AS `parent`,
1855 `item`.`received` AS `received`,
1856 `item`.`commented` AS `commented`,
1857 `item`.`created` AS `created`,
1858 `item`.`uid` AS `uid`,
1859 `item`.`starred` AS `starred`,
1860 `item`.`mention` AS `mention`,
1861 `item`.`network` AS `network`,
1862 `item`.`unseen` AS `unseen`,
1863 `item`.`gravity` AS `gravity`,
1864 `item`.`contact-id` AS `contact-id`,
1865 `ownercontact`.`contact-type` AS `contact-type`
1867 INNER JOIN `thread` ON `thread`.`iid` = `item`.`parent`
1868 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
1869 LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
1870 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
1871 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
1872 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
1873 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
1874 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
1875 AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
1876 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
1877 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
1880 -- VIEW network-thread-view
1882 DROP VIEW IF EXISTS `network-thread-view`;
1883 CREATE VIEW `network-thread-view` AS SELECT
1884 `item`.`uri-id` AS `uri-id`,
1885 `item`.`uri` AS `uri`,
1886 `item`.`parent-uri-id` AS `parent-uri-id`,
1887 `thread`.`iid` AS `parent`,
1888 `thread`.`received` AS `received`,
1889 `thread`.`commented` AS `commented`,
1890 `thread`.`created` AS `created`,
1891 `thread`.`uid` AS `uid`,
1892 `thread`.`starred` AS `starred`,
1893 `thread`.`mention` AS `mention`,
1894 `thread`.`network` AS `network`,
1895 `thread`.`contact-id` AS `contact-id`,
1896 `ownercontact`.`contact-type` AS `contact-type`
1898 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
1899 STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
1900 LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
1901 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
1902 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
1903 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
1904 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
1905 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
1906 AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
1907 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
1908 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
1913 DROP VIEW IF EXISTS `owner-view`;
1914 CREATE VIEW `owner-view` AS SELECT
1915 `contact`.`id` AS `id`,
1916 `contact`.`uid` AS `uid`,
1917 `contact`.`created` AS `created`,
1918 `contact`.`updated` AS `updated`,
1919 `contact`.`self` AS `self`,
1920 `contact`.`remote_self` AS `remote_self`,
1921 `contact`.`rel` AS `rel`,
1922 `contact`.`duplex` AS `duplex`,
1923 `contact`.`network` AS `network`,
1924 `contact`.`protocol` AS `protocol`,
1925 `contact`.`name` AS `name`,
1926 `contact`.`nick` AS `nick`,
1927 `contact`.`location` AS `location`,
1928 `contact`.`about` AS `about`,
1929 `contact`.`keywords` AS `keywords`,
1930 `contact`.`gender` AS `gender`,
1931 `contact`.`xmpp` AS `xmpp`,
1932 `contact`.`attag` AS `attag`,
1933 `contact`.`avatar` AS `avatar`,
1934 `contact`.`photo` AS `photo`,
1935 `contact`.`thumb` AS `thumb`,
1936 `contact`.`micro` AS `micro`,
1937 `contact`.`site-pubkey` AS `site-pubkey`,
1938 `contact`.`issued-id` AS `issued-id`,
1939 `contact`.`dfrn-id` AS `dfrn-id`,
1940 `contact`.`url` AS `url`,
1941 `contact`.`nurl` AS `nurl`,
1942 `contact`.`addr` AS `addr`,
1943 `contact`.`alias` AS `alias`,
1944 `contact`.`pubkey` AS `pubkey`,
1945 `contact`.`prvkey` AS `prvkey`,
1946 `contact`.`batch` AS `batch`,
1947 `contact`.`request` AS `request`,
1948 `contact`.`notify` AS `notify`,
1949 `contact`.`poll` AS `poll`,
1950 `contact`.`confirm` AS `confirm`,
1951 `contact`.`poco` AS `poco`,
1952 `contact`.`aes_allow` AS `aes_allow`,
1953 `contact`.`ret-aes` AS `ret-aes`,
1954 `contact`.`usehub` AS `usehub`,
1955 `contact`.`subhub` AS `subhub`,
1956 `contact`.`hub-verify` AS `hub-verify`,
1957 `contact`.`last-update` AS `last-update`,
1958 `contact`.`success_update` AS `success_update`,
1959 `contact`.`failure_update` AS `failure_update`,
1960 `contact`.`name-date` AS `name-date`,
1961 `contact`.`uri-date` AS `uri-date`,
1962 `contact`.`avatar-date` AS `avatar-date`,
1963 `contact`.`avatar-date` AS `picdate`,
1964 `contact`.`term-date` AS `term-date`,
1965 `contact`.`last-item` AS `last-item`,
1966 `contact`.`priority` AS `priority`,
1967 `user`.`blocked` AS `blocked`,
1968 `contact`.`block_reason` AS `block_reason`,
1969 `contact`.`readonly` AS `readonly`,
1970 `contact`.`writable` AS `writable`,
1971 `contact`.`forum` AS `forum`,
1972 `contact`.`prv` AS `prv`,
1973 `contact`.`contact-type` AS `contact-type`,
1974 `contact`.`manually-approve` AS `manually-approve`,
1975 `contact`.`hidden` AS `hidden`,
1976 `contact`.`archive` AS `archive`,
1977 `contact`.`pending` AS `pending`,
1978 `contact`.`deleted` AS `deleted`,
1979 `contact`.`unsearchable` AS `unsearchable`,
1980 `contact`.`sensitive` AS `sensitive`,
1981 `contact`.`baseurl` AS `baseurl`,
1982 `contact`.`reason` AS `reason`,
1983 `contact`.`closeness` AS `closeness`,
1984 `contact`.`info` AS `info`,
1985 `contact`.`profile-id` AS `profile-id`,
1986 `contact`.`bdyear` AS `bdyear`,
1987 `contact`.`bd` AS `bd`,
1988 `contact`.`notify_new_posts` AS `notify_new_posts`,
1989 `contact`.`fetch_further_information` AS `fetch_further_information`,
1990 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
1991 `user`.`parent-uid` AS `parent-uid`,
1992 `user`.`guid` AS `guid`,
1993 `user`.`nickname` AS `nickname`,
1994 `user`.`email` AS `email`,
1995 `user`.`openid` AS `openid`,
1996 `user`.`timezone` AS `timezone`,
1997 `user`.`language` AS `language`,
1998 `user`.`register_date` AS `register_date`,
1999 `user`.`login_date` AS `login_date`,
2000 `user`.`default-location` AS `default-location`,
2001 `user`.`allow_location` AS `allow_location`,
2002 `user`.`theme` AS `theme`,
2003 `user`.`pubkey` AS `upubkey`,
2004 `user`.`prvkey` AS `uprvkey`,
2005 `user`.`sprvkey` AS `sprvkey`,
2006 `user`.`spubkey` AS `spubkey`,
2007 `user`.`verified` AS `verified`,
2008 `user`.`blockwall` AS `blockwall`,
2009 `user`.`hidewall` AS `hidewall`,
2010 `user`.`blocktags` AS `blocktags`,
2011 `user`.`unkmail` AS `unkmail`,
2012 `user`.`cntunkmail` AS `cntunkmail`,
2013 `user`.`notify-flags` AS `notify-flags`,
2014 `user`.`page-flags` AS `page-flags`,
2015 `user`.`account-type` AS `account-type`,
2016 `user`.`prvnets` AS `prvnets`,
2017 `user`.`maxreq` AS `maxreq`,
2018 `user`.`expire` AS `expire`,
2019 `user`.`account_removed` AS `account_removed`,
2020 `user`.`account_expired` AS `account_expired`,
2021 `user`.`account_expires_on` AS `account_expires_on`,
2022 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2023 `user`.`def_gid` AS `def_gid`,
2024 `user`.`allow_cid` AS `allow_cid`,
2025 `user`.`allow_gid` AS `allow_gid`,
2026 `user`.`deny_cid` AS `deny_cid`,
2027 `user`.`deny_gid` AS `deny_gid`,
2028 `user`.`openidserver` AS `openidserver`,
2029 `profile`.`publish` AS `publish`,
2030 `profile`.`net-publish` AS `net-publish`,
2031 `profile`.`hide-friends` AS `hide-friends`,
2032 `profile`.`prv_keywords` AS `prv_keywords`,
2033 `profile`.`pub_keywords` AS `pub_keywords`,
2034 `profile`.`address` AS `address`,
2035 `profile`.`locality` AS `locality`,
2036 `profile`.`region` AS `region`,
2037 `profile`.`postal-code` AS `postal-code`,
2038 `profile`.`country-name` AS `country-name`,
2039 `profile`.`homepage` AS `homepage`,
2040 `profile`.`dob` AS `dob`
2042 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2043 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2046 -- VIEW pending-view
2048 DROP VIEW IF EXISTS `pending-view`;
2049 CREATE VIEW `pending-view` AS SELECT
2050 `register`.`id` AS `id`,
2051 `register`.`hash` AS `hash`,
2052 `register`.`created` AS `created`,
2053 `register`.`uid` AS `uid`,
2054 `register`.`password` AS `password`,
2055 `register`.`language` AS `language`,
2056 `register`.`note` AS `note`,
2057 `contact`.`self` AS `self`,
2058 `contact`.`name` AS `name`,
2059 `contact`.`url` AS `url`,
2060 `contact`.`micro` AS `micro`,
2061 `user`.`email` AS `email`,
2062 `contact`.`nick` AS `nick`
2064 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2065 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2068 -- VIEW tag-search-view
2070 DROP VIEW IF EXISTS `tag-search-view`;
2071 CREATE VIEW `tag-search-view` AS SELECT
2072 `post-tag`.`uri-id` AS `uri-id`,
2073 `item`.`id` AS `iid`,
2074 `item`.`uri` AS `uri`,
2075 `item`.`guid` AS `guid`,
2076 `item`.`uid` AS `uid`,
2077 `item`.`private` AS `private`,
2078 `item`.`wall` AS `wall`,
2079 `item`.`origin` AS `origin`,
2080 `item`.`gravity` AS `gravity`,
2081 `item`.`received` AS `received`,
2082 `tag`.`name` AS `name`
2084 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
2085 INNER JOIN `item` ON `item`.`uri-id` = `post-tag`.`uri-id`
2086 WHERE `post-tag`.`type` = 1;
2089 -- VIEW workerqueue-view
2091 DROP VIEW IF EXISTS `workerqueue-view`;
2092 CREATE VIEW `workerqueue-view` AS SELECT
2093 `process`.`pid` AS `pid`,
2094 `workerqueue`.`priority` AS `priority`
2096 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
2097 WHERE NOT `workerqueue`.`done`;