1 -- ------------------------------------------
2 -- Friendica 2022.09-dev (Giant Rhubarb)
3 -- DB_UPDATE_VERSION 1474
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 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
342 `name` varchar(255) COMMENT '',
343 `about` text COMMENT '',
344 `xmpp` varchar(255) COMMENT 'XMPP address',
345 `matrix` varchar(255) COMMENT 'Matrix address',
346 `photo` varchar(255) COMMENT '',
347 `header` varchar(255) COMMENT 'Header picture',
348 `addr` varchar(255) COMMENT '',
349 `alias` varchar(255) COMMENT '',
350 `pubkey` text COMMENT '',
351 `subscribe` varchar(255) COMMENT '',
352 `baseurl` varchar(255) COMMENT 'baseurl of the ap contact',
353 `gsid` int unsigned COMMENT 'Global Server ID',
354 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
355 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
356 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
357 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
358 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
360 INDEX `addr` (`addr`(32)),
361 INDEX `alias` (`alias`(190)),
362 INDEX `followers` (`followers`(190)),
363 INDEX `baseurl` (`baseurl`(190)),
364 INDEX `sharedinbox` (`sharedinbox`(190)),
365 INDEX `gsid` (`gsid`),
366 UNIQUE INDEX `uri-id` (`uri-id`),
367 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
368 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
369 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
374 CREATE TABLE IF NOT EXISTS `application` (
375 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
376 `client_id` varchar(64) NOT NULL COMMENT '',
377 `client_secret` varchar(64) NOT NULL COMMENT '',
378 `name` varchar(255) NOT NULL COMMENT '',
379 `redirect_uri` varchar(255) NOT NULL COMMENT '',
380 `website` varchar(255) COMMENT '',
381 `scopes` varchar(255) COMMENT '',
382 `read` boolean COMMENT 'Read scope',
383 `write` boolean COMMENT 'Write scope',
384 `follow` boolean COMMENT 'Follow scope',
385 `push` boolean COMMENT 'Push scope',
387 UNIQUE INDEX `client_id` (`client_id`)
388 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth application';
391 -- TABLE application-marker
393 CREATE TABLE IF NOT EXISTS `application-marker` (
394 `application-id` int unsigned NOT NULL COMMENT '',
395 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
396 `timeline` varchar(64) NOT NULL COMMENT 'Marker (home, notifications)',
397 `last_read_id` varchar(255) COMMENT 'Marker id for the timeline',
398 `version` smallint unsigned COMMENT 'Version number',
399 `updated_at` datetime COMMENT 'creation time',
400 PRIMARY KEY(`application-id`,`uid`,`timeline`),
401 INDEX `uid_id` (`uid`),
402 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
403 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
404 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Timeline marker';
407 -- TABLE application-token
409 CREATE TABLE IF NOT EXISTS `application-token` (
410 `application-id` int unsigned NOT NULL COMMENT '',
411 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
412 `code` varchar(64) NOT NULL COMMENT '',
413 `access_token` varchar(64) NOT NULL COMMENT '',
414 `created_at` datetime NOT NULL COMMENT 'creation time',
415 `scopes` varchar(255) COMMENT '',
416 `read` boolean COMMENT 'Read scope',
417 `write` boolean COMMENT 'Write scope',
418 `follow` boolean COMMENT 'Follow scope',
419 `push` boolean COMMENT 'Push scope',
420 PRIMARY KEY(`application-id`,`uid`),
421 INDEX `uid_id` (`uid`,`application-id`),
422 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
423 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
424 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth user token';
429 CREATE TABLE IF NOT EXISTS `attach` (
430 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
431 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
432 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
433 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
434 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
435 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
436 `data` longblob NOT NULL COMMENT 'file data',
437 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
438 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
439 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
440 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
441 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
442 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
443 `backend-class` tinytext COMMENT 'Storage backend class',
444 `backend-ref` text COMMENT 'Storage backend data reference',
447 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
448 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
453 CREATE TABLE IF NOT EXISTS `cache` (
454 `k` varbinary(255) NOT NULL COMMENT 'cache key',
455 `v` mediumtext COMMENT 'cached serialized value',
456 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
457 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
459 INDEX `k_expires` (`k`,`expires`)
460 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
465 CREATE TABLE IF NOT EXISTS `config` (
466 `id` int unsigned NOT NULL auto_increment COMMENT '',
467 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
468 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
469 `v` mediumtext COMMENT '',
471 UNIQUE INDEX `cat_k` (`cat`,`k`)
472 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
475 -- TABLE contact-relation
477 CREATE TABLE IF NOT EXISTS `contact-relation` (
478 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
479 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
480 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
481 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
482 `follows` boolean NOT NULL DEFAULT '0' COMMENT '',
483 PRIMARY KEY(`cid`,`relation-cid`),
484 INDEX `relation-cid` (`relation-cid`),
485 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
486 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
487 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
492 CREATE TABLE IF NOT EXISTS `conv` (
493 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
494 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
495 `recips` text COMMENT 'sender_handle;recipient_handle',
496 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
497 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
498 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
499 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
500 `subject` text COMMENT 'subject of initial message',
503 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
504 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
507 -- TABLE conversation
509 CREATE TABLE IF NOT EXISTS `conversation` (
510 `item-uri` varbinary(255) NOT NULL COMMENT 'Original URI of the item - unrelated to the table with the same name',
511 `reply-to-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'URI to which this item is a reply',
512 `conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI',
513 `conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link',
514 `protocol` tinyint unsigned NOT NULL DEFAULT 255 COMMENT 'The protocol of the item',
515 `direction` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'How the message arrived here: 1=push, 2=pull',
516 `source` mediumtext COMMENT 'Original source',
517 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Receiving date',
518 PRIMARY KEY(`item-uri`),
519 INDEX `conversation-uri` (`conversation-uri`),
520 INDEX `received` (`received`)
521 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Raw data and structure information for messages';
526 CREATE TABLE IF NOT EXISTS `workerqueue` (
527 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
528 `command` varchar(100) COMMENT 'Task command',
529 `parameter` mediumtext COMMENT 'Task parameter',
530 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
531 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
532 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
533 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
534 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
535 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
536 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
538 INDEX `command` (`command`),
539 INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
540 INDEX `done_executed` (`done`,`executed`),
541 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
542 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
543 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
544 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
545 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
546 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
549 -- TABLE delayed-post
551 CREATE TABLE IF NOT EXISTS `delayed-post` (
552 `id` int unsigned NOT NULL auto_increment,
553 `uri` varchar(255) COMMENT 'URI of the post that will be distributed later',
554 `uid` mediumint unsigned COMMENT 'Owner User id',
555 `delayed` datetime COMMENT 'delay time',
556 `wid` int unsigned COMMENT 'Workerqueue id',
558 UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
560 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
561 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
562 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
565 -- TABLE diaspora-interaction
567 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
568 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
569 `interaction` mediumtext COMMENT 'The Diaspora interaction',
570 PRIMARY KEY(`uri-id`),
571 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
572 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
577 CREATE TABLE IF NOT EXISTS `endpoint` (
578 `url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
579 `type` varchar(20) NOT NULL COMMENT '',
580 `owner-uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
582 UNIQUE INDEX `owner-uri-id_type` (`owner-uri-id`,`type`),
583 FOREIGN KEY (`owner-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
584 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub endpoints - used in the ActivityPub implementation';
589 CREATE TABLE IF NOT EXISTS `event` (
590 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
591 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
592 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
593 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
594 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
595 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the event uri',
596 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
597 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
598 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
599 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
600 `summary` text COMMENT 'short description or title of the event',
601 `desc` text COMMENT 'event description',
602 `location` text COMMENT 'event location',
603 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
604 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
605 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
606 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
607 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
608 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
609 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
611 INDEX `uid_start` (`uid`,`start`),
613 INDEX `uri-id` (`uri-id`),
614 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
615 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
616 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
617 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
622 CREATE TABLE IF NOT EXISTS `fcontact` (
623 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
624 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
625 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
626 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the fcontact url',
627 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
628 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
629 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
630 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
631 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
632 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
633 `notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
634 `poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
635 `confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
636 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
637 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
638 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
639 `pubkey` text COMMENT '',
640 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
641 `interacting_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts this contact interactes with',
642 `interacted_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts that interacted with this contact',
643 `post_count` int unsigned DEFAULT 0 COMMENT 'Number of posts and comments',
645 INDEX `addr` (`addr`(32)),
646 UNIQUE INDEX `url` (`url`(190)),
647 UNIQUE INDEX `uri-id` (`uri-id`),
648 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
649 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
654 CREATE TABLE IF NOT EXISTS `fsuggest` (
655 `id` int unsigned NOT NULL auto_increment COMMENT '',
656 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
657 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
658 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
659 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
660 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
661 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
662 `note` text COMMENT '',
663 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
667 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
668 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
669 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
674 CREATE TABLE IF NOT EXISTS `group` (
675 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
676 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
677 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
678 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
679 `cid` int unsigned COMMENT 'Contact id of forum. When this field is filled then the members are synced automatically.',
680 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
684 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
685 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
686 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
689 -- TABLE group_member
691 CREATE TABLE IF NOT EXISTS `group_member` (
692 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
693 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
694 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
696 INDEX `contactid` (`contact-id`),
697 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
698 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
699 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
700 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
705 CREATE TABLE IF NOT EXISTS `gserver-tag` (
706 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
707 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
708 PRIMARY KEY(`gserver-id`,`tag`),
710 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
711 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
716 CREATE TABLE IF NOT EXISTS `hook` (
717 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
718 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
719 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
720 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
721 `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',
723 INDEX `priority` (`priority`),
724 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
725 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
730 CREATE TABLE IF NOT EXISTS `inbox-entry` (
731 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
732 `activity-id` varbinary(255) COMMENT 'id of the incoming activity',
733 `object-id` varbinary(255) COMMENT '',
734 `in-reply-to-id` varbinary(255) COMMENT '',
735 `conversation` varbinary(255) COMMENT '',
736 `type` varchar(64) COMMENT 'Type of the activity',
737 `object-type` varchar(64) COMMENT 'Type of the object activity',
738 `object-object-type` varchar(64) COMMENT 'Type of the object\'s object activity',
739 `received` datetime COMMENT 'Receiving date',
740 `activity` mediumtext COMMENT 'The JSON activity',
741 `signer` varchar(255) COMMENT '',
742 `push` boolean COMMENT 'Is the entry pushed or have pulled it?',
743 `trust` boolean COMMENT 'Do we trust this entry?',
744 `wid` int unsigned COMMENT 'Workerqueue id',
746 UNIQUE INDEX `activity-id` (`activity-id`),
747 INDEX `object-id` (`object-id`),
748 INDEX `received` (`received`),
750 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
751 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Incoming activity';
754 -- TABLE inbox-entry-receiver
756 CREATE TABLE IF NOT EXISTS `inbox-entry-receiver` (
757 `queue-id` int unsigned NOT NULL COMMENT '',
758 `uid` mediumint unsigned NOT NULL COMMENT 'User id',
759 PRIMARY KEY(`queue-id`,`uid`),
761 FOREIGN KEY (`queue-id`) REFERENCES `inbox-entry` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
762 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
763 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Receiver for the incoming activity';
766 -- TABLE inbox-status
768 CREATE TABLE IF NOT EXISTS `inbox-status` (
769 `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
770 `uri-id` int unsigned COMMENT 'Item-uri id of inbox url',
771 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
772 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
773 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
774 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
775 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
776 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
778 INDEX `uri-id` (`uri-id`),
779 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
780 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
785 CREATE TABLE IF NOT EXISTS `intro` (
786 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
787 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
788 `fid` int unsigned COMMENT 'deprecated',
789 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
790 `suggest-cid` int unsigned COMMENT 'Suggested contact',
791 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
792 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
793 `note` text COMMENT '',
794 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
795 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
796 `blocked` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
797 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
799 INDEX `contact-id` (`contact-id`),
800 INDEX `suggest-cid` (`suggest-cid`),
802 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
803 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
804 FOREIGN KEY (`suggest-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
805 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
810 CREATE TABLE IF NOT EXISTS `locks` (
811 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
812 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
813 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
814 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
815 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
817 INDEX `name_expires` (`name`,`expires`)
818 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
823 CREATE TABLE IF NOT EXISTS `mail` (
824 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
825 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
826 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
827 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
828 `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
829 `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
830 `contact-id` varchar(255) COMMENT 'contact.id',
831 `author-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the author of the mail',
832 `convid` int unsigned COMMENT 'conv.id',
833 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
834 `body` mediumtext COMMENT '',
835 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
836 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
837 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
838 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
839 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
840 `uri-id` int unsigned COMMENT 'Item-uri id of the related mail',
841 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
842 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related mail',
843 `thr-parent` varchar(255) COMMENT '',
844 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
845 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
847 INDEX `uid_seen` (`uid`,`seen`),
848 INDEX `convid` (`convid`),
849 INDEX `uri` (`uri`(64)),
850 INDEX `parent-uri` (`parent-uri`(64)),
851 INDEX `contactid` (`contact-id`(32)),
852 INDEX `author-id` (`author-id`),
853 INDEX `uri-id` (`uri-id`),
854 INDEX `parent-uri-id` (`parent-uri-id`),
855 INDEX `thr-parent-id` (`thr-parent-id`),
856 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
857 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
858 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
859 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
860 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
861 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
866 CREATE TABLE IF NOT EXISTS `mailacct` (
867 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
868 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
869 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
870 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
871 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
872 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
873 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
874 `pass` text COMMENT '',
875 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
876 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
877 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
878 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
879 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
882 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
883 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
888 CREATE TABLE IF NOT EXISTS `manage` (
889 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
890 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
891 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
893 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
895 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
896 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
897 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
900 -- TABLE notification
902 CREATE TABLE IF NOT EXISTS `notification` (
903 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
904 `uid` mediumint unsigned COMMENT 'Owner User id',
905 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
906 `type` smallint unsigned COMMENT '',
907 `actor-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the actor that caused the notification',
908 `target-uri-id` int unsigned COMMENT 'Item-uri id of the related post',
909 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
910 `created` datetime COMMENT '',
911 `seen` boolean DEFAULT '0' COMMENT 'Seen on the desktop',
912 `dismissed` boolean DEFAULT '0' COMMENT 'Dismissed via the API',
914 UNIQUE INDEX `uid_vid_type_actor-id_target-uri-id` (`uid`,`vid`,`type`,`actor-id`,`target-uri-id`),
916 INDEX `actor-id` (`actor-id`),
917 INDEX `target-uri-id` (`target-uri-id`),
918 INDEX `parent-uri-id` (`parent-uri-id`),
919 INDEX `seen_uid` (`seen`,`uid`),
920 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
921 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
922 FOREIGN KEY (`actor-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
923 FOREIGN KEY (`target-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
924 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
925 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
930 CREATE TABLE IF NOT EXISTS `notify` (
931 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
932 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
933 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
934 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
935 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
936 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
937 `msg` mediumtext COMMENT '',
938 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
939 `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
940 `iid` int unsigned COMMENT '',
941 `parent` int unsigned COMMENT '',
942 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
943 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
944 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
945 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
946 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
947 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
948 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
950 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
951 INDEX `uid_date` (`uid`,`date`),
952 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
953 INDEX `uri-id` (`uri-id`),
954 INDEX `parent-uri-id` (`parent-uri-id`),
955 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
956 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
957 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
958 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='[Deprecated] User notifications';
961 -- TABLE notify-threads
963 CREATE TABLE IF NOT EXISTS `notify-threads` (
964 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
965 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
966 `master-parent-item` int unsigned COMMENT 'Deprecated',
967 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
968 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
969 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
971 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
972 INDEX `receiver-uid` (`receiver-uid`),
973 INDEX `notify-id` (`notify-id`),
974 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
975 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
976 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
977 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
982 CREATE TABLE IF NOT EXISTS `oembed` (
983 `url` varbinary(255) NOT NULL COMMENT 'page url',
984 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
985 `content` mediumtext COMMENT 'OEmbed data of the page',
986 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
987 PRIMARY KEY(`url`,`maxwidth`),
988 INDEX `created` (`created`)
989 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
992 -- TABLE openwebauth-token
994 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
995 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
996 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
997 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
998 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
999 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1000 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1002 INDEX `uid` (`uid`),
1003 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1004 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
1009 CREATE TABLE IF NOT EXISTS `parsed_url` (
1010 `url_hash` binary(64) NOT NULL COMMENT 'page url hash',
1011 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
1012 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
1013 `url` text NOT NULL COMMENT 'page url',
1014 `content` mediumtext COMMENT 'page data',
1015 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1016 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration',
1017 PRIMARY KEY(`url_hash`,`guessing`,`oembed`),
1018 INDEX `created` (`created`),
1019 INDEX `expires` (`expires`)
1020 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
1025 CREATE TABLE IF NOT EXISTS `pconfig` (
1026 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
1027 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1028 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
1029 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
1030 `v` mediumtext COMMENT 'Value',
1032 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
1033 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1034 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
1039 CREATE TABLE IF NOT EXISTS `photo` (
1040 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1041 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1042 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1043 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
1044 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
1045 `hash` char(32) COMMENT 'hash value of the photo',
1046 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
1047 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
1048 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1049 `desc` text COMMENT '',
1050 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
1051 `photo-type` tinyint unsigned COMMENT 'User avatar, user banner, contact avatar, contact banner or default',
1052 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1053 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
1054 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1055 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1056 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1057 `data` mediumblob NOT NULL COMMENT '',
1058 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1059 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
1060 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
1061 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
1062 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
1063 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
1064 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
1065 `backend-class` tinytext COMMENT 'Storage backend class',
1066 `backend-ref` text COMMENT 'Storage backend data reference',
1067 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1069 INDEX `contactid` (`contact-id`),
1070 INDEX `uid_contactid` (`uid`,`contact-id`),
1071 INDEX `uid_profile` (`uid`,`profile`),
1072 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
1073 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
1074 INDEX `resource-id` (`resource-id`),
1075 INDEX `uid_photo-type` (`uid`,`photo-type`),
1076 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1077 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1078 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1083 CREATE TABLE IF NOT EXISTS `post` (
1084 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1085 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1086 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1087 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1088 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1089 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1090 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1091 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1092 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1093 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1094 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1095 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1096 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1097 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1098 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1099 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1100 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1101 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1102 PRIMARY KEY(`uri-id`),
1103 INDEX `parent-uri-id` (`parent-uri-id`),
1104 INDEX `thr-parent-id` (`thr-parent-id`),
1105 INDEX `external-id` (`external-id`),
1106 INDEX `owner-id` (`owner-id`),
1107 INDEX `author-id` (`author-id`),
1108 INDEX `causer-id` (`causer-id`),
1109 INDEX `vid` (`vid`),
1110 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1111 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1112 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1113 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1114 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1115 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1116 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1117 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1118 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
1121 -- TABLE post-category
1123 CREATE TABLE IF NOT EXISTS `post-category` (
1124 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1125 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1126 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1127 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1128 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1129 INDEX `tid` (`tid`),
1130 INDEX `uid_uri-id` (`uid`,`uri-id`),
1131 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1132 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1133 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1134 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1137 -- TABLE post-collection
1139 CREATE TABLE IF NOT EXISTS `post-collection` (
1140 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1141 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0 - Featured',
1142 PRIMARY KEY(`uri-id`,`type`),
1143 INDEX `type` (`type`),
1144 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1145 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Collection of posts';
1148 -- TABLE post-content
1150 CREATE TABLE IF NOT EXISTS `post-content` (
1151 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1152 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1153 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1154 `body` mediumtext COMMENT 'item body content',
1155 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1156 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1157 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1158 `language` text COMMENT 'Language information about this post',
1159 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1160 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1161 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1162 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1163 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1164 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1165 `target` text COMMENT 'JSON encoded target structure if used',
1166 `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',
1167 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1168 PRIMARY KEY(`uri-id`),
1169 INDEX `plink` (`plink`(191)),
1170 INDEX `resource-id` (`resource-id`),
1171 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
1172 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1173 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1176 -- TABLE post-delivery
1178 CREATE TABLE IF NOT EXISTS `post-delivery` (
1179 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1180 `inbox-id` int unsigned NOT NULL COMMENT 'Item-uri id of inbox url',
1181 `uid` mediumint unsigned COMMENT 'Delivering user',
1182 `created` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
1183 `command` varbinary(32) COMMENT '',
1184 `failed` tinyint DEFAULT 0 COMMENT 'Number of times the delivery has failed',
1185 `receivers` mediumtext COMMENT 'JSON encoded array with the receiving contacts',
1186 PRIMARY KEY(`uri-id`,`inbox-id`),
1187 INDEX `inbox-id_created` (`inbox-id`,`created`),
1188 INDEX `uid` (`uid`),
1189 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1190 FOREIGN KEY (`inbox-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1191 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1192 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for posts for the batch processing';
1195 -- TABLE post-delivery-data
1197 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1198 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1199 `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',
1200 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1201 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1202 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1203 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1204 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1205 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1206 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1207 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1208 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1209 PRIMARY KEY(`uri-id`),
1210 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1211 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1214 -- TABLE post-history
1216 CREATE TABLE IF NOT EXISTS `post-history` (
1217 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1218 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of edit',
1219 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1220 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1221 `body` mediumtext COMMENT 'item body content',
1222 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1223 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1224 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1225 `language` text COMMENT 'Language information about this post',
1226 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1227 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1228 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1229 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1230 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1231 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1232 `target` text COMMENT 'JSON encoded target structure if used',
1233 `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',
1234 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1235 PRIMARY KEY(`uri-id`,`edited`),
1236 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1237 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post history';
1242 CREATE TABLE IF NOT EXISTS `post-link` (
1243 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1244 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1245 `url` varbinary(511) NOT NULL COMMENT 'External URL',
1246 `mimetype` varchar(60) COMMENT '',
1248 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1249 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1250 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post related external links';
1255 CREATE TABLE IF NOT EXISTS `post-media` (
1256 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1257 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1258 `url` varbinary(1024) NOT NULL COMMENT 'Media URL',
1259 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1260 `mimetype` varchar(60) COMMENT '',
1261 `height` smallint unsigned COMMENT 'Height of the media',
1262 `width` smallint unsigned COMMENT 'Width of the media',
1263 `size` bigint unsigned COMMENT 'Media size',
1264 `preview` varbinary(512) COMMENT 'Preview URL',
1265 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1266 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1267 `description` text COMMENT '',
1268 `name` varchar(255) COMMENT 'Name of the media',
1269 `author-url` varbinary(255) COMMENT 'URL of the author of the media',
1270 `author-name` varchar(255) COMMENT 'Name of the author of the media',
1271 `author-image` varbinary(255) COMMENT 'Image of the author of the media',
1272 `publisher-url` varbinary(255) COMMENT 'URL of the publisher of the media',
1273 `publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
1274 `publisher-image` varbinary(255) COMMENT 'Image of the publisher of the media',
1276 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`(512)),
1277 INDEX `uri-id-id` (`uri-id`,`id`),
1278 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1279 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1282 -- TABLE post-question
1284 CREATE TABLE IF NOT EXISTS `post-question` (
1285 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1286 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1287 `multiple` boolean NOT NULL DEFAULT '0' COMMENT 'Multiple choice',
1288 `voters` int unsigned COMMENT 'Number of voters for this question',
1289 `end-time` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Question end time',
1291 UNIQUE INDEX `uri-id` (`uri-id`),
1292 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1293 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question';
1296 -- TABLE post-question-option
1298 CREATE TABLE IF NOT EXISTS `post-question-option` (
1299 `id` int unsigned NOT NULL COMMENT 'Id of the question',
1300 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1301 `name` varchar(255) COMMENT 'Name of the option',
1302 `replies` int unsigned COMMENT 'Number of replies for this question option',
1303 PRIMARY KEY(`uri-id`,`id`),
1304 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1305 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question option';
1310 CREATE TABLE IF NOT EXISTS `post-tag` (
1311 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1312 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1313 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1314 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1315 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1316 INDEX `tid` (`tid`),
1317 INDEX `cid` (`cid`),
1318 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1319 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1320 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1321 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1324 -- TABLE post-thread
1326 CREATE TABLE IF NOT EXISTS `post-thread` (
1327 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1328 `conversation-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the conversation uri',
1329 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1330 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1331 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1332 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1333 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1334 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1335 `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',
1336 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1337 PRIMARY KEY(`uri-id`),
1338 INDEX `conversation-id` (`conversation-id`),
1339 INDEX `owner-id` (`owner-id`),
1340 INDEX `author-id` (`author-id`),
1341 INDEX `causer-id` (`causer-id`),
1342 INDEX `received` (`received`),
1343 INDEX `commented` (`commented`),
1344 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1345 FOREIGN KEY (`conversation-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1346 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1347 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1348 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1349 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1354 CREATE TABLE IF NOT EXISTS `post-user` (
1355 `id` int unsigned NOT NULL auto_increment,
1356 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1357 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1358 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1359 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1360 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1361 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1362 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1363 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1364 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1365 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1366 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1367 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1368 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1369 `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
1370 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1371 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1372 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1373 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1374 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1375 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1376 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1377 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1378 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1379 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1380 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1381 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1382 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1383 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1384 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1386 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1387 INDEX `uri-id` (`uri-id`),
1388 INDEX `parent-uri-id` (`parent-uri-id`),
1389 INDEX `thr-parent-id` (`thr-parent-id`),
1390 INDEX `external-id` (`external-id`),
1391 INDEX `owner-id` (`owner-id`),
1392 INDEX `author-id` (`author-id`),
1393 INDEX `causer-id` (`causer-id`),
1394 INDEX `vid` (`vid`),
1395 INDEX `contact-id` (`contact-id`),
1396 INDEX `event-id` (`event-id`),
1397 INDEX `psid` (`psid`),
1398 INDEX `author-id_uid` (`author-id`,`uid`),
1399 INDEX `author-id_received` (`author-id`,`received`),
1400 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1401 INDEX `uid_contactid` (`uid`,`contact-id`),
1402 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1403 INDEX `uid_unseen` (`uid`,`unseen`),
1404 INDEX `uid_hidden_uri-id` (`uid`,`hidden`,`uri-id`),
1405 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1406 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1407 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1408 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1409 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1410 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1411 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1412 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1413 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1414 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1415 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1416 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1417 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1420 -- TABLE post-thread-user
1422 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1423 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1424 `conversation-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the conversation uri',
1425 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1426 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1427 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1428 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1429 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1430 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1431 `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',
1432 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1433 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1434 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
1435 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1436 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1437 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1438 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1439 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1440 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Deprecated',
1441 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1442 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1443 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1444 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1445 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1446 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1447 PRIMARY KEY(`uid`,`uri-id`),
1448 INDEX `uri-id` (`uri-id`),
1449 INDEX `conversation-id` (`conversation-id`),
1450 INDEX `owner-id` (`owner-id`),
1451 INDEX `author-id` (`author-id`),
1452 INDEX `causer-id` (`causer-id`),
1453 INDEX `uid` (`uid`),
1454 INDEX `contact-id` (`contact-id`),
1455 INDEX `psid` (`psid`),
1456 INDEX `post-user-id` (`post-user-id`),
1457 INDEX `commented` (`commented`),
1458 INDEX `uid_received` (`uid`,`received`),
1459 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1460 INDEX `uid_commented` (`uid`,`commented`),
1461 INDEX `uid_starred` (`uid`,`starred`),
1462 INDEX `uid_mention` (`uid`,`mention`),
1463 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1464 FOREIGN KEY (`conversation-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1465 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1466 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1467 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1468 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1469 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1470 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1471 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1472 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1475 -- TABLE post-user-notification
1477 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1478 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1479 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1480 `notification-type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1481 PRIMARY KEY(`uid`,`uri-id`),
1482 INDEX `uri-id` (`uri-id`),
1483 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1484 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1485 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1490 CREATE TABLE IF NOT EXISTS `process` (
1491 `pid` int unsigned NOT NULL COMMENT 'The ID of the process',
1492 `hostname` varchar(32) NOT NULL COMMENT 'The name of the host the process is ran on',
1493 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1494 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1495 PRIMARY KEY(`pid`,`hostname`),
1496 INDEX `command` (`command`)
1497 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1502 CREATE TABLE IF NOT EXISTS `profile` (
1503 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1504 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1505 `profile-name` varchar(255) COMMENT 'Deprecated',
1506 `is-default` boolean COMMENT 'Deprecated',
1507 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1508 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1509 `pdesc` varchar(255) COMMENT 'Deprecated',
1510 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1511 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1512 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1513 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1514 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1515 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1516 `hometown` varchar(255) COMMENT 'Deprecated',
1517 `gender` varchar(32) COMMENT 'Deprecated',
1518 `marital` varchar(255) COMMENT 'Deprecated',
1519 `with` text COMMENT 'Deprecated',
1520 `howlong` datetime COMMENT 'Deprecated',
1521 `sexual` varchar(255) COMMENT 'Deprecated',
1522 `politic` varchar(255) COMMENT 'Deprecated',
1523 `religion` varchar(255) COMMENT 'Deprecated',
1524 `pub_keywords` text COMMENT '',
1525 `prv_keywords` text COMMENT '',
1526 `likes` text COMMENT 'Deprecated',
1527 `dislikes` text COMMENT 'Deprecated',
1528 `about` text COMMENT 'Profile description',
1529 `summary` varchar(255) COMMENT 'Deprecated',
1530 `music` text COMMENT 'Deprecated',
1531 `book` text COMMENT 'Deprecated',
1532 `tv` text COMMENT 'Deprecated',
1533 `film` text COMMENT 'Deprecated',
1534 `interest` text COMMENT 'Deprecated',
1535 `romance` text COMMENT 'Deprecated',
1536 `work` text COMMENT 'Deprecated',
1537 `education` text COMMENT 'Deprecated',
1538 `contact` text COMMENT 'Deprecated',
1539 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1540 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
1541 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
1542 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1543 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1544 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1545 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1547 INDEX `uid_is-default` (`uid`,`is-default`),
1548 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1549 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1550 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1553 -- TABLE profile_field
1555 CREATE TABLE IF NOT EXISTS `profile_field` (
1556 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1557 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1558 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1559 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1560 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1561 `value` text COMMENT 'Value of the field',
1562 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1563 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1565 INDEX `uid` (`uid`),
1566 INDEX `order` (`order`),
1567 INDEX `psid` (`psid`),
1568 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1569 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1570 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1573 -- TABLE push_subscriber
1575 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1576 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1577 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1578 `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1579 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1580 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1581 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1582 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1583 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1584 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1585 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1587 INDEX `next_try` (`next_try`),
1588 INDEX `uid` (`uid`),
1589 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1590 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1595 CREATE TABLE IF NOT EXISTS `register` (
1596 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1597 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1598 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1599 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1600 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1601 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1602 `note` text COMMENT '',
1604 INDEX `uid` (`uid`),
1605 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1606 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1611 CREATE TABLE IF NOT EXISTS `search` (
1612 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1613 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1614 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1616 INDEX `uid_term` (`uid`,`term`(64)),
1617 INDEX `term` (`term`(64)),
1618 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1619 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1624 CREATE TABLE IF NOT EXISTS `session` (
1625 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1626 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1627 `data` text COMMENT '',
1628 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1630 INDEX `sid` (`sid`(64)),
1631 INDEX `expire` (`expire`)
1632 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1637 CREATE TABLE IF NOT EXISTS `storage` (
1638 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1639 `data` longblob NOT NULL COMMENT 'file data',
1641 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1644 -- TABLE subscription
1646 CREATE TABLE IF NOT EXISTS `subscription` (
1647 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1648 `application-id` int unsigned NOT NULL COMMENT '',
1649 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
1650 `endpoint` varchar(511) COMMENT 'Endpoint URL',
1651 `pubkey` varchar(127) COMMENT 'User agent public key',
1652 `secret` varchar(32) COMMENT 'Auth secret',
1653 `follow` boolean COMMENT '',
1654 `favourite` boolean COMMENT '',
1655 `reblog` boolean COMMENT '',
1656 `mention` boolean COMMENT '',
1657 `poll` boolean COMMENT '',
1658 `follow_request` boolean COMMENT '',
1659 `status` boolean COMMENT '',
1661 UNIQUE INDEX `application-id_uid` (`application-id`,`uid`),
1662 INDEX `uid_application-id` (`uid`,`application-id`),
1663 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1664 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1665 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Push Subscription for the API';
1670 CREATE TABLE IF NOT EXISTS `userd` (
1671 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1672 `username` varchar(255) NOT NULL COMMENT '',
1674 INDEX `username` (`username`(32))
1675 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1678 -- TABLE user-contact
1680 CREATE TABLE IF NOT EXISTS `user-contact` (
1681 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1682 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1683 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
1684 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1685 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1686 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1687 `hidden` boolean COMMENT 'This contact is hidden from the others',
1688 `is-blocked` boolean COMMENT 'User is blocked by this contact',
1689 `pending` boolean COMMENT '',
1690 `rel` tinyint unsigned COMMENT 'The kind of the relation between the user and the contact',
1691 `info` mediumtext COMMENT '',
1692 `notify_new_posts` boolean COMMENT '',
1693 `remote_self` boolean COMMENT '',
1694 `fetch_further_information` tinyint unsigned COMMENT '',
1695 `ffi_keyword_denylist` text COMMENT '',
1696 `subhub` boolean COMMENT '',
1697 `hub-verify` varchar(255) COMMENT '',
1698 `protocol` char(4) COMMENT 'Protocol of the contact',
1699 `rating` tinyint COMMENT 'Automatically detected feed poll frequency',
1700 `priority` tinyint unsigned COMMENT 'Feed poll priority',
1701 PRIMARY KEY(`uid`,`cid`),
1702 INDEX `cid` (`cid`),
1703 UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
1704 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1705 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1706 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1707 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1712 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1713 `key` int NOT NULL COMMENT '',
1714 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1716 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1719 -- VIEW application-view
1721 DROP VIEW IF EXISTS `application-view`;
1722 CREATE VIEW `application-view` AS SELECT
1723 `application`.`id` AS `id`,
1724 `application-token`.`uid` AS `uid`,
1725 `application`.`name` AS `name`,
1726 `application`.`redirect_uri` AS `redirect_uri`,
1727 `application`.`website` AS `website`,
1728 `application`.`client_id` AS `client_id`,
1729 `application`.`client_secret` AS `client_secret`,
1730 `application-token`.`code` AS `code`,
1731 `application-token`.`access_token` AS `access_token`,
1732 `application-token`.`created_at` AS `created_at`,
1733 `application-token`.`scopes` AS `scopes`,
1734 `application-token`.`read` AS `read`,
1735 `application-token`.`write` AS `write`,
1736 `application-token`.`follow` AS `follow`,
1737 `application-token`.`push` AS `push`
1738 FROM `application-token`
1739 INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`;
1742 -- VIEW post-user-view
1744 DROP VIEW IF EXISTS `post-user-view`;
1745 CREATE VIEW `post-user-view` AS SELECT
1746 `post-user`.`id` AS `id`,
1747 `post-user`.`id` AS `post-user-id`,
1748 `post-user`.`uid` AS `uid`,
1749 `parent-post`.`id` AS `parent`,
1750 `item-uri`.`uri` AS `uri`,
1751 `post-user`.`uri-id` AS `uri-id`,
1752 `parent-item-uri`.`uri` AS `parent-uri`,
1753 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1754 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1755 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1756 `conversation-item-uri`.`uri` AS `conversation`,
1757 `post-thread-user`.`conversation-id` AS `conversation-id`,
1758 `item-uri`.`guid` AS `guid`,
1759 `post-user`.`wall` AS `wall`,
1760 `post-user`.`gravity` AS `gravity`,
1761 `external-item-uri`.`uri` AS `extid`,
1762 `post-user`.`external-id` AS `external-id`,
1763 `post-user`.`created` AS `created`,
1764 `post-user`.`edited` AS `edited`,
1765 `post-thread-user`.`commented` AS `commented`,
1766 `post-user`.`received` AS `received`,
1767 `post-thread-user`.`changed` AS `changed`,
1768 `post-user`.`post-type` AS `post-type`,
1769 `post-user`.`post-reason` AS `post-reason`,
1770 `post-user`.`private` AS `private`,
1771 `post-thread-user`.`pubmail` AS `pubmail`,
1772 `post-user`.`visible` AS `visible`,
1773 `post-thread-user`.`starred` AS `starred`,
1774 `post-user`.`unseen` AS `unseen`,
1775 `post-user`.`deleted` AS `deleted`,
1776 `post-user`.`origin` AS `origin`,
1777 `post-thread-user`.`origin` AS `parent-origin`,
1778 `post-thread-user`.`mention` AS `mention`,
1779 `post-user`.`global` AS `global`,
1780 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-user`.`uri-id`) AS `featured`,
1781 `post-user`.`network` AS `network`,
1782 `post-user`.`vid` AS `vid`,
1783 `post-user`.`psid` AS `psid`,
1784 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1785 `post-content`.`title` AS `title`,
1786 `post-content`.`content-warning` AS `content-warning`,
1787 `post-content`.`raw-body` AS `raw-body`,
1788 IFNULL (`post-content`.`body`, '') AS `body`,
1789 `post-content`.`rendered-hash` AS `rendered-hash`,
1790 `post-content`.`rendered-html` AS `rendered-html`,
1791 `post-content`.`language` AS `language`,
1792 `post-content`.`plink` AS `plink`,
1793 `post-content`.`location` AS `location`,
1794 `post-content`.`coord` AS `coord`,
1795 `post-content`.`app` AS `app`,
1796 `post-content`.`object-type` AS `object-type`,
1797 `post-content`.`object` AS `object`,
1798 `post-content`.`target-type` AS `target-type`,
1799 `post-content`.`target` AS `target`,
1800 `post-content`.`resource-id` AS `resource-id`,
1801 `post-user`.`contact-id` AS `contact-id`,
1802 `contact`.`uri-id` AS `contact-uri-id`,
1803 `contact`.`url` AS `contact-link`,
1804 `contact`.`addr` AS `contact-addr`,
1805 `contact`.`name` AS `contact-name`,
1806 `contact`.`nick` AS `contact-nick`,
1807 `contact`.`thumb` AS `contact-avatar`,
1808 `contact`.`network` AS `contact-network`,
1809 `contact`.`blocked` AS `contact-blocked`,
1810 `contact`.`hidden` AS `contact-hidden`,
1811 `contact`.`readonly` AS `contact-readonly`,
1812 `contact`.`archive` AS `contact-archive`,
1813 `contact`.`pending` AS `contact-pending`,
1814 `contact`.`rel` AS `contact-rel`,
1815 `contact`.`uid` AS `contact-uid`,
1816 `contact`.`contact-type` AS `contact-contact-type`,
1817 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1818 `contact`.`self` AS `self`,
1819 `contact`.`id` AS `cid`,
1820 `contact`.`alias` AS `alias`,
1821 `contact`.`photo` AS `photo`,
1822 `contact`.`name-date` AS `name-date`,
1823 `contact`.`uri-date` AS `uri-date`,
1824 `contact`.`avatar-date` AS `avatar-date`,
1825 `contact`.`thumb` AS `thumb`,
1826 `post-user`.`author-id` AS `author-id`,
1827 `author`.`uri-id` AS `author-uri-id`,
1828 `author`.`url` AS `author-link`,
1829 `author`.`addr` AS `author-addr`,
1830 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1831 `author`.`nick` AS `author-nick`,
1832 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1833 `author`.`network` AS `author-network`,
1834 `author`.`blocked` AS `author-blocked`,
1835 `author`.`hidden` AS `author-hidden`,
1836 `author`.`updated` AS `author-updated`,
1837 `author`.`gsid` AS `author-gsid`,
1838 `post-user`.`owner-id` AS `owner-id`,
1839 `owner`.`uri-id` AS `owner-uri-id`,
1840 `owner`.`url` AS `owner-link`,
1841 `owner`.`addr` AS `owner-addr`,
1842 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1843 `owner`.`nick` AS `owner-nick`,
1844 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1845 `owner`.`network` AS `owner-network`,
1846 `owner`.`blocked` AS `owner-blocked`,
1847 `owner`.`hidden` AS `owner-hidden`,
1848 `owner`.`updated` AS `owner-updated`,
1849 `owner`.`contact-type` AS `owner-contact-type`,
1850 `post-user`.`causer-id` AS `causer-id`,
1851 `causer`.`uri-id` AS `causer-uri-id`,
1852 `causer`.`url` AS `causer-link`,
1853 `causer`.`addr` AS `causer-addr`,
1854 `causer`.`name` AS `causer-name`,
1855 `causer`.`nick` AS `causer-nick`,
1856 `causer`.`thumb` AS `causer-avatar`,
1857 `causer`.`network` AS `causer-network`,
1858 `causer`.`blocked` AS `causer-blocked`,
1859 `causer`.`hidden` AS `causer-hidden`,
1860 `causer`.`contact-type` AS `causer-contact-type`,
1861 `post-delivery-data`.`postopts` AS `postopts`,
1862 `post-delivery-data`.`inform` AS `inform`,
1863 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1864 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1865 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1866 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1867 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1868 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1869 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1870 `post-user`.`event-id` AS `event-id`,
1871 `event`.`created` AS `event-created`,
1872 `event`.`edited` AS `event-edited`,
1873 `event`.`start` AS `event-start`,
1874 `event`.`finish` AS `event-finish`,
1875 `event`.`summary` AS `event-summary`,
1876 `event`.`desc` AS `event-desc`,
1877 `event`.`location` AS `event-location`,
1878 `event`.`type` AS `event-type`,
1879 `event`.`nofinish` AS `event-nofinish`,
1880 `event`.`ignore` AS `event-ignore`,
1881 `post-question`.`id` AS `question-id`,
1882 `post-question`.`multiple` AS `question-multiple`,
1883 `post-question`.`voters` AS `question-voters`,
1884 `post-question`.`end-time` AS `question-end-time`,
1885 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`,
1886 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-user`.`uri-id`) AS `has-media`,
1887 `diaspora-interaction`.`interaction` AS `signed_text`,
1888 `parent-item-uri`.`guid` AS `parent-guid`,
1889 `parent-post`.`network` AS `parent-network`,
1890 `parent-post`.`author-id` AS `parent-author-id`,
1891 `parent-post-author`.`url` AS `parent-author-link`,
1892 `parent-post-author`.`name` AS `parent-author-name`,
1893 `parent-post-author`.`nick` AS `parent-author-nick`,
1894 `parent-post-author`.`network` AS `parent-author-network`,
1895 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1896 `parent-post-author`.`hidden` AS `parent-author-hidden`
1898 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
1899 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
1900 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
1901 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
1902 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
1903 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
1904 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1905 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1906 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
1907 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1908 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1909 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1910 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
1911 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
1912 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
1913 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-user`.`uri-id`
1914 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
1915 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
1916 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1919 -- VIEW post-thread-user-view
1921 DROP VIEW IF EXISTS `post-thread-user-view`;
1922 CREATE VIEW `post-thread-user-view` AS SELECT
1923 `post-user`.`id` AS `id`,
1924 `post-user`.`id` AS `post-user-id`,
1925 `post-thread-user`.`uid` AS `uid`,
1926 `parent-post`.`id` AS `parent`,
1927 `item-uri`.`uri` AS `uri`,
1928 `post-thread-user`.`uri-id` AS `uri-id`,
1929 `parent-item-uri`.`uri` AS `parent-uri`,
1930 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1931 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1932 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1933 `conversation-item-uri`.`uri` AS `conversation`,
1934 `post-thread-user`.`conversation-id` AS `conversation-id`,
1935 `item-uri`.`guid` AS `guid`,
1936 `post-thread-user`.`wall` AS `wall`,
1937 `post-user`.`gravity` AS `gravity`,
1938 `external-item-uri`.`uri` AS `extid`,
1939 `post-user`.`external-id` AS `external-id`,
1940 `post-thread-user`.`created` AS `created`,
1941 `post-user`.`edited` AS `edited`,
1942 `post-thread-user`.`commented` AS `commented`,
1943 `post-thread-user`.`received` AS `received`,
1944 `post-thread-user`.`changed` AS `changed`,
1945 `post-user`.`post-type` AS `post-type`,
1946 `post-user`.`post-reason` AS `post-reason`,
1947 `post-user`.`private` AS `private`,
1948 `post-thread-user`.`pubmail` AS `pubmail`,
1949 `post-thread-user`.`ignored` AS `ignored`,
1950 `post-user`.`visible` AS `visible`,
1951 `post-thread-user`.`starred` AS `starred`,
1952 `post-thread-user`.`unseen` AS `unseen`,
1953 `post-user`.`deleted` AS `deleted`,
1954 `post-thread-user`.`origin` AS `origin`,
1955 `post-thread-user`.`mention` AS `mention`,
1956 `post-user`.`global` AS `global`,
1957 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread-user`.`uri-id`) AS `featured`,
1958 `post-thread-user`.`network` AS `network`,
1959 `post-user`.`vid` AS `vid`,
1960 `post-thread-user`.`psid` AS `psid`,
1961 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1962 `post-content`.`title` AS `title`,
1963 `post-content`.`content-warning` AS `content-warning`,
1964 `post-content`.`raw-body` AS `raw-body`,
1965 `post-content`.`body` AS `body`,
1966 `post-content`.`rendered-hash` AS `rendered-hash`,
1967 `post-content`.`rendered-html` AS `rendered-html`,
1968 `post-content`.`language` AS `language`,
1969 `post-content`.`plink` AS `plink`,
1970 `post-content`.`location` AS `location`,
1971 `post-content`.`coord` AS `coord`,
1972 `post-content`.`app` AS `app`,
1973 `post-content`.`object-type` AS `object-type`,
1974 `post-content`.`object` AS `object`,
1975 `post-content`.`target-type` AS `target-type`,
1976 `post-content`.`target` AS `target`,
1977 `post-content`.`resource-id` AS `resource-id`,
1978 `post-thread-user`.`contact-id` AS `contact-id`,
1979 `contact`.`uri-id` AS `contact-uri-id`,
1980 `contact`.`url` AS `contact-link`,
1981 `contact`.`addr` AS `contact-addr`,
1982 `contact`.`name` AS `contact-name`,
1983 `contact`.`nick` AS `contact-nick`,
1984 `contact`.`thumb` AS `contact-avatar`,
1985 `contact`.`network` AS `contact-network`,
1986 `contact`.`blocked` AS `contact-blocked`,
1987 `contact`.`hidden` AS `contact-hidden`,
1988 `contact`.`readonly` AS `contact-readonly`,
1989 `contact`.`archive` AS `contact-archive`,
1990 `contact`.`pending` AS `contact-pending`,
1991 `contact`.`rel` AS `contact-rel`,
1992 `contact`.`uid` AS `contact-uid`,
1993 `contact`.`contact-type` AS `contact-contact-type`,
1994 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1995 `contact`.`self` AS `self`,
1996 `contact`.`id` AS `cid`,
1997 `contact`.`alias` AS `alias`,
1998 `contact`.`photo` AS `photo`,
1999 `contact`.`name-date` AS `name-date`,
2000 `contact`.`uri-date` AS `uri-date`,
2001 `contact`.`avatar-date` AS `avatar-date`,
2002 `contact`.`thumb` AS `thumb`,
2003 `post-thread-user`.`author-id` AS `author-id`,
2004 `author`.`uri-id` AS `author-uri-id`,
2005 `author`.`url` AS `author-link`,
2006 `author`.`addr` AS `author-addr`,
2007 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
2008 `author`.`nick` AS `author-nick`,
2009 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
2010 `author`.`network` AS `author-network`,
2011 `author`.`blocked` AS `author-blocked`,
2012 `author`.`hidden` AS `author-hidden`,
2013 `author`.`updated` AS `author-updated`,
2014 `author`.`gsid` AS `author-gsid`,
2015 `post-thread-user`.`owner-id` AS `owner-id`,
2016 `owner`.`uri-id` AS `owner-uri-id`,
2017 `owner`.`url` AS `owner-link`,
2018 `owner`.`addr` AS `owner-addr`,
2019 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
2020 `owner`.`nick` AS `owner-nick`,
2021 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
2022 `owner`.`network` AS `owner-network`,
2023 `owner`.`blocked` AS `owner-blocked`,
2024 `owner`.`hidden` AS `owner-hidden`,
2025 `owner`.`updated` AS `owner-updated`,
2026 `owner`.`contact-type` AS `owner-contact-type`,
2027 `post-thread-user`.`causer-id` AS `causer-id`,
2028 `causer`.`uri-id` AS `causer-uri-id`,
2029 `causer`.`url` AS `causer-link`,
2030 `causer`.`addr` AS `causer-addr`,
2031 `causer`.`name` AS `causer-name`,
2032 `causer`.`nick` AS `causer-nick`,
2033 `causer`.`thumb` AS `causer-avatar`,
2034 `causer`.`network` AS `causer-network`,
2035 `causer`.`blocked` AS `causer-blocked`,
2036 `causer`.`hidden` AS `causer-hidden`,
2037 `causer`.`contact-type` AS `causer-contact-type`,
2038 `post-delivery-data`.`postopts` AS `postopts`,
2039 `post-delivery-data`.`inform` AS `inform`,
2040 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
2041 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
2042 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
2043 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
2044 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
2045 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
2046 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
2047 `post-user`.`event-id` AS `event-id`,
2048 `event`.`created` AS `event-created`,
2049 `event`.`edited` AS `event-edited`,
2050 `event`.`start` AS `event-start`,
2051 `event`.`finish` AS `event-finish`,
2052 `event`.`summary` AS `event-summary`,
2053 `event`.`desc` AS `event-desc`,
2054 `event`.`location` AS `event-location`,
2055 `event`.`type` AS `event-type`,
2056 `event`.`nofinish` AS `event-nofinish`,
2057 `event`.`ignore` AS `event-ignore`,
2058 `post-question`.`id` AS `question-id`,
2059 `post-question`.`multiple` AS `question-multiple`,
2060 `post-question`.`voters` AS `question-voters`,
2061 `post-question`.`end-time` AS `question-end-time`,
2062 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`,
2063 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread-user`.`uri-id`) AS `has-media`,
2064 `diaspora-interaction`.`interaction` AS `signed_text`,
2065 `parent-item-uri`.`guid` AS `parent-guid`,
2066 `parent-post`.`network` AS `parent-network`,
2067 `parent-post`.`author-id` AS `parent-author-id`,
2068 `parent-post-author`.`url` AS `parent-author-link`,
2069 `parent-post-author`.`name` AS `parent-author-name`,
2070 `parent-post-author`.`network` AS `parent-author-network`,
2071 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2072 `parent-post-author`.`hidden` AS `parent-author-hidden`
2073 FROM `post-thread-user`
2074 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2075 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2076 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
2077 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
2078 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
2079 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
2080 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
2081 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
2082 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
2083 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
2084 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
2085 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
2086 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
2087 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
2088 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
2089 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread-user`.`uri-id`
2090 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
2091 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`
2092 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2097 DROP VIEW IF EXISTS `post-view`;
2098 CREATE VIEW `post-view` AS SELECT
2099 `item-uri`.`uri` AS `uri`,
2100 `post`.`uri-id` AS `uri-id`,
2101 `parent-item-uri`.`uri` AS `parent-uri`,
2102 `post`.`parent-uri-id` AS `parent-uri-id`,
2103 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2104 `post`.`thr-parent-id` AS `thr-parent-id`,
2105 `conversation-item-uri`.`uri` AS `conversation`,
2106 `post-thread`.`conversation-id` AS `conversation-id`,
2107 `item-uri`.`guid` AS `guid`,
2108 `post`.`gravity` AS `gravity`,
2109 `external-item-uri`.`uri` AS `extid`,
2110 `post`.`external-id` AS `external-id`,
2111 `post`.`created` AS `created`,
2112 `post`.`edited` AS `edited`,
2113 `post-thread`.`commented` AS `commented`,
2114 `post`.`received` AS `received`,
2115 `post-thread`.`changed` AS `changed`,
2116 `post`.`post-type` AS `post-type`,
2117 `post`.`private` AS `private`,
2118 `post`.`visible` AS `visible`,
2119 `post`.`deleted` AS `deleted`,
2120 `post`.`global` AS `global`,
2121 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post`.`uri-id`) AS `featured`,
2122 `post`.`network` AS `network`,
2123 `post`.`vid` AS `vid`,
2124 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2125 `post-content`.`title` AS `title`,
2126 `post-content`.`content-warning` AS `content-warning`,
2127 `post-content`.`raw-body` AS `raw-body`,
2128 `post-content`.`body` AS `body`,
2129 `post-content`.`rendered-hash` AS `rendered-hash`,
2130 `post-content`.`rendered-html` AS `rendered-html`,
2131 `post-content`.`language` AS `language`,
2132 `post-content`.`plink` AS `plink`,
2133 `post-content`.`location` AS `location`,
2134 `post-content`.`coord` AS `coord`,
2135 `post-content`.`app` AS `app`,
2136 `post-content`.`object-type` AS `object-type`,
2137 `post-content`.`object` AS `object`,
2138 `post-content`.`target-type` AS `target-type`,
2139 `post-content`.`target` AS `target`,
2140 `post-content`.`resource-id` AS `resource-id`,
2141 `post`.`author-id` AS `contact-id`,
2142 `author`.`uri-id` AS `contact-uri-id`,
2143 `author`.`url` AS `contact-link`,
2144 `author`.`addr` AS `contact-addr`,
2145 `author`.`name` AS `contact-name`,
2146 `author`.`nick` AS `contact-nick`,
2147 `author`.`thumb` AS `contact-avatar`,
2148 `author`.`network` AS `contact-network`,
2149 `author`.`blocked` AS `contact-blocked`,
2150 `author`.`hidden` AS `contact-hidden`,
2151 `author`.`readonly` AS `contact-readonly`,
2152 `author`.`archive` AS `contact-archive`,
2153 `author`.`pending` AS `contact-pending`,
2154 `author`.`rel` AS `contact-rel`,
2155 `author`.`uid` AS `contact-uid`,
2156 `author`.`contact-type` AS `contact-contact-type`,
2157 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2159 `author`.`id` AS `cid`,
2160 `author`.`alias` AS `alias`,
2161 `author`.`photo` AS `photo`,
2162 `author`.`name-date` AS `name-date`,
2163 `author`.`uri-date` AS `uri-date`,
2164 `author`.`avatar-date` AS `avatar-date`,
2165 `author`.`thumb` AS `thumb`,
2166 `post`.`author-id` AS `author-id`,
2167 `author`.`uri-id` AS `author-uri-id`,
2168 `author`.`url` AS `author-link`,
2169 `author`.`addr` AS `author-addr`,
2170 `author`.`name` AS `author-name`,
2171 `author`.`nick` AS `author-nick`,
2172 `author`.`thumb` AS `author-avatar`,
2173 `author`.`network` AS `author-network`,
2174 `author`.`blocked` AS `author-blocked`,
2175 `author`.`hidden` AS `author-hidden`,
2176 `author`.`updated` AS `author-updated`,
2177 `author`.`gsid` AS `author-gsid`,
2178 `post`.`owner-id` AS `owner-id`,
2179 `owner`.`uri-id` AS `owner-uri-id`,
2180 `owner`.`url` AS `owner-link`,
2181 `owner`.`addr` AS `owner-addr`,
2182 `owner`.`name` AS `owner-name`,
2183 `owner`.`nick` AS `owner-nick`,
2184 `owner`.`thumb` AS `owner-avatar`,
2185 `owner`.`network` AS `owner-network`,
2186 `owner`.`blocked` AS `owner-blocked`,
2187 `owner`.`hidden` AS `owner-hidden`,
2188 `owner`.`updated` AS `owner-updated`,
2189 `owner`.`contact-type` AS `owner-contact-type`,
2190 `post`.`causer-id` AS `causer-id`,
2191 `causer`.`uri-id` AS `causer-uri-id`,
2192 `causer`.`url` AS `causer-link`,
2193 `causer`.`addr` AS `causer-addr`,
2194 `causer`.`name` AS `causer-name`,
2195 `causer`.`nick` AS `causer-nick`,
2196 `causer`.`thumb` AS `causer-avatar`,
2197 `causer`.`network` AS `causer-network`,
2198 `causer`.`blocked` AS `causer-blocked`,
2199 `causer`.`hidden` AS `causer-hidden`,
2200 `causer`.`contact-type` AS `causer-contact-type`,
2201 `post-question`.`id` AS `question-id`,
2202 `post-question`.`multiple` AS `question-multiple`,
2203 `post-question`.`voters` AS `question-voters`,
2204 `post-question`.`end-time` AS `question-end-time`,
2205 0 AS `has-categories`,
2206 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post`.`uri-id`) AS `has-media`,
2207 `diaspora-interaction`.`interaction` AS `signed_text`,
2208 `parent-item-uri`.`guid` AS `parent-guid`,
2209 `parent-post`.`network` AS `parent-network`,
2210 `parent-post`.`author-id` AS `parent-author-id`,
2211 `parent-post-author`.`url` AS `parent-author-link`,
2212 `parent-post-author`.`name` AS `parent-author-name`,
2213 `parent-post-author`.`network` AS `parent-author-network`,
2214 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2215 `parent-post-author`.`hidden` AS `parent-author-hidden`
2217 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
2218 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
2219 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
2220 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
2221 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
2222 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2223 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2224 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
2225 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2226 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2227 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
2228 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
2229 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post`.`uri-id`
2230 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2231 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2234 -- VIEW post-thread-view
2236 DROP VIEW IF EXISTS `post-thread-view`;
2237 CREATE VIEW `post-thread-view` AS SELECT
2238 `item-uri`.`uri` AS `uri`,
2239 `post-thread`.`uri-id` AS `uri-id`,
2240 `parent-item-uri`.`uri` AS `parent-uri`,
2241 `post`.`parent-uri-id` AS `parent-uri-id`,
2242 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2243 `post`.`thr-parent-id` AS `thr-parent-id`,
2244 `conversation-item-uri`.`uri` AS `conversation`,
2245 `post-thread`.`conversation-id` AS `conversation-id`,
2246 `item-uri`.`guid` AS `guid`,
2247 `post`.`gravity` AS `gravity`,
2248 `external-item-uri`.`uri` AS `extid`,
2249 `post`.`external-id` AS `external-id`,
2250 `post-thread`.`created` AS `created`,
2251 `post`.`edited` AS `edited`,
2252 `post-thread`.`commented` AS `commented`,
2253 `post-thread`.`received` AS `received`,
2254 `post-thread`.`changed` AS `changed`,
2255 `post`.`post-type` AS `post-type`,
2256 `post`.`private` AS `private`,
2257 `post`.`visible` AS `visible`,
2258 `post`.`deleted` AS `deleted`,
2259 `post`.`global` AS `global`,
2260 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread`.`uri-id`) AS `featured`,
2261 `post-thread`.`network` AS `network`,
2262 `post`.`vid` AS `vid`,
2263 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2264 `post-content`.`title` AS `title`,
2265 `post-content`.`content-warning` AS `content-warning`,
2266 `post-content`.`raw-body` AS `raw-body`,
2267 `post-content`.`body` AS `body`,
2268 `post-content`.`rendered-hash` AS `rendered-hash`,
2269 `post-content`.`rendered-html` AS `rendered-html`,
2270 `post-content`.`language` AS `language`,
2271 `post-content`.`plink` AS `plink`,
2272 `post-content`.`location` AS `location`,
2273 `post-content`.`coord` AS `coord`,
2274 `post-content`.`app` AS `app`,
2275 `post-content`.`object-type` AS `object-type`,
2276 `post-content`.`object` AS `object`,
2277 `post-content`.`target-type` AS `target-type`,
2278 `post-content`.`target` AS `target`,
2279 `post-content`.`resource-id` AS `resource-id`,
2280 `post-thread`.`author-id` AS `contact-id`,
2281 `author`.`uri-id` AS `contact-uri-id`,
2282 `author`.`url` AS `contact-link`,
2283 `author`.`addr` AS `contact-addr`,
2284 `author`.`name` AS `contact-name`,
2285 `author`.`nick` AS `contact-nick`,
2286 `author`.`thumb` AS `contact-avatar`,
2287 `author`.`network` AS `contact-network`,
2288 `author`.`blocked` AS `contact-blocked`,
2289 `author`.`hidden` AS `contact-hidden`,
2290 `author`.`readonly` AS `contact-readonly`,
2291 `author`.`archive` AS `contact-archive`,
2292 `author`.`pending` AS `contact-pending`,
2293 `author`.`rel` AS `contact-rel`,
2294 `author`.`uid` AS `contact-uid`,
2295 `author`.`contact-type` AS `contact-contact-type`,
2296 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2298 `author`.`id` AS `cid`,
2299 `author`.`alias` AS `alias`,
2300 `author`.`photo` AS `photo`,
2301 `author`.`name-date` AS `name-date`,
2302 `author`.`uri-date` AS `uri-date`,
2303 `author`.`avatar-date` AS `avatar-date`,
2304 `author`.`thumb` AS `thumb`,
2305 `post-thread`.`author-id` AS `author-id`,
2306 `author`.`uri-id` AS `author-uri-id`,
2307 `author`.`url` AS `author-link`,
2308 `author`.`addr` AS `author-addr`,
2309 `author`.`name` AS `author-name`,
2310 `author`.`nick` AS `author-nick`,
2311 `author`.`thumb` AS `author-avatar`,
2312 `author`.`network` AS `author-network`,
2313 `author`.`blocked` AS `author-blocked`,
2314 `author`.`hidden` AS `author-hidden`,
2315 `author`.`updated` AS `author-updated`,
2316 `author`.`gsid` AS `author-gsid`,
2317 `post-thread`.`owner-id` AS `owner-id`,
2318 `owner`.`uri-id` AS `owner-uri-id`,
2319 `owner`.`url` AS `owner-link`,
2320 `owner`.`addr` AS `owner-addr`,
2321 `owner`.`name` AS `owner-name`,
2322 `owner`.`nick` AS `owner-nick`,
2323 `owner`.`thumb` AS `owner-avatar`,
2324 `owner`.`network` AS `owner-network`,
2325 `owner`.`blocked` AS `owner-blocked`,
2326 `owner`.`hidden` AS `owner-hidden`,
2327 `owner`.`updated` AS `owner-updated`,
2328 `owner`.`contact-type` AS `owner-contact-type`,
2329 `post-thread`.`causer-id` AS `causer-id`,
2330 `causer`.`uri-id` AS `causer-uri-id`,
2331 `causer`.`url` AS `causer-link`,
2332 `causer`.`addr` AS `causer-addr`,
2333 `causer`.`name` AS `causer-name`,
2334 `causer`.`nick` AS `causer-nick`,
2335 `causer`.`thumb` AS `causer-avatar`,
2336 `causer`.`network` AS `causer-network`,
2337 `causer`.`blocked` AS `causer-blocked`,
2338 `causer`.`hidden` AS `causer-hidden`,
2339 `causer`.`contact-type` AS `causer-contact-type`,
2340 `post-question`.`id` AS `question-id`,
2341 `post-question`.`multiple` AS `question-multiple`,
2342 `post-question`.`voters` AS `question-voters`,
2343 `post-question`.`end-time` AS `question-end-time`,
2344 0 AS `has-categories`,
2345 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread`.`uri-id`) AS `has-media`,
2346 `diaspora-interaction`.`interaction` AS `signed_text`,
2347 `parent-item-uri`.`guid` AS `parent-guid`,
2348 `parent-post`.`network` AS `parent-network`,
2349 `parent-post`.`author-id` AS `parent-author-id`,
2350 `parent-post-author`.`url` AS `parent-author-link`,
2351 `parent-post-author`.`name` AS `parent-author-name`,
2352 `parent-post-author`.`network` AS `parent-author-network`,
2353 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2354 `parent-post-author`.`hidden` AS `parent-author-hidden`
2356 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
2357 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
2358 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
2359 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
2360 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
2361 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2362 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2363 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
2364 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2365 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2366 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
2367 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
2368 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread`.`uri-id`
2369 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2370 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2373 -- VIEW category-view
2375 DROP VIEW IF EXISTS `category-view`;
2376 CREATE VIEW `category-view` AS SELECT
2377 `post-category`.`uri-id` AS `uri-id`,
2378 `post-category`.`uid` AS `uid`,
2379 `post-category`.`type` AS `type`,
2380 `post-category`.`tid` AS `tid`,
2381 `tag`.`name` AS `name`,
2382 `tag`.`url` AS `url`
2383 FROM `post-category`
2384 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2387 -- VIEW collection-view
2389 DROP VIEW IF EXISTS `collection-view`;
2390 CREATE VIEW `collection-view` AS SELECT
2391 `post-collection`.`uri-id` AS `uri-id`,
2392 `post-collection`.`type` AS `type`,
2393 `post`.`author-id` AS `cid`,
2394 `post`.`received` AS `received`,
2395 `post`.`created` AS `created`,
2396 `post-thread`.`commented` AS `commented`,
2397 `post`.`private` AS `private`,
2398 `post`.`visible` AS `visible`,
2399 `post`.`deleted` AS `deleted`,
2400 `post`.`thr-parent-id` AS `thr-parent-id`,
2401 `post`.`author-id` AS `author-id`,
2402 `post`.`gravity` AS `gravity`
2403 FROM `post-collection`
2404 INNER JOIN `post` ON `post-collection`.`uri-id` = `post`.`uri-id`
2405 INNER JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`;
2410 DROP VIEW IF EXISTS `tag-view`;
2411 CREATE VIEW `tag-view` AS SELECT
2412 `post-tag`.`uri-id` AS `uri-id`,
2413 `post-tag`.`type` AS `type`,
2414 `post-tag`.`tid` AS `tid`,
2415 `post-tag`.`cid` AS `cid`,
2416 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2417 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`,
2418 CASE `cid` WHEN 0 THEN `tag`.`type` ELSE 1 END AS `tag-type`
2420 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2421 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2424 -- VIEW network-item-view
2426 DROP VIEW IF EXISTS `network-item-view`;
2427 CREATE VIEW `network-item-view` AS SELECT
2428 `post-user`.`uri-id` AS `uri-id`,
2429 `parent-post`.`id` AS `parent`,
2430 `post-user`.`received` AS `received`,
2431 `post-thread-user`.`commented` AS `commented`,
2432 `post-user`.`created` AS `created`,
2433 `post-user`.`uid` AS `uid`,
2434 `post-thread-user`.`starred` AS `starred`,
2435 `post-thread-user`.`mention` AS `mention`,
2436 `post-user`.`network` AS `network`,
2437 `post-user`.`unseen` AS `unseen`,
2438 `post-user`.`gravity` AS `gravity`,
2439 `post-user`.`contact-id` AS `contact-id`,
2440 `ownercontact`.`contact-type` AS `contact-type`
2442 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2443 INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2444 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2445 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2446 INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2447 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2448 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2449 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2450 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
2451 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2452 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2455 -- VIEW network-thread-view
2457 DROP VIEW IF EXISTS `network-thread-view`;
2458 CREATE VIEW `network-thread-view` AS SELECT
2459 `post-thread-user`.`uri-id` AS `uri-id`,
2460 `parent-post`.`id` AS `parent`,
2461 `post-thread-user`.`received` AS `received`,
2462 `post-thread-user`.`commented` AS `commented`,
2463 `post-thread-user`.`created` AS `created`,
2464 `post-thread-user`.`uid` AS `uid`,
2465 `post-thread-user`.`starred` AS `starred`,
2466 `post-thread-user`.`mention` AS `mention`,
2467 `post-thread-user`.`network` AS `network`,
2468 `post-thread-user`.`contact-id` AS `contact-id`,
2469 `ownercontact`.`contact-type` AS `contact-type`
2470 FROM `post-thread-user`
2471 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2472 STRAIGHT_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 LEFT 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-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2480 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2481 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2486 DROP VIEW IF EXISTS `owner-view`;
2487 CREATE VIEW `owner-view` AS SELECT
2488 `contact`.`id` AS `id`,
2489 `contact`.`uid` AS `uid`,
2490 `contact`.`created` AS `created`,
2491 `contact`.`updated` AS `updated`,
2492 `contact`.`self` AS `self`,
2493 `contact`.`remote_self` AS `remote_self`,
2494 `contact`.`rel` AS `rel`,
2495 `contact`.`network` AS `network`,
2496 `contact`.`protocol` AS `protocol`,
2497 `contact`.`name` AS `name`,
2498 `contact`.`nick` AS `nick`,
2499 `contact`.`location` AS `location`,
2500 `contact`.`about` AS `about`,
2501 `contact`.`keywords` AS `keywords`,
2502 `contact`.`xmpp` AS `xmpp`,
2503 `contact`.`matrix` AS `matrix`,
2504 `contact`.`attag` AS `attag`,
2505 `contact`.`avatar` AS `avatar`,
2506 `contact`.`photo` AS `photo`,
2507 `contact`.`thumb` AS `thumb`,
2508 `contact`.`micro` AS `micro`,
2509 `contact`.`header` AS `header`,
2510 `contact`.`url` AS `url`,
2511 `contact`.`nurl` AS `nurl`,
2512 `contact`.`uri-id` AS `uri-id`,
2513 `contact`.`addr` AS `addr`,
2514 `contact`.`alias` AS `alias`,
2515 `contact`.`pubkey` AS `pubkey`,
2516 `contact`.`prvkey` AS `prvkey`,
2517 `contact`.`batch` AS `batch`,
2518 `contact`.`request` AS `request`,
2519 `contact`.`notify` AS `notify`,
2520 `contact`.`poll` AS `poll`,
2521 `contact`.`confirm` AS `confirm`,
2522 `contact`.`poco` AS `poco`,
2523 `contact`.`subhub` AS `subhub`,
2524 `contact`.`hub-verify` AS `hub-verify`,
2525 `contact`.`last-update` AS `last-update`,
2526 `contact`.`success_update` AS `success_update`,
2527 `contact`.`failure_update` AS `failure_update`,
2528 `contact`.`name-date` AS `name-date`,
2529 `contact`.`uri-date` AS `uri-date`,
2530 `contact`.`avatar-date` AS `avatar-date`,
2531 `contact`.`avatar-date` AS `picdate`,
2532 `contact`.`term-date` AS `term-date`,
2533 `contact`.`last-item` AS `last-item`,
2534 `contact`.`priority` AS `priority`,
2535 `user`.`blocked` AS `blocked`,
2536 `contact`.`block_reason` AS `block_reason`,
2537 `contact`.`readonly` AS `readonly`,
2538 `contact`.`writable` AS `writable`,
2539 `contact`.`forum` AS `forum`,
2540 `contact`.`prv` AS `prv`,
2541 `contact`.`contact-type` AS `contact-type`,
2542 `contact`.`manually-approve` AS `manually-approve`,
2543 `contact`.`hidden` AS `hidden`,
2544 `contact`.`archive` AS `archive`,
2545 `contact`.`pending` AS `pending`,
2546 `contact`.`deleted` AS `deleted`,
2547 `contact`.`unsearchable` AS `unsearchable`,
2548 `contact`.`sensitive` AS `sensitive`,
2549 `contact`.`baseurl` AS `baseurl`,
2550 `contact`.`reason` AS `reason`,
2551 `contact`.`info` AS `info`,
2552 `contact`.`bdyear` AS `bdyear`,
2553 `contact`.`bd` AS `bd`,
2554 `contact`.`notify_new_posts` AS `notify_new_posts`,
2555 `contact`.`fetch_further_information` AS `fetch_further_information`,
2556 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2557 `user`.`parent-uid` AS `parent-uid`,
2558 `user`.`guid` AS `guid`,
2559 `user`.`nickname` AS `nickname`,
2560 `user`.`email` AS `email`,
2561 `user`.`openid` AS `openid`,
2562 `user`.`timezone` AS `timezone`,
2563 `user`.`language` AS `language`,
2564 `user`.`register_date` AS `register_date`,
2565 `user`.`login_date` AS `login_date`,
2566 `user`.`default-location` AS `default-location`,
2567 `user`.`allow_location` AS `allow_location`,
2568 `user`.`theme` AS `theme`,
2569 `user`.`pubkey` AS `upubkey`,
2570 `user`.`prvkey` AS `uprvkey`,
2571 `user`.`sprvkey` AS `sprvkey`,
2572 `user`.`spubkey` AS `spubkey`,
2573 `user`.`verified` AS `verified`,
2574 `user`.`blockwall` AS `blockwall`,
2575 `user`.`hidewall` AS `hidewall`,
2576 `user`.`blocktags` AS `blocktags`,
2577 `user`.`unkmail` AS `unkmail`,
2578 `user`.`cntunkmail` AS `cntunkmail`,
2579 `user`.`notify-flags` AS `notify-flags`,
2580 `user`.`page-flags` AS `page-flags`,
2581 `user`.`account-type` AS `account-type`,
2582 `user`.`prvnets` AS `prvnets`,
2583 `user`.`maxreq` AS `maxreq`,
2584 `user`.`expire` AS `expire`,
2585 `user`.`account_removed` AS `account_removed`,
2586 `user`.`account_expired` AS `account_expired`,
2587 `user`.`account_expires_on` AS `account_expires_on`,
2588 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2589 `user`.`def_gid` AS `def_gid`,
2590 `user`.`allow_cid` AS `allow_cid`,
2591 `user`.`allow_gid` AS `allow_gid`,
2592 `user`.`deny_cid` AS `deny_cid`,
2593 `user`.`deny_gid` AS `deny_gid`,
2594 `user`.`openidserver` AS `openidserver`,
2595 `profile`.`publish` AS `publish`,
2596 `profile`.`net-publish` AS `net-publish`,
2597 `profile`.`hide-friends` AS `hide-friends`,
2598 `profile`.`prv_keywords` AS `prv_keywords`,
2599 `profile`.`pub_keywords` AS `pub_keywords`,
2600 `profile`.`address` AS `address`,
2601 `profile`.`locality` AS `locality`,
2602 `profile`.`region` AS `region`,
2603 `profile`.`postal-code` AS `postal-code`,
2604 `profile`.`country-name` AS `country-name`,
2605 `profile`.`homepage` AS `homepage`,
2606 `profile`.`dob` AS `dob`
2608 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2609 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2612 -- VIEW account-view
2614 DROP VIEW IF EXISTS `account-view`;
2615 CREATE VIEW `account-view` AS SELECT
2616 `contact`.`id` AS `id`,
2617 `contact`.`url` AS `url`,
2618 `contact`.`nurl` AS `nurl`,
2619 `contact`.`uri-id` AS `uri-id`,
2620 `item-uri`.`guid` AS `guid`,
2621 `contact`.`addr` AS `addr`,
2622 `contact`.`alias` AS `alias`,
2623 `contact`.`name` AS `name`,
2624 `contact`.`nick` AS `nick`,
2625 `contact`.`about` AS `about`,
2626 `contact`.`keywords` AS `keywords`,
2627 `contact`.`xmpp` AS `xmpp`,
2628 `contact`.`matrix` AS `matrix`,
2629 `contact`.`avatar` AS `avatar`,
2630 `contact`.`photo` AS `photo`,
2631 `contact`.`thumb` AS `thumb`,
2632 `contact`.`micro` AS `micro`,
2633 `contact`.`header` AS `header`,
2634 `contact`.`created` AS `created`,
2635 `contact`.`updated` AS `updated`,
2636 `contact`.`network` AS `network`,
2637 `contact`.`protocol` AS `protocol`,
2638 `contact`.`location` AS `location`,
2639 `contact`.`attag` AS `attag`,
2640 `contact`.`pubkey` AS `pubkey`,
2641 `contact`.`prvkey` AS `prvkey`,
2642 `contact`.`subscribe` AS `subscribe`,
2643 `contact`.`last-update` AS `last-update`,
2644 `contact`.`success_update` AS `success_update`,
2645 `contact`.`failure_update` AS `failure_update`,
2646 `contact`.`failed` AS `failed`,
2647 `contact`.`last-item` AS `last-item`,
2648 `contact`.`last-discovery` AS `last-discovery`,
2649 `contact`.`contact-type` AS `contact-type`,
2650 `contact`.`manually-approve` AS `manually-approve`,
2651 `contact`.`unsearchable` AS `unsearchable`,
2652 `contact`.`sensitive` AS `sensitive`,
2653 `contact`.`baseurl` AS `baseurl`,
2654 `contact`.`gsid` AS `gsid`,
2655 `contact`.`info` AS `info`,
2656 `contact`.`bdyear` AS `bdyear`,
2657 `contact`.`bd` AS `bd`,
2658 `contact`.`poco` AS `poco`,
2659 `contact`.`name-date` AS `name-date`,
2660 `contact`.`uri-date` AS `uri-date`,
2661 `contact`.`avatar-date` AS `avatar-date`,
2662 `contact`.`term-date` AS `term-date`,
2663 `contact`.`hidden` AS `global-ignored`,
2664 `contact`.`blocked` AS `global-blocked`,
2665 `contact`.`hidden` AS `hidden`,
2666 `contact`.`archive` AS `archive`,
2667 `contact`.`deleted` AS `deleted`,
2668 `contact`.`blocked` AS `blocked`,
2669 `contact`.`notify` AS `dfrn-notify`,
2670 `contact`.`poll` AS `dfrn-poll`,
2671 `fcontact`.`guid` AS `diaspora-guid`,
2672 `fcontact`.`batch` AS `diaspora-batch`,
2673 `fcontact`.`notify` AS `diaspora-notify`,
2674 `fcontact`.`poll` AS `diaspora-poll`,
2675 `fcontact`.`alias` AS `diaspora-alias`,
2676 `apcontact`.`uuid` AS `ap-uuid`,
2677 `apcontact`.`type` AS `ap-type`,
2678 `apcontact`.`following` AS `ap-following`,
2679 `apcontact`.`followers` AS `ap-followers`,
2680 `apcontact`.`inbox` AS `ap-inbox`,
2681 `apcontact`.`outbox` AS `ap-outbox`,
2682 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2683 `apcontact`.`generator` AS `ap-generator`,
2684 `apcontact`.`following_count` AS `ap-following_count`,
2685 `apcontact`.`followers_count` AS `ap-followers_count`,
2686 `apcontact`.`statuses_count` AS `ap-statuses_count`,
2687 `gserver`.`site_name` AS `site_name`,
2688 `gserver`.`platform` AS `platform`,
2689 `gserver`.`version` AS `version`
2691 LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id`
2692 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
2693 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = contact.`uri-id`
2694 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`
2695 WHERE `contact`.`uid` = 0;
2698 -- VIEW account-user-view
2700 DROP VIEW IF EXISTS `account-user-view`;
2701 CREATE VIEW `account-user-view` AS SELECT
2702 `ucontact`.`id` AS `id`,
2703 `contact`.`id` AS `pid`,
2704 `ucontact`.`uid` AS `uid`,
2705 `contact`.`url` AS `url`,
2706 `contact`.`nurl` AS `nurl`,
2707 `contact`.`uri-id` AS `uri-id`,
2708 `item-uri`.`guid` AS `guid`,
2709 `contact`.`addr` AS `addr`,
2710 `contact`.`alias` AS `alias`,
2711 `contact`.`name` AS `name`,
2712 `contact`.`nick` AS `nick`,
2713 `contact`.`about` AS `about`,
2714 `contact`.`keywords` AS `keywords`,
2715 `contact`.`xmpp` AS `xmpp`,
2716 `contact`.`matrix` AS `matrix`,
2717 `contact`.`avatar` AS `avatar`,
2718 `contact`.`photo` AS `photo`,
2719 `contact`.`thumb` AS `thumb`,
2720 `contact`.`micro` AS `micro`,
2721 `contact`.`header` AS `header`,
2722 `contact`.`created` AS `created`,
2723 `contact`.`updated` AS `updated`,
2724 `ucontact`.`self` AS `self`,
2725 `ucontact`.`remote_self` AS `remote_self`,
2726 `ucontact`.`rel` AS `rel`,
2727 `contact`.`network` AS `network`,
2728 `ucontact`.`protocol` AS `protocol`,
2729 `contact`.`location` AS `location`,
2730 `ucontact`.`attag` AS `attag`,
2731 `contact`.`pubkey` AS `pubkey`,
2732 `contact`.`prvkey` AS `prvkey`,
2733 `contact`.`subscribe` AS `subscribe`,
2734 `contact`.`last-update` AS `last-update`,
2735 `contact`.`success_update` AS `success_update`,
2736 `contact`.`failure_update` AS `failure_update`,
2737 `contact`.`failed` AS `failed`,
2738 `contact`.`last-item` AS `last-item`,
2739 `contact`.`last-discovery` AS `last-discovery`,
2740 `contact`.`contact-type` AS `contact-type`,
2741 `contact`.`manually-approve` AS `manually-approve`,
2742 `contact`.`unsearchable` AS `unsearchable`,
2743 `contact`.`sensitive` AS `sensitive`,
2744 `contact`.`baseurl` AS `baseurl`,
2745 `contact`.`gsid` AS `gsid`,
2746 `ucontact`.`info` AS `info`,
2747 `contact`.`bdyear` AS `bdyear`,
2748 `contact`.`bd` AS `bd`,
2749 `contact`.`poco` AS `poco`,
2750 `contact`.`name-date` AS `name-date`,
2751 `contact`.`uri-date` AS `uri-date`,
2752 `contact`.`avatar-date` AS `avatar-date`,
2753 `contact`.`term-date` AS `term-date`,
2754 `contact`.`hidden` AS `global-ignored`,
2755 `contact`.`blocked` AS `global-blocked`,
2756 `ucontact`.`hidden` AS `hidden`,
2757 `ucontact`.`archive` AS `archive`,
2758 `ucontact`.`pending` AS `pending`,
2759 `ucontact`.`deleted` AS `deleted`,
2760 `ucontact`.`notify_new_posts` AS `notify_new_posts`,
2761 `ucontact`.`fetch_further_information` AS `fetch_further_information`,
2762 `ucontact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2763 `ucontact`.`rating` AS `rating`,
2764 `ucontact`.`readonly` AS `readonly`,
2765 `ucontact`.`blocked` AS `blocked`,
2766 `ucontact`.`block_reason` AS `block_reason`,
2767 `ucontact`.`subhub` AS `subhub`,
2768 `ucontact`.`hub-verify` AS `hub-verify`,
2769 `ucontact`.`reason` AS `reason`,
2770 `contact`.`notify` AS `dfrn-notify`,
2771 `contact`.`poll` AS `dfrn-poll`,
2772 `fcontact`.`guid` AS `diaspora-guid`,
2773 `fcontact`.`batch` AS `diaspora-batch`,
2774 `fcontact`.`notify` AS `diaspora-notify`,
2775 `fcontact`.`poll` AS `diaspora-poll`,
2776 `fcontact`.`alias` AS `diaspora-alias`,
2777 `fcontact`.`interacting_count` AS `diaspora-interacting_count`,
2778 `fcontact`.`interacted_count` AS `diaspora-interacted_count`,
2779 `fcontact`.`post_count` AS `diaspora-post_count`,
2780 `apcontact`.`uuid` AS `ap-uuid`,
2781 `apcontact`.`type` AS `ap-type`,
2782 `apcontact`.`following` AS `ap-following`,
2783 `apcontact`.`followers` AS `ap-followers`,
2784 `apcontact`.`inbox` AS `ap-inbox`,
2785 `apcontact`.`outbox` AS `ap-outbox`,
2786 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2787 `apcontact`.`generator` AS `ap-generator`,
2788 `apcontact`.`following_count` AS `ap-following_count`,
2789 `apcontact`.`followers_count` AS `ap-followers_count`,
2790 `apcontact`.`statuses_count` AS `ap-statuses_count`,
2791 `gserver`.`site_name` AS `site_name`,
2792 `gserver`.`platform` AS `platform`,
2793 `gserver`.`version` AS `version`
2794 FROM `contact` AS `ucontact`
2795 INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
2796 LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id`
2797 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
2798 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = `ucontact`.`uri-id` AND `fcontact`.`network` = 'dspr'
2799 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`;
2802 -- VIEW pending-view
2804 DROP VIEW IF EXISTS `pending-view`;
2805 CREATE VIEW `pending-view` AS SELECT
2806 `register`.`id` AS `id`,
2807 `register`.`hash` AS `hash`,
2808 `register`.`created` AS `created`,
2809 `register`.`uid` AS `uid`,
2810 `register`.`password` AS `password`,
2811 `register`.`language` AS `language`,
2812 `register`.`note` AS `note`,
2813 `contact`.`self` AS `self`,
2814 `contact`.`name` AS `name`,
2815 `contact`.`url` AS `url`,
2816 `contact`.`micro` AS `micro`,
2817 `user`.`email` AS `email`,
2818 `contact`.`nick` AS `nick`
2820 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2821 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2824 -- VIEW tag-search-view
2826 DROP VIEW IF EXISTS `tag-search-view`;
2827 CREATE VIEW `tag-search-view` AS SELECT
2828 `post-tag`.`uri-id` AS `uri-id`,
2829 `post-user`.`uid` AS `uid`,
2830 `post-user`.`id` AS `iid`,
2831 `post-user`.`private` AS `private`,
2832 `post-user`.`wall` AS `wall`,
2833 `post-user`.`origin` AS `origin`,
2834 `post-user`.`global` AS `global`,
2835 `post-user`.`gravity` AS `gravity`,
2836 `post-user`.`received` AS `received`,
2837 `post-user`.`network` AS `network`,
2838 `post-user`.`author-id` AS `author-id`,
2839 `tag`.`name` AS `name`
2841 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
2842 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
2843 WHERE `post-tag`.`type` = 1;
2846 -- VIEW workerqueue-view
2848 DROP VIEW IF EXISTS `workerqueue-view`;
2849 CREATE VIEW `workerqueue-view` AS SELECT
2850 `process`.`pid` AS `pid`,
2851 `workerqueue`.`priority` AS `priority`
2853 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
2854 WHERE NOT `workerqueue`.`done`;
2857 -- VIEW profile_field-view
2859 DROP VIEW IF EXISTS `profile_field-view`;
2860 CREATE VIEW `profile_field-view` AS SELECT
2861 `profile_field`.`id` AS `id`,
2862 `profile_field`.`uid` AS `uid`,
2863 `profile_field`.`label` AS `label`,
2864 `profile_field`.`value` AS `value`,
2865 `profile_field`.`order` AS `order`,
2866 `profile_field`.`psid` AS `psid`,
2867 `permissionset`.`allow_cid` AS `allow_cid`,
2868 `permissionset`.`allow_gid` AS `allow_gid`,
2869 `permissionset`.`deny_cid` AS `deny_cid`,
2870 `permissionset`.`deny_gid` AS `deny_gid`,
2871 `profile_field`.`created` AS `created`,
2872 `profile_field`.`edited` AS `edited`
2873 FROM `profile_field`
2874 INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`;