1 -- ------------------------------------------
2 -- Friendica 2022.09-dev (Giant Rhubarb)
3 -- DB_UPDATE_VERSION 1476
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 `active-week-users` int unsigned COMMENT 'Number of active users in the last week',
20 `active-month-users` int unsigned COMMENT 'Number of active users in the last month',
21 `active-halfyear-users` int unsigned COMMENT 'Number of active users in the last six month',
22 `local-posts` int unsigned COMMENT 'Number of local posts',
23 `local-comments` int unsigned COMMENT 'Number of local comments',
24 `directory-type` tinyint DEFAULT 0 COMMENT 'Type of directory service (Poco, Mastodon)',
25 `poco` varchar(255) NOT NULL DEFAULT '' COMMENT '',
26 `noscrape` varchar(255) NOT NULL DEFAULT '' COMMENT '',
27 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
28 `protocol` tinyint unsigned COMMENT 'The protocol of the server',
29 `platform` varchar(255) NOT NULL DEFAULT '' COMMENT '',
30 `relay-subscribe` boolean NOT NULL DEFAULT '0' COMMENT 'Has the server subscribed to the relay system',
31 `relay-scope` varchar(10) NOT NULL DEFAULT '' COMMENT 'The scope of messages that the server wants to get',
32 `detection-method` tinyint unsigned COMMENT 'Method that had been used to detect that server',
33 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
34 `last_poco_query` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
35 `last_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Last successful connection request',
36 `last_failure` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Last failed connection request',
37 `failed` boolean COMMENT 'Connection failed',
38 `next_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Next connection request',
40 UNIQUE INDEX `nurl` (`nurl`(190)),
41 INDEX `next_contact` (`next_contact`),
42 INDEX `network` (`network`)
43 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Global servers';
48 CREATE TABLE IF NOT EXISTS `user` (
49 `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
50 `parent-uid` mediumint unsigned COMMENT 'The parent user that has full control about this user',
51 `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
52 `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
53 `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
54 `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
55 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
56 `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
57 `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
58 `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
59 `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
60 `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
61 `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
62 `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
63 `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
64 `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
65 `pubkey` text COMMENT 'RSA public key 4096 bit',
66 `prvkey` text COMMENT 'RSA private key 4096 bit',
67 `spubkey` text COMMENT '',
68 `sprvkey` text COMMENT '',
69 `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
70 `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
71 `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
72 `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unkown viewers',
73 `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
74 `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
75 `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
76 `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
77 `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
78 `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
79 `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
80 `pwdreset` varchar(255) COMMENT 'Password reset request token',
81 `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
82 `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
83 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
84 `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
85 `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
86 `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
87 `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
88 `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
89 `allow_cid` mediumtext COMMENT 'default permission for this user',
90 `allow_gid` mediumtext COMMENT 'default permission for this user',
91 `deny_cid` mediumtext COMMENT 'default permission for this user',
92 `deny_gid` mediumtext COMMENT 'default permission for this user',
93 `openidserver` text COMMENT '',
95 INDEX `nickname` (`nickname`(32)),
96 INDEX `parent-uid` (`parent-uid`),
97 INDEX `guid` (`guid`),
98 INDEX `email` (`email`(64)),
99 FOREIGN KEY (`parent-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
100 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
105 CREATE TABLE IF NOT EXISTS `item-uri` (
106 `id` int unsigned NOT NULL auto_increment,
107 `uri` varbinary(255) NOT NULL COMMENT 'URI of an item',
108 `guid` varbinary(255) COMMENT 'A unique identifier for an item',
110 UNIQUE INDEX `uri` (`uri`),
111 INDEX `guid` (`guid`)
112 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
117 CREATE TABLE IF NOT EXISTS `contact` (
118 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
119 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
120 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
121 `updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last contact update',
122 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network of the contact',
123 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
124 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
125 `location` varchar(255) DEFAULT '' COMMENT '',
126 `about` text COMMENT '',
127 `keywords` text COMMENT 'public keywords (interests) of the contact',
128 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
129 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
130 `avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '',
131 `header` varchar(255) COMMENT 'Header picture',
132 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
133 `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
134 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
135 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
136 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
137 `pubkey` text COMMENT 'RSA public key 4096 bit',
138 `prvkey` text COMMENT 'RSA private key 4096 bit',
139 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
140 `notify` varchar(255) COMMENT '',
141 `poll` varchar(255) COMMENT '',
142 `subscribe` varchar(255) COMMENT '',
143 `last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
144 `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
145 `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
146 `failed` boolean COMMENT 'Connection failed',
147 `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
148 `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
149 `last-discovery` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last follower discovery',
150 `blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
151 `block_reason` text COMMENT 'Node-wide block reason',
152 `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
153 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Person, organisation, news, community, relay',
154 `manually-approve` boolean COMMENT 'Contact requests have to be approved manually',
155 `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
156 `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
157 `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
158 `baseurl` varchar(255) DEFAULT '' COMMENT 'baseurl of the contact',
159 `gsid` int unsigned COMMENT 'Global Server ID',
160 `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
161 `reason` text COMMENT '',
162 `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
163 `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
164 `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
165 `protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
166 `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
167 `hub-verify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
168 `rating` tinyint NOT NULL DEFAULT 0 COMMENT 'Automatically detected feed poll frequency',
169 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Feed poll priority',
170 `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
171 `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
172 `pending` boolean NOT NULL DEFAULT '1' COMMENT 'Contact request is pending',
173 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
174 `info` mediumtext 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 '',
178 `photo` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
179 `thumb` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
180 `micro` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
181 `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
182 `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
183 `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
184 `request` varchar(255) COMMENT '',
185 `confirm` varchar(255) COMMENT '',
186 `poco` varchar(255) COMMENT '',
187 `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
188 `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = false instead',
189 `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = true instead',
190 `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
191 `site-pubkey` text COMMENT 'Deprecated',
192 `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
193 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
194 `issued-id` varchar(255) NOT NULL DEFAULT '' COMMENT 'Deprecated',
195 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT 'Deprecated',
196 `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
197 `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
198 `usehub` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
199 `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT 'Deprecated',
200 `profile-id` int unsigned COMMENT 'Deprecated',
202 INDEX `uid_name` (`uid`,`name`(190)),
203 INDEX `self_uid` (`self`,`uid`),
204 INDEX `alias_uid` (`alias`(128),`uid`),
205 INDEX `pending_uid` (`pending`,`uid`),
206 INDEX `blocked_uid` (`blocked`,`uid`),
207 INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
208 INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
209 INDEX `batch_contact-type` (`batch`(64),`contact-type`),
210 INDEX `addr_uid` (`addr`(128),`uid`),
211 INDEX `nurl_uid` (`nurl`(128),`uid`),
212 INDEX `nick_uid` (`nick`(128),`uid`),
213 INDEX `attag_uid` (`attag`(96),`uid`),
214 INDEX `network_uid_lastupdate` (`network`,`uid`,`last-update`),
215 INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`),
216 INDEX `uid_lastitem` (`uid`,`last-item`),
217 INDEX `baseurl` (`baseurl`(64)),
218 INDEX `uid_contact-type` (`uid`,`contact-type`),
219 INDEX `uid_self_contact-type` (`uid`,`self`,`contact-type`),
220 INDEX `self_network_uid` (`self`,`network`,`uid`),
221 INDEX `gsid` (`gsid`),
222 INDEX `uri-id` (`uri-id`),
223 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
224 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
225 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
226 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
231 CREATE TABLE IF NOT EXISTS `tag` (
232 `id` int unsigned NOT NULL auto_increment COMMENT '',
233 `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
234 `url` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
235 `type` tinyint unsigned COMMENT 'Type of the tag (Unknown, General Collection, Follower Collection or Account)',
237 UNIQUE INDEX `type_name_url` (`name`,`url`),
239 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
242 -- TABLE permissionset
244 CREATE TABLE IF NOT EXISTS `permissionset` (
245 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
246 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
247 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
248 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
249 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
250 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
252 INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`uid`,`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30)),
253 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
254 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
259 CREATE TABLE IF NOT EXISTS `verb` (
260 `id` smallint unsigned NOT NULL auto_increment,
261 `name` varchar(100) NOT NULL DEFAULT '' COMMENT '',
263 INDEX `name` (`name`)
264 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activity Verbs';
267 -- TABLE 2fa_app_specific_password
269 CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
270 `id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
271 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
272 `description` varchar(255) COMMENT 'Description of the usage of the password',
273 `hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
274 `generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
275 `last_used` datetime COMMENT 'Datetime the password was last used',
277 INDEX `uid_description` (`uid`,`description`(190)),
278 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
279 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
282 -- TABLE 2fa_recovery_codes
284 CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
285 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
286 `code` varchar(50) NOT NULL COMMENT 'Recovery code string',
287 `generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
288 `used` datetime COMMENT 'Datetime the code was used',
289 PRIMARY KEY(`uid`,`code`),
290 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
291 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
294 -- TABLE 2fa_trusted_browser
296 CREATE TABLE IF NOT EXISTS `2fa_trusted_browser` (
297 `cookie_hash` varchar(80) NOT NULL COMMENT 'Trusted cookie hash',
298 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
299 `user_agent` text COMMENT 'User agent string',
300 `trusted` boolean NOT NULL DEFAULT '1' COMMENT 'Whenever this browser should be trusted or not',
301 `created` datetime NOT NULL COMMENT 'Datetime the trusted browser was recorded',
302 `last_used` datetime COMMENT 'Datetime the trusted browser was last used',
303 PRIMARY KEY(`cookie_hash`),
305 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
306 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication trusted browsers';
311 CREATE TABLE IF NOT EXISTS `addon` (
312 `id` int unsigned NOT NULL auto_increment COMMENT '',
313 `name` varchar(50) NOT NULL DEFAULT '' COMMENT 'addon base (file)name',
314 `version` varchar(50) NOT NULL DEFAULT '' COMMENT 'currently unused',
315 `installed` boolean NOT NULL DEFAULT '0' COMMENT 'currently always 1',
316 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'currently unused',
317 `timestamp` int unsigned NOT NULL DEFAULT 0 COMMENT 'file timestamp to check for reloads',
318 `plugin_admin` boolean NOT NULL DEFAULT '0' COMMENT '1 = has admin config, 0 = has no admin config',
320 INDEX `installed_name` (`installed`,`name`),
321 UNIQUE INDEX `name` (`name`)
322 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registered addons';
327 CREATE TABLE IF NOT EXISTS `apcontact` (
328 `url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
329 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
330 `uuid` varchar(255) COMMENT '',
331 `type` varchar(20) NOT NULL COMMENT '',
332 `following` varchar(255) COMMENT '',
333 `followers` varchar(255) COMMENT '',
334 `inbox` varchar(255) NOT NULL COMMENT '',
335 `outbox` varchar(255) COMMENT '',
336 `sharedinbox` varchar(255) COMMENT '',
337 `featured` varchar(255) COMMENT 'Address for the collection of featured posts',
338 `featured-tags` varchar(255) COMMENT 'Address for the collection of featured tags',
339 `manually-approve` boolean COMMENT '',
340 `discoverable` boolean COMMENT 'Mastodon extension: true if profile is published in their directory',
341 `suspended` boolean COMMENT 'Mastodon extension: true if profile is suspended',
342 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
343 `name` varchar(255) COMMENT '',
344 `about` text COMMENT '',
345 `xmpp` varchar(255) COMMENT 'XMPP address',
346 `matrix` varchar(255) COMMENT 'Matrix address',
347 `photo` varchar(255) COMMENT '',
348 `header` varchar(255) COMMENT 'Header picture',
349 `addr` varchar(255) COMMENT '',
350 `alias` varchar(255) COMMENT '',
351 `pubkey` text COMMENT '',
352 `subscribe` varchar(255) COMMENT '',
353 `baseurl` varchar(255) COMMENT 'baseurl of the ap contact',
354 `gsid` int unsigned COMMENT 'Global Server ID',
355 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
356 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
357 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
358 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
359 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
361 INDEX `addr` (`addr`(32)),
362 INDEX `alias` (`alias`(190)),
363 INDEX `followers` (`followers`(190)),
364 INDEX `baseurl` (`baseurl`(190)),
365 INDEX `sharedinbox` (`sharedinbox`(190)),
366 INDEX `gsid` (`gsid`),
367 UNIQUE INDEX `uri-id` (`uri-id`),
368 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
369 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
370 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
375 CREATE TABLE IF NOT EXISTS `application` (
376 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
377 `client_id` varchar(64) NOT NULL COMMENT '',
378 `client_secret` varchar(64) NOT NULL COMMENT '',
379 `name` varchar(255) NOT NULL COMMENT '',
380 `redirect_uri` varchar(255) NOT NULL COMMENT '',
381 `website` varchar(255) COMMENT '',
382 `scopes` varchar(255) COMMENT '',
383 `read` boolean COMMENT 'Read scope',
384 `write` boolean COMMENT 'Write scope',
385 `follow` boolean COMMENT 'Follow scope',
386 `push` boolean COMMENT 'Push scope',
388 UNIQUE INDEX `client_id` (`client_id`)
389 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth application';
392 -- TABLE application-marker
394 CREATE TABLE IF NOT EXISTS `application-marker` (
395 `application-id` int unsigned NOT NULL COMMENT '',
396 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
397 `timeline` varchar(64) NOT NULL COMMENT 'Marker (home, notifications)',
398 `last_read_id` varchar(255) COMMENT 'Marker id for the timeline',
399 `version` smallint unsigned COMMENT 'Version number',
400 `updated_at` datetime COMMENT 'creation time',
401 PRIMARY KEY(`application-id`,`uid`,`timeline`),
402 INDEX `uid_id` (`uid`),
403 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
404 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
405 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Timeline marker';
408 -- TABLE application-token
410 CREATE TABLE IF NOT EXISTS `application-token` (
411 `application-id` int unsigned NOT NULL COMMENT '',
412 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
413 `code` varchar(64) NOT NULL COMMENT '',
414 `access_token` varchar(64) NOT NULL COMMENT '',
415 `created_at` datetime NOT NULL COMMENT 'creation time',
416 `scopes` varchar(255) COMMENT '',
417 `read` boolean COMMENT 'Read scope',
418 `write` boolean COMMENT 'Write scope',
419 `follow` boolean COMMENT 'Follow scope',
420 `push` boolean COMMENT 'Push scope',
421 PRIMARY KEY(`application-id`,`uid`),
422 INDEX `uid_id` (`uid`,`application-id`),
423 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
424 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
425 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth user token';
430 CREATE TABLE IF NOT EXISTS `attach` (
431 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
432 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
433 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
434 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
435 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
436 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
437 `data` longblob NOT NULL COMMENT 'file data',
438 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
439 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
440 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
441 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
442 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
443 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
444 `backend-class` tinytext COMMENT 'Storage backend class',
445 `backend-ref` text COMMENT 'Storage backend data reference',
448 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
449 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
454 CREATE TABLE IF NOT EXISTS `cache` (
455 `k` varbinary(255) NOT NULL COMMENT 'cache key',
456 `v` mediumtext COMMENT 'cached serialized value',
457 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
458 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
460 INDEX `k_expires` (`k`,`expires`)
461 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
466 CREATE TABLE IF NOT EXISTS `config` (
467 `id` int unsigned NOT NULL auto_increment COMMENT '',
468 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
469 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
470 `v` mediumtext COMMENT '',
472 UNIQUE INDEX `cat_k` (`cat`,`k`)
473 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
476 -- TABLE contact-relation
478 CREATE TABLE IF NOT EXISTS `contact-relation` (
479 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
480 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
481 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
482 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
483 `follows` boolean NOT NULL DEFAULT '0' COMMENT '',
484 PRIMARY KEY(`cid`,`relation-cid`),
485 INDEX `relation-cid` (`relation-cid`),
486 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
487 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
488 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
493 CREATE TABLE IF NOT EXISTS `conv` (
494 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
495 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
496 `recips` text COMMENT 'sender_handle;recipient_handle',
497 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
498 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
499 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
500 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
501 `subject` text COMMENT 'subject of initial message',
504 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
505 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
510 CREATE TABLE IF NOT EXISTS `workerqueue` (
511 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
512 `command` varchar(100) COMMENT 'Task command',
513 `parameter` mediumtext COMMENT 'Task parameter',
514 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
515 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
516 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
517 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
518 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
519 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
520 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
522 INDEX `command` (`command`),
523 INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
524 INDEX `done_executed` (`done`,`executed`),
525 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
526 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
527 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
528 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
529 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
530 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
533 -- TABLE delayed-post
535 CREATE TABLE IF NOT EXISTS `delayed-post` (
536 `id` int unsigned NOT NULL auto_increment,
537 `uri` varchar(255) COMMENT 'URI of the post that will be distributed later',
538 `uid` mediumint unsigned COMMENT 'Owner User id',
539 `delayed` datetime COMMENT 'delay time',
540 `wid` int unsigned COMMENT 'Workerqueue id',
542 UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
544 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
545 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
546 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
549 -- TABLE diaspora-interaction
551 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
552 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
553 `interaction` mediumtext COMMENT 'The Diaspora interaction',
554 PRIMARY KEY(`uri-id`),
555 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
556 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
561 CREATE TABLE IF NOT EXISTS `endpoint` (
562 `url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
563 `type` varchar(20) NOT NULL COMMENT '',
564 `owner-uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
566 UNIQUE INDEX `owner-uri-id_type` (`owner-uri-id`,`type`),
567 FOREIGN KEY (`owner-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
568 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub endpoints - used in the ActivityPub implementation';
573 CREATE TABLE IF NOT EXISTS `event` (
574 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
575 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
576 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
577 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
578 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
579 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the event uri',
580 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
581 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
582 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
583 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
584 `summary` text COMMENT 'short description or title of the event',
585 `desc` text COMMENT 'event description',
586 `location` text COMMENT 'event location',
587 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
588 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
589 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
590 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
591 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
592 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
593 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
595 INDEX `uid_start` (`uid`,`start`),
597 INDEX `uri-id` (`uri-id`),
598 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
599 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
600 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
601 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
606 CREATE TABLE IF NOT EXISTS `fcontact` (
607 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
608 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
609 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
610 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the fcontact url',
611 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
612 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
613 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
614 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
615 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
616 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
617 `notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
618 `poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
619 `confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
620 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
621 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
622 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
623 `pubkey` text COMMENT '',
624 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
625 `interacting_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts this contact interactes with',
626 `interacted_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts that interacted with this contact',
627 `post_count` int unsigned DEFAULT 0 COMMENT 'Number of posts and comments',
629 INDEX `addr` (`addr`(32)),
630 UNIQUE INDEX `url` (`url`(190)),
631 UNIQUE INDEX `uri-id` (`uri-id`),
632 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
633 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
638 CREATE TABLE IF NOT EXISTS `fsuggest` (
639 `id` int unsigned NOT NULL auto_increment COMMENT '',
640 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
641 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
642 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
643 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
644 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
645 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
646 `note` text COMMENT '',
647 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
651 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
652 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
653 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
658 CREATE TABLE IF NOT EXISTS `group` (
659 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
660 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
661 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
662 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
663 `cid` int unsigned COMMENT 'Contact id of forum. When this field is filled then the members are synced automatically.',
664 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
668 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
669 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
670 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
673 -- TABLE group_member
675 CREATE TABLE IF NOT EXISTS `group_member` (
676 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
677 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
678 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
680 INDEX `contactid` (`contact-id`),
681 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
682 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
683 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
684 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
689 CREATE TABLE IF NOT EXISTS `gserver-tag` (
690 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
691 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
692 PRIMARY KEY(`gserver-id`,`tag`),
694 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
695 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
700 CREATE TABLE IF NOT EXISTS `hook` (
701 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
702 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
703 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
704 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
705 `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',
707 INDEX `priority` (`priority`),
708 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
709 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
714 CREATE TABLE IF NOT EXISTS `inbox-entry` (
715 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
716 `activity-id` varbinary(255) COMMENT 'id of the incoming activity',
717 `object-id` varbinary(255) COMMENT '',
718 `in-reply-to-id` varbinary(255) COMMENT '',
719 `conversation` varbinary(255) COMMENT '',
720 `type` varchar(64) COMMENT 'Type of the activity',
721 `object-type` varchar(64) COMMENT 'Type of the object activity',
722 `object-object-type` varchar(64) COMMENT 'Type of the object\'s object activity',
723 `received` datetime COMMENT 'Receiving date',
724 `activity` mediumtext COMMENT 'The JSON activity',
725 `signer` varchar(255) COMMENT '',
726 `push` boolean COMMENT 'Is the entry pushed or have pulled it?',
727 `trust` boolean COMMENT 'Do we trust this entry?',
728 `wid` int unsigned COMMENT 'Workerqueue id',
730 UNIQUE INDEX `activity-id` (`activity-id`),
731 INDEX `object-id` (`object-id`),
732 INDEX `received` (`received`),
734 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
735 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Incoming activity';
738 -- TABLE inbox-entry-receiver
740 CREATE TABLE IF NOT EXISTS `inbox-entry-receiver` (
741 `queue-id` int unsigned NOT NULL COMMENT '',
742 `uid` mediumint unsigned NOT NULL COMMENT 'User id',
743 PRIMARY KEY(`queue-id`,`uid`),
745 FOREIGN KEY (`queue-id`) REFERENCES `inbox-entry` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
746 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
747 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Receiver for the incoming activity';
750 -- TABLE inbox-status
752 CREATE TABLE IF NOT EXISTS `inbox-status` (
753 `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
754 `uri-id` int unsigned COMMENT 'Item-uri id of inbox url',
755 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
756 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
757 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
758 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
759 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
760 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
762 INDEX `uri-id` (`uri-id`),
763 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
764 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
769 CREATE TABLE IF NOT EXISTS `intro` (
770 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
771 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
772 `fid` int unsigned COMMENT 'deprecated',
773 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
774 `suggest-cid` int unsigned COMMENT 'Suggested contact',
775 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
776 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
777 `note` text COMMENT '',
778 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
779 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
780 `blocked` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
781 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
783 INDEX `contact-id` (`contact-id`),
784 INDEX `suggest-cid` (`suggest-cid`),
786 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
787 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
788 FOREIGN KEY (`suggest-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
789 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
794 CREATE TABLE IF NOT EXISTS `locks` (
795 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
796 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
797 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
798 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
799 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
801 INDEX `name_expires` (`name`,`expires`)
802 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
807 CREATE TABLE IF NOT EXISTS `mail` (
808 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
809 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
810 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
811 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
812 `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
813 `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
814 `contact-id` varchar(255) COMMENT 'contact.id',
815 `author-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the author of the mail',
816 `convid` int unsigned COMMENT 'conv.id',
817 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
818 `body` mediumtext COMMENT '',
819 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
820 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
821 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
822 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
823 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
824 `uri-id` int unsigned COMMENT 'Item-uri id of the related mail',
825 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
826 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related mail',
827 `thr-parent` varchar(255) COMMENT '',
828 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
829 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
831 INDEX `uid_seen` (`uid`,`seen`),
832 INDEX `convid` (`convid`),
833 INDEX `uri` (`uri`(64)),
834 INDEX `parent-uri` (`parent-uri`(64)),
835 INDEX `contactid` (`contact-id`(32)),
836 INDEX `author-id` (`author-id`),
837 INDEX `uri-id` (`uri-id`),
838 INDEX `parent-uri-id` (`parent-uri-id`),
839 INDEX `thr-parent-id` (`thr-parent-id`),
840 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
841 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
842 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
843 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
844 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
845 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
850 CREATE TABLE IF NOT EXISTS `mailacct` (
851 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
852 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
853 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
854 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
855 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
856 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
857 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
858 `pass` text COMMENT '',
859 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
860 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
861 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
862 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
863 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
866 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
867 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
872 CREATE TABLE IF NOT EXISTS `manage` (
873 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
874 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
875 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
877 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
879 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
880 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
881 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
884 -- TABLE notification
886 CREATE TABLE IF NOT EXISTS `notification` (
887 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
888 `uid` mediumint unsigned COMMENT 'Owner User id',
889 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
890 `type` smallint unsigned COMMENT '',
891 `actor-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the actor that caused the notification',
892 `target-uri-id` int unsigned COMMENT 'Item-uri id of the related post',
893 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
894 `created` datetime COMMENT '',
895 `seen` boolean DEFAULT '0' COMMENT 'Seen on the desktop',
896 `dismissed` boolean DEFAULT '0' COMMENT 'Dismissed via the API',
898 UNIQUE INDEX `uid_vid_type_actor-id_target-uri-id` (`uid`,`vid`,`type`,`actor-id`,`target-uri-id`),
900 INDEX `actor-id` (`actor-id`),
901 INDEX `target-uri-id` (`target-uri-id`),
902 INDEX `parent-uri-id` (`parent-uri-id`),
903 INDEX `seen_uid` (`seen`,`uid`),
904 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
905 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
906 FOREIGN KEY (`actor-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
907 FOREIGN KEY (`target-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
908 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
909 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
914 CREATE TABLE IF NOT EXISTS `notify` (
915 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
916 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
917 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
918 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
919 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
920 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
921 `msg` mediumtext COMMENT '',
922 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
923 `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
924 `iid` int unsigned COMMENT '',
925 `parent` int unsigned COMMENT '',
926 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
927 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
928 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
929 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
930 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
931 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
932 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
934 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
935 INDEX `uid_date` (`uid`,`date`),
936 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
937 INDEX `uri-id` (`uri-id`),
938 INDEX `parent-uri-id` (`parent-uri-id`),
939 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
940 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
941 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
942 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='[Deprecated] User notifications';
945 -- TABLE notify-threads
947 CREATE TABLE IF NOT EXISTS `notify-threads` (
948 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
949 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
950 `master-parent-item` int unsigned COMMENT 'Deprecated',
951 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
952 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
953 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
955 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
956 INDEX `receiver-uid` (`receiver-uid`),
957 INDEX `notify-id` (`notify-id`),
958 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
959 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
960 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
961 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
966 CREATE TABLE IF NOT EXISTS `oembed` (
967 `url` varbinary(255) NOT NULL COMMENT 'page url',
968 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
969 `content` mediumtext COMMENT 'OEmbed data of the page',
970 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
971 PRIMARY KEY(`url`,`maxwidth`),
972 INDEX `created` (`created`)
973 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
976 -- TABLE openwebauth-token
978 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
979 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
980 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
981 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
982 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
983 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
984 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
987 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
988 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
993 CREATE TABLE IF NOT EXISTS `parsed_url` (
994 `url_hash` binary(64) NOT NULL COMMENT 'page url hash',
995 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
996 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
997 `url` text NOT NULL COMMENT 'page url',
998 `content` mediumtext COMMENT 'page data',
999 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1000 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration',
1001 PRIMARY KEY(`url_hash`,`guessing`,`oembed`),
1002 INDEX `created` (`created`),
1003 INDEX `expires` (`expires`)
1004 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
1009 CREATE TABLE IF NOT EXISTS `pconfig` (
1010 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
1011 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1012 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
1013 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
1014 `v` mediumtext COMMENT 'Value',
1016 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
1017 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1018 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
1023 CREATE TABLE IF NOT EXISTS `photo` (
1024 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1025 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1026 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1027 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
1028 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
1029 `hash` char(32) COMMENT 'hash value of the photo',
1030 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
1031 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
1032 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1033 `desc` text COMMENT '',
1034 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
1035 `photo-type` tinyint unsigned COMMENT 'User avatar, user banner, contact avatar, contact banner or default',
1036 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1037 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
1038 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1039 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1040 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1041 `data` mediumblob NOT NULL COMMENT '',
1042 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1043 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
1044 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
1045 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
1046 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
1047 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
1048 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
1049 `backend-class` tinytext COMMENT 'Storage backend class',
1050 `backend-ref` text COMMENT 'Storage backend data reference',
1051 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1053 INDEX `contactid` (`contact-id`),
1054 INDEX `uid_contactid` (`uid`,`contact-id`),
1055 INDEX `uid_profile` (`uid`,`profile`),
1056 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
1057 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
1058 INDEX `resource-id` (`resource-id`),
1059 INDEX `uid_photo-type` (`uid`,`photo-type`),
1060 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1061 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1062 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1067 CREATE TABLE IF NOT EXISTS `post` (
1068 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1069 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1070 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1071 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1072 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1073 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1074 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1075 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1076 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1077 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1078 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1079 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1080 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1081 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1082 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1083 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1084 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1085 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1086 PRIMARY KEY(`uri-id`),
1087 INDEX `parent-uri-id` (`parent-uri-id`),
1088 INDEX `thr-parent-id` (`thr-parent-id`),
1089 INDEX `external-id` (`external-id`),
1090 INDEX `owner-id` (`owner-id`),
1091 INDEX `author-id` (`author-id`),
1092 INDEX `causer-id` (`causer-id`),
1093 INDEX `vid` (`vid`),
1094 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1095 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1096 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1097 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1098 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1099 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1100 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1101 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1102 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
1105 -- TABLE post-activity
1107 CREATE TABLE IF NOT EXISTS `post-activity` (
1108 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1109 `activity` mediumtext COMMENT 'Original activity',
1110 `received` datetime COMMENT '',
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='Original remote activity';
1116 -- TABLE post-category
1118 CREATE TABLE IF NOT EXISTS `post-category` (
1119 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1120 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1121 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1122 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1123 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1124 INDEX `tid` (`tid`),
1125 INDEX `uid_uri-id` (`uid`,`uri-id`),
1126 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1127 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1128 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1129 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1132 -- TABLE post-collection
1134 CREATE TABLE IF NOT EXISTS `post-collection` (
1135 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1136 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0 - Featured',
1137 PRIMARY KEY(`uri-id`,`type`),
1138 INDEX `type` (`type`),
1139 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1140 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Collection of posts';
1143 -- TABLE post-content
1145 CREATE TABLE IF NOT EXISTS `post-content` (
1146 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1147 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1148 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1149 `body` mediumtext COMMENT 'item body content',
1150 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1151 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1152 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1153 `language` text COMMENT 'Language information about this post',
1154 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1155 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1156 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1157 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1158 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1159 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1160 `target` text COMMENT 'JSON encoded target structure if used',
1161 `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',
1162 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1163 PRIMARY KEY(`uri-id`),
1164 INDEX `plink` (`plink`(191)),
1165 INDEX `resource-id` (`resource-id`),
1166 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
1167 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1168 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1171 -- TABLE post-delivery
1173 CREATE TABLE IF NOT EXISTS `post-delivery` (
1174 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1175 `inbox-id` int unsigned NOT NULL COMMENT 'Item-uri id of inbox url',
1176 `uid` mediumint unsigned COMMENT 'Delivering user',
1177 `created` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
1178 `command` varbinary(32) COMMENT '',
1179 `failed` tinyint DEFAULT 0 COMMENT 'Number of times the delivery has failed',
1180 `receivers` mediumtext COMMENT 'JSON encoded array with the receiving contacts',
1181 PRIMARY KEY(`uri-id`,`inbox-id`),
1182 INDEX `inbox-id_created` (`inbox-id`,`created`),
1183 INDEX `uid` (`uid`),
1184 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1185 FOREIGN KEY (`inbox-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1186 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1187 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for posts for the batch processing';
1190 -- TABLE post-delivery-data
1192 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1193 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1194 `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',
1195 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1196 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1197 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1198 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1199 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1200 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1201 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1202 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1203 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1204 PRIMARY KEY(`uri-id`),
1205 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1206 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1209 -- TABLE post-history
1211 CREATE TABLE IF NOT EXISTS `post-history` (
1212 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1213 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of edit',
1214 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1215 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1216 `body` mediumtext COMMENT 'item body content',
1217 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1218 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1219 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1220 `language` text COMMENT 'Language information about this post',
1221 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1222 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1223 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1224 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1225 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1226 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1227 `target` text COMMENT 'JSON encoded target structure if used',
1228 `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',
1229 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1230 PRIMARY KEY(`uri-id`,`edited`),
1231 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1232 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post history';
1237 CREATE TABLE IF NOT EXISTS `post-link` (
1238 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1239 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1240 `url` varbinary(511) NOT NULL COMMENT 'External URL',
1241 `mimetype` varchar(60) COMMENT '',
1243 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1244 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1245 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post related external links';
1250 CREATE TABLE IF NOT EXISTS `post-media` (
1251 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1252 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1253 `url` varbinary(1024) NOT NULL COMMENT 'Media URL',
1254 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1255 `mimetype` varchar(60) COMMENT '',
1256 `height` smallint unsigned COMMENT 'Height of the media',
1257 `width` smallint unsigned COMMENT 'Width of the media',
1258 `size` bigint unsigned COMMENT 'Media size',
1259 `preview` varbinary(512) COMMENT 'Preview URL',
1260 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1261 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1262 `description` text COMMENT '',
1263 `name` varchar(255) COMMENT 'Name of the media',
1264 `author-url` varbinary(255) COMMENT 'URL of the author of the media',
1265 `author-name` varchar(255) COMMENT 'Name of the author of the media',
1266 `author-image` varbinary(255) COMMENT 'Image of the author of the media',
1267 `publisher-url` varbinary(255) COMMENT 'URL of the publisher of the media',
1268 `publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
1269 `publisher-image` varbinary(255) COMMENT 'Image of the publisher of the media',
1271 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`(512)),
1272 INDEX `uri-id-id` (`uri-id`,`id`),
1273 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1274 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1277 -- TABLE post-question
1279 CREATE TABLE IF NOT EXISTS `post-question` (
1280 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1281 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1282 `multiple` boolean NOT NULL DEFAULT '0' COMMENT 'Multiple choice',
1283 `voters` int unsigned COMMENT 'Number of voters for this question',
1284 `end-time` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Question end time',
1286 UNIQUE INDEX `uri-id` (`uri-id`),
1287 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1288 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question';
1291 -- TABLE post-question-option
1293 CREATE TABLE IF NOT EXISTS `post-question-option` (
1294 `id` int unsigned NOT NULL COMMENT 'Id of the question',
1295 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1296 `name` varchar(255) COMMENT 'Name of the option',
1297 `replies` int unsigned COMMENT 'Number of replies for this question option',
1298 PRIMARY KEY(`uri-id`,`id`),
1299 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1300 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question option';
1305 CREATE TABLE IF NOT EXISTS `post-tag` (
1306 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1307 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1308 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1309 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1310 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1311 INDEX `tid` (`tid`),
1312 INDEX `cid` (`cid`),
1313 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1314 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1315 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1316 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1319 -- TABLE post-thread
1321 CREATE TABLE IF NOT EXISTS `post-thread` (
1322 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1323 `conversation-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the conversation uri',
1324 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1325 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1326 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1327 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1328 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1329 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1330 `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',
1331 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1332 PRIMARY KEY(`uri-id`),
1333 INDEX `conversation-id` (`conversation-id`),
1334 INDEX `owner-id` (`owner-id`),
1335 INDEX `author-id` (`author-id`),
1336 INDEX `causer-id` (`causer-id`),
1337 INDEX `received` (`received`),
1338 INDEX `commented` (`commented`),
1339 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1340 FOREIGN KEY (`conversation-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1341 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1342 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1343 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1344 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1349 CREATE TABLE IF NOT EXISTS `post-user` (
1350 `id` int unsigned NOT NULL auto_increment,
1351 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1352 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1353 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1354 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1355 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1356 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1357 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1358 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1359 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1360 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1361 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1362 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1363 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1364 `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
1365 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1366 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1367 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1368 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1369 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1370 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1371 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1372 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1373 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1374 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1375 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1376 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1377 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1378 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1379 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1381 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1382 INDEX `uri-id` (`uri-id`),
1383 INDEX `parent-uri-id` (`parent-uri-id`),
1384 INDEX `thr-parent-id` (`thr-parent-id`),
1385 INDEX `external-id` (`external-id`),
1386 INDEX `owner-id` (`owner-id`),
1387 INDEX `author-id` (`author-id`),
1388 INDEX `causer-id` (`causer-id`),
1389 INDEX `vid` (`vid`),
1390 INDEX `contact-id` (`contact-id`),
1391 INDEX `event-id` (`event-id`),
1392 INDEX `psid` (`psid`),
1393 INDEX `author-id_uid` (`author-id`,`uid`),
1394 INDEX `author-id_received` (`author-id`,`received`),
1395 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1396 INDEX `uid_contactid` (`uid`,`contact-id`),
1397 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1398 INDEX `uid_unseen` (`uid`,`unseen`),
1399 INDEX `uid_hidden_uri-id` (`uid`,`hidden`,`uri-id`),
1400 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1401 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1402 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1403 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1404 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1405 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1406 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1407 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1408 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1409 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1410 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1411 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1412 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1415 -- TABLE post-thread-user
1417 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1418 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1419 `conversation-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the conversation uri',
1420 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1421 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1422 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1423 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1424 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1425 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1426 `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',
1427 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1428 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1429 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
1430 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1431 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1432 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1433 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1434 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1435 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Deprecated',
1436 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1437 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1438 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1439 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1440 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1441 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1442 PRIMARY KEY(`uid`,`uri-id`),
1443 INDEX `uri-id` (`uri-id`),
1444 INDEX `conversation-id` (`conversation-id`),
1445 INDEX `owner-id` (`owner-id`),
1446 INDEX `author-id` (`author-id`),
1447 INDEX `causer-id` (`causer-id`),
1448 INDEX `uid` (`uid`),
1449 INDEX `contact-id` (`contact-id`),
1450 INDEX `psid` (`psid`),
1451 INDEX `post-user-id` (`post-user-id`),
1452 INDEX `commented` (`commented`),
1453 INDEX `uid_received` (`uid`,`received`),
1454 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1455 INDEX `uid_commented` (`uid`,`commented`),
1456 INDEX `uid_starred` (`uid`,`starred`),
1457 INDEX `uid_mention` (`uid`,`mention`),
1458 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1459 FOREIGN KEY (`conversation-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1460 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1461 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1462 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1463 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1464 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1465 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1466 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1467 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1470 -- TABLE post-user-notification
1472 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1473 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1474 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1475 `notification-type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1476 PRIMARY KEY(`uid`,`uri-id`),
1477 INDEX `uri-id` (`uri-id`),
1478 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1479 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1480 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1485 CREATE TABLE IF NOT EXISTS `process` (
1486 `pid` int unsigned NOT NULL COMMENT 'The ID of the process',
1487 `hostname` varchar(32) NOT NULL COMMENT 'The name of the host the process is ran on',
1488 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1489 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1490 PRIMARY KEY(`pid`,`hostname`),
1491 INDEX `command` (`command`)
1492 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1497 CREATE TABLE IF NOT EXISTS `profile` (
1498 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1499 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1500 `profile-name` varchar(255) COMMENT 'Deprecated',
1501 `is-default` boolean COMMENT 'Deprecated',
1502 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1503 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1504 `pdesc` varchar(255) COMMENT 'Deprecated',
1505 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1506 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1507 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1508 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1509 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1510 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1511 `hometown` varchar(255) COMMENT 'Deprecated',
1512 `gender` varchar(32) COMMENT 'Deprecated',
1513 `marital` varchar(255) COMMENT 'Deprecated',
1514 `with` text COMMENT 'Deprecated',
1515 `howlong` datetime COMMENT 'Deprecated',
1516 `sexual` varchar(255) COMMENT 'Deprecated',
1517 `politic` varchar(255) COMMENT 'Deprecated',
1518 `religion` varchar(255) COMMENT 'Deprecated',
1519 `pub_keywords` text COMMENT '',
1520 `prv_keywords` text COMMENT '',
1521 `likes` text COMMENT 'Deprecated',
1522 `dislikes` text COMMENT 'Deprecated',
1523 `about` text COMMENT 'Profile description',
1524 `summary` varchar(255) COMMENT 'Deprecated',
1525 `music` text COMMENT 'Deprecated',
1526 `book` text COMMENT 'Deprecated',
1527 `tv` text COMMENT 'Deprecated',
1528 `film` text COMMENT 'Deprecated',
1529 `interest` text COMMENT 'Deprecated',
1530 `romance` text COMMENT 'Deprecated',
1531 `work` text COMMENT 'Deprecated',
1532 `education` text COMMENT 'Deprecated',
1533 `contact` text COMMENT 'Deprecated',
1534 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1535 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
1536 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
1537 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1538 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1539 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1540 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1542 INDEX `uid_is-default` (`uid`,`is-default`),
1543 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1544 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1545 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1548 -- TABLE profile_field
1550 CREATE TABLE IF NOT EXISTS `profile_field` (
1551 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1552 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1553 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1554 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1555 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1556 `value` text COMMENT 'Value of the field',
1557 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1558 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1560 INDEX `uid` (`uid`),
1561 INDEX `order` (`order`),
1562 INDEX `psid` (`psid`),
1563 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1564 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1565 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1568 -- TABLE push_subscriber
1570 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1571 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1572 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1573 `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1574 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1575 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1576 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1577 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1578 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1579 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1580 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1582 INDEX `next_try` (`next_try`),
1583 INDEX `uid` (`uid`),
1584 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1585 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1590 CREATE TABLE IF NOT EXISTS `register` (
1591 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1592 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1593 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1594 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1595 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1596 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1597 `note` text COMMENT '',
1599 INDEX `uid` (`uid`),
1600 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1601 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1606 CREATE TABLE IF NOT EXISTS `search` (
1607 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1608 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1609 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1611 INDEX `uid_term` (`uid`,`term`(64)),
1612 INDEX `term` (`term`(64)),
1613 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1614 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1619 CREATE TABLE IF NOT EXISTS `session` (
1620 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1621 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1622 `data` text COMMENT '',
1623 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1625 INDEX `sid` (`sid`(64)),
1626 INDEX `expire` (`expire`)
1627 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1632 CREATE TABLE IF NOT EXISTS `storage` (
1633 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1634 `data` longblob NOT NULL COMMENT 'file data',
1636 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1639 -- TABLE subscription
1641 CREATE TABLE IF NOT EXISTS `subscription` (
1642 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1643 `application-id` int unsigned NOT NULL COMMENT '',
1644 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
1645 `endpoint` varchar(511) COMMENT 'Endpoint URL',
1646 `pubkey` varchar(127) COMMENT 'User agent public key',
1647 `secret` varchar(32) COMMENT 'Auth secret',
1648 `follow` boolean COMMENT '',
1649 `favourite` boolean COMMENT '',
1650 `reblog` boolean COMMENT '',
1651 `mention` boolean COMMENT '',
1652 `poll` boolean COMMENT '',
1653 `follow_request` boolean COMMENT '',
1654 `status` boolean COMMENT '',
1656 UNIQUE INDEX `application-id_uid` (`application-id`,`uid`),
1657 INDEX `uid_application-id` (`uid`,`application-id`),
1658 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1659 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1660 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Push Subscription for the API';
1665 CREATE TABLE IF NOT EXISTS `userd` (
1666 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1667 `username` varchar(255) NOT NULL COMMENT '',
1669 INDEX `username` (`username`(32))
1670 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1673 -- TABLE user-contact
1675 CREATE TABLE IF NOT EXISTS `user-contact` (
1676 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1677 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1678 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
1679 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1680 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1681 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1682 `hidden` boolean COMMENT 'This contact is hidden from the others',
1683 `is-blocked` boolean COMMENT 'User is blocked by this contact',
1684 `pending` boolean COMMENT '',
1685 `rel` tinyint unsigned COMMENT 'The kind of the relation between the user and the contact',
1686 `info` mediumtext COMMENT '',
1687 `notify_new_posts` boolean COMMENT '',
1688 `remote_self` boolean COMMENT '',
1689 `fetch_further_information` tinyint unsigned COMMENT '',
1690 `ffi_keyword_denylist` text COMMENT '',
1691 `subhub` boolean COMMENT '',
1692 `hub-verify` varchar(255) COMMENT '',
1693 `protocol` char(4) COMMENT 'Protocol of the contact',
1694 `rating` tinyint COMMENT 'Automatically detected feed poll frequency',
1695 `priority` tinyint unsigned COMMENT 'Feed poll priority',
1696 PRIMARY KEY(`uid`,`cid`),
1697 INDEX `cid` (`cid`),
1698 UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
1699 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1700 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1701 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1702 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1707 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1708 `key` int NOT NULL COMMENT '',
1709 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1711 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1714 -- VIEW application-view
1716 DROP VIEW IF EXISTS `application-view`;
1717 CREATE VIEW `application-view` AS SELECT
1718 `application`.`id` AS `id`,
1719 `application-token`.`uid` AS `uid`,
1720 `application`.`name` AS `name`,
1721 `application`.`redirect_uri` AS `redirect_uri`,
1722 `application`.`website` AS `website`,
1723 `application`.`client_id` AS `client_id`,
1724 `application`.`client_secret` AS `client_secret`,
1725 `application-token`.`code` AS `code`,
1726 `application-token`.`access_token` AS `access_token`,
1727 `application-token`.`created_at` AS `created_at`,
1728 `application-token`.`scopes` AS `scopes`,
1729 `application-token`.`read` AS `read`,
1730 `application-token`.`write` AS `write`,
1731 `application-token`.`follow` AS `follow`,
1732 `application-token`.`push` AS `push`
1733 FROM `application-token`
1734 INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`;
1737 -- VIEW post-user-view
1739 DROP VIEW IF EXISTS `post-user-view`;
1740 CREATE VIEW `post-user-view` AS SELECT
1741 `post-user`.`id` AS `id`,
1742 `post-user`.`id` AS `post-user-id`,
1743 `post-user`.`uid` AS `uid`,
1744 `parent-post`.`id` AS `parent`,
1745 `item-uri`.`uri` AS `uri`,
1746 `post-user`.`uri-id` AS `uri-id`,
1747 `parent-item-uri`.`uri` AS `parent-uri`,
1748 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1749 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1750 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1751 `conversation-item-uri`.`uri` AS `conversation`,
1752 `post-thread-user`.`conversation-id` AS `conversation-id`,
1753 `item-uri`.`guid` AS `guid`,
1754 `post-user`.`wall` AS `wall`,
1755 `post-user`.`gravity` AS `gravity`,
1756 `external-item-uri`.`uri` AS `extid`,
1757 `post-user`.`external-id` AS `external-id`,
1758 `post-user`.`created` AS `created`,
1759 `post-user`.`edited` AS `edited`,
1760 `post-thread-user`.`commented` AS `commented`,
1761 `post-user`.`received` AS `received`,
1762 `post-thread-user`.`changed` AS `changed`,
1763 `post-user`.`post-type` AS `post-type`,
1764 `post-user`.`post-reason` AS `post-reason`,
1765 `post-user`.`private` AS `private`,
1766 `post-thread-user`.`pubmail` AS `pubmail`,
1767 `post-user`.`visible` AS `visible`,
1768 `post-thread-user`.`starred` AS `starred`,
1769 `post-user`.`unseen` AS `unseen`,
1770 `post-user`.`deleted` AS `deleted`,
1771 `post-user`.`origin` AS `origin`,
1772 `post-thread-user`.`origin` AS `parent-origin`,
1773 `post-thread-user`.`mention` AS `mention`,
1774 `post-user`.`global` AS `global`,
1775 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-user`.`uri-id`) AS `featured`,
1776 `post-user`.`network` AS `network`,
1777 `post-user`.`protocol` AS `protocol`,
1778 `post-user`.`vid` AS `vid`,
1779 `post-user`.`psid` AS `psid`,
1780 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1781 `post-content`.`title` AS `title`,
1782 `post-content`.`content-warning` AS `content-warning`,
1783 `post-content`.`raw-body` AS `raw-body`,
1784 IFNULL (`post-content`.`body`, '') AS `body`,
1785 `post-content`.`rendered-hash` AS `rendered-hash`,
1786 `post-content`.`rendered-html` AS `rendered-html`,
1787 `post-content`.`language` AS `language`,
1788 `post-content`.`plink` AS `plink`,
1789 `post-content`.`location` AS `location`,
1790 `post-content`.`coord` AS `coord`,
1791 `post-content`.`app` AS `app`,
1792 `post-content`.`object-type` AS `object-type`,
1793 `post-content`.`object` AS `object`,
1794 `post-content`.`target-type` AS `target-type`,
1795 `post-content`.`target` AS `target`,
1796 `post-content`.`resource-id` AS `resource-id`,
1797 `post-user`.`contact-id` AS `contact-id`,
1798 `contact`.`uri-id` AS `contact-uri-id`,
1799 `contact`.`url` AS `contact-link`,
1800 `contact`.`addr` AS `contact-addr`,
1801 `contact`.`name` AS `contact-name`,
1802 `contact`.`nick` AS `contact-nick`,
1803 `contact`.`thumb` AS `contact-avatar`,
1804 `contact`.`network` AS `contact-network`,
1805 `contact`.`blocked` AS `contact-blocked`,
1806 `contact`.`hidden` AS `contact-hidden`,
1807 `contact`.`readonly` AS `contact-readonly`,
1808 `contact`.`archive` AS `contact-archive`,
1809 `contact`.`pending` AS `contact-pending`,
1810 `contact`.`rel` AS `contact-rel`,
1811 `contact`.`uid` AS `contact-uid`,
1812 `contact`.`contact-type` AS `contact-contact-type`,
1813 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1814 `contact`.`self` AS `self`,
1815 `contact`.`id` AS `cid`,
1816 `contact`.`alias` AS `alias`,
1817 `contact`.`photo` AS `photo`,
1818 `contact`.`name-date` AS `name-date`,
1819 `contact`.`uri-date` AS `uri-date`,
1820 `contact`.`avatar-date` AS `avatar-date`,
1821 `contact`.`thumb` AS `thumb`,
1822 `post-user`.`author-id` AS `author-id`,
1823 `author`.`uri-id` AS `author-uri-id`,
1824 `author`.`url` AS `author-link`,
1825 `author`.`addr` AS `author-addr`,
1826 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1827 `author`.`nick` AS `author-nick`,
1828 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1829 `author`.`network` AS `author-network`,
1830 `author`.`blocked` AS `author-blocked`,
1831 `author`.`hidden` AS `author-hidden`,
1832 `author`.`updated` AS `author-updated`,
1833 `author`.`gsid` AS `author-gsid`,
1834 `post-user`.`owner-id` AS `owner-id`,
1835 `owner`.`uri-id` AS `owner-uri-id`,
1836 `owner`.`url` AS `owner-link`,
1837 `owner`.`addr` AS `owner-addr`,
1838 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1839 `owner`.`nick` AS `owner-nick`,
1840 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1841 `owner`.`network` AS `owner-network`,
1842 `owner`.`blocked` AS `owner-blocked`,
1843 `owner`.`hidden` AS `owner-hidden`,
1844 `owner`.`updated` AS `owner-updated`,
1845 `owner`.`contact-type` AS `owner-contact-type`,
1846 `post-user`.`causer-id` AS `causer-id`,
1847 `causer`.`uri-id` AS `causer-uri-id`,
1848 `causer`.`url` AS `causer-link`,
1849 `causer`.`addr` AS `causer-addr`,
1850 `causer`.`name` AS `causer-name`,
1851 `causer`.`nick` AS `causer-nick`,
1852 `causer`.`thumb` AS `causer-avatar`,
1853 `causer`.`network` AS `causer-network`,
1854 `causer`.`blocked` AS `causer-blocked`,
1855 `causer`.`hidden` AS `causer-hidden`,
1856 `causer`.`contact-type` AS `causer-contact-type`,
1857 `post-delivery-data`.`postopts` AS `postopts`,
1858 `post-delivery-data`.`inform` AS `inform`,
1859 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1860 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1861 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1862 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1863 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1864 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1865 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1866 `post-user`.`event-id` AS `event-id`,
1867 `event`.`created` AS `event-created`,
1868 `event`.`edited` AS `event-edited`,
1869 `event`.`start` AS `event-start`,
1870 `event`.`finish` AS `event-finish`,
1871 `event`.`summary` AS `event-summary`,
1872 `event`.`desc` AS `event-desc`,
1873 `event`.`location` AS `event-location`,
1874 `event`.`type` AS `event-type`,
1875 `event`.`nofinish` AS `event-nofinish`,
1876 `event`.`ignore` AS `event-ignore`,
1877 `post-question`.`id` AS `question-id`,
1878 `post-question`.`multiple` AS `question-multiple`,
1879 `post-question`.`voters` AS `question-voters`,
1880 `post-question`.`end-time` AS `question-end-time`,
1881 EXISTS(SELECT `uri-id` FROM `post-category` WHERE `post-category`.`uri-id` = `post-user`.`uri-id` AND `post-category`.`uid` = `post-user`.`uid`) AS `has-categories`,
1882 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-user`.`uri-id`) AS `has-media`,
1883 `diaspora-interaction`.`interaction` AS `signed_text`,
1884 `parent-item-uri`.`guid` AS `parent-guid`,
1885 `parent-post`.`network` AS `parent-network`,
1886 `parent-post`.`author-id` AS `parent-author-id`,
1887 `parent-post-author`.`url` AS `parent-author-link`,
1888 `parent-post-author`.`name` AS `parent-author-name`,
1889 `parent-post-author`.`nick` AS `parent-author-nick`,
1890 `parent-post-author`.`network` AS `parent-author-network`,
1891 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1892 `parent-post-author`.`hidden` AS `parent-author-hidden`
1894 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
1895 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
1896 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
1897 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
1898 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
1899 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
1900 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1901 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1902 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
1903 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1904 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1905 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1906 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
1907 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
1908 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
1909 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-user`.`uri-id`
1910 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
1911 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
1912 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1915 -- VIEW post-thread-user-view
1917 DROP VIEW IF EXISTS `post-thread-user-view`;
1918 CREATE VIEW `post-thread-user-view` AS SELECT
1919 `post-user`.`id` AS `id`,
1920 `post-user`.`id` AS `post-user-id`,
1921 `post-thread-user`.`uid` AS `uid`,
1922 `parent-post`.`id` AS `parent`,
1923 `item-uri`.`uri` AS `uri`,
1924 `post-thread-user`.`uri-id` AS `uri-id`,
1925 `parent-item-uri`.`uri` AS `parent-uri`,
1926 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1927 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1928 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1929 `conversation-item-uri`.`uri` AS `conversation`,
1930 `post-thread-user`.`conversation-id` AS `conversation-id`,
1931 `item-uri`.`guid` AS `guid`,
1932 `post-thread-user`.`wall` AS `wall`,
1933 `post-user`.`gravity` AS `gravity`,
1934 `external-item-uri`.`uri` AS `extid`,
1935 `post-user`.`external-id` AS `external-id`,
1936 `post-thread-user`.`created` AS `created`,
1937 `post-user`.`edited` AS `edited`,
1938 `post-thread-user`.`commented` AS `commented`,
1939 `post-thread-user`.`received` AS `received`,
1940 `post-thread-user`.`changed` AS `changed`,
1941 `post-user`.`post-type` AS `post-type`,
1942 `post-user`.`post-reason` AS `post-reason`,
1943 `post-user`.`private` AS `private`,
1944 `post-thread-user`.`pubmail` AS `pubmail`,
1945 `post-thread-user`.`ignored` AS `ignored`,
1946 `post-user`.`visible` AS `visible`,
1947 `post-thread-user`.`starred` AS `starred`,
1948 `post-thread-user`.`unseen` AS `unseen`,
1949 `post-user`.`deleted` AS `deleted`,
1950 `post-thread-user`.`origin` AS `origin`,
1951 `post-thread-user`.`mention` AS `mention`,
1952 `post-user`.`global` AS `global`,
1953 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread-user`.`uri-id`) AS `featured`,
1954 `post-thread-user`.`network` AS `network`,
1955 `post-user`.`vid` AS `vid`,
1956 `post-thread-user`.`psid` AS `psid`,
1957 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1958 `post-content`.`title` AS `title`,
1959 `post-content`.`content-warning` AS `content-warning`,
1960 `post-content`.`raw-body` AS `raw-body`,
1961 `post-content`.`body` AS `body`,
1962 `post-content`.`rendered-hash` AS `rendered-hash`,
1963 `post-content`.`rendered-html` AS `rendered-html`,
1964 `post-content`.`language` AS `language`,
1965 `post-content`.`plink` AS `plink`,
1966 `post-content`.`location` AS `location`,
1967 `post-content`.`coord` AS `coord`,
1968 `post-content`.`app` AS `app`,
1969 `post-content`.`object-type` AS `object-type`,
1970 `post-content`.`object` AS `object`,
1971 `post-content`.`target-type` AS `target-type`,
1972 `post-content`.`target` AS `target`,
1973 `post-content`.`resource-id` AS `resource-id`,
1974 `post-thread-user`.`contact-id` AS `contact-id`,
1975 `contact`.`uri-id` AS `contact-uri-id`,
1976 `contact`.`url` AS `contact-link`,
1977 `contact`.`addr` AS `contact-addr`,
1978 `contact`.`name` AS `contact-name`,
1979 `contact`.`nick` AS `contact-nick`,
1980 `contact`.`thumb` AS `contact-avatar`,
1981 `contact`.`network` AS `contact-network`,
1982 `contact`.`blocked` AS `contact-blocked`,
1983 `contact`.`hidden` AS `contact-hidden`,
1984 `contact`.`readonly` AS `contact-readonly`,
1985 `contact`.`archive` AS `contact-archive`,
1986 `contact`.`pending` AS `contact-pending`,
1987 `contact`.`rel` AS `contact-rel`,
1988 `contact`.`uid` AS `contact-uid`,
1989 `contact`.`contact-type` AS `contact-contact-type`,
1990 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1991 `contact`.`self` AS `self`,
1992 `contact`.`id` AS `cid`,
1993 `contact`.`alias` AS `alias`,
1994 `contact`.`photo` AS `photo`,
1995 `contact`.`name-date` AS `name-date`,
1996 `contact`.`uri-date` AS `uri-date`,
1997 `contact`.`avatar-date` AS `avatar-date`,
1998 `contact`.`thumb` AS `thumb`,
1999 `post-thread-user`.`author-id` AS `author-id`,
2000 `author`.`uri-id` AS `author-uri-id`,
2001 `author`.`url` AS `author-link`,
2002 `author`.`addr` AS `author-addr`,
2003 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
2004 `author`.`nick` AS `author-nick`,
2005 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
2006 `author`.`network` AS `author-network`,
2007 `author`.`blocked` AS `author-blocked`,
2008 `author`.`hidden` AS `author-hidden`,
2009 `author`.`updated` AS `author-updated`,
2010 `author`.`gsid` AS `author-gsid`,
2011 `post-thread-user`.`owner-id` AS `owner-id`,
2012 `owner`.`uri-id` AS `owner-uri-id`,
2013 `owner`.`url` AS `owner-link`,
2014 `owner`.`addr` AS `owner-addr`,
2015 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
2016 `owner`.`nick` AS `owner-nick`,
2017 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
2018 `owner`.`network` AS `owner-network`,
2019 `owner`.`blocked` AS `owner-blocked`,
2020 `owner`.`hidden` AS `owner-hidden`,
2021 `owner`.`updated` AS `owner-updated`,
2022 `owner`.`contact-type` AS `owner-contact-type`,
2023 `post-thread-user`.`causer-id` AS `causer-id`,
2024 `causer`.`uri-id` AS `causer-uri-id`,
2025 `causer`.`url` AS `causer-link`,
2026 `causer`.`addr` AS `causer-addr`,
2027 `causer`.`name` AS `causer-name`,
2028 `causer`.`nick` AS `causer-nick`,
2029 `causer`.`thumb` AS `causer-avatar`,
2030 `causer`.`network` AS `causer-network`,
2031 `causer`.`blocked` AS `causer-blocked`,
2032 `causer`.`hidden` AS `causer-hidden`,
2033 `causer`.`contact-type` AS `causer-contact-type`,
2034 `post-delivery-data`.`postopts` AS `postopts`,
2035 `post-delivery-data`.`inform` AS `inform`,
2036 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
2037 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
2038 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
2039 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
2040 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
2041 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
2042 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
2043 `post-user`.`event-id` AS `event-id`,
2044 `event`.`created` AS `event-created`,
2045 `event`.`edited` AS `event-edited`,
2046 `event`.`start` AS `event-start`,
2047 `event`.`finish` AS `event-finish`,
2048 `event`.`summary` AS `event-summary`,
2049 `event`.`desc` AS `event-desc`,
2050 `event`.`location` AS `event-location`,
2051 `event`.`type` AS `event-type`,
2052 `event`.`nofinish` AS `event-nofinish`,
2053 `event`.`ignore` AS `event-ignore`,
2054 `post-question`.`id` AS `question-id`,
2055 `post-question`.`multiple` AS `question-multiple`,
2056 `post-question`.`voters` AS `question-voters`,
2057 `post-question`.`end-time` AS `question-end-time`,
2058 EXISTS(SELECT `uri-id` FROM `post-category` WHERE `post-category`.`uri-id` = `post-thread-user`.`uri-id` AND `post-category`.`uid` = `post-thread-user`.`uid`) AS `has-categories`,
2059 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread-user`.`uri-id`) AS `has-media`,
2060 `diaspora-interaction`.`interaction` AS `signed_text`,
2061 `parent-item-uri`.`guid` AS `parent-guid`,
2062 `parent-post`.`network` AS `parent-network`,
2063 `parent-post`.`author-id` AS `parent-author-id`,
2064 `parent-post-author`.`url` AS `parent-author-link`,
2065 `parent-post-author`.`name` AS `parent-author-name`,
2066 `parent-post-author`.`network` AS `parent-author-network`,
2067 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2068 `parent-post-author`.`hidden` AS `parent-author-hidden`
2069 FROM `post-thread-user`
2070 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2071 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2072 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
2073 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
2074 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
2075 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
2076 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
2077 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
2078 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
2079 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
2080 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
2081 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
2082 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
2083 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
2084 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
2085 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread-user`.`uri-id`
2086 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
2087 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-thread-user`.`uid`
2088 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2093 DROP VIEW IF EXISTS `post-view`;
2094 CREATE VIEW `post-view` AS SELECT
2095 `item-uri`.`uri` AS `uri`,
2096 `post`.`uri-id` AS `uri-id`,
2097 `parent-item-uri`.`uri` AS `parent-uri`,
2098 `post`.`parent-uri-id` AS `parent-uri-id`,
2099 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2100 `post`.`thr-parent-id` AS `thr-parent-id`,
2101 `conversation-item-uri`.`uri` AS `conversation`,
2102 `post-thread`.`conversation-id` AS `conversation-id`,
2103 `item-uri`.`guid` AS `guid`,
2104 `post`.`gravity` AS `gravity`,
2105 `external-item-uri`.`uri` AS `extid`,
2106 `post`.`external-id` AS `external-id`,
2107 `post`.`created` AS `created`,
2108 `post`.`edited` AS `edited`,
2109 `post-thread`.`commented` AS `commented`,
2110 `post`.`received` AS `received`,
2111 `post-thread`.`changed` AS `changed`,
2112 `post`.`post-type` AS `post-type`,
2113 `post`.`private` AS `private`,
2114 `post`.`visible` AS `visible`,
2115 `post`.`deleted` AS `deleted`,
2116 `post`.`global` AS `global`,
2117 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post`.`uri-id`) AS `featured`,
2118 `post`.`network` AS `network`,
2119 `post`.`vid` AS `vid`,
2120 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2121 `post-content`.`title` AS `title`,
2122 `post-content`.`content-warning` AS `content-warning`,
2123 `post-content`.`raw-body` AS `raw-body`,
2124 `post-content`.`body` AS `body`,
2125 `post-content`.`rendered-hash` AS `rendered-hash`,
2126 `post-content`.`rendered-html` AS `rendered-html`,
2127 `post-content`.`language` AS `language`,
2128 `post-content`.`plink` AS `plink`,
2129 `post-content`.`location` AS `location`,
2130 `post-content`.`coord` AS `coord`,
2131 `post-content`.`app` AS `app`,
2132 `post-content`.`object-type` AS `object-type`,
2133 `post-content`.`object` AS `object`,
2134 `post-content`.`target-type` AS `target-type`,
2135 `post-content`.`target` AS `target`,
2136 `post-content`.`resource-id` AS `resource-id`,
2137 `post`.`author-id` AS `contact-id`,
2138 `author`.`uri-id` AS `contact-uri-id`,
2139 `author`.`url` AS `contact-link`,
2140 `author`.`addr` AS `contact-addr`,
2141 `author`.`name` AS `contact-name`,
2142 `author`.`nick` AS `contact-nick`,
2143 `author`.`thumb` AS `contact-avatar`,
2144 `author`.`network` AS `contact-network`,
2145 `author`.`blocked` AS `contact-blocked`,
2146 `author`.`hidden` AS `contact-hidden`,
2147 `author`.`readonly` AS `contact-readonly`,
2148 `author`.`archive` AS `contact-archive`,
2149 `author`.`pending` AS `contact-pending`,
2150 `author`.`rel` AS `contact-rel`,
2151 `author`.`uid` AS `contact-uid`,
2152 `author`.`contact-type` AS `contact-contact-type`,
2153 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2155 `author`.`id` AS `cid`,
2156 `author`.`alias` AS `alias`,
2157 `author`.`photo` AS `photo`,
2158 `author`.`name-date` AS `name-date`,
2159 `author`.`uri-date` AS `uri-date`,
2160 `author`.`avatar-date` AS `avatar-date`,
2161 `author`.`thumb` AS `thumb`,
2162 `post`.`author-id` AS `author-id`,
2163 `author`.`uri-id` AS `author-uri-id`,
2164 `author`.`url` AS `author-link`,
2165 `author`.`addr` AS `author-addr`,
2166 `author`.`name` AS `author-name`,
2167 `author`.`nick` AS `author-nick`,
2168 `author`.`thumb` AS `author-avatar`,
2169 `author`.`network` AS `author-network`,
2170 `author`.`blocked` AS `author-blocked`,
2171 `author`.`hidden` AS `author-hidden`,
2172 `author`.`updated` AS `author-updated`,
2173 `author`.`gsid` AS `author-gsid`,
2174 `post`.`owner-id` AS `owner-id`,
2175 `owner`.`uri-id` AS `owner-uri-id`,
2176 `owner`.`url` AS `owner-link`,
2177 `owner`.`addr` AS `owner-addr`,
2178 `owner`.`name` AS `owner-name`,
2179 `owner`.`nick` AS `owner-nick`,
2180 `owner`.`thumb` AS `owner-avatar`,
2181 `owner`.`network` AS `owner-network`,
2182 `owner`.`blocked` AS `owner-blocked`,
2183 `owner`.`hidden` AS `owner-hidden`,
2184 `owner`.`updated` AS `owner-updated`,
2185 `owner`.`contact-type` AS `owner-contact-type`,
2186 `post`.`causer-id` AS `causer-id`,
2187 `causer`.`uri-id` AS `causer-uri-id`,
2188 `causer`.`url` AS `causer-link`,
2189 `causer`.`addr` AS `causer-addr`,
2190 `causer`.`name` AS `causer-name`,
2191 `causer`.`nick` AS `causer-nick`,
2192 `causer`.`thumb` AS `causer-avatar`,
2193 `causer`.`network` AS `causer-network`,
2194 `causer`.`blocked` AS `causer-blocked`,
2195 `causer`.`hidden` AS `causer-hidden`,
2196 `causer`.`contact-type` AS `causer-contact-type`,
2197 `post-question`.`id` AS `question-id`,
2198 `post-question`.`multiple` AS `question-multiple`,
2199 `post-question`.`voters` AS `question-voters`,
2200 `post-question`.`end-time` AS `question-end-time`,
2201 0 AS `has-categories`,
2202 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post`.`uri-id`) AS `has-media`,
2203 `diaspora-interaction`.`interaction` AS `signed_text`,
2204 `parent-item-uri`.`guid` AS `parent-guid`,
2205 `parent-post`.`network` AS `parent-network`,
2206 `parent-post`.`author-id` AS `parent-author-id`,
2207 `parent-post-author`.`url` AS `parent-author-link`,
2208 `parent-post-author`.`name` AS `parent-author-name`,
2209 `parent-post-author`.`network` AS `parent-author-network`,
2210 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2211 `parent-post-author`.`hidden` AS `parent-author-hidden`
2213 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
2214 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
2215 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
2216 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
2217 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
2218 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2219 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2220 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
2221 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2222 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2223 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
2224 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
2225 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post`.`uri-id`
2226 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2227 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2230 -- VIEW post-thread-view
2232 DROP VIEW IF EXISTS `post-thread-view`;
2233 CREATE VIEW `post-thread-view` AS SELECT
2234 `item-uri`.`uri` AS `uri`,
2235 `post-thread`.`uri-id` AS `uri-id`,
2236 `parent-item-uri`.`uri` AS `parent-uri`,
2237 `post`.`parent-uri-id` AS `parent-uri-id`,
2238 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2239 `post`.`thr-parent-id` AS `thr-parent-id`,
2240 `conversation-item-uri`.`uri` AS `conversation`,
2241 `post-thread`.`conversation-id` AS `conversation-id`,
2242 `item-uri`.`guid` AS `guid`,
2243 `post`.`gravity` AS `gravity`,
2244 `external-item-uri`.`uri` AS `extid`,
2245 `post`.`external-id` AS `external-id`,
2246 `post-thread`.`created` AS `created`,
2247 `post`.`edited` AS `edited`,
2248 `post-thread`.`commented` AS `commented`,
2249 `post-thread`.`received` AS `received`,
2250 `post-thread`.`changed` AS `changed`,
2251 `post`.`post-type` AS `post-type`,
2252 `post`.`private` AS `private`,
2253 `post`.`visible` AS `visible`,
2254 `post`.`deleted` AS `deleted`,
2255 `post`.`global` AS `global`,
2256 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread`.`uri-id`) AS `featured`,
2257 `post-thread`.`network` AS `network`,
2258 `post`.`vid` AS `vid`,
2259 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2260 `post-content`.`title` AS `title`,
2261 `post-content`.`content-warning` AS `content-warning`,
2262 `post-content`.`raw-body` AS `raw-body`,
2263 `post-content`.`body` AS `body`,
2264 `post-content`.`rendered-hash` AS `rendered-hash`,
2265 `post-content`.`rendered-html` AS `rendered-html`,
2266 `post-content`.`language` AS `language`,
2267 `post-content`.`plink` AS `plink`,
2268 `post-content`.`location` AS `location`,
2269 `post-content`.`coord` AS `coord`,
2270 `post-content`.`app` AS `app`,
2271 `post-content`.`object-type` AS `object-type`,
2272 `post-content`.`object` AS `object`,
2273 `post-content`.`target-type` AS `target-type`,
2274 `post-content`.`target` AS `target`,
2275 `post-content`.`resource-id` AS `resource-id`,
2276 `post-thread`.`author-id` AS `contact-id`,
2277 `author`.`uri-id` AS `contact-uri-id`,
2278 `author`.`url` AS `contact-link`,
2279 `author`.`addr` AS `contact-addr`,
2280 `author`.`name` AS `contact-name`,
2281 `author`.`nick` AS `contact-nick`,
2282 `author`.`thumb` AS `contact-avatar`,
2283 `author`.`network` AS `contact-network`,
2284 `author`.`blocked` AS `contact-blocked`,
2285 `author`.`hidden` AS `contact-hidden`,
2286 `author`.`readonly` AS `contact-readonly`,
2287 `author`.`archive` AS `contact-archive`,
2288 `author`.`pending` AS `contact-pending`,
2289 `author`.`rel` AS `contact-rel`,
2290 `author`.`uid` AS `contact-uid`,
2291 `author`.`contact-type` AS `contact-contact-type`,
2292 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2294 `author`.`id` AS `cid`,
2295 `author`.`alias` AS `alias`,
2296 `author`.`photo` AS `photo`,
2297 `author`.`name-date` AS `name-date`,
2298 `author`.`uri-date` AS `uri-date`,
2299 `author`.`avatar-date` AS `avatar-date`,
2300 `author`.`thumb` AS `thumb`,
2301 `post-thread`.`author-id` AS `author-id`,
2302 `author`.`uri-id` AS `author-uri-id`,
2303 `author`.`url` AS `author-link`,
2304 `author`.`addr` AS `author-addr`,
2305 `author`.`name` AS `author-name`,
2306 `author`.`nick` AS `author-nick`,
2307 `author`.`thumb` AS `author-avatar`,
2308 `author`.`network` AS `author-network`,
2309 `author`.`blocked` AS `author-blocked`,
2310 `author`.`hidden` AS `author-hidden`,
2311 `author`.`updated` AS `author-updated`,
2312 `author`.`gsid` AS `author-gsid`,
2313 `post-thread`.`owner-id` AS `owner-id`,
2314 `owner`.`uri-id` AS `owner-uri-id`,
2315 `owner`.`url` AS `owner-link`,
2316 `owner`.`addr` AS `owner-addr`,
2317 `owner`.`name` AS `owner-name`,
2318 `owner`.`nick` AS `owner-nick`,
2319 `owner`.`thumb` AS `owner-avatar`,
2320 `owner`.`network` AS `owner-network`,
2321 `owner`.`blocked` AS `owner-blocked`,
2322 `owner`.`hidden` AS `owner-hidden`,
2323 `owner`.`updated` AS `owner-updated`,
2324 `owner`.`contact-type` AS `owner-contact-type`,
2325 `post-thread`.`causer-id` AS `causer-id`,
2326 `causer`.`uri-id` AS `causer-uri-id`,
2327 `causer`.`url` AS `causer-link`,
2328 `causer`.`addr` AS `causer-addr`,
2329 `causer`.`name` AS `causer-name`,
2330 `causer`.`nick` AS `causer-nick`,
2331 `causer`.`thumb` AS `causer-avatar`,
2332 `causer`.`network` AS `causer-network`,
2333 `causer`.`blocked` AS `causer-blocked`,
2334 `causer`.`hidden` AS `causer-hidden`,
2335 `causer`.`contact-type` AS `causer-contact-type`,
2336 `post-question`.`id` AS `question-id`,
2337 `post-question`.`multiple` AS `question-multiple`,
2338 `post-question`.`voters` AS `question-voters`,
2339 `post-question`.`end-time` AS `question-end-time`,
2340 0 AS `has-categories`,
2341 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread`.`uri-id`) AS `has-media`,
2342 `diaspora-interaction`.`interaction` AS `signed_text`,
2343 `parent-item-uri`.`guid` AS `parent-guid`,
2344 `parent-post`.`network` AS `parent-network`,
2345 `parent-post`.`author-id` AS `parent-author-id`,
2346 `parent-post-author`.`url` AS `parent-author-link`,
2347 `parent-post-author`.`name` AS `parent-author-name`,
2348 `parent-post-author`.`network` AS `parent-author-network`,
2349 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2350 `parent-post-author`.`hidden` AS `parent-author-hidden`
2352 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
2353 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
2354 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
2355 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
2356 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
2357 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2358 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2359 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
2360 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2361 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2362 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
2363 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
2364 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread`.`uri-id`
2365 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2366 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2369 -- VIEW category-view
2371 DROP VIEW IF EXISTS `category-view`;
2372 CREATE VIEW `category-view` AS SELECT
2373 `post-category`.`uri-id` AS `uri-id`,
2374 `post-category`.`uid` AS `uid`,
2375 `post-category`.`type` AS `type`,
2376 `post-category`.`tid` AS `tid`,
2377 `tag`.`name` AS `name`,
2378 `tag`.`url` AS `url`
2379 FROM `post-category`
2380 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2383 -- VIEW collection-view
2385 DROP VIEW IF EXISTS `collection-view`;
2386 CREATE VIEW `collection-view` AS SELECT
2387 `post-collection`.`uri-id` AS `uri-id`,
2388 `post-collection`.`type` AS `type`,
2389 `post`.`author-id` AS `cid`,
2390 `post`.`received` AS `received`,
2391 `post`.`created` AS `created`,
2392 `post-thread`.`commented` AS `commented`,
2393 `post`.`private` AS `private`,
2394 `post`.`visible` AS `visible`,
2395 `post`.`deleted` AS `deleted`,
2396 `post`.`thr-parent-id` AS `thr-parent-id`,
2397 `post`.`author-id` AS `author-id`,
2398 `post`.`gravity` AS `gravity`
2399 FROM `post-collection`
2400 INNER JOIN `post` ON `post-collection`.`uri-id` = `post`.`uri-id`
2401 INNER JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`;
2406 DROP VIEW IF EXISTS `tag-view`;
2407 CREATE VIEW `tag-view` AS SELECT
2408 `post-tag`.`uri-id` AS `uri-id`,
2409 `post-tag`.`type` AS `type`,
2410 `post-tag`.`tid` AS `tid`,
2411 `post-tag`.`cid` AS `cid`,
2412 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2413 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`,
2414 CASE `cid` WHEN 0 THEN `tag`.`type` ELSE 1 END AS `tag-type`
2416 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2417 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2420 -- VIEW network-item-view
2422 DROP VIEW IF EXISTS `network-item-view`;
2423 CREATE VIEW `network-item-view` AS SELECT
2424 `post-user`.`uri-id` AS `uri-id`,
2425 `parent-post`.`id` AS `parent`,
2426 `post-user`.`received` AS `received`,
2427 `post-thread-user`.`commented` AS `commented`,
2428 `post-user`.`created` AS `created`,
2429 `post-user`.`uid` AS `uid`,
2430 `post-thread-user`.`starred` AS `starred`,
2431 `post-thread-user`.`mention` AS `mention`,
2432 `post-user`.`network` AS `network`,
2433 `post-user`.`unseen` AS `unseen`,
2434 `post-user`.`gravity` AS `gravity`,
2435 `post-user`.`contact-id` AS `contact-id`,
2436 `ownercontact`.`contact-type` AS `contact-type`
2438 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2439 INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2440 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2441 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2442 INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2443 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2444 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2445 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2446 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
2447 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2448 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2451 -- VIEW network-thread-view
2453 DROP VIEW IF EXISTS `network-thread-view`;
2454 CREATE VIEW `network-thread-view` AS SELECT
2455 `post-thread-user`.`uri-id` AS `uri-id`,
2456 `parent-post`.`id` AS `parent`,
2457 `post-thread-user`.`received` AS `received`,
2458 `post-thread-user`.`commented` AS `commented`,
2459 `post-thread-user`.`created` AS `created`,
2460 `post-thread-user`.`uid` AS `uid`,
2461 `post-thread-user`.`starred` AS `starred`,
2462 `post-thread-user`.`mention` AS `mention`,
2463 `post-thread-user`.`network` AS `network`,
2464 `post-thread-user`.`contact-id` AS `contact-id`,
2465 `ownercontact`.`contact-type` AS `contact-type`
2466 FROM `post-thread-user`
2467 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2468 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2469 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2470 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2471 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2472 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2473 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2474 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2475 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2476 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2477 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2482 DROP VIEW IF EXISTS `owner-view`;
2483 CREATE VIEW `owner-view` AS SELECT
2484 `contact`.`id` AS `id`,
2485 `contact`.`uid` AS `uid`,
2486 `contact`.`created` AS `created`,
2487 `contact`.`updated` AS `updated`,
2488 `contact`.`self` AS `self`,
2489 `contact`.`remote_self` AS `remote_self`,
2490 `contact`.`rel` AS `rel`,
2491 `contact`.`network` AS `network`,
2492 `contact`.`protocol` AS `protocol`,
2493 `contact`.`name` AS `name`,
2494 `contact`.`nick` AS `nick`,
2495 `contact`.`location` AS `location`,
2496 `contact`.`about` AS `about`,
2497 `contact`.`keywords` AS `keywords`,
2498 `contact`.`xmpp` AS `xmpp`,
2499 `contact`.`matrix` AS `matrix`,
2500 `contact`.`attag` AS `attag`,
2501 `contact`.`avatar` AS `avatar`,
2502 `contact`.`photo` AS `photo`,
2503 `contact`.`thumb` AS `thumb`,
2504 `contact`.`micro` AS `micro`,
2505 `contact`.`header` AS `header`,
2506 `contact`.`url` AS `url`,
2507 `contact`.`nurl` AS `nurl`,
2508 `contact`.`uri-id` AS `uri-id`,
2509 `contact`.`addr` AS `addr`,
2510 `contact`.`alias` AS `alias`,
2511 `contact`.`pubkey` AS `pubkey`,
2512 `contact`.`prvkey` AS `prvkey`,
2513 `contact`.`batch` AS `batch`,
2514 `contact`.`request` AS `request`,
2515 `contact`.`notify` AS `notify`,
2516 `contact`.`poll` AS `poll`,
2517 `contact`.`confirm` AS `confirm`,
2518 `contact`.`poco` AS `poco`,
2519 `contact`.`subhub` AS `subhub`,
2520 `contact`.`hub-verify` AS `hub-verify`,
2521 `contact`.`last-update` AS `last-update`,
2522 `contact`.`success_update` AS `success_update`,
2523 `contact`.`failure_update` AS `failure_update`,
2524 `contact`.`name-date` AS `name-date`,
2525 `contact`.`uri-date` AS `uri-date`,
2526 `contact`.`avatar-date` AS `avatar-date`,
2527 `contact`.`avatar-date` AS `picdate`,
2528 `contact`.`term-date` AS `term-date`,
2529 `contact`.`last-item` AS `last-item`,
2530 `contact`.`priority` AS `priority`,
2531 `user`.`blocked` AS `blocked`,
2532 `contact`.`block_reason` AS `block_reason`,
2533 `contact`.`readonly` AS `readonly`,
2534 `contact`.`writable` AS `writable`,
2535 `contact`.`forum` AS `forum`,
2536 `contact`.`prv` AS `prv`,
2537 `contact`.`contact-type` AS `contact-type`,
2538 `contact`.`manually-approve` AS `manually-approve`,
2539 `contact`.`hidden` AS `hidden`,
2540 `contact`.`archive` AS `archive`,
2541 `contact`.`pending` AS `pending`,
2542 `contact`.`deleted` AS `deleted`,
2543 `contact`.`unsearchable` AS `unsearchable`,
2544 `contact`.`sensitive` AS `sensitive`,
2545 `contact`.`baseurl` AS `baseurl`,
2546 `contact`.`reason` AS `reason`,
2547 `contact`.`info` AS `info`,
2548 `contact`.`bdyear` AS `bdyear`,
2549 `contact`.`bd` AS `bd`,
2550 `contact`.`notify_new_posts` AS `notify_new_posts`,
2551 `contact`.`fetch_further_information` AS `fetch_further_information`,
2552 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2553 `user`.`parent-uid` AS `parent-uid`,
2554 `user`.`guid` AS `guid`,
2555 `user`.`nickname` AS `nickname`,
2556 `user`.`email` AS `email`,
2557 `user`.`openid` AS `openid`,
2558 `user`.`timezone` AS `timezone`,
2559 `user`.`language` AS `language`,
2560 `user`.`register_date` AS `register_date`,
2561 `user`.`login_date` AS `login_date`,
2562 `user`.`default-location` AS `default-location`,
2563 `user`.`allow_location` AS `allow_location`,
2564 `user`.`theme` AS `theme`,
2565 `user`.`pubkey` AS `upubkey`,
2566 `user`.`prvkey` AS `uprvkey`,
2567 `user`.`sprvkey` AS `sprvkey`,
2568 `user`.`spubkey` AS `spubkey`,
2569 `user`.`verified` AS `verified`,
2570 `user`.`blockwall` AS `blockwall`,
2571 `user`.`hidewall` AS `hidewall`,
2572 `user`.`blocktags` AS `blocktags`,
2573 `user`.`unkmail` AS `unkmail`,
2574 `user`.`cntunkmail` AS `cntunkmail`,
2575 `user`.`notify-flags` AS `notify-flags`,
2576 `user`.`page-flags` AS `page-flags`,
2577 `user`.`account-type` AS `account-type`,
2578 `user`.`prvnets` AS `prvnets`,
2579 `user`.`maxreq` AS `maxreq`,
2580 `user`.`expire` AS `expire`,
2581 `user`.`account_removed` AS `account_removed`,
2582 `user`.`account_expired` AS `account_expired`,
2583 `user`.`account_expires_on` AS `account_expires_on`,
2584 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2585 `user`.`def_gid` AS `def_gid`,
2586 `user`.`allow_cid` AS `allow_cid`,
2587 `user`.`allow_gid` AS `allow_gid`,
2588 `user`.`deny_cid` AS `deny_cid`,
2589 `user`.`deny_gid` AS `deny_gid`,
2590 `user`.`openidserver` AS `openidserver`,
2591 `profile`.`publish` AS `publish`,
2592 `profile`.`net-publish` AS `net-publish`,
2593 `profile`.`hide-friends` AS `hide-friends`,
2594 `profile`.`prv_keywords` AS `prv_keywords`,
2595 `profile`.`pub_keywords` AS `pub_keywords`,
2596 `profile`.`address` AS `address`,
2597 `profile`.`locality` AS `locality`,
2598 `profile`.`region` AS `region`,
2599 `profile`.`postal-code` AS `postal-code`,
2600 `profile`.`country-name` AS `country-name`,
2601 `profile`.`homepage` AS `homepage`,
2602 `profile`.`dob` AS `dob`
2604 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2605 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2608 -- VIEW account-view
2610 DROP VIEW IF EXISTS `account-view`;
2611 CREATE VIEW `account-view` AS SELECT
2612 `contact`.`id` AS `id`,
2613 `contact`.`url` AS `url`,
2614 `contact`.`nurl` AS `nurl`,
2615 `contact`.`uri-id` AS `uri-id`,
2616 `item-uri`.`guid` AS `guid`,
2617 `contact`.`addr` AS `addr`,
2618 `contact`.`alias` AS `alias`,
2619 `contact`.`name` AS `name`,
2620 `contact`.`nick` AS `nick`,
2621 `contact`.`about` AS `about`,
2622 `contact`.`keywords` AS `keywords`,
2623 `contact`.`xmpp` AS `xmpp`,
2624 `contact`.`matrix` AS `matrix`,
2625 `contact`.`avatar` AS `avatar`,
2626 `contact`.`photo` AS `photo`,
2627 `contact`.`thumb` AS `thumb`,
2628 `contact`.`micro` AS `micro`,
2629 `contact`.`header` AS `header`,
2630 `contact`.`created` AS `created`,
2631 `contact`.`updated` AS `updated`,
2632 `contact`.`network` AS `network`,
2633 `contact`.`protocol` AS `protocol`,
2634 `contact`.`location` AS `location`,
2635 `contact`.`attag` AS `attag`,
2636 `contact`.`pubkey` AS `pubkey`,
2637 `contact`.`prvkey` AS `prvkey`,
2638 `contact`.`subscribe` AS `subscribe`,
2639 `contact`.`last-update` AS `last-update`,
2640 `contact`.`success_update` AS `success_update`,
2641 `contact`.`failure_update` AS `failure_update`,
2642 `contact`.`failed` AS `failed`,
2643 `contact`.`last-item` AS `last-item`,
2644 `contact`.`last-discovery` AS `last-discovery`,
2645 `contact`.`contact-type` AS `contact-type`,
2646 `contact`.`manually-approve` AS `manually-approve`,
2647 `contact`.`unsearchable` AS `unsearchable`,
2648 `contact`.`sensitive` AS `sensitive`,
2649 `contact`.`baseurl` AS `baseurl`,
2650 `contact`.`gsid` AS `gsid`,
2651 `contact`.`info` AS `info`,
2652 `contact`.`bdyear` AS `bdyear`,
2653 `contact`.`bd` AS `bd`,
2654 `contact`.`poco` AS `poco`,
2655 `contact`.`name-date` AS `name-date`,
2656 `contact`.`uri-date` AS `uri-date`,
2657 `contact`.`avatar-date` AS `avatar-date`,
2658 `contact`.`term-date` AS `term-date`,
2659 `contact`.`hidden` AS `global-ignored`,
2660 `contact`.`blocked` AS `global-blocked`,
2661 `contact`.`hidden` AS `hidden`,
2662 `contact`.`archive` AS `archive`,
2663 `contact`.`deleted` AS `deleted`,
2664 `contact`.`blocked` AS `blocked`,
2665 `contact`.`notify` AS `dfrn-notify`,
2666 `contact`.`poll` AS `dfrn-poll`,
2667 `fcontact`.`guid` AS `diaspora-guid`,
2668 `fcontact`.`batch` AS `diaspora-batch`,
2669 `fcontact`.`notify` AS `diaspora-notify`,
2670 `fcontact`.`poll` AS `diaspora-poll`,
2671 `fcontact`.`alias` AS `diaspora-alias`,
2672 `apcontact`.`uuid` AS `ap-uuid`,
2673 `apcontact`.`type` AS `ap-type`,
2674 `apcontact`.`following` AS `ap-following`,
2675 `apcontact`.`followers` AS `ap-followers`,
2676 `apcontact`.`inbox` AS `ap-inbox`,
2677 `apcontact`.`outbox` AS `ap-outbox`,
2678 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2679 `apcontact`.`generator` AS `ap-generator`,
2680 `apcontact`.`following_count` AS `ap-following_count`,
2681 `apcontact`.`followers_count` AS `ap-followers_count`,
2682 `apcontact`.`statuses_count` AS `ap-statuses_count`,
2683 `gserver`.`site_name` AS `site_name`,
2684 `gserver`.`platform` AS `platform`,
2685 `gserver`.`version` AS `version`
2687 LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id`
2688 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
2689 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = contact.`uri-id`
2690 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`
2691 WHERE `contact`.`uid` = 0;
2694 -- VIEW account-user-view
2696 DROP VIEW IF EXISTS `account-user-view`;
2697 CREATE VIEW `account-user-view` AS SELECT
2698 `ucontact`.`id` AS `id`,
2699 `contact`.`id` AS `pid`,
2700 `ucontact`.`uid` AS `uid`,
2701 `contact`.`url` AS `url`,
2702 `contact`.`nurl` AS `nurl`,
2703 `contact`.`uri-id` AS `uri-id`,
2704 `item-uri`.`guid` AS `guid`,
2705 `contact`.`addr` AS `addr`,
2706 `contact`.`alias` AS `alias`,
2707 `contact`.`name` AS `name`,
2708 `contact`.`nick` AS `nick`,
2709 `contact`.`about` AS `about`,
2710 `contact`.`keywords` AS `keywords`,
2711 `contact`.`xmpp` AS `xmpp`,
2712 `contact`.`matrix` AS `matrix`,
2713 `contact`.`avatar` AS `avatar`,
2714 `contact`.`photo` AS `photo`,
2715 `contact`.`thumb` AS `thumb`,
2716 `contact`.`micro` AS `micro`,
2717 `contact`.`header` AS `header`,
2718 `contact`.`created` AS `created`,
2719 `contact`.`updated` AS `updated`,
2720 `ucontact`.`self` AS `self`,
2721 `ucontact`.`remote_self` AS `remote_self`,
2722 `ucontact`.`rel` AS `rel`,
2723 `contact`.`network` AS `network`,
2724 `ucontact`.`protocol` AS `protocol`,
2725 `contact`.`location` AS `location`,
2726 `ucontact`.`attag` AS `attag`,
2727 `contact`.`pubkey` AS `pubkey`,
2728 `contact`.`prvkey` AS `prvkey`,
2729 `contact`.`subscribe` AS `subscribe`,
2730 `contact`.`last-update` AS `last-update`,
2731 `contact`.`success_update` AS `success_update`,
2732 `contact`.`failure_update` AS `failure_update`,
2733 `contact`.`failed` AS `failed`,
2734 `contact`.`last-item` AS `last-item`,
2735 `contact`.`last-discovery` AS `last-discovery`,
2736 `contact`.`contact-type` AS `contact-type`,
2737 `contact`.`manually-approve` AS `manually-approve`,
2738 `contact`.`unsearchable` AS `unsearchable`,
2739 `contact`.`sensitive` AS `sensitive`,
2740 `contact`.`baseurl` AS `baseurl`,
2741 `contact`.`gsid` AS `gsid`,
2742 `ucontact`.`info` AS `info`,
2743 `contact`.`bdyear` AS `bdyear`,
2744 `contact`.`bd` AS `bd`,
2745 `contact`.`poco` AS `poco`,
2746 `contact`.`name-date` AS `name-date`,
2747 `contact`.`uri-date` AS `uri-date`,
2748 `contact`.`avatar-date` AS `avatar-date`,
2749 `contact`.`term-date` AS `term-date`,
2750 `contact`.`hidden` AS `global-ignored`,
2751 `contact`.`blocked` AS `global-blocked`,
2752 `ucontact`.`hidden` AS `hidden`,
2753 `ucontact`.`archive` AS `archive`,
2754 `ucontact`.`pending` AS `pending`,
2755 `ucontact`.`deleted` AS `deleted`,
2756 `ucontact`.`notify_new_posts` AS `notify_new_posts`,
2757 `ucontact`.`fetch_further_information` AS `fetch_further_information`,
2758 `ucontact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2759 `ucontact`.`rating` AS `rating`,
2760 `ucontact`.`readonly` AS `readonly`,
2761 `ucontact`.`blocked` AS `blocked`,
2762 `ucontact`.`block_reason` AS `block_reason`,
2763 `ucontact`.`subhub` AS `subhub`,
2764 `ucontact`.`hub-verify` AS `hub-verify`,
2765 `ucontact`.`reason` AS `reason`,
2766 `contact`.`notify` AS `dfrn-notify`,
2767 `contact`.`poll` AS `dfrn-poll`,
2768 `fcontact`.`guid` AS `diaspora-guid`,
2769 `fcontact`.`batch` AS `diaspora-batch`,
2770 `fcontact`.`notify` AS `diaspora-notify`,
2771 `fcontact`.`poll` AS `diaspora-poll`,
2772 `fcontact`.`alias` AS `diaspora-alias`,
2773 `fcontact`.`interacting_count` AS `diaspora-interacting_count`,
2774 `fcontact`.`interacted_count` AS `diaspora-interacted_count`,
2775 `fcontact`.`post_count` AS `diaspora-post_count`,
2776 `apcontact`.`uuid` AS `ap-uuid`,
2777 `apcontact`.`type` AS `ap-type`,
2778 `apcontact`.`following` AS `ap-following`,
2779 `apcontact`.`followers` AS `ap-followers`,
2780 `apcontact`.`inbox` AS `ap-inbox`,
2781 `apcontact`.`outbox` AS `ap-outbox`,
2782 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2783 `apcontact`.`generator` AS `ap-generator`,
2784 `apcontact`.`following_count` AS `ap-following_count`,
2785 `apcontact`.`followers_count` AS `ap-followers_count`,
2786 `apcontact`.`statuses_count` AS `ap-statuses_count`,
2787 `gserver`.`site_name` AS `site_name`,
2788 `gserver`.`platform` AS `platform`,
2789 `gserver`.`version` AS `version`
2790 FROM `contact` AS `ucontact`
2791 INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
2792 LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id`
2793 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
2794 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = `ucontact`.`uri-id` AND `fcontact`.`network` = 'dspr'
2795 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`;
2798 -- VIEW pending-view
2800 DROP VIEW IF EXISTS `pending-view`;
2801 CREATE VIEW `pending-view` AS SELECT
2802 `register`.`id` AS `id`,
2803 `register`.`hash` AS `hash`,
2804 `register`.`created` AS `created`,
2805 `register`.`uid` AS `uid`,
2806 `register`.`password` AS `password`,
2807 `register`.`language` AS `language`,
2808 `register`.`note` AS `note`,
2809 `contact`.`self` AS `self`,
2810 `contact`.`name` AS `name`,
2811 `contact`.`url` AS `url`,
2812 `contact`.`micro` AS `micro`,
2813 `user`.`email` AS `email`,
2814 `contact`.`nick` AS `nick`
2816 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2817 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2820 -- VIEW tag-search-view
2822 DROP VIEW IF EXISTS `tag-search-view`;
2823 CREATE VIEW `tag-search-view` AS SELECT
2824 `post-tag`.`uri-id` AS `uri-id`,
2825 `post-user`.`uid` AS `uid`,
2826 `post-user`.`id` AS `iid`,
2827 `post-user`.`private` AS `private`,
2828 `post-user`.`wall` AS `wall`,
2829 `post-user`.`origin` AS `origin`,
2830 `post-user`.`global` AS `global`,
2831 `post-user`.`gravity` AS `gravity`,
2832 `post-user`.`received` AS `received`,
2833 `post-user`.`network` AS `network`,
2834 `post-user`.`author-id` AS `author-id`,
2835 `tag`.`name` AS `name`
2837 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
2838 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
2839 WHERE `post-tag`.`type` = 1;
2842 -- VIEW workerqueue-view
2844 DROP VIEW IF EXISTS `workerqueue-view`;
2845 CREATE VIEW `workerqueue-view` AS SELECT
2846 `process`.`pid` AS `pid`,
2847 `workerqueue`.`priority` AS `priority`
2849 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
2850 WHERE NOT `workerqueue`.`done`;
2853 -- VIEW profile_field-view
2855 DROP VIEW IF EXISTS `profile_field-view`;
2856 CREATE VIEW `profile_field-view` AS SELECT
2857 `profile_field`.`id` AS `id`,
2858 `profile_field`.`uid` AS `uid`,
2859 `profile_field`.`label` AS `label`,
2860 `profile_field`.`value` AS `value`,
2861 `profile_field`.`order` AS `order`,
2862 `profile_field`.`psid` AS `psid`,
2863 `permissionset`.`allow_cid` AS `allow_cid`,
2864 `permissionset`.`allow_gid` AS `allow_gid`,
2865 `permissionset`.`deny_cid` AS `deny_cid`,
2866 `permissionset`.`deny_gid` AS `deny_gid`,
2867 `profile_field`.`created` AS `created`,
2868 `profile_field`.`edited` AS `edited`
2869 FROM `profile_field`
2870 INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`;