1 -- ------------------------------------------
2 -- Friendica 2021.03-dev (Red Hot Poker)
3 -- DB_UPDATE_VERSION 1394
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 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
690 `extid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
691 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
692 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
693 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
694 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
695 `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
696 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been deleted',
697 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
698 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
699 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
700 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
701 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
702 `starred` boolean NOT NULL DEFAULT '0' COMMENT 'item has been favourited',
703 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'item has not been seen',
704 `mention` boolean NOT NULL DEFAULT '0' COMMENT 'The owner of this item was mentioned in it',
705 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
706 `psid` int unsigned COMMENT 'ID of the permission set of this post',
707 `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',
708 `event-id` int unsigned COMMENT 'Used to link to the event.id',
709 `iaid` int unsigned COMMENT 'Deprecated',
710 `icid` 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`),
769 INDEX `psid_wall` (`psid`,`wall`),
770 INDEX `uri-id` (`uri-id`),
771 INDEX `parent-uri-id` (`parent-uri-id`),
772 INDEX `thr-parent-id` (`thr-parent-id`),
773 INDEX `causer-id` (`causer-id`),
774 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
775 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
776 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
777 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
778 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
779 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
780 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
781 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
782 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
783 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
784 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
787 -- TABLE item-activity
789 CREATE TABLE IF NOT EXISTS `item-activity` (
790 `id` int unsigned NOT NULL auto_increment,
791 `uri` varchar(255) COMMENT '',
792 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
793 `uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
794 `activity` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
796 UNIQUE INDEX `uri-hash` (`uri-hash`),
797 INDEX `uri` (`uri`(191)),
798 INDEX `uri-id` (`uri-id`),
799 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
800 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activities for items';
803 -- TABLE item-content
805 CREATE TABLE IF NOT EXISTS `item-content` (
806 `id` int unsigned NOT NULL auto_increment,
807 `uri` varchar(255) COMMENT '',
808 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
809 `uri-plink-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
810 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
811 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
812 `body` mediumtext COMMENT 'item body content',
813 `raw-body` mediumtext COMMENT 'Body without embedded media links',
814 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
815 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
816 `language` text COMMENT 'Language information about this post',
817 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
818 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
819 `rendered-html` mediumtext COMMENT 'item.body converted to html',
820 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
821 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
822 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
823 `target` text COMMENT 'JSON encoded target structure if used',
824 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
825 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams verb',
827 UNIQUE INDEX `uri-plink-hash` (`uri-plink-hash`),
828 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
829 INDEX `uri` (`uri`(191)),
830 INDEX `plink` (`plink`(191)),
831 INDEX `uri-id` (`uri-id`),
832 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
833 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
838 CREATE TABLE IF NOT EXISTS `locks` (
839 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
840 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
841 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
842 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
843 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
845 INDEX `name_expires` (`name`,`expires`)
846 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
851 CREATE TABLE IF NOT EXISTS `mail` (
852 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
853 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
854 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
855 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
856 `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
857 `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
858 `contact-id` varchar(255) COMMENT 'contact.id',
859 `convid` int unsigned COMMENT 'conv.id',
860 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
861 `body` mediumtext COMMENT '',
862 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
863 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
864 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
865 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
866 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
867 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
868 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
870 INDEX `uid_seen` (`uid`,`seen`),
871 INDEX `convid` (`convid`),
872 INDEX `uri` (`uri`(64)),
873 INDEX `parent-uri` (`parent-uri`(64)),
874 INDEX `contactid` (`contact-id`(32)),
875 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
876 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
881 CREATE TABLE IF NOT EXISTS `mailacct` (
882 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
883 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
884 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
885 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
886 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
887 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
888 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
889 `pass` text COMMENT '',
890 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
891 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
892 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
893 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
894 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
897 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
898 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
903 CREATE TABLE IF NOT EXISTS `manage` (
904 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
905 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
906 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
908 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
910 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
911 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
912 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
917 CREATE TABLE IF NOT EXISTS `notify` (
918 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
919 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
920 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
921 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
922 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
923 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
924 `msg` mediumtext COMMENT '',
925 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
926 `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
927 `iid` int unsigned COMMENT 'item.id',
928 `parent` int unsigned COMMENT '',
929 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
930 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
931 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
932 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
933 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
934 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
935 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
937 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
938 INDEX `uid_date` (`uid`,`date`),
939 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
940 INDEX `uri-id` (`uri-id`),
941 INDEX `parent-uri-id` (`parent-uri-id`),
942 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
943 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
944 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
945 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
948 -- TABLE notify-threads
950 CREATE TABLE IF NOT EXISTS `notify-threads` (
951 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
952 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
953 `master-parent-item` int unsigned COMMENT '',
954 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
955 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
956 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
958 INDEX `master-parent-item` (`master-parent-item`),
959 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
960 INDEX `receiver-uid` (`receiver-uid`),
961 INDEX `notify-id` (`notify-id`),
962 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
963 FOREIGN KEY (`master-parent-item`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
964 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
965 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
966 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
971 CREATE TABLE IF NOT EXISTS `oembed` (
972 `url` varbinary(255) NOT NULL COMMENT 'page url',
973 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
974 `content` mediumtext COMMENT 'OEmbed data of the page',
975 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
976 PRIMARY KEY(`url`,`maxwidth`),
977 INDEX `created` (`created`)
978 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
981 -- TABLE openwebauth-token
983 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
984 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
985 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
986 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
987 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
988 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
989 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
992 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
993 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
998 CREATE TABLE IF NOT EXISTS `parsed_url` (
999 `url` varbinary(255) NOT NULL COMMENT 'page url',
1000 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
1001 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
1002 `content` mediumtext COMMENT 'page data',
1003 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1004 PRIMARY KEY(`url`,`guessing`,`oembed`),
1005 INDEX `created` (`created`)
1006 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
1009 -- TABLE participation
1011 CREATE TABLE IF NOT EXISTS `participation` (
1012 `iid` int unsigned NOT NULL COMMENT '',
1013 `server` varchar(60) NOT NULL COMMENT '',
1014 `cid` int unsigned NOT NULL COMMENT '',
1015 `fid` int unsigned NOT NULL COMMENT '',
1016 PRIMARY KEY(`iid`,`server`),
1017 INDEX `cid` (`cid`),
1018 INDEX `fid` (`fid`),
1019 FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1020 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1021 FOREIGN KEY (`fid`) REFERENCES `fcontact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1022 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Storage for participation messages from Diaspora';
1027 CREATE TABLE IF NOT EXISTS `pconfig` (
1028 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
1029 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1030 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
1031 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
1032 `v` mediumtext COMMENT 'Value',
1034 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
1035 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1036 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
1041 CREATE TABLE IF NOT EXISTS `photo` (
1042 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1043 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1044 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1045 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
1046 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
1047 `hash` char(32) COMMENT 'hash value of the photo',
1048 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
1049 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
1050 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1051 `desc` text COMMENT '',
1052 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
1053 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1054 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
1055 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1056 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1057 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1058 `data` mediumblob NOT NULL COMMENT '',
1059 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1060 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
1061 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
1062 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
1063 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
1064 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
1065 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
1066 `backend-class` tinytext COMMENT 'Storage backend class',
1067 `backend-ref` text COMMENT 'Storage backend data reference',
1068 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1070 INDEX `contactid` (`contact-id`),
1071 INDEX `uid_contactid` (`uid`,`contact-id`),
1072 INDEX `uid_profile` (`uid`,`profile`),
1073 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
1074 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
1075 INDEX `resource-id` (`resource-id`),
1076 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1077 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1078 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1081 -- TABLE post-category
1083 CREATE TABLE IF NOT EXISTS `post-category` (
1084 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1085 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1086 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1087 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1088 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1089 INDEX `uri-id` (`tid`),
1090 INDEX `uid` (`uid`),
1091 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1092 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1093 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1094 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1097 -- TABLE post-delivery-data
1099 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1100 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1101 `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',
1102 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1103 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1104 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1105 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1106 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1107 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1108 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1109 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1110 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1111 PRIMARY KEY(`uri-id`),
1112 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1113 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1118 CREATE TABLE IF NOT EXISTS `post-media` (
1119 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1120 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1121 `url` varbinary(511) NOT NULL COMMENT 'Media URL',
1122 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1123 `mimetype` varchar(60) COMMENT '',
1124 `height` smallint unsigned COMMENT 'Height of the media',
1125 `width` smallint unsigned COMMENT 'Width of the media',
1126 `size` int unsigned COMMENT 'Media size',
1127 `preview` varbinary(255) COMMENT 'Preview URL',
1128 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1129 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1130 `description` text COMMENT '',
1132 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1133 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1134 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1139 CREATE TABLE IF NOT EXISTS `post-tag` (
1140 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1141 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1142 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1143 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1144 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1145 INDEX `tid` (`tid`),
1146 INDEX `cid` (`cid`),
1147 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1148 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1149 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1150 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1155 CREATE TABLE IF NOT EXISTS `post-user` (
1156 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1157 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1158 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1159 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1160 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1161 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1162 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1163 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1164 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1165 PRIMARY KEY(`uid`,`uri-id`),
1166 INDEX `uri-id` (`uri-id`),
1167 INDEX `contact-id` (`contact-id`),
1168 INDEX `psid` (`psid`),
1169 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1170 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1171 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1172 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1173 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1178 CREATE TABLE IF NOT EXISTS `process` (
1179 `pid` int unsigned NOT NULL COMMENT '',
1180 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1181 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1183 INDEX `command` (`command`)
1184 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1189 CREATE TABLE IF NOT EXISTS `profile` (
1190 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1191 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1192 `profile-name` varchar(255) COMMENT 'Deprecated',
1193 `is-default` boolean COMMENT 'Deprecated',
1194 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1195 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1196 `pdesc` varchar(255) COMMENT 'Deprecated',
1197 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1198 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1199 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1200 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1201 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1202 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1203 `hometown` varchar(255) COMMENT 'Deprecated',
1204 `gender` varchar(32) COMMENT 'Deprecated',
1205 `marital` varchar(255) COMMENT 'Deprecated',
1206 `with` text COMMENT 'Deprecated',
1207 `howlong` datetime COMMENT 'Deprecated',
1208 `sexual` varchar(255) COMMENT 'Deprecated',
1209 `politic` varchar(255) COMMENT 'Deprecated',
1210 `religion` varchar(255) COMMENT 'Deprecated',
1211 `pub_keywords` text COMMENT '',
1212 `prv_keywords` text COMMENT '',
1213 `likes` text COMMENT 'Deprecated',
1214 `dislikes` text COMMENT 'Deprecated',
1215 `about` text COMMENT 'Profile description',
1216 `summary` varchar(255) COMMENT 'Deprecated',
1217 `music` text COMMENT 'Deprecated',
1218 `book` text COMMENT 'Deprecated',
1219 `tv` text COMMENT 'Deprecated',
1220 `film` text COMMENT 'Deprecated',
1221 `interest` text COMMENT 'Deprecated',
1222 `romance` text COMMENT 'Deprecated',
1223 `work` text COMMENT 'Deprecated',
1224 `education` text COMMENT 'Deprecated',
1225 `contact` text COMMENT 'Deprecated',
1226 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1227 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1228 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1229 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1230 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1231 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1233 INDEX `uid_is-default` (`uid`,`is-default`),
1234 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1235 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1236 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1239 -- TABLE profile_check
1241 CREATE TABLE IF NOT EXISTS `profile_check` (
1242 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1243 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1244 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1245 `dfrn_id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1246 `sec` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1247 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1249 INDEX `uid` (`uid`),
1250 INDEX `cid` (`cid`),
1251 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1252 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1253 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='DFRN remote auth use';
1256 -- TABLE profile_field
1258 CREATE TABLE IF NOT EXISTS `profile_field` (
1259 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1260 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1261 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1262 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1263 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1264 `value` text COMMENT 'Value of the field',
1265 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1266 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1268 INDEX `uid` (`uid`),
1269 INDEX `order` (`order`),
1270 INDEX `psid` (`psid`),
1271 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1272 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1273 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1276 -- TABLE push_subscriber
1278 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1279 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1280 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1281 `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1282 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1283 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1284 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1285 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1286 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1287 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1288 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1290 INDEX `next_try` (`next_try`),
1291 INDEX `uid` (`uid`),
1292 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1293 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1298 CREATE TABLE IF NOT EXISTS `register` (
1299 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1300 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1301 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1302 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1303 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1304 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1305 `note` text COMMENT '',
1307 INDEX `uid` (`uid`),
1308 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1309 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1314 CREATE TABLE IF NOT EXISTS `search` (
1315 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1316 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1317 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1319 INDEX `uid` (`uid`),
1320 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1321 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1326 CREATE TABLE IF NOT EXISTS `session` (
1327 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1328 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1329 `data` text COMMENT '',
1330 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1332 INDEX `sid` (`sid`(64)),
1333 INDEX `expire` (`expire`)
1334 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1339 CREATE TABLE IF NOT EXISTS `storage` (
1340 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1341 `data` longblob NOT NULL COMMENT 'file data',
1343 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1348 CREATE TABLE IF NOT EXISTS `thread` (
1349 `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'sequential ID',
1350 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
1351 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1352 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1353 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1354 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1355 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1356 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1357 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1358 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1359 `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1360 `wall` boolean NOT NULL DEFAULT '0' COMMENT '',
1361 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1362 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1363 `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
1364 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1365 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1366 `ignored` boolean NOT NULL DEFAULT '0' COMMENT '',
1367 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
1368 `unseen` boolean NOT NULL DEFAULT '1' COMMENT '',
1369 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '',
1370 `origin` boolean NOT NULL DEFAULT '0' COMMENT '',
1371 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1372 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1373 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1374 `bookmark` boolean COMMENT '',
1376 INDEX `uid_network_commented` (`uid`,`network`,`commented`),
1377 INDEX `uid_network_received` (`uid`,`network`,`received`),
1378 INDEX `uid_contactid_commented` (`uid`,`contact-id`,`commented`),
1379 INDEX `uid_contactid_received` (`uid`,`contact-id`,`received`),
1380 INDEX `contactid` (`contact-id`),
1381 INDEX `ownerid` (`owner-id`),
1382 INDEX `authorid` (`author-id`),
1383 INDEX `uid_received` (`uid`,`received`),
1384 INDEX `uid_commented` (`uid`,`commented`),
1385 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1386 INDEX `private_wall_origin_commented` (`private`,`wall`,`origin`,`commented`),
1387 INDEX `uri-id` (`uri-id`),
1388 FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1389 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1390 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1391 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1392 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1393 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1394 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1399 CREATE TABLE IF NOT EXISTS `tokens` (
1400 `id` varchar(40) NOT NULL COMMENT '',
1401 `secret` text COMMENT '',
1402 `client_id` varchar(20) NOT NULL DEFAULT '',
1403 `expires` int NOT NULL DEFAULT 0 COMMENT '',
1404 `scope` varchar(200) NOT NULL DEFAULT '' COMMENT '',
1405 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1407 INDEX `client_id` (`client_id`),
1408 INDEX `uid` (`uid`),
1409 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1410 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1411 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
1416 CREATE TABLE IF NOT EXISTS `userd` (
1417 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1418 `username` varchar(255) NOT NULL COMMENT '',
1420 INDEX `username` (`username`(32))
1421 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1424 -- TABLE user-contact
1426 CREATE TABLE IF NOT EXISTS `user-contact` (
1427 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1428 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1429 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1430 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1431 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1432 PRIMARY KEY(`uid`,`cid`),
1433 INDEX `cid` (`cid`),
1434 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1435 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1436 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1441 CREATE TABLE IF NOT EXISTS `user-item` (
1442 `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item id',
1443 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1444 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide an item from the user',
1445 `ignored` boolean COMMENT 'Ignore this thread if set',
1446 `pinned` boolean COMMENT 'The item is pinned on the profile page',
1447 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1448 PRIMARY KEY(`uid`,`iid`),
1449 INDEX `uid_pinned` (`uid`,`pinned`),
1450 INDEX `iid_uid` (`iid`,`uid`),
1451 FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1452 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1453 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific item data';
1458 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1459 `key` int NOT NULL COMMENT '',
1460 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1462 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1465 -- TABLE workerqueue
1467 CREATE TABLE IF NOT EXISTS `workerqueue` (
1468 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
1469 `command` varchar(100) COMMENT 'Task command',
1470 `parameter` mediumtext COMMENT 'Task parameter',
1471 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
1472 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
1473 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
1474 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
1475 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1476 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1477 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
1479 INDEX `command` (`command`),
1480 INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
1481 INDEX `done_executed` (`done`,`executed`),
1482 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
1483 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
1484 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
1485 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
1486 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
1487 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
1492 DROP VIEW IF EXISTS `post-view`;
1493 CREATE VIEW `post-view` AS SELECT
1494 `item`.`id` AS `id`,
1495 `item`.`id` AS `item_id`,
1496 `item`.`uid` AS `uid`,
1497 `item`.`parent` AS `parent`,
1498 `item`.`uri` AS `uri`,
1499 `item`.`uri-id` AS `uri-id`,
1500 `item`.`parent-uri` AS `parent-uri`,
1501 `item`.`parent-uri-id` AS `parent-uri-id`,
1502 `item`.`thr-parent` AS `thr-parent`,
1503 `item`.`thr-parent-id` AS `thr-parent-id`,
1504 `item`.`guid` AS `guid`,
1505 `item`.`type` AS `type`,
1506 `item`.`wall` AS `wall`,
1507 `item`.`gravity` AS `gravity`,
1508 `item`.`extid` AS `extid`,
1509 `item`.`created` AS `created`,
1510 `item`.`edited` AS `edited`,
1511 `item`.`commented` AS `commented`,
1512 `item`.`received` AS `received`,
1513 `item`.`changed` AS `changed`,
1514 `item`.`resource-id` AS `resource-id`,
1515 `item`.`post-type` AS `post-type`,
1516 `item`.`private` AS `private`,
1517 `item`.`pubmail` AS `pubmail`,
1518 `item`.`moderated` AS `moderated`,
1519 `item`.`visible` AS `visible`,
1520 `item`.`starred` AS `starred`,
1521 `item`.`bookmark` AS `bookmark`,
1522 `item`.`unseen` AS `unseen`,
1523 `item`.`deleted` AS `deleted`,
1524 `item`.`origin` AS `origin`,
1525 `item`.`forum_mode` AS `forum_mode`,
1526 `item`.`mention` AS `mention`,
1527 `item`.`global` AS `global`,
1528 `item`.`network` AS `network`,
1529 `item`.`vid` AS `vid`,
1530 `item`.`psid` AS `psid`,
1531 IF (`item`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1532 `item-content`.`title` AS `title`,
1533 `item-content`.`content-warning` AS `content-warning`,
1534 `item-content`.`raw-body` AS `raw-body`,
1535 `item-content`.`body` AS `body`,
1536 `item-content`.`rendered-hash` AS `rendered-hash`,
1537 `item-content`.`rendered-html` AS `rendered-html`,
1538 `item-content`.`language` AS `language`,
1539 `item-content`.`plink` AS `plink`,
1540 `item-content`.`location` AS `location`,
1541 `item-content`.`coord` AS `coord`,
1542 `item-content`.`app` AS `app`,
1543 `item-content`.`object-type` AS `object-type`,
1544 `item-content`.`object` AS `object`,
1545 `item-content`.`target-type` AS `target-type`,
1546 `item-content`.`target` AS `target`,
1547 `item`.`contact-id` AS `contact-id`,
1548 `contact`.`url` AS `contact-link`,
1549 `contact`.`addr` AS `contact-addr`,
1550 `contact`.`name` AS `contact-name`,
1551 `contact`.`nick` AS `contact-nick`,
1552 `contact`.`thumb` AS `contact-avatar`,
1553 `contact`.`network` AS `contact-network`,
1554 `contact`.`blocked` AS `contact-blocked`,
1555 `contact`.`hidden` AS `contact-hidden`,
1556 `contact`.`readonly` AS `contact-readonly`,
1557 `contact`.`archive` AS `contact-archive`,
1558 `contact`.`pending` AS `contact-pending`,
1559 `contact`.`rel` AS `contact-rel`,
1560 `contact`.`uid` AS `contact-uid`,
1561 `contact`.`contact-type` AS `contact-contact-type`,
1562 IF (`item`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1563 `contact`.`self` AS `self`,
1564 `contact`.`id` AS `cid`,
1565 `contact`.`alias` AS `alias`,
1566 `contact`.`photo` AS `photo`,
1567 `contact`.`name-date` AS `name-date`,
1568 `contact`.`uri-date` AS `uri-date`,
1569 `contact`.`avatar-date` AS `avatar-date`,
1570 `contact`.`thumb` AS `thumb`,
1571 `contact`.`dfrn-id` AS `dfrn-id`,
1572 `item`.`author-id` AS `author-id`,
1573 `author`.`url` AS `author-link`,
1574 `author`.`addr` AS `author-addr`,
1575 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1576 `author`.`nick` AS `author-nick`,
1577 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1578 `author`.`network` AS `author-network`,
1579 `author`.`blocked` AS `author-blocked`,
1580 `author`.`hidden` AS `author-hidden`,
1581 `item`.`owner-id` AS `owner-id`,
1582 `owner`.`url` AS `owner-link`,
1583 `owner`.`addr` AS `owner-addr`,
1584 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1585 `owner`.`nick` AS `owner-nick`,
1586 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1587 `owner`.`network` AS `owner-network`,
1588 `owner`.`blocked` AS `owner-blocked`,
1589 `owner`.`hidden` AS `owner-hidden`,
1590 `item`.`causer-id` AS `causer-id`,
1591 `causer`.`url` AS `causer-link`,
1592 `causer`.`addr` AS `causer-addr`,
1593 `causer`.`name` AS `causer-name`,
1594 `causer`.`nick` AS `causer-nick`,
1595 `causer`.`thumb` AS `causer-avatar`,
1596 `causer`.`network` AS `causer-network`,
1597 `causer`.`blocked` AS `causer-blocked`,
1598 `causer`.`hidden` AS `causer-hidden`,
1599 `causer`.`contact-type` AS `causer-contact-type`,
1600 `post-delivery-data`.`postopts` AS `postopts`,
1601 `post-delivery-data`.`inform` AS `inform`,
1602 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1603 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1604 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1605 IF (`item`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1606 IF (`item`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1607 IF (`item`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1608 IF (`item`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1609 `item`.`event-id` AS `event-id`,
1610 `event`.`created` AS `event-created`,
1611 `event`.`edited` AS `event-edited`,
1612 `event`.`start` AS `event-start`,
1613 `event`.`finish` AS `event-finish`,
1614 `event`.`summary` AS `event-summary`,
1615 `event`.`desc` AS `event-desc`,
1616 `event`.`location` AS `event-location`,
1617 `event`.`type` AS `event-type`,
1618 `event`.`nofinish` AS `event-nofinish`,
1619 `event`.`adjust` AS `event-adjust`,
1620 `event`.`ignore` AS `event-ignore`,
1621 `diaspora-interaction`.`interaction` AS `signed_text`,
1622 `parent-item`.`guid` AS `parent-guid`,
1623 `parent-item`.`network` AS `parent-network`,
1624 `parent-item`.`author-id` AS `parent-author-id`,
1625 `parent-item-author`.`url` AS `parent-author-link`,
1626 `parent-item-author`.`name` AS `parent-author-name`,
1627 `parent-item-author`.`network` AS `parent-author-network`
1629 STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
1630 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `item`.`author-id`
1631 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `item`.`owner-id`
1632 STRAIGHT_JOIN `contact` AS `causer` ON `causer`.`id` = `item`.`causer-id`
1633 LEFT JOIN `verb` ON `verb`.`id` = `item`.`vid`
1634 LEFT JOIN `event` ON `event`.`id` = `item`.`event-id`
1635 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `item`.`uri-id`
1636 LEFT JOIN `item-content` ON `item-content`.`uri-id` = `item`.`uri-id`
1637 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `item`.`uri-id` AND `item`.`origin`
1638 LEFT JOIN `permissionset` ON `permissionset`.`id` = `item`.`psid`
1639 STRAIGHT_JOIN `item` AS `parent-item` ON `parent-item`.`uri-id` = `item`.`parent-uri-id` AND `parent-item`.`uid` = `item`.`uid`
1640 STRAIGHT_JOIN `contact` AS `parent-item-author` ON `parent-item-author`.`id` = `parent-item`.`author-id`;
1643 -- VIEW post-thread-view
1645 DROP VIEW IF EXISTS `post-thread-view`;
1646 CREATE VIEW `post-thread-view` AS SELECT
1647 `item`.`id` AS `id`,
1648 `thread`.`iid` AS `iid`,
1649 `item`.`id` AS `item_id`,
1650 `thread`.`uid` AS `uid`,
1651 `item`.`parent` AS `parent`,
1652 `item`.`uri` AS `uri`,
1653 `item`.`uri-id` AS `uri-id`,
1654 `item`.`parent-uri` AS `parent-uri`,
1655 `item`.`parent-uri-id` AS `parent-uri-id`,
1656 `item`.`thr-parent` AS `thr-parent`,
1657 `item`.`thr-parent-id` AS `thr-parent-id`,
1658 `item`.`guid` AS `guid`,
1659 `item`.`type` AS `type`,
1660 `thread`.`wall` AS `wall`,
1661 `item`.`gravity` AS `gravity`,
1662 `item`.`extid` AS `extid`,
1663 `thread`.`created` AS `created`,
1664 `item`.`edited` AS `edited`,
1665 `thread`.`commented` AS `commented`,
1666 `thread`.`received` AS `received`,
1667 `thread`.`changed` AS `changed`,
1668 `item`.`resource-id` AS `resource-id`,
1669 `thread`.`post-type` AS `post-type`,
1670 `thread`.`private` AS `private`,
1671 `thread`.`pubmail` AS `pubmail`,
1672 `thread`.`moderated` AS `moderated`,
1673 `thread`.`ignored` AS `ignored`,
1674 `thread`.`visible` AS `visible`,
1675 `thread`.`starred` AS `starred`,
1676 `item`.`bookmark` AS `bookmark`,
1677 `item`.`unseen` AS `unseen`,
1678 `thread`.`deleted` AS `deleted`,
1679 `thread`.`origin` AS `origin`,
1680 `thread`.`forum_mode` AS `forum_mode`,
1681 `thread`.`mention` AS `mention`,
1682 `item`.`global` AS `global`,
1683 `thread`.`network` AS `network`,
1684 `item`.`vid` AS `vid`,
1685 `item`.`psid` AS `psid`,
1686 IF (`item`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1687 `item-content`.`title` AS `title`,
1688 `item-content`.`content-warning` AS `content-warning`,
1689 `item-content`.`raw-body` AS `raw-body`,
1690 `item-content`.`body` AS `body`,
1691 `item-content`.`rendered-hash` AS `rendered-hash`,
1692 `item-content`.`rendered-html` AS `rendered-html`,
1693 `item-content`.`language` AS `language`,
1694 `item-content`.`plink` AS `plink`,
1695 `item-content`.`location` AS `location`,
1696 `item-content`.`coord` AS `coord`,
1697 `item-content`.`app` AS `app`,
1698 `item-content`.`object-type` AS `object-type`,
1699 `item-content`.`object` AS `object`,
1700 `item-content`.`target-type` AS `target-type`,
1701 `item-content`.`target` AS `target`,
1702 `thread`.`contact-id` AS `contact-id`,
1703 `contact`.`url` AS `contact-link`,
1704 `contact`.`addr` AS `contact-addr`,
1705 `contact`.`name` AS `contact-name`,
1706 `contact`.`nick` AS `contact-nick`,
1707 `contact`.`thumb` AS `contact-avatar`,
1708 `contact`.`network` AS `contact-network`,
1709 `contact`.`blocked` AS `contact-blocked`,
1710 `contact`.`hidden` AS `contact-hidden`,
1711 `contact`.`readonly` AS `contact-readonly`,
1712 `contact`.`archive` AS `contact-archive`,
1713 `contact`.`pending` AS `contact-pending`,
1714 `contact`.`rel` AS `contact-rel`,
1715 `contact`.`uid` AS `contact-uid`,
1716 `contact`.`contact-type` AS `contact-contact-type`,
1717 IF (`item`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1718 `contact`.`self` AS `self`,
1719 `contact`.`id` AS `cid`,
1720 `contact`.`alias` AS `alias`,
1721 `contact`.`photo` AS `photo`,
1722 `contact`.`name-date` AS `name-date`,
1723 `contact`.`uri-date` AS `uri-date`,
1724 `contact`.`avatar-date` AS `avatar-date`,
1725 `contact`.`thumb` AS `thumb`,
1726 `contact`.`dfrn-id` AS `dfrn-id`,
1727 `thread`.`author-id` AS `author-id`,
1728 `author`.`url` AS `author-link`,
1729 `author`.`addr` AS `author-addr`,
1730 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1731 `author`.`nick` AS `author-nick`,
1732 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1733 `author`.`network` AS `author-network`,
1734 `author`.`blocked` AS `author-blocked`,
1735 `author`.`hidden` AS `author-hidden`,
1736 `thread`.`owner-id` AS `owner-id`,
1737 `owner`.`url` AS `owner-link`,
1738 `owner`.`addr` AS `owner-addr`,
1739 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1740 `owner`.`nick` AS `owner-nick`,
1741 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1742 `owner`.`network` AS `owner-network`,
1743 `owner`.`blocked` AS `owner-blocked`,
1744 `owner`.`hidden` AS `owner-hidden`,
1745 `item`.`causer-id` AS `causer-id`,
1746 `causer`.`url` AS `causer-link`,
1747 `causer`.`addr` AS `causer-addr`,
1748 `causer`.`name` AS `causer-name`,
1749 `causer`.`nick` AS `causer-nick`,
1750 `causer`.`thumb` AS `causer-avatar`,
1751 `causer`.`network` AS `causer-network`,
1752 `causer`.`blocked` AS `causer-blocked`,
1753 `causer`.`hidden` AS `causer-hidden`,
1754 `causer`.`contact-type` AS `causer-contact-type`,
1755 `post-delivery-data`.`postopts` AS `postopts`,
1756 `post-delivery-data`.`inform` AS `inform`,
1757 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1758 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1759 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1760 IF (`item`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1761 IF (`item`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1762 IF (`item`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1763 IF (`item`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1764 `item`.`event-id` AS `event-id`,
1765 `event`.`created` AS `event-created`,
1766 `event`.`edited` AS `event-edited`,
1767 `event`.`start` AS `event-start`,
1768 `event`.`finish` AS `event-finish`,
1769 `event`.`summary` AS `event-summary`,
1770 `event`.`desc` AS `event-desc`,
1771 `event`.`location` AS `event-location`,
1772 `event`.`type` AS `event-type`,
1773 `event`.`nofinish` AS `event-nofinish`,
1774 `event`.`adjust` AS `event-adjust`,
1775 `event`.`ignore` AS `event-ignore`,
1776 `diaspora-interaction`.`interaction` AS `signed_text`,
1777 `parent-item`.`guid` AS `parent-guid`,
1778 `parent-item`.`network` AS `parent-network`,
1779 `parent-item`.`author-id` AS `parent-author-id`,
1780 `parent-item-author`.`url` AS `parent-author-link`,
1781 `parent-item-author`.`name` AS `parent-author-name`,
1782 `parent-item-author`.`network` AS `parent-author-network`
1784 STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
1785 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
1786 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `thread`.`author-id`
1787 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `thread`.`owner-id`
1788 STRAIGHT_JOIN `contact` AS `causer` ON `causer`.`id` = `item`.`causer-id`
1789 LEFT JOIN `verb` ON `verb`.`id` = `item`.`vid`
1790 LEFT JOIN `event` ON `event`.`id` = `item`.`event-id`
1791 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `thread`.`uri-id`
1792 LEFT JOIN `item-content` ON `item-content`.`uri-id` = `thread`.`uri-id`
1793 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `thread`.`uri-id` AND `thread`.`origin`
1794 LEFT JOIN `permissionset` ON `permissionset`.`id` = `item`.`psid`
1795 STRAIGHT_JOIN `item` AS `parent-item` ON `parent-item`.`id` = `item`.`parent`
1796 STRAIGHT_JOIN `contact` AS `parent-item-author` ON `parent-item-author`.`id` = `parent-item`.`author-id`;
1799 -- VIEW category-view
1801 DROP VIEW IF EXISTS `category-view`;
1802 CREATE VIEW `category-view` AS SELECT
1803 `post-category`.`uri-id` AS `uri-id`,
1804 `post-category`.`uid` AS `uid`,
1805 `item-uri`.`uri` AS `uri`,
1806 `item-uri`.`guid` AS `guid`,
1807 `post-category`.`type` AS `type`,
1808 `post-category`.`tid` AS `tid`,
1809 `tag`.`name` AS `name`,
1810 `tag`.`url` AS `url`
1811 FROM `post-category`
1812 INNER JOIN `item-uri` ON `item-uri`.id = `post-category`.`uri-id`
1813 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
1818 DROP VIEW IF EXISTS `tag-view`;
1819 CREATE VIEW `tag-view` AS SELECT
1820 `post-tag`.`uri-id` AS `uri-id`,
1821 `item-uri`.`uri` AS `uri`,
1822 `item-uri`.`guid` AS `guid`,
1823 `post-tag`.`type` AS `type`,
1824 `post-tag`.`tid` AS `tid`,
1825 `post-tag`.`cid` AS `cid`,
1826 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
1827 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
1829 INNER JOIN `item-uri` ON `item-uri`.id = `post-tag`.`uri-id`
1830 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
1831 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
1834 -- VIEW network-item-view
1836 DROP VIEW IF EXISTS `network-item-view`;
1837 CREATE VIEW `network-item-view` AS SELECT
1838 `item`.`parent-uri-id` AS `uri-id`,
1839 `item`.`parent-uri` AS `uri`,
1840 `item`.`parent` AS `parent`,
1841 `item`.`received` AS `received`,
1842 `item`.`commented` AS `commented`,
1843 `item`.`created` AS `created`,
1844 `item`.`uid` AS `uid`,
1845 `item`.`starred` AS `starred`,
1846 `item`.`mention` AS `mention`,
1847 `item`.`network` AS `network`,
1848 `item`.`unseen` AS `unseen`,
1849 `item`.`gravity` AS `gravity`,
1850 `item`.`contact-id` AS `contact-id`,
1851 `ownercontact`.`contact-type` AS `contact-type`
1853 INNER JOIN `thread` ON `thread`.`iid` = `item`.`parent`
1854 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
1855 LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
1856 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
1857 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
1858 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
1859 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
1860 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
1861 AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
1862 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
1863 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
1866 -- VIEW network-thread-view
1868 DROP VIEW IF EXISTS `network-thread-view`;
1869 CREATE VIEW `network-thread-view` AS SELECT
1870 `item`.`uri-id` AS `uri-id`,
1871 `item`.`uri` AS `uri`,
1872 `item`.`parent-uri-id` AS `parent-uri-id`,
1873 `thread`.`iid` AS `parent`,
1874 `thread`.`received` AS `received`,
1875 `thread`.`commented` AS `commented`,
1876 `thread`.`created` AS `created`,
1877 `thread`.`uid` AS `uid`,
1878 `thread`.`starred` AS `starred`,
1879 `thread`.`mention` AS `mention`,
1880 `thread`.`network` AS `network`,
1881 `thread`.`contact-id` AS `contact-id`,
1882 `ownercontact`.`contact-type` AS `contact-type`
1884 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
1885 STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
1886 LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
1887 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
1888 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
1889 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
1890 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
1891 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
1892 AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
1893 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
1894 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
1899 DROP VIEW IF EXISTS `owner-view`;
1900 CREATE VIEW `owner-view` AS SELECT
1901 `contact`.`id` AS `id`,
1902 `contact`.`uid` AS `uid`,
1903 `contact`.`created` AS `created`,
1904 `contact`.`updated` AS `updated`,
1905 `contact`.`self` AS `self`,
1906 `contact`.`remote_self` AS `remote_self`,
1907 `contact`.`rel` AS `rel`,
1908 `contact`.`duplex` AS `duplex`,
1909 `contact`.`network` AS `network`,
1910 `contact`.`protocol` AS `protocol`,
1911 `contact`.`name` AS `name`,
1912 `contact`.`nick` AS `nick`,
1913 `contact`.`location` AS `location`,
1914 `contact`.`about` AS `about`,
1915 `contact`.`keywords` AS `keywords`,
1916 `contact`.`gender` AS `gender`,
1917 `contact`.`xmpp` AS `xmpp`,
1918 `contact`.`attag` AS `attag`,
1919 `contact`.`avatar` AS `avatar`,
1920 `contact`.`photo` AS `photo`,
1921 `contact`.`thumb` AS `thumb`,
1922 `contact`.`micro` AS `micro`,
1923 `contact`.`site-pubkey` AS `site-pubkey`,
1924 `contact`.`issued-id` AS `issued-id`,
1925 `contact`.`dfrn-id` AS `dfrn-id`,
1926 `contact`.`url` AS `url`,
1927 `contact`.`nurl` AS `nurl`,
1928 `contact`.`addr` AS `addr`,
1929 `contact`.`alias` AS `alias`,
1930 `contact`.`pubkey` AS `pubkey`,
1931 `contact`.`prvkey` AS `prvkey`,
1932 `contact`.`batch` AS `batch`,
1933 `contact`.`request` AS `request`,
1934 `contact`.`notify` AS `notify`,
1935 `contact`.`poll` AS `poll`,
1936 `contact`.`confirm` AS `confirm`,
1937 `contact`.`poco` AS `poco`,
1938 `contact`.`aes_allow` AS `aes_allow`,
1939 `contact`.`ret-aes` AS `ret-aes`,
1940 `contact`.`usehub` AS `usehub`,
1941 `contact`.`subhub` AS `subhub`,
1942 `contact`.`hub-verify` AS `hub-verify`,
1943 `contact`.`last-update` AS `last-update`,
1944 `contact`.`success_update` AS `success_update`,
1945 `contact`.`failure_update` AS `failure_update`,
1946 `contact`.`name-date` AS `name-date`,
1947 `contact`.`uri-date` AS `uri-date`,
1948 `contact`.`avatar-date` AS `avatar-date`,
1949 `contact`.`avatar-date` AS `picdate`,
1950 `contact`.`term-date` AS `term-date`,
1951 `contact`.`last-item` AS `last-item`,
1952 `contact`.`priority` AS `priority`,
1953 `user`.`blocked` AS `blocked`,
1954 `contact`.`block_reason` AS `block_reason`,
1955 `contact`.`readonly` AS `readonly`,
1956 `contact`.`writable` AS `writable`,
1957 `contact`.`forum` AS `forum`,
1958 `contact`.`prv` AS `prv`,
1959 `contact`.`contact-type` AS `contact-type`,
1960 `contact`.`manually-approve` AS `manually-approve`,
1961 `contact`.`hidden` AS `hidden`,
1962 `contact`.`archive` AS `archive`,
1963 `contact`.`pending` AS `pending`,
1964 `contact`.`deleted` AS `deleted`,
1965 `contact`.`unsearchable` AS `unsearchable`,
1966 `contact`.`sensitive` AS `sensitive`,
1967 `contact`.`baseurl` AS `baseurl`,
1968 `contact`.`reason` AS `reason`,
1969 `contact`.`closeness` AS `closeness`,
1970 `contact`.`info` AS `info`,
1971 `contact`.`profile-id` AS `profile-id`,
1972 `contact`.`bdyear` AS `bdyear`,
1973 `contact`.`bd` AS `bd`,
1974 `contact`.`notify_new_posts` AS `notify_new_posts`,
1975 `contact`.`fetch_further_information` AS `fetch_further_information`,
1976 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
1977 `user`.`parent-uid` AS `parent-uid`,
1978 `user`.`guid` AS `guid`,
1979 `user`.`nickname` AS `nickname`,
1980 `user`.`email` AS `email`,
1981 `user`.`openid` AS `openid`,
1982 `user`.`timezone` AS `timezone`,
1983 `user`.`language` AS `language`,
1984 `user`.`register_date` AS `register_date`,
1985 `user`.`login_date` AS `login_date`,
1986 `user`.`default-location` AS `default-location`,
1987 `user`.`allow_location` AS `allow_location`,
1988 `user`.`theme` AS `theme`,
1989 `user`.`pubkey` AS `upubkey`,
1990 `user`.`prvkey` AS `uprvkey`,
1991 `user`.`sprvkey` AS `sprvkey`,
1992 `user`.`spubkey` AS `spubkey`,
1993 `user`.`verified` AS `verified`,
1994 `user`.`blockwall` AS `blockwall`,
1995 `user`.`hidewall` AS `hidewall`,
1996 `user`.`blocktags` AS `blocktags`,
1997 `user`.`unkmail` AS `unkmail`,
1998 `user`.`cntunkmail` AS `cntunkmail`,
1999 `user`.`notify-flags` AS `notify-flags`,
2000 `user`.`page-flags` AS `page-flags`,
2001 `user`.`account-type` AS `account-type`,
2002 `user`.`prvnets` AS `prvnets`,
2003 `user`.`maxreq` AS `maxreq`,
2004 `user`.`expire` AS `expire`,
2005 `user`.`account_removed` AS `account_removed`,
2006 `user`.`account_expired` AS `account_expired`,
2007 `user`.`account_expires_on` AS `account_expires_on`,
2008 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2009 `user`.`def_gid` AS `def_gid`,
2010 `user`.`allow_cid` AS `allow_cid`,
2011 `user`.`allow_gid` AS `allow_gid`,
2012 `user`.`deny_cid` AS `deny_cid`,
2013 `user`.`deny_gid` AS `deny_gid`,
2014 `user`.`openidserver` AS `openidserver`,
2015 `profile`.`publish` AS `publish`,
2016 `profile`.`net-publish` AS `net-publish`,
2017 `profile`.`hide-friends` AS `hide-friends`,
2018 `profile`.`prv_keywords` AS `prv_keywords`,
2019 `profile`.`pub_keywords` AS `pub_keywords`,
2020 `profile`.`address` AS `address`,
2021 `profile`.`locality` AS `locality`,
2022 `profile`.`region` AS `region`,
2023 `profile`.`postal-code` AS `postal-code`,
2024 `profile`.`country-name` AS `country-name`,
2025 `profile`.`homepage` AS `homepage`,
2026 `profile`.`dob` AS `dob`
2028 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2029 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2032 -- VIEW pending-view
2034 DROP VIEW IF EXISTS `pending-view`;
2035 CREATE VIEW `pending-view` AS SELECT
2036 `register`.`id` AS `id`,
2037 `register`.`hash` AS `hash`,
2038 `register`.`created` AS `created`,
2039 `register`.`uid` AS `uid`,
2040 `register`.`password` AS `password`,
2041 `register`.`language` AS `language`,
2042 `register`.`note` AS `note`,
2043 `contact`.`self` AS `self`,
2044 `contact`.`name` AS `name`,
2045 `contact`.`url` AS `url`,
2046 `contact`.`micro` AS `micro`,
2047 `user`.`email` AS `email`,
2048 `contact`.`nick` AS `nick`
2050 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2051 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2054 -- VIEW tag-search-view
2056 DROP VIEW IF EXISTS `tag-search-view`;
2057 CREATE VIEW `tag-search-view` AS SELECT
2058 `post-tag`.`uri-id` AS `uri-id`,
2059 `item`.`id` AS `iid`,
2060 `item`.`uri` AS `uri`,
2061 `item`.`guid` AS `guid`,
2062 `item`.`uid` AS `uid`,
2063 `item`.`private` AS `private`,
2064 `item`.`wall` AS `wall`,
2065 `item`.`origin` AS `origin`,
2066 `item`.`gravity` AS `gravity`,
2067 `item`.`received` AS `received`,
2068 `tag`.`name` AS `name`
2070 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
2071 INNER JOIN `item` ON `item`.`uri-id` = `post-tag`.`uri-id`
2072 WHERE `post-tag`.`type` = 1;
2075 -- VIEW workerqueue-view
2077 DROP VIEW IF EXISTS `workerqueue-view`;
2078 CREATE VIEW `workerqueue-view` AS SELECT
2079 `process`.`pid` AS `pid`,
2080 `workerqueue`.`priority` AS `priority`
2082 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
2083 WHERE NOT `workerqueue`.`done`;