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