1 -- ------------------------------------------
2 -- Friendica 2022.09-rc (Giant Rhubarb)
3 -- DB_UPDATE_VERSION 1482
4 -- ------------------------------------------
10 CREATE TABLE IF NOT EXISTS `gserver` (
11 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
12 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
13 `nurl` varbinary(383) 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` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
26 `noscrape` varbinary(383) 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(383) 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` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
131 `header` varbinary(383) COMMENT 'Header picture',
132 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
133 `nurl` varbinary(383) 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` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
137 `pubkey` text COMMENT 'RSA public key 4096 bit',
138 `prvkey` text COMMENT 'RSA private key 4096 bit',
139 `batch` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
140 `notify` varbinary(383) COMMENT '',
141 `poll` varbinary(383) COMMENT '',
142 `subscribe` varbinary(383) 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 `next-update` datetime COMMENT 'Next connection request',
145 `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
146 `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
147 `failed` boolean COMMENT 'Connection failed',
148 `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
149 `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
150 `last-discovery` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last follower discovery',
151 `local-data` boolean COMMENT 'Is true when there are posts with this contact on the system',
152 `blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
153 `block_reason` text COMMENT 'Node-wide block reason',
154 `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
155 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Person, organisation, news, community, relay',
156 `manually-approve` boolean COMMENT 'Contact requests have to be approved manually',
157 `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
158 `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
159 `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
160 `baseurl` varbinary(383) DEFAULT '' COMMENT 'baseurl of the contact',
161 `gsid` int unsigned COMMENT 'Global Server ID',
162 `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
163 `reason` text COMMENT '',
164 `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
165 `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
166 `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
167 `protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
168 `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
169 `hub-verify` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
170 `rating` tinyint NOT NULL DEFAULT 0 COMMENT 'Automatically detected feed poll frequency',
171 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Feed poll priority',
172 `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
173 `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
174 `pending` boolean NOT NULL DEFAULT '1' COMMENT 'Contact request is pending',
175 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
176 `info` mediumtext COMMENT '',
177 `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
178 `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
179 `ffi_keyword_denylist` text COMMENT '',
180 `photo` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
181 `thumb` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
182 `micro` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
183 `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
184 `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
185 `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
186 `request` varbinary(383) COMMENT '',
187 `confirm` varbinary(383) COMMENT '',
188 `poco` varbinary(383) COMMENT '',
189 `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
190 `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = false instead',
191 `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = true instead',
192 `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
193 `site-pubkey` text COMMENT 'Deprecated',
194 `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
195 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
196 `issued-id` varbinary(383) NOT NULL DEFAULT '' COMMENT 'Deprecated',
197 `dfrn-id` varbinary(383) NOT NULL DEFAULT '' COMMENT 'Deprecated',
198 `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
199 `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
200 `usehub` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
201 `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT 'Deprecated',
202 `profile-id` int unsigned COMMENT 'Deprecated',
204 INDEX `uid_name` (`uid`,`name`(190)),
205 INDEX `self_uid` (`self`,`uid`),
206 INDEX `alias_uid` (`alias`(128),`uid`),
207 INDEX `pending_uid` (`pending`,`uid`),
208 INDEX `blocked_uid` (`blocked`,`uid`),
209 INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
210 INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
211 INDEX `batch_contact-type` (`batch`(64),`contact-type`),
212 INDEX `addr_uid` (`addr`(128),`uid`),
213 INDEX `nurl_uid` (`nurl`(128),`uid`),
214 INDEX `nick_uid` (`nick`(128),`uid`),
215 INDEX `attag_uid` (`attag`(96),`uid`),
216 INDEX `network_uid_lastupdate` (`network`,`uid`,`last-update`),
217 INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`),
218 INDEX `next-update` (`next-update`),
219 INDEX `local-data-next-update` (`local-data`,`next-update`),
220 INDEX `uid_lastitem` (`uid`,`last-item`),
221 INDEX `baseurl` (`baseurl`(64)),
222 INDEX `uid_contact-type` (`uid`,`contact-type`),
223 INDEX `uid_self_contact-type` (`uid`,`self`,`contact-type`),
224 INDEX `self_network_uid` (`self`,`network`,`uid`),
225 INDEX `gsid_uid_failed` (`gsid`,`uid`,`failed`),
226 INDEX `uri-id` (`uri-id`),
227 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
228 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
229 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
230 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
235 CREATE TABLE IF NOT EXISTS `tag` (
236 `id` int unsigned NOT NULL auto_increment COMMENT '',
237 `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
238 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
239 `type` tinyint unsigned COMMENT 'Type of the tag (Unknown, General Collection, Follower Collection or Account)',
241 UNIQUE INDEX `type_name_url` (`name`,`url`),
243 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
246 -- TABLE permissionset
248 CREATE TABLE IF NOT EXISTS `permissionset` (
249 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
250 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
251 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
252 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
253 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
254 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
256 INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`uid`,`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30)),
257 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
258 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
263 CREATE TABLE IF NOT EXISTS `verb` (
264 `id` smallint unsigned NOT NULL auto_increment,
265 `name` varchar(100) NOT NULL DEFAULT '' COMMENT '',
267 INDEX `name` (`name`)
268 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activity Verbs';
271 -- TABLE 2fa_app_specific_password
273 CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
274 `id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
275 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
276 `description` varchar(255) COMMENT 'Description of the usage of the password',
277 `hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
278 `generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
279 `last_used` datetime COMMENT 'Datetime the password was last used',
281 INDEX `uid_description` (`uid`,`description`(190)),
282 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
283 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
286 -- TABLE 2fa_recovery_codes
288 CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
289 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
290 `code` varchar(50) NOT NULL COMMENT 'Recovery code string',
291 `generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
292 `used` datetime COMMENT 'Datetime the code was used',
293 PRIMARY KEY(`uid`,`code`),
294 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
295 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
298 -- TABLE 2fa_trusted_browser
300 CREATE TABLE IF NOT EXISTS `2fa_trusted_browser` (
301 `cookie_hash` varchar(80) NOT NULL COMMENT 'Trusted cookie hash',
302 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
303 `user_agent` text COMMENT 'User agent string',
304 `trusted` boolean NOT NULL DEFAULT '1' COMMENT 'Whenever this browser should be trusted or not',
305 `created` datetime NOT NULL COMMENT 'Datetime the trusted browser was recorded',
306 `last_used` datetime COMMENT 'Datetime the trusted browser was last used',
307 PRIMARY KEY(`cookie_hash`),
309 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
310 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication trusted browsers';
315 CREATE TABLE IF NOT EXISTS `addon` (
316 `id` int unsigned NOT NULL auto_increment COMMENT '',
317 `name` varchar(50) NOT NULL DEFAULT '' COMMENT 'addon base (file)name',
318 `version` varchar(50) NOT NULL DEFAULT '' COMMENT 'currently unused',
319 `installed` boolean NOT NULL DEFAULT '0' COMMENT 'currently always 1',
320 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'currently unused',
321 `timestamp` int unsigned NOT NULL DEFAULT 0 COMMENT 'file timestamp to check for reloads',
322 `plugin_admin` boolean NOT NULL DEFAULT '0' COMMENT '1 = has admin config, 0 = has no admin config',
324 INDEX `installed_name` (`installed`,`name`),
325 UNIQUE INDEX `name` (`name`)
326 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registered addons';
331 CREATE TABLE IF NOT EXISTS `apcontact` (
332 `url` varbinary(383) NOT NULL COMMENT 'URL of the contact',
333 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
334 `uuid` varbinary(255) COMMENT '',
335 `type` varchar(20) NOT NULL COMMENT '',
336 `following` varbinary(383) COMMENT '',
337 `followers` varbinary(383) COMMENT '',
338 `inbox` varbinary(383) NOT NULL COMMENT '',
339 `outbox` varbinary(383) COMMENT '',
340 `sharedinbox` varbinary(383) COMMENT '',
341 `featured` varbinary(383) COMMENT 'Address for the collection of featured posts',
342 `featured-tags` varbinary(383) COMMENT 'Address for the collection of featured tags',
343 `manually-approve` boolean COMMENT '',
344 `discoverable` boolean COMMENT 'Mastodon extension: true if profile is published in their directory',
345 `suspended` boolean COMMENT 'Mastodon extension: true if profile is suspended',
346 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
347 `name` varchar(255) COMMENT '',
348 `about` text COMMENT '',
349 `xmpp` varchar(255) COMMENT 'XMPP address',
350 `matrix` varchar(255) COMMENT 'Matrix address',
351 `photo` varbinary(383) COMMENT '',
352 `header` varbinary(383) COMMENT 'Header picture',
353 `addr` varchar(255) COMMENT '',
354 `alias` varbinary(383) COMMENT '',
355 `pubkey` text COMMENT '',
356 `subscribe` varbinary(383) COMMENT '',
357 `baseurl` varbinary(383) COMMENT 'baseurl of the ap contact',
358 `gsid` int unsigned COMMENT 'Global Server ID',
359 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
360 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
361 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
362 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
363 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
365 INDEX `addr` (`addr`(32)),
366 INDEX `alias` (`alias`(190)),
367 INDEX `followers` (`followers`(190)),
368 INDEX `baseurl` (`baseurl`(190)),
369 INDEX `sharedinbox` (`sharedinbox`(190)),
370 INDEX `gsid` (`gsid`),
371 UNIQUE INDEX `uri-id` (`uri-id`),
372 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
373 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
374 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
379 CREATE TABLE IF NOT EXISTS `application` (
380 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
381 `client_id` varchar(64) NOT NULL COMMENT '',
382 `client_secret` varchar(64) NOT NULL COMMENT '',
383 `name` varchar(255) NOT NULL COMMENT '',
384 `redirect_uri` varbinary(383) NOT NULL COMMENT '',
385 `website` varbinary(383) COMMENT '',
386 `scopes` varchar(255) COMMENT '',
387 `read` boolean COMMENT 'Read scope',
388 `write` boolean COMMENT 'Write scope',
389 `follow` boolean COMMENT 'Follow scope',
390 `push` boolean COMMENT 'Push scope',
392 UNIQUE INDEX `client_id` (`client_id`)
393 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth application';
396 -- TABLE application-marker
398 CREATE TABLE IF NOT EXISTS `application-marker` (
399 `application-id` int unsigned NOT NULL COMMENT '',
400 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
401 `timeline` varchar(64) NOT NULL COMMENT 'Marker (home, notifications)',
402 `last_read_id` varbinary(383) COMMENT 'Marker id for the timeline',
403 `version` smallint unsigned COMMENT 'Version number',
404 `updated_at` datetime COMMENT 'creation time',
405 PRIMARY KEY(`application-id`,`uid`,`timeline`),
406 INDEX `uid_id` (`uid`),
407 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
408 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
409 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Timeline marker';
412 -- TABLE application-token
414 CREATE TABLE IF NOT EXISTS `application-token` (
415 `application-id` int unsigned NOT NULL COMMENT '',
416 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
417 `code` varchar(64) NOT NULL COMMENT '',
418 `access_token` varchar(64) NOT NULL COMMENT '',
419 `created_at` datetime NOT NULL COMMENT 'creation time',
420 `scopes` varchar(255) COMMENT '',
421 `read` boolean COMMENT 'Read scope',
422 `write` boolean COMMENT 'Write scope',
423 `follow` boolean COMMENT 'Follow scope',
424 `push` boolean COMMENT 'Push scope',
425 PRIMARY KEY(`application-id`,`uid`),
426 INDEX `uid_id` (`uid`,`application-id`),
427 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
428 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
429 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth user token';
434 CREATE TABLE IF NOT EXISTS `attach` (
435 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
436 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
437 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
438 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
439 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
440 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
441 `data` longblob NOT NULL COMMENT 'file data',
442 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
443 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
444 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
445 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
446 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
447 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
448 `backend-class` tinytext COMMENT 'Storage backend class',
449 `backend-ref` text COMMENT 'Storage backend data reference',
452 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
453 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
458 CREATE TABLE IF NOT EXISTS `cache` (
459 `k` varbinary(255) NOT NULL COMMENT 'cache key',
460 `v` mediumtext COMMENT 'cached serialized value',
461 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
462 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
464 INDEX `k_expires` (`k`,`expires`)
465 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
470 CREATE TABLE IF NOT EXISTS `config` (
471 `id` int unsigned NOT NULL auto_increment COMMENT '',
472 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
473 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
474 `v` mediumtext COMMENT '',
476 UNIQUE INDEX `cat_k` (`cat`,`k`)
477 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
480 -- TABLE contact-relation
482 CREATE TABLE IF NOT EXISTS `contact-relation` (
483 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
484 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
485 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
486 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
487 `follows` boolean NOT NULL DEFAULT '0' COMMENT '',
488 PRIMARY KEY(`cid`,`relation-cid`),
489 INDEX `relation-cid` (`relation-cid`),
490 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
491 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
492 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
497 CREATE TABLE IF NOT EXISTS `conv` (
498 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
499 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
500 `recips` text COMMENT 'sender_handle;recipient_handle',
501 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
502 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
503 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
504 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
505 `subject` text COMMENT 'subject of initial message',
508 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
509 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
514 CREATE TABLE IF NOT EXISTS `workerqueue` (
515 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
516 `command` varchar(100) COMMENT 'Task command',
517 `parameter` mediumtext COMMENT 'Task parameter',
518 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
519 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
520 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
521 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
522 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
523 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
524 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
526 INDEX `command` (`command`),
527 INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
528 INDEX `done_executed` (`done`,`executed`),
529 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
530 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
531 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
532 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
533 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
534 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
537 -- TABLE delayed-post
539 CREATE TABLE IF NOT EXISTS `delayed-post` (
540 `id` int unsigned NOT NULL auto_increment,
541 `uri` varbinary(383) COMMENT 'URI of the post that will be distributed later',
542 `uid` mediumint unsigned COMMENT 'Owner User id',
543 `delayed` datetime COMMENT 'delay time',
544 `wid` int unsigned COMMENT 'Workerqueue id',
546 UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
548 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
549 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
550 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
553 -- TABLE diaspora-interaction
555 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
556 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
557 `interaction` mediumtext COMMENT 'The Diaspora interaction',
558 PRIMARY KEY(`uri-id`),
559 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
560 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
565 CREATE TABLE IF NOT EXISTS `endpoint` (
566 `url` varbinary(383) NOT NULL COMMENT 'URL of the contact',
567 `type` varchar(20) NOT NULL COMMENT '',
568 `owner-uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
570 UNIQUE INDEX `owner-uri-id_type` (`owner-uri-id`,`type`),
571 FOREIGN KEY (`owner-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
572 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub endpoints - used in the ActivityPub implementation';
577 CREATE TABLE IF NOT EXISTS `event` (
578 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
579 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
580 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
581 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
582 `uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
583 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the event uri',
584 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
585 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
586 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
587 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
588 `summary` text COMMENT 'short description or title of the event',
589 `desc` text COMMENT 'event description',
590 `location` text COMMENT 'event location',
591 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
592 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
593 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
594 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
595 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
596 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
597 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
599 INDEX `uid_start` (`uid`,`start`),
601 INDEX `uri-id` (`uri-id`),
602 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
603 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
604 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
605 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
610 CREATE TABLE IF NOT EXISTS `fcontact` (
611 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
612 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'unique id',
613 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
614 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the fcontact url',
615 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
616 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
617 `request` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
618 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
619 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
620 `batch` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
621 `notify` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
622 `poll` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
623 `confirm` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
624 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
625 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
626 `alias` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
627 `pubkey` text COMMENT '',
628 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
629 `interacting_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts this contact interactes with',
630 `interacted_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts that interacted with this contact',
631 `post_count` int unsigned DEFAULT 0 COMMENT 'Number of posts and comments',
633 INDEX `addr` (`addr`(32)),
634 UNIQUE INDEX `url` (`url`(190)),
635 UNIQUE INDEX `uri-id` (`uri-id`),
636 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
637 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
642 CREATE TABLE IF NOT EXISTS `fetch-entry` (
643 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
644 `url` varbinary(383) COMMENT 'url that awaiting to be fetched',
645 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of the fetch request',
646 `wid` int unsigned COMMENT 'Workerqueue id',
648 UNIQUE INDEX `url` (`url`),
649 INDEX `created` (`created`),
651 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
652 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
657 CREATE TABLE IF NOT EXISTS `fsuggest` (
658 `id` int unsigned NOT NULL auto_increment COMMENT '',
659 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
660 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
661 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
662 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
663 `request` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
664 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
665 `note` text COMMENT '',
666 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
670 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
671 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
672 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
677 CREATE TABLE IF NOT EXISTS `group` (
678 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
679 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
680 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
681 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
682 `cid` int unsigned COMMENT 'Contact id of forum. When this field is filled then the members are synced automatically.',
683 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
687 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
688 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
689 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
692 -- TABLE group_member
694 CREATE TABLE IF NOT EXISTS `group_member` (
695 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
696 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
697 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
699 INDEX `contactid` (`contact-id`),
700 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
701 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
702 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
703 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
708 CREATE TABLE IF NOT EXISTS `gserver-tag` (
709 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
710 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
711 PRIMARY KEY(`gserver-id`,`tag`),
713 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
714 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
719 CREATE TABLE IF NOT EXISTS `hook` (
720 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
721 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
722 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
723 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
724 `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',
726 INDEX `priority` (`priority`),
727 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
728 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
733 CREATE TABLE IF NOT EXISTS `inbox-entry` (
734 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
735 `activity-id` varbinary(383) COMMENT 'id of the incoming activity',
736 `object-id` varbinary(383) COMMENT '',
737 `in-reply-to-id` varbinary(383) COMMENT '',
738 `conversation` varbinary(383) COMMENT '',
739 `type` varchar(64) COMMENT 'Type of the activity',
740 `object-type` varchar(64) COMMENT 'Type of the object activity',
741 `object-object-type` varchar(64) COMMENT 'Type of the object\'s object activity',
742 `received` datetime COMMENT 'Receiving date',
743 `activity` mediumtext COMMENT 'The JSON activity',
744 `signer` varchar(255) COMMENT '',
745 `push` boolean COMMENT 'Is the entry pushed or have pulled it?',
746 `trust` boolean COMMENT 'Do we trust this entry?',
747 `wid` int unsigned COMMENT 'Workerqueue id',
749 UNIQUE INDEX `activity-id` (`activity-id`),
750 INDEX `object-id` (`object-id`),
751 INDEX `received` (`received`),
753 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
754 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Incoming activity';
757 -- TABLE inbox-entry-receiver
759 CREATE TABLE IF NOT EXISTS `inbox-entry-receiver` (
760 `queue-id` int unsigned NOT NULL COMMENT '',
761 `uid` mediumint unsigned NOT NULL COMMENT 'User id',
762 PRIMARY KEY(`queue-id`,`uid`),
764 FOREIGN KEY (`queue-id`) REFERENCES `inbox-entry` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
765 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
766 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Receiver for the incoming activity';
769 -- TABLE inbox-status
771 CREATE TABLE IF NOT EXISTS `inbox-status` (
772 `url` varbinary(383) NOT NULL COMMENT 'URL of the inbox',
773 `uri-id` int unsigned COMMENT 'Item-uri id of inbox url',
774 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
775 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
776 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
777 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
778 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
779 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
781 INDEX `uri-id` (`uri-id`),
782 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
783 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
788 CREATE TABLE IF NOT EXISTS `intro` (
789 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
790 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
791 `fid` int unsigned COMMENT 'deprecated',
792 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
793 `suggest-cid` int unsigned COMMENT 'Suggested contact',
794 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
795 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
796 `note` text COMMENT '',
797 `hash` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
798 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
799 `blocked` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
800 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
802 INDEX `contact-id` (`contact-id`),
803 INDEX `suggest-cid` (`suggest-cid`),
805 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
806 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
807 FOREIGN KEY (`suggest-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
808 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
813 CREATE TABLE IF NOT EXISTS `locks` (
814 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
815 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
816 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
817 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
818 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
820 INDEX `name_expires` (`name`,`expires`)
821 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
826 CREATE TABLE IF NOT EXISTS `mail` (
827 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
828 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
829 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
830 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
831 `from-photo` varbinary(383) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
832 `from-url` varbinary(383) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
833 `contact-id` varbinary(255) COMMENT 'contact.id',
834 `author-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the author of the mail',
835 `convid` int unsigned COMMENT 'conv.id',
836 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
837 `body` mediumtext COMMENT '',
838 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
839 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
840 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
841 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
842 `uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
843 `uri-id` int unsigned COMMENT 'Item-uri id of the related mail',
844 `parent-uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
845 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related mail',
846 `thr-parent` varbinary(383) COMMENT '',
847 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
848 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
850 INDEX `uid_seen` (`uid`,`seen`),
851 INDEX `convid` (`convid`),
852 INDEX `uri` (`uri`(64)),
853 INDEX `parent-uri` (`parent-uri`(64)),
854 INDEX `contactid` (`contact-id`(32)),
855 INDEX `author-id` (`author-id`),
856 INDEX `uri-id` (`uri-id`),
857 INDEX `parent-uri-id` (`parent-uri-id`),
858 INDEX `thr-parent-id` (`thr-parent-id`),
859 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
860 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
861 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
862 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
863 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
864 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
869 CREATE TABLE IF NOT EXISTS `mailacct` (
870 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
871 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
872 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
873 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
874 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
875 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
876 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
877 `pass` text COMMENT '',
878 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
879 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
880 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
881 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
882 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
885 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
886 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
891 CREATE TABLE IF NOT EXISTS `manage` (
892 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
893 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
894 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
896 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
898 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
899 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
900 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
903 -- TABLE notification
905 CREATE TABLE IF NOT EXISTS `notification` (
906 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
907 `uid` mediumint unsigned COMMENT 'Owner User id',
908 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
909 `type` smallint unsigned COMMENT '',
910 `actor-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the actor that caused the notification',
911 `target-uri-id` int unsigned COMMENT 'Item-uri id of the related post',
912 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
913 `created` datetime COMMENT '',
914 `seen` boolean DEFAULT '0' COMMENT 'Seen on the desktop',
915 `dismissed` boolean DEFAULT '0' COMMENT 'Dismissed via the API',
917 UNIQUE INDEX `uid_vid_type_actor-id_target-uri-id` (`uid`,`vid`,`type`,`actor-id`,`target-uri-id`),
919 INDEX `actor-id` (`actor-id`),
920 INDEX `target-uri-id` (`target-uri-id`),
921 INDEX `parent-uri-id` (`parent-uri-id`),
922 INDEX `seen_uid` (`seen`,`uid`),
923 INDEX `uid_type_parent-uri-id_actor-id` (`uid`,`type`,`parent-uri-id`,`actor-id`),
924 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
925 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
926 FOREIGN KEY (`actor-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
927 FOREIGN KEY (`target-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
928 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
929 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
934 CREATE TABLE IF NOT EXISTS `notify` (
935 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
936 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
937 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
938 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
939 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
940 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
941 `msg` mediumtext COMMENT '',
942 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
943 `link` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
944 `iid` int unsigned COMMENT '',
945 `parent` int unsigned COMMENT '',
946 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
947 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
948 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
949 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
950 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
951 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
952 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
954 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
955 INDEX `uid_date` (`uid`,`date`),
956 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
957 INDEX `uri-id` (`uri-id`),
958 INDEX `parent-uri-id` (`parent-uri-id`),
959 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
960 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
961 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
962 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='[Deprecated] User notifications';
965 -- TABLE notify-threads
967 CREATE TABLE IF NOT EXISTS `notify-threads` (
968 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
969 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
970 `master-parent-item` int unsigned COMMENT 'Deprecated',
971 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
972 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
973 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
975 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
976 INDEX `receiver-uid` (`receiver-uid`),
977 INDEX `notify-id` (`notify-id`),
978 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
979 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
980 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
981 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
986 CREATE TABLE IF NOT EXISTS `oembed` (
987 `url` varbinary(383) NOT NULL COMMENT 'page url',
988 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
989 `content` mediumtext COMMENT 'OEmbed data of the page',
990 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
991 PRIMARY KEY(`url`,`maxwidth`),
992 INDEX `created` (`created`)
993 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
996 -- TABLE openwebauth-token
998 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
999 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1000 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
1001 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
1002 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
1003 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1004 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1006 INDEX `uid` (`uid`),
1007 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1008 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
1013 CREATE TABLE IF NOT EXISTS `parsed_url` (
1014 `url_hash` binary(64) NOT NULL COMMENT 'page url hash',
1015 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
1016 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
1017 `url` text NOT NULL COMMENT 'page url',
1018 `content` mediumtext COMMENT 'page data',
1019 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1020 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration',
1021 PRIMARY KEY(`url_hash`,`guessing`,`oembed`),
1022 INDEX `created` (`created`),
1023 INDEX `expires` (`expires`)
1024 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
1029 CREATE TABLE IF NOT EXISTS `pconfig` (
1030 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
1031 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1032 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
1033 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
1034 `v` mediumtext COMMENT 'Value',
1036 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
1037 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1038 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
1043 CREATE TABLE IF NOT EXISTS `photo` (
1044 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1045 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1046 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1047 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
1048 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
1049 `hash` char(32) COMMENT 'hash value of the photo',
1050 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
1051 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
1052 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1053 `desc` text COMMENT '',
1054 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
1055 `photo-type` tinyint unsigned COMMENT 'User avatar, user banner, contact avatar, contact banner or default',
1056 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1057 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
1058 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1059 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1060 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1061 `data` mediumblob NOT NULL COMMENT '',
1062 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1063 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
1064 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
1065 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
1066 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
1067 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
1068 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
1069 `backend-class` tinytext COMMENT 'Storage backend class',
1070 `backend-ref` text COMMENT 'Storage backend data reference',
1071 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1073 INDEX `contactid` (`contact-id`),
1074 INDEX `uid_contactid` (`uid`,`contact-id`),
1075 INDEX `uid_profile` (`uid`,`profile`),
1076 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
1077 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
1078 INDEX `resource-id` (`resource-id`),
1079 INDEX `uid_photo-type` (`uid`,`photo-type`),
1080 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1081 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1082 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1087 CREATE TABLE IF NOT EXISTS `post` (
1088 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1089 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1090 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1091 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1092 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1093 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1094 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1095 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1096 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1097 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1098 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1099 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1100 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1101 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1102 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1103 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1104 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1105 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1106 PRIMARY KEY(`uri-id`),
1107 INDEX `parent-uri-id` (`parent-uri-id`),
1108 INDEX `thr-parent-id` (`thr-parent-id`),
1109 INDEX `external-id` (`external-id`),
1110 INDEX `owner-id` (`owner-id`),
1111 INDEX `author-id` (`author-id`),
1112 INDEX `causer-id` (`causer-id`),
1113 INDEX `vid` (`vid`),
1114 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1115 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1116 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1117 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1118 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1119 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1120 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1121 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1122 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
1125 -- TABLE post-activity
1127 CREATE TABLE IF NOT EXISTS `post-activity` (
1128 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1129 `activity` mediumtext COMMENT 'Original activity',
1130 `received` datetime COMMENT '',
1131 PRIMARY KEY(`uri-id`),
1132 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1133 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Original remote activity';
1136 -- TABLE post-category
1138 CREATE TABLE IF NOT EXISTS `post-category` (
1139 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1140 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1141 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1142 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1143 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1144 INDEX `tid` (`tid`),
1145 INDEX `uid_uri-id` (`uid`,`uri-id`),
1146 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1147 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1148 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1149 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1152 -- TABLE post-collection
1154 CREATE TABLE IF NOT EXISTS `post-collection` (
1155 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1156 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0 - Featured',
1157 `author-id` int unsigned COMMENT 'Author of the featured post',
1158 PRIMARY KEY(`uri-id`,`type`),
1159 INDEX `type` (`type`),
1160 INDEX `author-id` (`author-id`),
1161 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1162 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1163 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Collection of posts';
1166 -- TABLE post-content
1168 CREATE TABLE IF NOT EXISTS `post-content` (
1169 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1170 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1171 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1172 `body` mediumtext COMMENT 'item body content',
1173 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1174 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1175 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1176 `language` text COMMENT 'Language information about this post',
1177 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1178 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1179 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1180 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1181 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1182 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1183 `target` text COMMENT 'JSON encoded target structure if used',
1184 `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',
1185 `plink` varbinary(383) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1186 PRIMARY KEY(`uri-id`),
1187 INDEX `plink` (`plink`(191)),
1188 INDEX `resource-id` (`resource-id`),
1189 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
1190 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1191 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1194 -- TABLE post-delivery
1196 CREATE TABLE IF NOT EXISTS `post-delivery` (
1197 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1198 `inbox-id` int unsigned NOT NULL COMMENT 'Item-uri id of inbox url',
1199 `uid` mediumint unsigned COMMENT 'Delivering user',
1200 `created` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
1201 `command` varbinary(32) COMMENT '',
1202 `failed` tinyint DEFAULT 0 COMMENT 'Number of times the delivery has failed',
1203 `receivers` mediumtext COMMENT 'JSON encoded array with the receiving contacts',
1204 PRIMARY KEY(`uri-id`,`inbox-id`),
1205 INDEX `inbox-id_created` (`inbox-id`,`created`),
1206 INDEX `uid` (`uid`),
1207 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1208 FOREIGN KEY (`inbox-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1209 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1210 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for posts for the batch processing';
1213 -- TABLE post-delivery-data
1215 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1216 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1217 `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',
1218 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1219 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1220 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1221 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1222 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1223 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1224 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1225 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1226 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1227 PRIMARY KEY(`uri-id`),
1228 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1229 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1232 -- TABLE post-history
1234 CREATE TABLE IF NOT EXISTS `post-history` (
1235 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1236 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of edit',
1237 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1238 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1239 `body` mediumtext COMMENT 'item body content',
1240 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1241 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1242 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1243 `language` text COMMENT 'Language information about this post',
1244 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1245 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1246 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1247 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1248 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1249 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1250 `target` text COMMENT 'JSON encoded target structure if used',
1251 `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',
1252 `plink` varbinary(383) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1253 PRIMARY KEY(`uri-id`,`edited`),
1254 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1255 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post history';
1260 CREATE TABLE IF NOT EXISTS `post-link` (
1261 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1262 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1263 `url` varbinary(511) NOT NULL COMMENT 'External URL',
1264 `mimetype` varchar(60) COMMENT '',
1266 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1267 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1268 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post related external links';
1273 CREATE TABLE IF NOT EXISTS `post-media` (
1274 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1275 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1276 `url` varbinary(1024) NOT NULL COMMENT 'Media URL',
1277 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1278 `mimetype` varchar(60) COMMENT '',
1279 `height` smallint unsigned COMMENT 'Height of the media',
1280 `width` smallint unsigned COMMENT 'Width of the media',
1281 `size` bigint unsigned COMMENT 'Media size',
1282 `preview` varbinary(512) COMMENT 'Preview URL',
1283 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1284 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1285 `description` text COMMENT '',
1286 `name` varchar(255) COMMENT 'Name of the media',
1287 `author-url` varbinary(383) COMMENT 'URL of the author of the media',
1288 `author-name` varchar(255) COMMENT 'Name of the author of the media',
1289 `author-image` varbinary(383) COMMENT 'Image of the author of the media',
1290 `publisher-url` varbinary(383) COMMENT 'URL of the publisher of the media',
1291 `publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
1292 `publisher-image` varbinary(383) COMMENT 'Image of the publisher of the media',
1294 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`(512)),
1295 INDEX `uri-id-id` (`uri-id`,`id`),
1296 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1297 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1300 -- TABLE post-question
1302 CREATE TABLE IF NOT EXISTS `post-question` (
1303 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1304 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1305 `multiple` boolean NOT NULL DEFAULT '0' COMMENT 'Multiple choice',
1306 `voters` int unsigned COMMENT 'Number of voters for this question',
1307 `end-time` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Question end time',
1309 UNIQUE INDEX `uri-id` (`uri-id`),
1310 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1311 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question';
1314 -- TABLE post-question-option
1316 CREATE TABLE IF NOT EXISTS `post-question-option` (
1317 `id` int unsigned NOT NULL COMMENT 'Id of the question',
1318 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1319 `name` varchar(255) COMMENT 'Name of the option',
1320 `replies` int unsigned COMMENT 'Number of replies for this question option',
1321 PRIMARY KEY(`uri-id`,`id`),
1322 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1323 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question option';
1328 CREATE TABLE IF NOT EXISTS `post-tag` (
1329 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1330 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1331 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1332 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1333 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1334 INDEX `tid` (`tid`),
1335 INDEX `cid` (`cid`),
1336 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1337 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1338 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1339 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1342 -- TABLE post-thread
1344 CREATE TABLE IF NOT EXISTS `post-thread` (
1345 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1346 `conversation-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the conversation uri',
1347 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1348 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1349 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1350 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1351 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1352 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1353 `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',
1354 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1355 PRIMARY KEY(`uri-id`),
1356 INDEX `conversation-id` (`conversation-id`),
1357 INDEX `owner-id` (`owner-id`),
1358 INDEX `author-id` (`author-id`),
1359 INDEX `causer-id` (`causer-id`),
1360 INDEX `received` (`received`),
1361 INDEX `commented` (`commented`),
1362 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1363 FOREIGN KEY (`conversation-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1364 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1365 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1366 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1367 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1372 CREATE TABLE IF NOT EXISTS `post-user` (
1373 `id` int unsigned NOT NULL auto_increment,
1374 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1375 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1376 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1377 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1378 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1379 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1380 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1381 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1382 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1383 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1384 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1385 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1386 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1387 `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
1388 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1389 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1390 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1391 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1392 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1393 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1394 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1395 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1396 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1397 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1398 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1399 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1400 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1401 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1402 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1404 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1405 INDEX `uri-id` (`uri-id`),
1406 INDEX `parent-uri-id` (`parent-uri-id`),
1407 INDEX `thr-parent-id` (`thr-parent-id`),
1408 INDEX `external-id` (`external-id`),
1409 INDEX `owner-id` (`owner-id`),
1410 INDEX `author-id` (`author-id`),
1411 INDEX `causer-id` (`causer-id`),
1412 INDEX `vid` (`vid`),
1413 INDEX `contact-id` (`contact-id`),
1414 INDEX `event-id` (`event-id`),
1415 INDEX `psid` (`psid`),
1416 INDEX `author-id_uid` (`author-id`,`uid`),
1417 INDEX `author-id_received` (`author-id`,`received`),
1418 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1419 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1420 INDEX `uid_contactid` (`uid`,`contact-id`),
1421 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1422 INDEX `uid_unseen` (`uid`,`unseen`),
1423 INDEX `uid_hidden_uri-id` (`uid`,`hidden`,`uri-id`),
1424 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1425 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1426 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1427 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1428 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1429 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1430 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1431 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1432 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1433 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1434 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1435 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1436 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1439 -- TABLE post-thread-user
1441 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1442 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1443 `conversation-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the conversation uri',
1444 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1445 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1446 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1447 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1448 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1449 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1450 `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',
1451 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1452 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1453 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
1454 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1455 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1456 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1457 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1458 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1459 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Deprecated',
1460 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1461 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1462 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1463 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1464 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1465 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1466 PRIMARY KEY(`uid`,`uri-id`),
1467 INDEX `uri-id` (`uri-id`),
1468 INDEX `conversation-id` (`conversation-id`),
1469 INDEX `owner-id` (`owner-id`),
1470 INDEX `author-id` (`author-id`),
1471 INDEX `causer-id` (`causer-id`),
1472 INDEX `uid` (`uid`),
1473 INDEX `contact-id` (`contact-id`),
1474 INDEX `psid` (`psid`),
1475 INDEX `post-user-id` (`post-user-id`),
1476 INDEX `commented` (`commented`),
1477 INDEX `uid_received` (`uid`,`received`),
1478 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1479 INDEX `uid_commented` (`uid`,`commented`),
1480 INDEX `uid_starred` (`uid`,`starred`),
1481 INDEX `uid_mention` (`uid`,`mention`),
1482 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1483 FOREIGN KEY (`conversation-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1484 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1485 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1486 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1487 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1488 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1489 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1490 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1491 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1494 -- TABLE post-user-notification
1496 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1497 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1498 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1499 `notification-type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1500 PRIMARY KEY(`uid`,`uri-id`),
1501 INDEX `uri-id` (`uri-id`),
1502 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1503 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1504 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1509 CREATE TABLE IF NOT EXISTS `process` (
1510 `pid` int unsigned NOT NULL COMMENT 'The ID of the process',
1511 `hostname` varchar(32) NOT NULL COMMENT 'The name of the host the process is ran on',
1512 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1513 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1514 PRIMARY KEY(`pid`,`hostname`),
1515 INDEX `command` (`command`)
1516 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1521 CREATE TABLE IF NOT EXISTS `profile` (
1522 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1523 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1524 `profile-name` varchar(255) COMMENT 'Deprecated',
1525 `is-default` boolean COMMENT 'Deprecated',
1526 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1527 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1528 `pdesc` varchar(255) COMMENT 'Deprecated',
1529 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1530 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1531 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1532 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1533 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1534 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1535 `hometown` varchar(255) COMMENT 'Deprecated',
1536 `gender` varchar(32) COMMENT 'Deprecated',
1537 `marital` varchar(255) COMMENT 'Deprecated',
1538 `with` text COMMENT 'Deprecated',
1539 `howlong` datetime COMMENT 'Deprecated',
1540 `sexual` varchar(255) COMMENT 'Deprecated',
1541 `politic` varchar(255) COMMENT 'Deprecated',
1542 `religion` varchar(255) COMMENT 'Deprecated',
1543 `pub_keywords` text COMMENT '',
1544 `prv_keywords` text COMMENT '',
1545 `likes` text COMMENT 'Deprecated',
1546 `dislikes` text COMMENT 'Deprecated',
1547 `about` text COMMENT 'Profile description',
1548 `summary` varchar(255) COMMENT 'Deprecated',
1549 `music` text COMMENT 'Deprecated',
1550 `book` text COMMENT 'Deprecated',
1551 `tv` text COMMENT 'Deprecated',
1552 `film` text COMMENT 'Deprecated',
1553 `interest` text COMMENT 'Deprecated',
1554 `romance` text COMMENT 'Deprecated',
1555 `work` text COMMENT 'Deprecated',
1556 `education` text COMMENT 'Deprecated',
1557 `contact` text COMMENT 'Deprecated',
1558 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1559 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
1560 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
1561 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1562 `thumb` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1563 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1564 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1566 INDEX `uid_is-default` (`uid`,`is-default`),
1567 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1568 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1569 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1572 -- TABLE profile_field
1574 CREATE TABLE IF NOT EXISTS `profile_field` (
1575 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1576 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1577 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1578 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1579 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1580 `value` text COMMENT 'Value of the field',
1581 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1582 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1584 INDEX `uid` (`uid`),
1585 INDEX `order` (`order`),
1586 INDEX `psid` (`psid`),
1587 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1588 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1589 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1592 -- TABLE push_subscriber
1594 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1595 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1596 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1597 `callback_url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1598 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1599 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1600 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1601 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1602 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1603 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1604 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1606 INDEX `next_try` (`next_try`),
1607 INDEX `uid` (`uid`),
1608 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1609 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1614 CREATE TABLE IF NOT EXISTS `register` (
1615 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1616 `hash` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1617 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1618 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1619 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1620 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1621 `note` text COMMENT '',
1623 INDEX `uid` (`uid`),
1624 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1625 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1630 CREATE TABLE IF NOT EXISTS `search` (
1631 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1632 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1633 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1635 INDEX `uid_term` (`uid`,`term`(64)),
1636 INDEX `term` (`term`(64)),
1637 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1638 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1643 CREATE TABLE IF NOT EXISTS `session` (
1644 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1645 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1646 `data` text COMMENT '',
1647 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1649 INDEX `sid` (`sid`(64)),
1650 INDEX `expire` (`expire`)
1651 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1656 CREATE TABLE IF NOT EXISTS `storage` (
1657 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1658 `data` longblob NOT NULL COMMENT 'file data',
1660 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1663 -- TABLE subscription
1665 CREATE TABLE IF NOT EXISTS `subscription` (
1666 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1667 `application-id` int unsigned NOT NULL COMMENT '',
1668 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
1669 `endpoint` varchar(511) COMMENT 'Endpoint URL',
1670 `pubkey` varchar(127) COMMENT 'User agent public key',
1671 `secret` varchar(32) COMMENT 'Auth secret',
1672 `follow` boolean COMMENT '',
1673 `favourite` boolean COMMENT '',
1674 `reblog` boolean COMMENT '',
1675 `mention` boolean COMMENT '',
1676 `poll` boolean COMMENT '',
1677 `follow_request` boolean COMMENT '',
1678 `status` boolean COMMENT '',
1680 UNIQUE INDEX `application-id_uid` (`application-id`,`uid`),
1681 INDEX `uid_application-id` (`uid`,`application-id`),
1682 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1683 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1684 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Push Subscription for the API';
1689 CREATE TABLE IF NOT EXISTS `userd` (
1690 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1691 `username` varchar(255) NOT NULL COMMENT '',
1693 INDEX `username` (`username`(32))
1694 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1697 -- TABLE user-contact
1699 CREATE TABLE IF NOT EXISTS `user-contact` (
1700 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1701 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1702 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
1703 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1704 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1705 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1706 `hidden` boolean COMMENT 'This contact is hidden from the others',
1707 `is-blocked` boolean COMMENT 'User is blocked by this contact',
1708 `pending` boolean COMMENT '',
1709 `rel` tinyint unsigned COMMENT 'The kind of the relation between the user and the contact',
1710 `info` mediumtext COMMENT '',
1711 `notify_new_posts` boolean COMMENT '',
1712 `remote_self` boolean COMMENT '',
1713 `fetch_further_information` tinyint unsigned COMMENT '',
1714 `ffi_keyword_denylist` text COMMENT '',
1715 `subhub` boolean COMMENT '',
1716 `hub-verify` varbinary(383) COMMENT '',
1717 `protocol` char(4) COMMENT 'Protocol of the contact',
1718 `rating` tinyint COMMENT 'Automatically detected feed poll frequency',
1719 `priority` tinyint unsigned COMMENT 'Feed poll priority',
1720 PRIMARY KEY(`uid`,`cid`),
1721 INDEX `cid` (`cid`),
1722 UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
1723 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1724 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1725 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1726 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1729 -- TABLE arrived-activity
1731 CREATE TABLE IF NOT EXISTS `arrived-activity` (
1732 `object-id` varbinary(383) NOT NULL COMMENT 'object id of the incoming activity',
1733 `received` datetime COMMENT 'Receiving date',
1734 PRIMARY KEY(`object-id`)
1735 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Id of arrived activities';
1738 -- TABLE fetched-activity
1740 CREATE TABLE IF NOT EXISTS `fetched-activity` (
1741 `object-id` varbinary(383) NOT NULL COMMENT 'object id of fetched activity',
1742 `received` datetime COMMENT 'Receiving date',
1743 PRIMARY KEY(`object-id`)
1744 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Id of fetched activities';
1749 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1750 `key` int NOT NULL COMMENT '',
1751 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1753 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1756 -- VIEW application-view
1758 DROP VIEW IF EXISTS `application-view`;
1759 CREATE VIEW `application-view` AS SELECT
1760 `application`.`id` AS `id`,
1761 `application-token`.`uid` AS `uid`,
1762 `application`.`name` AS `name`,
1763 `application`.`redirect_uri` AS `redirect_uri`,
1764 `application`.`website` AS `website`,
1765 `application`.`client_id` AS `client_id`,
1766 `application`.`client_secret` AS `client_secret`,
1767 `application-token`.`code` AS `code`,
1768 `application-token`.`access_token` AS `access_token`,
1769 `application-token`.`created_at` AS `created_at`,
1770 `application-token`.`scopes` AS `scopes`,
1771 `application-token`.`read` AS `read`,
1772 `application-token`.`write` AS `write`,
1773 `application-token`.`follow` AS `follow`,
1774 `application-token`.`push` AS `push`
1775 FROM `application-token`
1776 INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`;
1779 -- VIEW post-user-view
1781 DROP VIEW IF EXISTS `post-user-view`;
1782 CREATE VIEW `post-user-view` AS SELECT
1783 `post-user`.`id` AS `id`,
1784 `post-user`.`id` AS `post-user-id`,
1785 `post-user`.`uid` AS `uid`,
1786 `parent-post`.`id` AS `parent`,
1787 `item-uri`.`uri` AS `uri`,
1788 `post-user`.`uri-id` AS `uri-id`,
1789 `parent-item-uri`.`uri` AS `parent-uri`,
1790 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1791 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1792 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1793 `conversation-item-uri`.`uri` AS `conversation`,
1794 `post-thread-user`.`conversation-id` AS `conversation-id`,
1795 `item-uri`.`guid` AS `guid`,
1796 `post-user`.`wall` AS `wall`,
1797 `post-user`.`gravity` AS `gravity`,
1798 `external-item-uri`.`uri` AS `extid`,
1799 `post-user`.`external-id` AS `external-id`,
1800 `post-user`.`created` AS `created`,
1801 `post-user`.`edited` AS `edited`,
1802 `post-thread-user`.`commented` AS `commented`,
1803 `post-user`.`received` AS `received`,
1804 `post-thread-user`.`changed` AS `changed`,
1805 `post-user`.`post-type` AS `post-type`,
1806 `post-user`.`post-reason` AS `post-reason`,
1807 `post-user`.`private` AS `private`,
1808 `post-thread-user`.`pubmail` AS `pubmail`,
1809 `post-user`.`visible` AS `visible`,
1810 `post-thread-user`.`starred` AS `starred`,
1811 `post-user`.`unseen` AS `unseen`,
1812 `post-user`.`deleted` AS `deleted`,
1813 `post-user`.`origin` AS `origin`,
1814 `post-thread-user`.`origin` AS `parent-origin`,
1815 `post-thread-user`.`mention` AS `mention`,
1816 `post-user`.`global` AS `global`,
1817 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-user`.`uri-id`) AS `featured`,
1818 `post-user`.`network` AS `network`,
1819 `post-user`.`protocol` AS `protocol`,
1820 `post-user`.`vid` AS `vid`,
1821 `post-user`.`psid` AS `psid`,
1822 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1823 `post-content`.`title` AS `title`,
1824 `post-content`.`content-warning` AS `content-warning`,
1825 `post-content`.`raw-body` AS `raw-body`,
1826 IFNULL (`post-content`.`body`, '') AS `body`,
1827 `post-content`.`rendered-hash` AS `rendered-hash`,
1828 `post-content`.`rendered-html` AS `rendered-html`,
1829 `post-content`.`language` AS `language`,
1830 `post-content`.`plink` AS `plink`,
1831 `post-content`.`location` AS `location`,
1832 `post-content`.`coord` AS `coord`,
1833 `post-content`.`app` AS `app`,
1834 `post-content`.`object-type` AS `object-type`,
1835 `post-content`.`object` AS `object`,
1836 `post-content`.`target-type` AS `target-type`,
1837 `post-content`.`target` AS `target`,
1838 `post-content`.`resource-id` AS `resource-id`,
1839 `post-user`.`contact-id` AS `contact-id`,
1840 `contact`.`uri-id` AS `contact-uri-id`,
1841 `contact`.`url` AS `contact-link`,
1842 `contact`.`addr` AS `contact-addr`,
1843 `contact`.`name` AS `contact-name`,
1844 `contact`.`nick` AS `contact-nick`,
1845 `contact`.`thumb` AS `contact-avatar`,
1846 `contact`.`network` AS `contact-network`,
1847 `contact`.`blocked` AS `contact-blocked`,
1848 `contact`.`hidden` AS `contact-hidden`,
1849 `contact`.`readonly` AS `contact-readonly`,
1850 `contact`.`archive` AS `contact-archive`,
1851 `contact`.`pending` AS `contact-pending`,
1852 `contact`.`rel` AS `contact-rel`,
1853 `contact`.`uid` AS `contact-uid`,
1854 `contact`.`contact-type` AS `contact-contact-type`,
1855 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1856 `contact`.`self` AS `self`,
1857 `contact`.`id` AS `cid`,
1858 `contact`.`alias` AS `alias`,
1859 `contact`.`photo` AS `photo`,
1860 `contact`.`name-date` AS `name-date`,
1861 `contact`.`uri-date` AS `uri-date`,
1862 `contact`.`avatar-date` AS `avatar-date`,
1863 `contact`.`thumb` AS `thumb`,
1864 `post-user`.`author-id` AS `author-id`,
1865 `author`.`uri-id` AS `author-uri-id`,
1866 `author`.`url` AS `author-link`,
1867 `author`.`addr` AS `author-addr`,
1868 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1869 `author`.`nick` AS `author-nick`,
1870 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1871 `author`.`network` AS `author-network`,
1872 `author`.`blocked` AS `author-blocked`,
1873 `author`.`hidden` AS `author-hidden`,
1874 `author`.`updated` AS `author-updated`,
1875 `author`.`gsid` AS `author-gsid`,
1876 `post-user`.`owner-id` AS `owner-id`,
1877 `owner`.`uri-id` AS `owner-uri-id`,
1878 `owner`.`url` AS `owner-link`,
1879 `owner`.`addr` AS `owner-addr`,
1880 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1881 `owner`.`nick` AS `owner-nick`,
1882 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1883 `owner`.`network` AS `owner-network`,
1884 `owner`.`blocked` AS `owner-blocked`,
1885 `owner`.`hidden` AS `owner-hidden`,
1886 `owner`.`updated` AS `owner-updated`,
1887 `owner`.`contact-type` AS `owner-contact-type`,
1888 `post-user`.`causer-id` AS `causer-id`,
1889 `causer`.`uri-id` AS `causer-uri-id`,
1890 `causer`.`url` AS `causer-link`,
1891 `causer`.`addr` AS `causer-addr`,
1892 `causer`.`name` AS `causer-name`,
1893 `causer`.`nick` AS `causer-nick`,
1894 `causer`.`thumb` AS `causer-avatar`,
1895 `causer`.`network` AS `causer-network`,
1896 `causer`.`blocked` AS `causer-blocked`,
1897 `causer`.`hidden` AS `causer-hidden`,
1898 `causer`.`contact-type` AS `causer-contact-type`,
1899 `post-delivery-data`.`postopts` AS `postopts`,
1900 `post-delivery-data`.`inform` AS `inform`,
1901 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1902 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1903 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1904 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1905 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1906 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1907 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1908 `post-user`.`event-id` AS `event-id`,
1909 `event`.`created` AS `event-created`,
1910 `event`.`edited` AS `event-edited`,
1911 `event`.`start` AS `event-start`,
1912 `event`.`finish` AS `event-finish`,
1913 `event`.`summary` AS `event-summary`,
1914 `event`.`desc` AS `event-desc`,
1915 `event`.`location` AS `event-location`,
1916 `event`.`type` AS `event-type`,
1917 `event`.`nofinish` AS `event-nofinish`,
1918 `event`.`ignore` AS `event-ignore`,
1919 `post-question`.`id` AS `question-id`,
1920 `post-question`.`multiple` AS `question-multiple`,
1921 `post-question`.`voters` AS `question-voters`,
1922 `post-question`.`end-time` AS `question-end-time`,
1923 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`,
1924 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-user`.`uri-id`) AS `has-media`,
1925 `diaspora-interaction`.`interaction` AS `signed_text`,
1926 `parent-item-uri`.`guid` AS `parent-guid`,
1927 `parent-post`.`network` AS `parent-network`,
1928 `parent-post`.`author-id` AS `parent-author-id`,
1929 `parent-post-author`.`url` AS `parent-author-link`,
1930 `parent-post-author`.`name` AS `parent-author-name`,
1931 `parent-post-author`.`nick` AS `parent-author-nick`,
1932 `parent-post-author`.`network` AS `parent-author-network`,
1933 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1934 `parent-post-author`.`hidden` AS `parent-author-hidden`
1936 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
1937 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
1938 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
1939 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
1940 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
1941 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
1942 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1943 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1944 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
1945 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1946 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1947 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1948 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
1949 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
1950 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
1951 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-user`.`uri-id`
1952 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
1953 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
1954 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1957 -- VIEW post-thread-user-view
1959 DROP VIEW IF EXISTS `post-thread-user-view`;
1960 CREATE VIEW `post-thread-user-view` AS SELECT
1961 `post-user`.`id` AS `id`,
1962 `post-user`.`id` AS `post-user-id`,
1963 `post-thread-user`.`uid` AS `uid`,
1964 `parent-post`.`id` AS `parent`,
1965 `item-uri`.`uri` AS `uri`,
1966 `post-thread-user`.`uri-id` AS `uri-id`,
1967 `parent-item-uri`.`uri` AS `parent-uri`,
1968 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1969 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1970 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1971 `conversation-item-uri`.`uri` AS `conversation`,
1972 `post-thread-user`.`conversation-id` AS `conversation-id`,
1973 `item-uri`.`guid` AS `guid`,
1974 `post-thread-user`.`wall` AS `wall`,
1975 `post-user`.`gravity` AS `gravity`,
1976 `external-item-uri`.`uri` AS `extid`,
1977 `post-user`.`external-id` AS `external-id`,
1978 `post-thread-user`.`created` AS `created`,
1979 `post-user`.`edited` AS `edited`,
1980 `post-thread-user`.`commented` AS `commented`,
1981 `post-thread-user`.`received` AS `received`,
1982 `post-thread-user`.`changed` AS `changed`,
1983 `post-user`.`post-type` AS `post-type`,
1984 `post-user`.`post-reason` AS `post-reason`,
1985 `post-user`.`private` AS `private`,
1986 `post-thread-user`.`pubmail` AS `pubmail`,
1987 `post-thread-user`.`ignored` AS `ignored`,
1988 `post-user`.`visible` AS `visible`,
1989 `post-thread-user`.`starred` AS `starred`,
1990 `post-thread-user`.`unseen` AS `unseen`,
1991 `post-user`.`deleted` AS `deleted`,
1992 `post-thread-user`.`origin` AS `origin`,
1993 `post-thread-user`.`mention` AS `mention`,
1994 `post-user`.`global` AS `global`,
1995 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread-user`.`uri-id`) AS `featured`,
1996 `post-thread-user`.`network` AS `network`,
1997 `post-user`.`vid` AS `vid`,
1998 `post-thread-user`.`psid` AS `psid`,
1999 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2000 `post-content`.`title` AS `title`,
2001 `post-content`.`content-warning` AS `content-warning`,
2002 `post-content`.`raw-body` AS `raw-body`,
2003 `post-content`.`body` AS `body`,
2004 `post-content`.`rendered-hash` AS `rendered-hash`,
2005 `post-content`.`rendered-html` AS `rendered-html`,
2006 `post-content`.`language` AS `language`,
2007 `post-content`.`plink` AS `plink`,
2008 `post-content`.`location` AS `location`,
2009 `post-content`.`coord` AS `coord`,
2010 `post-content`.`app` AS `app`,
2011 `post-content`.`object-type` AS `object-type`,
2012 `post-content`.`object` AS `object`,
2013 `post-content`.`target-type` AS `target-type`,
2014 `post-content`.`target` AS `target`,
2015 `post-content`.`resource-id` AS `resource-id`,
2016 `post-thread-user`.`contact-id` AS `contact-id`,
2017 `contact`.`uri-id` AS `contact-uri-id`,
2018 `contact`.`url` AS `contact-link`,
2019 `contact`.`addr` AS `contact-addr`,
2020 `contact`.`name` AS `contact-name`,
2021 `contact`.`nick` AS `contact-nick`,
2022 `contact`.`thumb` AS `contact-avatar`,
2023 `contact`.`network` AS `contact-network`,
2024 `contact`.`blocked` AS `contact-blocked`,
2025 `contact`.`hidden` AS `contact-hidden`,
2026 `contact`.`readonly` AS `contact-readonly`,
2027 `contact`.`archive` AS `contact-archive`,
2028 `contact`.`pending` AS `contact-pending`,
2029 `contact`.`rel` AS `contact-rel`,
2030 `contact`.`uid` AS `contact-uid`,
2031 `contact`.`contact-type` AS `contact-contact-type`,
2032 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
2033 `contact`.`self` AS `self`,
2034 `contact`.`id` AS `cid`,
2035 `contact`.`alias` AS `alias`,
2036 `contact`.`photo` AS `photo`,
2037 `contact`.`name-date` AS `name-date`,
2038 `contact`.`uri-date` AS `uri-date`,
2039 `contact`.`avatar-date` AS `avatar-date`,
2040 `contact`.`thumb` AS `thumb`,
2041 `post-thread-user`.`author-id` AS `author-id`,
2042 `author`.`uri-id` AS `author-uri-id`,
2043 `author`.`url` AS `author-link`,
2044 `author`.`addr` AS `author-addr`,
2045 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
2046 `author`.`nick` AS `author-nick`,
2047 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
2048 `author`.`network` AS `author-network`,
2049 `author`.`blocked` AS `author-blocked`,
2050 `author`.`hidden` AS `author-hidden`,
2051 `author`.`updated` AS `author-updated`,
2052 `author`.`gsid` AS `author-gsid`,
2053 `post-thread-user`.`owner-id` AS `owner-id`,
2054 `owner`.`uri-id` AS `owner-uri-id`,
2055 `owner`.`url` AS `owner-link`,
2056 `owner`.`addr` AS `owner-addr`,
2057 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
2058 `owner`.`nick` AS `owner-nick`,
2059 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
2060 `owner`.`network` AS `owner-network`,
2061 `owner`.`blocked` AS `owner-blocked`,
2062 `owner`.`hidden` AS `owner-hidden`,
2063 `owner`.`updated` AS `owner-updated`,
2064 `owner`.`contact-type` AS `owner-contact-type`,
2065 `post-thread-user`.`causer-id` AS `causer-id`,
2066 `causer`.`uri-id` AS `causer-uri-id`,
2067 `causer`.`url` AS `causer-link`,
2068 `causer`.`addr` AS `causer-addr`,
2069 `causer`.`name` AS `causer-name`,
2070 `causer`.`nick` AS `causer-nick`,
2071 `causer`.`thumb` AS `causer-avatar`,
2072 `causer`.`network` AS `causer-network`,
2073 `causer`.`blocked` AS `causer-blocked`,
2074 `causer`.`hidden` AS `causer-hidden`,
2075 `causer`.`contact-type` AS `causer-contact-type`,
2076 `post-delivery-data`.`postopts` AS `postopts`,
2077 `post-delivery-data`.`inform` AS `inform`,
2078 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
2079 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
2080 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
2081 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
2082 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
2083 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
2084 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
2085 `post-user`.`event-id` AS `event-id`,
2086 `event`.`created` AS `event-created`,
2087 `event`.`edited` AS `event-edited`,
2088 `event`.`start` AS `event-start`,
2089 `event`.`finish` AS `event-finish`,
2090 `event`.`summary` AS `event-summary`,
2091 `event`.`desc` AS `event-desc`,
2092 `event`.`location` AS `event-location`,
2093 `event`.`type` AS `event-type`,
2094 `event`.`nofinish` AS `event-nofinish`,
2095 `event`.`ignore` AS `event-ignore`,
2096 `post-question`.`id` AS `question-id`,
2097 `post-question`.`multiple` AS `question-multiple`,
2098 `post-question`.`voters` AS `question-voters`,
2099 `post-question`.`end-time` AS `question-end-time`,
2100 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`,
2101 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread-user`.`uri-id`) AS `has-media`,
2102 `diaspora-interaction`.`interaction` AS `signed_text`,
2103 `parent-item-uri`.`guid` AS `parent-guid`,
2104 `parent-post`.`network` AS `parent-network`,
2105 `parent-post`.`author-id` AS `parent-author-id`,
2106 `parent-post-author`.`url` AS `parent-author-link`,
2107 `parent-post-author`.`name` AS `parent-author-name`,
2108 `parent-post-author`.`network` AS `parent-author-network`,
2109 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2110 `parent-post-author`.`hidden` AS `parent-author-hidden`
2111 FROM `post-thread-user`
2112 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2113 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2114 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
2115 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
2116 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
2117 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
2118 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
2119 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
2120 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
2121 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
2122 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
2123 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
2124 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
2125 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
2126 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
2127 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread-user`.`uri-id`
2128 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
2129 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`
2130 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2135 DROP VIEW IF EXISTS `post-view`;
2136 CREATE VIEW `post-view` AS SELECT
2137 `item-uri`.`uri` AS `uri`,
2138 `post`.`uri-id` AS `uri-id`,
2139 `parent-item-uri`.`uri` AS `parent-uri`,
2140 `post`.`parent-uri-id` AS `parent-uri-id`,
2141 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2142 `post`.`thr-parent-id` AS `thr-parent-id`,
2143 `conversation-item-uri`.`uri` AS `conversation`,
2144 `post-thread`.`conversation-id` AS `conversation-id`,
2145 `item-uri`.`guid` AS `guid`,
2146 `post`.`gravity` AS `gravity`,
2147 `external-item-uri`.`uri` AS `extid`,
2148 `post`.`external-id` AS `external-id`,
2149 `post`.`created` AS `created`,
2150 `post`.`edited` AS `edited`,
2151 `post-thread`.`commented` AS `commented`,
2152 `post`.`received` AS `received`,
2153 `post-thread`.`changed` AS `changed`,
2154 `post`.`post-type` AS `post-type`,
2155 `post`.`private` AS `private`,
2156 `post`.`visible` AS `visible`,
2157 `post`.`deleted` AS `deleted`,
2158 `post`.`global` AS `global`,
2159 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post`.`uri-id`) AS `featured`,
2160 `post`.`network` AS `network`,
2161 `post`.`vid` AS `vid`,
2162 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2163 `post-content`.`title` AS `title`,
2164 `post-content`.`content-warning` AS `content-warning`,
2165 `post-content`.`raw-body` AS `raw-body`,
2166 `post-content`.`body` AS `body`,
2167 `post-content`.`rendered-hash` AS `rendered-hash`,
2168 `post-content`.`rendered-html` AS `rendered-html`,
2169 `post-content`.`language` AS `language`,
2170 `post-content`.`plink` AS `plink`,
2171 `post-content`.`location` AS `location`,
2172 `post-content`.`coord` AS `coord`,
2173 `post-content`.`app` AS `app`,
2174 `post-content`.`object-type` AS `object-type`,
2175 `post-content`.`object` AS `object`,
2176 `post-content`.`target-type` AS `target-type`,
2177 `post-content`.`target` AS `target`,
2178 `post-content`.`resource-id` AS `resource-id`,
2179 `post`.`author-id` AS `contact-id`,
2180 `author`.`uri-id` AS `contact-uri-id`,
2181 `author`.`url` AS `contact-link`,
2182 `author`.`addr` AS `contact-addr`,
2183 `author`.`name` AS `contact-name`,
2184 `author`.`nick` AS `contact-nick`,
2185 `author`.`thumb` AS `contact-avatar`,
2186 `author`.`network` AS `contact-network`,
2187 `author`.`blocked` AS `contact-blocked`,
2188 `author`.`hidden` AS `contact-hidden`,
2189 `author`.`readonly` AS `contact-readonly`,
2190 `author`.`archive` AS `contact-archive`,
2191 `author`.`pending` AS `contact-pending`,
2192 `author`.`rel` AS `contact-rel`,
2193 `author`.`uid` AS `contact-uid`,
2194 `author`.`contact-type` AS `contact-contact-type`,
2195 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2197 `author`.`id` AS `cid`,
2198 `author`.`alias` AS `alias`,
2199 `author`.`photo` AS `photo`,
2200 `author`.`name-date` AS `name-date`,
2201 `author`.`uri-date` AS `uri-date`,
2202 `author`.`avatar-date` AS `avatar-date`,
2203 `author`.`thumb` AS `thumb`,
2204 `post`.`author-id` AS `author-id`,
2205 `author`.`uri-id` AS `author-uri-id`,
2206 `author`.`url` AS `author-link`,
2207 `author`.`addr` AS `author-addr`,
2208 `author`.`name` AS `author-name`,
2209 `author`.`nick` AS `author-nick`,
2210 `author`.`thumb` AS `author-avatar`,
2211 `author`.`network` AS `author-network`,
2212 `author`.`blocked` AS `author-blocked`,
2213 `author`.`hidden` AS `author-hidden`,
2214 `author`.`updated` AS `author-updated`,
2215 `author`.`gsid` AS `author-gsid`,
2216 `post`.`owner-id` AS `owner-id`,
2217 `owner`.`uri-id` AS `owner-uri-id`,
2218 `owner`.`url` AS `owner-link`,
2219 `owner`.`addr` AS `owner-addr`,
2220 `owner`.`name` AS `owner-name`,
2221 `owner`.`nick` AS `owner-nick`,
2222 `owner`.`thumb` AS `owner-avatar`,
2223 `owner`.`network` AS `owner-network`,
2224 `owner`.`blocked` AS `owner-blocked`,
2225 `owner`.`hidden` AS `owner-hidden`,
2226 `owner`.`updated` AS `owner-updated`,
2227 `owner`.`contact-type` AS `owner-contact-type`,
2228 `post`.`causer-id` AS `causer-id`,
2229 `causer`.`uri-id` AS `causer-uri-id`,
2230 `causer`.`url` AS `causer-link`,
2231 `causer`.`addr` AS `causer-addr`,
2232 `causer`.`name` AS `causer-name`,
2233 `causer`.`nick` AS `causer-nick`,
2234 `causer`.`thumb` AS `causer-avatar`,
2235 `causer`.`network` AS `causer-network`,
2236 `causer`.`blocked` AS `causer-blocked`,
2237 `causer`.`hidden` AS `causer-hidden`,
2238 `causer`.`contact-type` AS `causer-contact-type`,
2239 `post-question`.`id` AS `question-id`,
2240 `post-question`.`multiple` AS `question-multiple`,
2241 `post-question`.`voters` AS `question-voters`,
2242 `post-question`.`end-time` AS `question-end-time`,
2243 0 AS `has-categories`,
2244 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post`.`uri-id`) AS `has-media`,
2245 `diaspora-interaction`.`interaction` AS `signed_text`,
2246 `parent-item-uri`.`guid` AS `parent-guid`,
2247 `parent-post`.`network` AS `parent-network`,
2248 `parent-post`.`author-id` AS `parent-author-id`,
2249 `parent-post-author`.`url` AS `parent-author-link`,
2250 `parent-post-author`.`name` AS `parent-author-name`,
2251 `parent-post-author`.`network` AS `parent-author-network`,
2252 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2253 `parent-post-author`.`hidden` AS `parent-author-hidden`
2255 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
2256 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
2257 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
2258 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
2259 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
2260 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2261 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2262 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
2263 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2264 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2265 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
2266 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
2267 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post`.`uri-id`
2268 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2269 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2272 -- VIEW post-thread-view
2274 DROP VIEW IF EXISTS `post-thread-view`;
2275 CREATE VIEW `post-thread-view` AS SELECT
2276 `item-uri`.`uri` AS `uri`,
2277 `post-thread`.`uri-id` AS `uri-id`,
2278 `parent-item-uri`.`uri` AS `parent-uri`,
2279 `post`.`parent-uri-id` AS `parent-uri-id`,
2280 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2281 `post`.`thr-parent-id` AS `thr-parent-id`,
2282 `conversation-item-uri`.`uri` AS `conversation`,
2283 `post-thread`.`conversation-id` AS `conversation-id`,
2284 `item-uri`.`guid` AS `guid`,
2285 `post`.`gravity` AS `gravity`,
2286 `external-item-uri`.`uri` AS `extid`,
2287 `post`.`external-id` AS `external-id`,
2288 `post-thread`.`created` AS `created`,
2289 `post`.`edited` AS `edited`,
2290 `post-thread`.`commented` AS `commented`,
2291 `post-thread`.`received` AS `received`,
2292 `post-thread`.`changed` AS `changed`,
2293 `post`.`post-type` AS `post-type`,
2294 `post`.`private` AS `private`,
2295 `post`.`visible` AS `visible`,
2296 `post`.`deleted` AS `deleted`,
2297 `post`.`global` AS `global`,
2298 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread`.`uri-id`) AS `featured`,
2299 `post-thread`.`network` AS `network`,
2300 `post`.`vid` AS `vid`,
2301 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2302 `post-content`.`title` AS `title`,
2303 `post-content`.`content-warning` AS `content-warning`,
2304 `post-content`.`raw-body` AS `raw-body`,
2305 `post-content`.`body` AS `body`,
2306 `post-content`.`rendered-hash` AS `rendered-hash`,
2307 `post-content`.`rendered-html` AS `rendered-html`,
2308 `post-content`.`language` AS `language`,
2309 `post-content`.`plink` AS `plink`,
2310 `post-content`.`location` AS `location`,
2311 `post-content`.`coord` AS `coord`,
2312 `post-content`.`app` AS `app`,
2313 `post-content`.`object-type` AS `object-type`,
2314 `post-content`.`object` AS `object`,
2315 `post-content`.`target-type` AS `target-type`,
2316 `post-content`.`target` AS `target`,
2317 `post-content`.`resource-id` AS `resource-id`,
2318 `post-thread`.`author-id` AS `contact-id`,
2319 `author`.`uri-id` AS `contact-uri-id`,
2320 `author`.`url` AS `contact-link`,
2321 `author`.`addr` AS `contact-addr`,
2322 `author`.`name` AS `contact-name`,
2323 `author`.`nick` AS `contact-nick`,
2324 `author`.`thumb` AS `contact-avatar`,
2325 `author`.`network` AS `contact-network`,
2326 `author`.`blocked` AS `contact-blocked`,
2327 `author`.`hidden` AS `contact-hidden`,
2328 `author`.`readonly` AS `contact-readonly`,
2329 `author`.`archive` AS `contact-archive`,
2330 `author`.`pending` AS `contact-pending`,
2331 `author`.`rel` AS `contact-rel`,
2332 `author`.`uid` AS `contact-uid`,
2333 `author`.`contact-type` AS `contact-contact-type`,
2334 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2336 `author`.`id` AS `cid`,
2337 `author`.`alias` AS `alias`,
2338 `author`.`photo` AS `photo`,
2339 `author`.`name-date` AS `name-date`,
2340 `author`.`uri-date` AS `uri-date`,
2341 `author`.`avatar-date` AS `avatar-date`,
2342 `author`.`thumb` AS `thumb`,
2343 `post-thread`.`author-id` AS `author-id`,
2344 `author`.`uri-id` AS `author-uri-id`,
2345 `author`.`url` AS `author-link`,
2346 `author`.`addr` AS `author-addr`,
2347 `author`.`name` AS `author-name`,
2348 `author`.`nick` AS `author-nick`,
2349 `author`.`thumb` AS `author-avatar`,
2350 `author`.`network` AS `author-network`,
2351 `author`.`blocked` AS `author-blocked`,
2352 `author`.`hidden` AS `author-hidden`,
2353 `author`.`updated` AS `author-updated`,
2354 `author`.`gsid` AS `author-gsid`,
2355 `post-thread`.`owner-id` AS `owner-id`,
2356 `owner`.`uri-id` AS `owner-uri-id`,
2357 `owner`.`url` AS `owner-link`,
2358 `owner`.`addr` AS `owner-addr`,
2359 `owner`.`name` AS `owner-name`,
2360 `owner`.`nick` AS `owner-nick`,
2361 `owner`.`thumb` AS `owner-avatar`,
2362 `owner`.`network` AS `owner-network`,
2363 `owner`.`blocked` AS `owner-blocked`,
2364 `owner`.`hidden` AS `owner-hidden`,
2365 `owner`.`updated` AS `owner-updated`,
2366 `owner`.`contact-type` AS `owner-contact-type`,
2367 `post-thread`.`causer-id` AS `causer-id`,
2368 `causer`.`uri-id` AS `causer-uri-id`,
2369 `causer`.`url` AS `causer-link`,
2370 `causer`.`addr` AS `causer-addr`,
2371 `causer`.`name` AS `causer-name`,
2372 `causer`.`nick` AS `causer-nick`,
2373 `causer`.`thumb` AS `causer-avatar`,
2374 `causer`.`network` AS `causer-network`,
2375 `causer`.`blocked` AS `causer-blocked`,
2376 `causer`.`hidden` AS `causer-hidden`,
2377 `causer`.`contact-type` AS `causer-contact-type`,
2378 `post-question`.`id` AS `question-id`,
2379 `post-question`.`multiple` AS `question-multiple`,
2380 `post-question`.`voters` AS `question-voters`,
2381 `post-question`.`end-time` AS `question-end-time`,
2382 0 AS `has-categories`,
2383 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread`.`uri-id`) AS `has-media`,
2384 `diaspora-interaction`.`interaction` AS `signed_text`,
2385 `parent-item-uri`.`guid` AS `parent-guid`,
2386 `parent-post`.`network` AS `parent-network`,
2387 `parent-post`.`author-id` AS `parent-author-id`,
2388 `parent-post-author`.`url` AS `parent-author-link`,
2389 `parent-post-author`.`name` AS `parent-author-name`,
2390 `parent-post-author`.`network` AS `parent-author-network`,
2391 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2392 `parent-post-author`.`hidden` AS `parent-author-hidden`
2394 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
2395 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
2396 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
2397 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
2398 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
2399 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2400 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2401 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
2402 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2403 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2404 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
2405 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
2406 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread`.`uri-id`
2407 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2408 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2411 -- VIEW category-view
2413 DROP VIEW IF EXISTS `category-view`;
2414 CREATE VIEW `category-view` AS SELECT
2415 `post-category`.`uri-id` AS `uri-id`,
2416 `post-category`.`uid` AS `uid`,
2417 `post-category`.`type` AS `type`,
2418 `post-category`.`tid` AS `tid`,
2419 `tag`.`name` AS `name`,
2420 `tag`.`url` AS `url`
2421 FROM `post-category`
2422 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2425 -- VIEW collection-view
2427 DROP VIEW IF EXISTS `collection-view`;
2428 CREATE VIEW `collection-view` AS SELECT
2429 `post-collection`.`uri-id` AS `uri-id`,
2430 `post-collection`.`type` AS `type`,
2431 `post-collection`.`author-id` AS `cid`,
2432 `post`.`received` AS `received`,
2433 `post`.`created` AS `created`,
2434 `post-thread`.`commented` AS `commented`,
2435 `post`.`private` AS `private`,
2436 `post`.`visible` AS `visible`,
2437 `post`.`deleted` AS `deleted`,
2438 `post`.`thr-parent-id` AS `thr-parent-id`,
2439 `post-collection`.`author-id` AS `author-id`,
2440 `post`.`gravity` AS `gravity`
2441 FROM `post-collection`
2442 INNER JOIN `post` ON `post-collection`.`uri-id` = `post`.`uri-id`
2443 INNER JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`;
2448 DROP VIEW IF EXISTS `tag-view`;
2449 CREATE VIEW `tag-view` AS SELECT
2450 `post-tag`.`uri-id` AS `uri-id`,
2451 `post-tag`.`type` AS `type`,
2452 `post-tag`.`tid` AS `tid`,
2453 `post-tag`.`cid` AS `cid`,
2454 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2455 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`,
2456 CASE `cid` WHEN 0 THEN `tag`.`type` ELSE 1 END AS `tag-type`
2458 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2459 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2462 -- VIEW network-item-view
2464 DROP VIEW IF EXISTS `network-item-view`;
2465 CREATE VIEW `network-item-view` AS SELECT
2466 `post-user`.`uri-id` AS `uri-id`,
2467 `parent-post`.`id` AS `parent`,
2468 `post-user`.`received` AS `received`,
2469 `post-thread-user`.`commented` AS `commented`,
2470 `post-user`.`created` AS `created`,
2471 `post-user`.`uid` AS `uid`,
2472 `post-thread-user`.`starred` AS `starred`,
2473 `post-thread-user`.`mention` AS `mention`,
2474 `post-user`.`network` AS `network`,
2475 `post-user`.`unseen` AS `unseen`,
2476 `post-user`.`gravity` AS `gravity`,
2477 `post-user`.`contact-id` AS `contact-id`,
2478 `ownercontact`.`contact-type` AS `contact-type`
2480 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2481 INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2482 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2483 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2484 INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2485 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2486 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2487 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2488 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
2489 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2490 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2493 -- VIEW network-thread-view
2495 DROP VIEW IF EXISTS `network-thread-view`;
2496 CREATE VIEW `network-thread-view` AS SELECT
2497 `post-thread-user`.`uri-id` AS `uri-id`,
2498 `parent-post`.`id` AS `parent`,
2499 `post-thread-user`.`received` AS `received`,
2500 `post-thread-user`.`commented` AS `commented`,
2501 `post-thread-user`.`created` AS `created`,
2502 `post-thread-user`.`uid` AS `uid`,
2503 `post-thread-user`.`starred` AS `starred`,
2504 `post-thread-user`.`mention` AS `mention`,
2505 `post-thread-user`.`network` AS `network`,
2506 `post-thread-user`.`contact-id` AS `contact-id`,
2507 `ownercontact`.`contact-type` AS `contact-type`
2508 FROM `post-thread-user`
2509 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2510 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2511 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2512 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2513 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2514 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2515 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2516 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2517 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2518 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2519 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2524 DROP VIEW IF EXISTS `owner-view`;
2525 CREATE VIEW `owner-view` AS SELECT
2526 `contact`.`id` AS `id`,
2527 `contact`.`uid` AS `uid`,
2528 `contact`.`created` AS `created`,
2529 `contact`.`updated` AS `updated`,
2530 `contact`.`self` AS `self`,
2531 `contact`.`remote_self` AS `remote_self`,
2532 `contact`.`rel` AS `rel`,
2533 `contact`.`network` AS `network`,
2534 `contact`.`protocol` AS `protocol`,
2535 `contact`.`name` AS `name`,
2536 `contact`.`nick` AS `nick`,
2537 `contact`.`location` AS `location`,
2538 `contact`.`about` AS `about`,
2539 `contact`.`keywords` AS `keywords`,
2540 `contact`.`xmpp` AS `xmpp`,
2541 `contact`.`matrix` AS `matrix`,
2542 `contact`.`attag` AS `attag`,
2543 `contact`.`avatar` AS `avatar`,
2544 `contact`.`photo` AS `photo`,
2545 `contact`.`thumb` AS `thumb`,
2546 `contact`.`micro` AS `micro`,
2547 `contact`.`header` AS `header`,
2548 `contact`.`url` AS `url`,
2549 `contact`.`nurl` AS `nurl`,
2550 `contact`.`uri-id` AS `uri-id`,
2551 `contact`.`addr` AS `addr`,
2552 `contact`.`alias` AS `alias`,
2553 `contact`.`pubkey` AS `pubkey`,
2554 `contact`.`prvkey` AS `prvkey`,
2555 `contact`.`batch` AS `batch`,
2556 `contact`.`request` AS `request`,
2557 `contact`.`notify` AS `notify`,
2558 `contact`.`poll` AS `poll`,
2559 `contact`.`confirm` AS `confirm`,
2560 `contact`.`poco` AS `poco`,
2561 `contact`.`subhub` AS `subhub`,
2562 `contact`.`hub-verify` AS `hub-verify`,
2563 `contact`.`last-update` AS `last-update`,
2564 `contact`.`success_update` AS `success_update`,
2565 `contact`.`failure_update` AS `failure_update`,
2566 `contact`.`name-date` AS `name-date`,
2567 `contact`.`uri-date` AS `uri-date`,
2568 `contact`.`avatar-date` AS `avatar-date`,
2569 `contact`.`avatar-date` AS `picdate`,
2570 `contact`.`term-date` AS `term-date`,
2571 `contact`.`last-item` AS `last-item`,
2572 `contact`.`priority` AS `priority`,
2573 `user`.`blocked` AS `blocked`,
2574 `contact`.`block_reason` AS `block_reason`,
2575 `contact`.`readonly` AS `readonly`,
2576 `contact`.`writable` AS `writable`,
2577 `contact`.`forum` AS `forum`,
2578 `contact`.`prv` AS `prv`,
2579 `contact`.`contact-type` AS `contact-type`,
2580 `contact`.`manually-approve` AS `manually-approve`,
2581 `contact`.`hidden` AS `hidden`,
2582 `contact`.`archive` AS `archive`,
2583 `contact`.`pending` AS `pending`,
2584 `contact`.`deleted` AS `deleted`,
2585 `contact`.`unsearchable` AS `unsearchable`,
2586 `contact`.`sensitive` AS `sensitive`,
2587 `contact`.`baseurl` AS `baseurl`,
2588 `contact`.`reason` AS `reason`,
2589 `contact`.`info` AS `info`,
2590 `contact`.`bdyear` AS `bdyear`,
2591 `contact`.`bd` AS `bd`,
2592 `contact`.`notify_new_posts` AS `notify_new_posts`,
2593 `contact`.`fetch_further_information` AS `fetch_further_information`,
2594 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2595 `user`.`parent-uid` AS `parent-uid`,
2596 `user`.`guid` AS `guid`,
2597 `user`.`nickname` AS `nickname`,
2598 `user`.`email` AS `email`,
2599 `user`.`openid` AS `openid`,
2600 `user`.`timezone` AS `timezone`,
2601 `user`.`language` AS `language`,
2602 `user`.`register_date` AS `register_date`,
2603 `user`.`login_date` AS `login_date`,
2604 `user`.`default-location` AS `default-location`,
2605 `user`.`allow_location` AS `allow_location`,
2606 `user`.`theme` AS `theme`,
2607 `user`.`pubkey` AS `upubkey`,
2608 `user`.`prvkey` AS `uprvkey`,
2609 `user`.`sprvkey` AS `sprvkey`,
2610 `user`.`spubkey` AS `spubkey`,
2611 `user`.`verified` AS `verified`,
2612 `user`.`blockwall` AS `blockwall`,
2613 `user`.`hidewall` AS `hidewall`,
2614 `user`.`blocktags` AS `blocktags`,
2615 `user`.`unkmail` AS `unkmail`,
2616 `user`.`cntunkmail` AS `cntunkmail`,
2617 `user`.`notify-flags` AS `notify-flags`,
2618 `user`.`page-flags` AS `page-flags`,
2619 `user`.`account-type` AS `account-type`,
2620 `user`.`prvnets` AS `prvnets`,
2621 `user`.`maxreq` AS `maxreq`,
2622 `user`.`expire` AS `expire`,
2623 `user`.`account_removed` AS `account_removed`,
2624 `user`.`account_expired` AS `account_expired`,
2625 `user`.`account_expires_on` AS `account_expires_on`,
2626 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2627 `user`.`def_gid` AS `def_gid`,
2628 `user`.`allow_cid` AS `allow_cid`,
2629 `user`.`allow_gid` AS `allow_gid`,
2630 `user`.`deny_cid` AS `deny_cid`,
2631 `user`.`deny_gid` AS `deny_gid`,
2632 `user`.`openidserver` AS `openidserver`,
2633 `profile`.`publish` AS `publish`,
2634 `profile`.`net-publish` AS `net-publish`,
2635 `profile`.`hide-friends` AS `hide-friends`,
2636 `profile`.`prv_keywords` AS `prv_keywords`,
2637 `profile`.`pub_keywords` AS `pub_keywords`,
2638 `profile`.`address` AS `address`,
2639 `profile`.`locality` AS `locality`,
2640 `profile`.`region` AS `region`,
2641 `profile`.`postal-code` AS `postal-code`,
2642 `profile`.`country-name` AS `country-name`,
2643 `profile`.`homepage` AS `homepage`,
2644 `profile`.`dob` AS `dob`
2646 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2647 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2650 -- VIEW account-view
2652 DROP VIEW IF EXISTS `account-view`;
2653 CREATE VIEW `account-view` AS SELECT
2654 `contact`.`id` AS `id`,
2655 `contact`.`url` AS `url`,
2656 `contact`.`nurl` AS `nurl`,
2657 `contact`.`uri-id` AS `uri-id`,
2658 `item-uri`.`guid` AS `guid`,
2659 `contact`.`addr` AS `addr`,
2660 `contact`.`alias` AS `alias`,
2661 `contact`.`name` AS `name`,
2662 `contact`.`nick` AS `nick`,
2663 `contact`.`about` AS `about`,
2664 `contact`.`keywords` AS `keywords`,
2665 `contact`.`xmpp` AS `xmpp`,
2666 `contact`.`matrix` AS `matrix`,
2667 `contact`.`avatar` AS `avatar`,
2668 `contact`.`photo` AS `photo`,
2669 `contact`.`thumb` AS `thumb`,
2670 `contact`.`micro` AS `micro`,
2671 `contact`.`header` AS `header`,
2672 `contact`.`created` AS `created`,
2673 `contact`.`updated` AS `updated`,
2674 `contact`.`network` AS `network`,
2675 `contact`.`protocol` AS `protocol`,
2676 `contact`.`location` AS `location`,
2677 `contact`.`attag` AS `attag`,
2678 `contact`.`pubkey` AS `pubkey`,
2679 `contact`.`prvkey` AS `prvkey`,
2680 `contact`.`subscribe` AS `subscribe`,
2681 `contact`.`last-update` AS `last-update`,
2682 `contact`.`success_update` AS `success_update`,
2683 `contact`.`failure_update` AS `failure_update`,
2684 `contact`.`failed` AS `failed`,
2685 `contact`.`last-item` AS `last-item`,
2686 `contact`.`last-discovery` AS `last-discovery`,
2687 `contact`.`contact-type` AS `contact-type`,
2688 `contact`.`manually-approve` AS `manually-approve`,
2689 `contact`.`unsearchable` AS `unsearchable`,
2690 `contact`.`sensitive` AS `sensitive`,
2691 `contact`.`baseurl` AS `baseurl`,
2692 `contact`.`gsid` AS `gsid`,
2693 `contact`.`info` AS `info`,
2694 `contact`.`bdyear` AS `bdyear`,
2695 `contact`.`bd` AS `bd`,
2696 `contact`.`poco` AS `poco`,
2697 `contact`.`name-date` AS `name-date`,
2698 `contact`.`uri-date` AS `uri-date`,
2699 `contact`.`avatar-date` AS `avatar-date`,
2700 `contact`.`term-date` AS `term-date`,
2701 `contact`.`hidden` AS `global-ignored`,
2702 `contact`.`blocked` AS `global-blocked`,
2703 `contact`.`hidden` AS `hidden`,
2704 `contact`.`archive` AS `archive`,
2705 `contact`.`deleted` AS `deleted`,
2706 `contact`.`blocked` AS `blocked`,
2707 `contact`.`notify` AS `dfrn-notify`,
2708 `contact`.`poll` AS `dfrn-poll`,
2709 `fcontact`.`guid` AS `diaspora-guid`,
2710 `fcontact`.`batch` AS `diaspora-batch`,
2711 `fcontact`.`notify` AS `diaspora-notify`,
2712 `fcontact`.`poll` AS `diaspora-poll`,
2713 `fcontact`.`alias` AS `diaspora-alias`,
2714 `apcontact`.`uuid` AS `ap-uuid`,
2715 `apcontact`.`type` AS `ap-type`,
2716 `apcontact`.`following` AS `ap-following`,
2717 `apcontact`.`followers` AS `ap-followers`,
2718 `apcontact`.`inbox` AS `ap-inbox`,
2719 `apcontact`.`outbox` AS `ap-outbox`,
2720 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2721 `apcontact`.`generator` AS `ap-generator`,
2722 `apcontact`.`following_count` AS `ap-following_count`,
2723 `apcontact`.`followers_count` AS `ap-followers_count`,
2724 `apcontact`.`statuses_count` AS `ap-statuses_count`,
2725 `gserver`.`site_name` AS `site_name`,
2726 `gserver`.`platform` AS `platform`,
2727 `gserver`.`version` AS `version`
2729 LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id`
2730 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
2731 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = contact.`uri-id`
2732 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`
2733 WHERE `contact`.`uid` = 0;
2736 -- VIEW account-user-view
2738 DROP VIEW IF EXISTS `account-user-view`;
2739 CREATE VIEW `account-user-view` AS SELECT
2740 `ucontact`.`id` AS `id`,
2741 `contact`.`id` AS `pid`,
2742 `ucontact`.`uid` AS `uid`,
2743 `contact`.`url` AS `url`,
2744 `contact`.`nurl` AS `nurl`,
2745 `contact`.`uri-id` AS `uri-id`,
2746 `item-uri`.`guid` AS `guid`,
2747 `contact`.`addr` AS `addr`,
2748 `contact`.`alias` AS `alias`,
2749 `contact`.`name` AS `name`,
2750 `contact`.`nick` AS `nick`,
2751 `contact`.`about` AS `about`,
2752 `contact`.`keywords` AS `keywords`,
2753 `contact`.`xmpp` AS `xmpp`,
2754 `contact`.`matrix` AS `matrix`,
2755 `contact`.`avatar` AS `avatar`,
2756 `contact`.`photo` AS `photo`,
2757 `contact`.`thumb` AS `thumb`,
2758 `contact`.`micro` AS `micro`,
2759 `contact`.`header` AS `header`,
2760 `contact`.`created` AS `created`,
2761 `contact`.`updated` AS `updated`,
2762 `ucontact`.`self` AS `self`,
2763 `ucontact`.`remote_self` AS `remote_self`,
2764 `ucontact`.`rel` AS `rel`,
2765 `contact`.`network` AS `network`,
2766 `ucontact`.`protocol` AS `protocol`,
2767 `contact`.`location` AS `location`,
2768 `ucontact`.`attag` AS `attag`,
2769 `contact`.`pubkey` AS `pubkey`,
2770 `contact`.`prvkey` AS `prvkey`,
2771 `contact`.`subscribe` AS `subscribe`,
2772 `contact`.`last-update` AS `last-update`,
2773 `contact`.`success_update` AS `success_update`,
2774 `contact`.`failure_update` AS `failure_update`,
2775 `contact`.`failed` AS `failed`,
2776 `contact`.`last-item` AS `last-item`,
2777 `contact`.`last-discovery` AS `last-discovery`,
2778 `contact`.`contact-type` AS `contact-type`,
2779 `contact`.`manually-approve` AS `manually-approve`,
2780 `contact`.`unsearchable` AS `unsearchable`,
2781 `contact`.`sensitive` AS `sensitive`,
2782 `contact`.`baseurl` AS `baseurl`,
2783 `contact`.`gsid` AS `gsid`,
2784 `ucontact`.`info` AS `info`,
2785 `contact`.`bdyear` AS `bdyear`,
2786 `contact`.`bd` AS `bd`,
2787 `contact`.`poco` AS `poco`,
2788 `contact`.`name-date` AS `name-date`,
2789 `contact`.`uri-date` AS `uri-date`,
2790 `contact`.`avatar-date` AS `avatar-date`,
2791 `contact`.`term-date` AS `term-date`,
2792 `contact`.`hidden` AS `global-ignored`,
2793 `contact`.`blocked` AS `global-blocked`,
2794 `ucontact`.`hidden` AS `hidden`,
2795 `ucontact`.`archive` AS `archive`,
2796 `ucontact`.`pending` AS `pending`,
2797 `ucontact`.`deleted` AS `deleted`,
2798 `ucontact`.`notify_new_posts` AS `notify_new_posts`,
2799 `ucontact`.`fetch_further_information` AS `fetch_further_information`,
2800 `ucontact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2801 `ucontact`.`rating` AS `rating`,
2802 `ucontact`.`readonly` AS `readonly`,
2803 `ucontact`.`blocked` AS `blocked`,
2804 `ucontact`.`block_reason` AS `block_reason`,
2805 `ucontact`.`subhub` AS `subhub`,
2806 `ucontact`.`hub-verify` AS `hub-verify`,
2807 `ucontact`.`reason` AS `reason`,
2808 `contact`.`notify` AS `dfrn-notify`,
2809 `contact`.`poll` AS `dfrn-poll`,
2810 `fcontact`.`guid` AS `diaspora-guid`,
2811 `fcontact`.`batch` AS `diaspora-batch`,
2812 `fcontact`.`notify` AS `diaspora-notify`,
2813 `fcontact`.`poll` AS `diaspora-poll`,
2814 `fcontact`.`alias` AS `diaspora-alias`,
2815 `fcontact`.`interacting_count` AS `diaspora-interacting_count`,
2816 `fcontact`.`interacted_count` AS `diaspora-interacted_count`,
2817 `fcontact`.`post_count` AS `diaspora-post_count`,
2818 `apcontact`.`uuid` AS `ap-uuid`,
2819 `apcontact`.`type` AS `ap-type`,
2820 `apcontact`.`following` AS `ap-following`,
2821 `apcontact`.`followers` AS `ap-followers`,
2822 `apcontact`.`inbox` AS `ap-inbox`,
2823 `apcontact`.`outbox` AS `ap-outbox`,
2824 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2825 `apcontact`.`generator` AS `ap-generator`,
2826 `apcontact`.`following_count` AS `ap-following_count`,
2827 `apcontact`.`followers_count` AS `ap-followers_count`,
2828 `apcontact`.`statuses_count` AS `ap-statuses_count`,
2829 `gserver`.`site_name` AS `site_name`,
2830 `gserver`.`platform` AS `platform`,
2831 `gserver`.`version` AS `version`
2832 FROM `contact` AS `ucontact`
2833 INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
2834 LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id`
2835 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
2836 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = `ucontact`.`uri-id` AND `fcontact`.`network` = 'dspr'
2837 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`;
2840 -- VIEW pending-view
2842 DROP VIEW IF EXISTS `pending-view`;
2843 CREATE VIEW `pending-view` AS SELECT
2844 `register`.`id` AS `id`,
2845 `register`.`hash` AS `hash`,
2846 `register`.`created` AS `created`,
2847 `register`.`uid` AS `uid`,
2848 `register`.`password` AS `password`,
2849 `register`.`language` AS `language`,
2850 `register`.`note` AS `note`,
2851 `contact`.`self` AS `self`,
2852 `contact`.`name` AS `name`,
2853 `contact`.`url` AS `url`,
2854 `contact`.`micro` AS `micro`,
2855 `user`.`email` AS `email`,
2856 `contact`.`nick` AS `nick`
2858 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2859 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2862 -- VIEW tag-search-view
2864 DROP VIEW IF EXISTS `tag-search-view`;
2865 CREATE VIEW `tag-search-view` AS SELECT
2866 `post-tag`.`uri-id` AS `uri-id`,
2867 `post-user`.`uid` AS `uid`,
2868 `post-user`.`id` AS `iid`,
2869 `post-user`.`private` AS `private`,
2870 `post-user`.`wall` AS `wall`,
2871 `post-user`.`origin` AS `origin`,
2872 `post-user`.`global` AS `global`,
2873 `post-user`.`gravity` AS `gravity`,
2874 `post-user`.`received` AS `received`,
2875 `post-user`.`network` AS `network`,
2876 `post-user`.`author-id` AS `author-id`,
2877 `tag`.`name` AS `name`
2879 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
2880 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
2881 WHERE `post-tag`.`type` = 1;
2884 -- VIEW workerqueue-view
2886 DROP VIEW IF EXISTS `workerqueue-view`;
2887 CREATE VIEW `workerqueue-view` AS SELECT
2888 `process`.`pid` AS `pid`,
2889 `workerqueue`.`priority` AS `priority`
2891 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
2892 WHERE NOT `workerqueue`.`done`;
2895 -- VIEW profile_field-view
2897 DROP VIEW IF EXISTS `profile_field-view`;
2898 CREATE VIEW `profile_field-view` AS SELECT
2899 `profile_field`.`id` AS `id`,
2900 `profile_field`.`uid` AS `uid`,
2901 `profile_field`.`label` AS `label`,
2902 `profile_field`.`value` AS `value`,
2903 `profile_field`.`order` AS `order`,
2904 `profile_field`.`psid` AS `psid`,
2905 `permissionset`.`allow_cid` AS `allow_cid`,
2906 `permissionset`.`allow_gid` AS `allow_gid`,
2907 `permissionset`.`deny_cid` AS `deny_cid`,
2908 `permissionset`.`deny_gid` AS `deny_gid`,
2909 `profile_field`.`created` AS `created`,
2910 `profile_field`.`edited` AS `edited`
2911 FROM `profile_field`
2912 INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`;