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 NOT NULL DEFAULT '0' COMMENT '',
743 `wid` int unsigned COMMENT 'Workerqueue id',
745 UNIQUE INDEX `activity-id` (`activity-id`),
746 INDEX `object-id` (`object-id`),
747 INDEX `received` (`received`),
749 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
750 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Incoming activity';
753 -- TABLE inbox-entry-receiver
755 CREATE TABLE IF NOT EXISTS `inbox-entry-receiver` (
756 `queue-id` int unsigned NOT NULL COMMENT '',
757 `uid` mediumint unsigned NOT NULL COMMENT 'User id',
758 PRIMARY KEY(`queue-id`,`uid`),
760 FOREIGN KEY (`queue-id`) REFERENCES `inbox-entry` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
761 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
762 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Receiver for the incoming activity';
765 -- TABLE inbox-status
767 CREATE TABLE IF NOT EXISTS `inbox-status` (
768 `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
769 `uri-id` int unsigned COMMENT 'Item-uri id of inbox url',
770 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
771 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
772 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
773 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
774 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
775 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
777 INDEX `uri-id` (`uri-id`),
778 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
779 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
784 CREATE TABLE IF NOT EXISTS `intro` (
785 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
786 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
787 `fid` int unsigned COMMENT 'deprecated',
788 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
789 `suggest-cid` int unsigned COMMENT 'Suggested contact',
790 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
791 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
792 `note` text COMMENT '',
793 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
794 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
795 `blocked` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
796 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
798 INDEX `contact-id` (`contact-id`),
799 INDEX `suggest-cid` (`suggest-cid`),
801 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
802 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
803 FOREIGN KEY (`suggest-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
804 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
809 CREATE TABLE IF NOT EXISTS `locks` (
810 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
811 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
812 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
813 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
814 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
816 INDEX `name_expires` (`name`,`expires`)
817 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
822 CREATE TABLE IF NOT EXISTS `mail` (
823 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
824 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
825 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
826 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
827 `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
828 `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
829 `contact-id` varchar(255) COMMENT 'contact.id',
830 `author-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the author of the mail',
831 `convid` int unsigned COMMENT 'conv.id',
832 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
833 `body` mediumtext COMMENT '',
834 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
835 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
836 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
837 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
838 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
839 `uri-id` int unsigned COMMENT 'Item-uri id of the related mail',
840 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
841 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related mail',
842 `thr-parent` varchar(255) COMMENT '',
843 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
844 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
846 INDEX `uid_seen` (`uid`,`seen`),
847 INDEX `convid` (`convid`),
848 INDEX `uri` (`uri`(64)),
849 INDEX `parent-uri` (`parent-uri`(64)),
850 INDEX `contactid` (`contact-id`(32)),
851 INDEX `author-id` (`author-id`),
852 INDEX `uri-id` (`uri-id`),
853 INDEX `parent-uri-id` (`parent-uri-id`),
854 INDEX `thr-parent-id` (`thr-parent-id`),
855 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
856 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
857 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
858 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
859 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
860 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
865 CREATE TABLE IF NOT EXISTS `mailacct` (
866 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
867 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
868 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
869 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
870 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
871 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
872 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
873 `pass` text COMMENT '',
874 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
875 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
876 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
877 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
878 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
881 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
882 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
887 CREATE TABLE IF NOT EXISTS `manage` (
888 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
889 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
890 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
892 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
894 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
895 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
896 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
899 -- TABLE notification
901 CREATE TABLE IF NOT EXISTS `notification` (
902 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
903 `uid` mediumint unsigned COMMENT 'Owner User id',
904 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
905 `type` smallint unsigned COMMENT '',
906 `actor-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the actor that caused the notification',
907 `target-uri-id` int unsigned COMMENT 'Item-uri id of the related post',
908 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
909 `created` datetime COMMENT '',
910 `seen` boolean DEFAULT '0' COMMENT 'Seen on the desktop',
911 `dismissed` boolean DEFAULT '0' COMMENT 'Dismissed via the API',
913 UNIQUE INDEX `uid_vid_type_actor-id_target-uri-id` (`uid`,`vid`,`type`,`actor-id`,`target-uri-id`),
915 INDEX `actor-id` (`actor-id`),
916 INDEX `target-uri-id` (`target-uri-id`),
917 INDEX `parent-uri-id` (`parent-uri-id`),
918 INDEX `seen_uid` (`seen`,`uid`),
919 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
920 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
921 FOREIGN KEY (`actor-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
922 FOREIGN KEY (`target-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
923 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
924 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
929 CREATE TABLE IF NOT EXISTS `notify` (
930 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
931 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
932 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
933 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
934 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
935 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
936 `msg` mediumtext COMMENT '',
937 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
938 `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
939 `iid` int unsigned COMMENT '',
940 `parent` int unsigned COMMENT '',
941 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
942 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
943 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
944 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
945 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
946 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
947 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
949 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
950 INDEX `uid_date` (`uid`,`date`),
951 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
952 INDEX `uri-id` (`uri-id`),
953 INDEX `parent-uri-id` (`parent-uri-id`),
954 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
955 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
956 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
957 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='[Deprecated] User notifications';
960 -- TABLE notify-threads
962 CREATE TABLE IF NOT EXISTS `notify-threads` (
963 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
964 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
965 `master-parent-item` int unsigned COMMENT 'Deprecated',
966 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
967 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
968 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
970 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
971 INDEX `receiver-uid` (`receiver-uid`),
972 INDEX `notify-id` (`notify-id`),
973 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
974 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
975 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
976 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
981 CREATE TABLE IF NOT EXISTS `oembed` (
982 `url` varbinary(255) NOT NULL COMMENT 'page url',
983 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
984 `content` mediumtext COMMENT 'OEmbed data of the page',
985 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
986 PRIMARY KEY(`url`,`maxwidth`),
987 INDEX `created` (`created`)
988 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
991 -- TABLE openwebauth-token
993 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
994 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
995 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
996 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
997 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
998 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
999 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1001 INDEX `uid` (`uid`),
1002 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1003 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
1008 CREATE TABLE IF NOT EXISTS `parsed_url` (
1009 `url_hash` binary(64) NOT NULL COMMENT 'page url hash',
1010 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
1011 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
1012 `url` text NOT NULL COMMENT 'page url',
1013 `content` mediumtext COMMENT 'page data',
1014 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1015 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration',
1016 PRIMARY KEY(`url_hash`,`guessing`,`oembed`),
1017 INDEX `created` (`created`),
1018 INDEX `expires` (`expires`)
1019 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
1024 CREATE TABLE IF NOT EXISTS `pconfig` (
1025 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
1026 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1027 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
1028 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
1029 `v` mediumtext COMMENT 'Value',
1031 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
1032 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1033 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
1038 CREATE TABLE IF NOT EXISTS `photo` (
1039 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1040 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1041 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1042 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
1043 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
1044 `hash` char(32) COMMENT 'hash value of the photo',
1045 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
1046 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
1047 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1048 `desc` text COMMENT '',
1049 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
1050 `photo-type` tinyint unsigned COMMENT 'User avatar, user banner, contact avatar, contact banner or default',
1051 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1052 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
1053 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1054 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1055 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1056 `data` mediumblob NOT NULL COMMENT '',
1057 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1058 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
1059 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
1060 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
1061 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
1062 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
1063 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
1064 `backend-class` tinytext COMMENT 'Storage backend class',
1065 `backend-ref` text COMMENT 'Storage backend data reference',
1066 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1068 INDEX `contactid` (`contact-id`),
1069 INDEX `uid_contactid` (`uid`,`contact-id`),
1070 INDEX `uid_profile` (`uid`,`profile`),
1071 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
1072 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
1073 INDEX `resource-id` (`resource-id`),
1074 INDEX `uid_photo-type` (`uid`,`photo-type`),
1075 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1076 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1077 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1082 CREATE TABLE IF NOT EXISTS `post` (
1083 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1084 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1085 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1086 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1087 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1088 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1089 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1090 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1091 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1092 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1093 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1094 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1095 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1096 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1097 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1098 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1099 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1100 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1101 PRIMARY KEY(`uri-id`),
1102 INDEX `parent-uri-id` (`parent-uri-id`),
1103 INDEX `thr-parent-id` (`thr-parent-id`),
1104 INDEX `external-id` (`external-id`),
1105 INDEX `owner-id` (`owner-id`),
1106 INDEX `author-id` (`author-id`),
1107 INDEX `causer-id` (`causer-id`),
1108 INDEX `vid` (`vid`),
1109 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1110 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1111 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1112 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1113 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1114 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1115 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1116 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1117 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
1120 -- TABLE post-category
1122 CREATE TABLE IF NOT EXISTS `post-category` (
1123 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1124 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1125 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1126 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1127 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1128 INDEX `tid` (`tid`),
1129 INDEX `uid_uri-id` (`uid`,`uri-id`),
1130 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1131 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1132 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1133 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1136 -- TABLE post-collection
1138 CREATE TABLE IF NOT EXISTS `post-collection` (
1139 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1140 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0 - Featured',
1141 PRIMARY KEY(`uri-id`,`type`),
1142 INDEX `type` (`type`),
1143 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1144 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Collection of posts';
1147 -- TABLE post-content
1149 CREATE TABLE IF NOT EXISTS `post-content` (
1150 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1151 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1152 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1153 `body` mediumtext COMMENT 'item body content',
1154 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1155 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1156 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1157 `language` text COMMENT 'Language information about this post',
1158 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1159 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1160 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1161 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1162 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1163 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1164 `target` text COMMENT 'JSON encoded target structure if used',
1165 `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',
1166 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1167 PRIMARY KEY(`uri-id`),
1168 INDEX `plink` (`plink`(191)),
1169 INDEX `resource-id` (`resource-id`),
1170 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
1171 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1172 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1175 -- TABLE post-delivery
1177 CREATE TABLE IF NOT EXISTS `post-delivery` (
1178 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1179 `inbox-id` int unsigned NOT NULL COMMENT 'Item-uri id of inbox url',
1180 `uid` mediumint unsigned COMMENT 'Delivering user',
1181 `created` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
1182 `command` varbinary(32) COMMENT '',
1183 `failed` tinyint DEFAULT 0 COMMENT 'Number of times the delivery has failed',
1184 `receivers` mediumtext COMMENT 'JSON encoded array with the receiving contacts',
1185 PRIMARY KEY(`uri-id`,`inbox-id`),
1186 INDEX `inbox-id_created` (`inbox-id`,`created`),
1187 INDEX `uid` (`uid`),
1188 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1189 FOREIGN KEY (`inbox-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1190 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1191 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for posts for the batch processing';
1194 -- TABLE post-delivery-data
1196 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1197 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1198 `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',
1199 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1200 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1201 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1202 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1203 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1204 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1205 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1206 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1207 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1208 PRIMARY KEY(`uri-id`),
1209 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1210 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1213 -- TABLE post-history
1215 CREATE TABLE IF NOT EXISTS `post-history` (
1216 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1217 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of edit',
1218 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1219 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1220 `body` mediumtext COMMENT 'item body content',
1221 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1222 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1223 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1224 `language` text COMMENT 'Language information about this post',
1225 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1226 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1227 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1228 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1229 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1230 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1231 `target` text COMMENT 'JSON encoded target structure if used',
1232 `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',
1233 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1234 PRIMARY KEY(`uri-id`,`edited`),
1235 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1236 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post history';
1241 CREATE TABLE IF NOT EXISTS `post-link` (
1242 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1243 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1244 `url` varbinary(511) NOT NULL COMMENT 'External URL',
1245 `mimetype` varchar(60) COMMENT '',
1247 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1248 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1249 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post related external links';
1254 CREATE TABLE IF NOT EXISTS `post-media` (
1255 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1256 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1257 `url` varbinary(1024) NOT NULL COMMENT 'Media URL',
1258 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1259 `mimetype` varchar(60) COMMENT '',
1260 `height` smallint unsigned COMMENT 'Height of the media',
1261 `width` smallint unsigned COMMENT 'Width of the media',
1262 `size` bigint unsigned COMMENT 'Media size',
1263 `preview` varbinary(512) COMMENT 'Preview URL',
1264 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1265 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1266 `description` text COMMENT '',
1267 `name` varchar(255) COMMENT 'Name of the media',
1268 `author-url` varbinary(255) COMMENT 'URL of the author of the media',
1269 `author-name` varchar(255) COMMENT 'Name of the author of the media',
1270 `author-image` varbinary(255) COMMENT 'Image of the author of the media',
1271 `publisher-url` varbinary(255) COMMENT 'URL of the publisher of the media',
1272 `publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
1273 `publisher-image` varbinary(255) COMMENT 'Image of the publisher of the media',
1275 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`(512)),
1276 INDEX `uri-id-id` (`uri-id`,`id`),
1277 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1278 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1281 -- TABLE post-question
1283 CREATE TABLE IF NOT EXISTS `post-question` (
1284 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1285 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1286 `multiple` boolean NOT NULL DEFAULT '0' COMMENT 'Multiple choice',
1287 `voters` int unsigned COMMENT 'Number of voters for this question',
1288 `end-time` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Question end time',
1290 UNIQUE INDEX `uri-id` (`uri-id`),
1291 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1292 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question';
1295 -- TABLE post-question-option
1297 CREATE TABLE IF NOT EXISTS `post-question-option` (
1298 `id` int unsigned NOT NULL COMMENT 'Id of the question',
1299 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1300 `name` varchar(255) COMMENT 'Name of the option',
1301 `replies` int unsigned COMMENT 'Number of replies for this question option',
1302 PRIMARY KEY(`uri-id`,`id`),
1303 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1304 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question option';
1309 CREATE TABLE IF NOT EXISTS `post-tag` (
1310 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1311 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1312 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1313 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1314 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1315 INDEX `tid` (`tid`),
1316 INDEX `cid` (`cid`),
1317 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1318 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1319 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1320 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1323 -- TABLE post-thread
1325 CREATE TABLE IF NOT EXISTS `post-thread` (
1326 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1327 `conversation-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the conversation uri',
1328 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1329 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1330 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1331 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1332 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1333 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1334 `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',
1335 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1336 PRIMARY KEY(`uri-id`),
1337 INDEX `conversation-id` (`conversation-id`),
1338 INDEX `owner-id` (`owner-id`),
1339 INDEX `author-id` (`author-id`),
1340 INDEX `causer-id` (`causer-id`),
1341 INDEX `received` (`received`),
1342 INDEX `commented` (`commented`),
1343 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1344 FOREIGN KEY (`conversation-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1345 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1346 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1347 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1348 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1353 CREATE TABLE IF NOT EXISTS `post-user` (
1354 `id` int unsigned NOT NULL auto_increment,
1355 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1356 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1357 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1358 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1359 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1360 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1361 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1362 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1363 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1364 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1365 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1366 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1367 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1368 `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
1369 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1370 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1371 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1372 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1373 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1374 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1375 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1376 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1377 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1378 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1379 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1380 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1381 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1382 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1383 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1385 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1386 INDEX `uri-id` (`uri-id`),
1387 INDEX `parent-uri-id` (`parent-uri-id`),
1388 INDEX `thr-parent-id` (`thr-parent-id`),
1389 INDEX `external-id` (`external-id`),
1390 INDEX `owner-id` (`owner-id`),
1391 INDEX `author-id` (`author-id`),
1392 INDEX `causer-id` (`causer-id`),
1393 INDEX `vid` (`vid`),
1394 INDEX `contact-id` (`contact-id`),
1395 INDEX `event-id` (`event-id`),
1396 INDEX `psid` (`psid`),
1397 INDEX `author-id_uid` (`author-id`,`uid`),
1398 INDEX `author-id_received` (`author-id`,`received`),
1399 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1400 INDEX `uid_contactid` (`uid`,`contact-id`),
1401 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1402 INDEX `uid_unseen` (`uid`,`unseen`),
1403 INDEX `uid_hidden_uri-id` (`uid`,`hidden`,`uri-id`),
1404 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1405 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1406 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1407 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1408 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1409 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1410 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1411 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1412 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1413 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1414 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1415 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1416 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1419 -- TABLE post-thread-user
1421 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1422 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1423 `conversation-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the conversation uri',
1424 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1425 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1426 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1427 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1428 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1429 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1430 `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',
1431 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1432 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1433 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
1434 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1435 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1436 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1437 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1438 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1439 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Deprecated',
1440 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1441 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1442 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1443 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1444 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1445 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1446 PRIMARY KEY(`uid`,`uri-id`),
1447 INDEX `uri-id` (`uri-id`),
1448 INDEX `conversation-id` (`conversation-id`),
1449 INDEX `owner-id` (`owner-id`),
1450 INDEX `author-id` (`author-id`),
1451 INDEX `causer-id` (`causer-id`),
1452 INDEX `uid` (`uid`),
1453 INDEX `contact-id` (`contact-id`),
1454 INDEX `psid` (`psid`),
1455 INDEX `post-user-id` (`post-user-id`),
1456 INDEX `commented` (`commented`),
1457 INDEX `uid_received` (`uid`,`received`),
1458 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1459 INDEX `uid_commented` (`uid`,`commented`),
1460 INDEX `uid_starred` (`uid`,`starred`),
1461 INDEX `uid_mention` (`uid`,`mention`),
1462 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1463 FOREIGN KEY (`conversation-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1464 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1465 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1466 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1467 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1468 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1469 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1470 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1471 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1474 -- TABLE post-user-notification
1476 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1477 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1478 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1479 `notification-type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1480 PRIMARY KEY(`uid`,`uri-id`),
1481 INDEX `uri-id` (`uri-id`),
1482 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1483 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1484 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1489 CREATE TABLE IF NOT EXISTS `process` (
1490 `pid` int unsigned NOT NULL COMMENT 'The ID of the process',
1491 `hostname` varchar(32) NOT NULL COMMENT 'The name of the host the process is ran on',
1492 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1493 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1494 PRIMARY KEY(`pid`,`hostname`),
1495 INDEX `command` (`command`)
1496 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1501 CREATE TABLE IF NOT EXISTS `profile` (
1502 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1503 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1504 `profile-name` varchar(255) COMMENT 'Deprecated',
1505 `is-default` boolean COMMENT 'Deprecated',
1506 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1507 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1508 `pdesc` varchar(255) COMMENT 'Deprecated',
1509 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1510 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1511 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1512 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1513 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1514 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1515 `hometown` varchar(255) COMMENT 'Deprecated',
1516 `gender` varchar(32) COMMENT 'Deprecated',
1517 `marital` varchar(255) COMMENT 'Deprecated',
1518 `with` text COMMENT 'Deprecated',
1519 `howlong` datetime COMMENT 'Deprecated',
1520 `sexual` varchar(255) COMMENT 'Deprecated',
1521 `politic` varchar(255) COMMENT 'Deprecated',
1522 `religion` varchar(255) COMMENT 'Deprecated',
1523 `pub_keywords` text COMMENT '',
1524 `prv_keywords` text COMMENT '',
1525 `likes` text COMMENT 'Deprecated',
1526 `dislikes` text COMMENT 'Deprecated',
1527 `about` text COMMENT 'Profile description',
1528 `summary` varchar(255) COMMENT 'Deprecated',
1529 `music` text COMMENT 'Deprecated',
1530 `book` text COMMENT 'Deprecated',
1531 `tv` text COMMENT 'Deprecated',
1532 `film` text COMMENT 'Deprecated',
1533 `interest` text COMMENT 'Deprecated',
1534 `romance` text COMMENT 'Deprecated',
1535 `work` text COMMENT 'Deprecated',
1536 `education` text COMMENT 'Deprecated',
1537 `contact` text COMMENT 'Deprecated',
1538 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1539 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
1540 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
1541 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1542 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1543 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1544 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1546 INDEX `uid_is-default` (`uid`,`is-default`),
1547 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1548 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1549 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1552 -- TABLE profile_field
1554 CREATE TABLE IF NOT EXISTS `profile_field` (
1555 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1556 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1557 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1558 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1559 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1560 `value` text COMMENT 'Value of the field',
1561 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1562 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1564 INDEX `uid` (`uid`),
1565 INDEX `order` (`order`),
1566 INDEX `psid` (`psid`),
1567 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1568 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1569 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1572 -- TABLE push_subscriber
1574 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1575 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1576 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1577 `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1578 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1579 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1580 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1581 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1582 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1583 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1584 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1586 INDEX `next_try` (`next_try`),
1587 INDEX `uid` (`uid`),
1588 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1589 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1594 CREATE TABLE IF NOT EXISTS `register` (
1595 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1596 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1597 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1598 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1599 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1600 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1601 `note` text COMMENT '',
1603 INDEX `uid` (`uid`),
1604 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1605 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1610 CREATE TABLE IF NOT EXISTS `search` (
1611 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1612 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1613 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1615 INDEX `uid_term` (`uid`,`term`(64)),
1616 INDEX `term` (`term`(64)),
1617 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1618 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1623 CREATE TABLE IF NOT EXISTS `session` (
1624 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1625 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1626 `data` text COMMENT '',
1627 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1629 INDEX `sid` (`sid`(64)),
1630 INDEX `expire` (`expire`)
1631 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1636 CREATE TABLE IF NOT EXISTS `storage` (
1637 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1638 `data` longblob NOT NULL COMMENT 'file data',
1640 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1643 -- TABLE subscription
1645 CREATE TABLE IF NOT EXISTS `subscription` (
1646 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1647 `application-id` int unsigned NOT NULL COMMENT '',
1648 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
1649 `endpoint` varchar(511) COMMENT 'Endpoint URL',
1650 `pubkey` varchar(127) COMMENT 'User agent public key',
1651 `secret` varchar(32) COMMENT 'Auth secret',
1652 `follow` boolean COMMENT '',
1653 `favourite` boolean COMMENT '',
1654 `reblog` boolean COMMENT '',
1655 `mention` boolean COMMENT '',
1656 `poll` boolean COMMENT '',
1657 `follow_request` boolean COMMENT '',
1658 `status` boolean COMMENT '',
1660 UNIQUE INDEX `application-id_uid` (`application-id`,`uid`),
1661 INDEX `uid_application-id` (`uid`,`application-id`),
1662 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1663 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1664 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Push Subscription for the API';
1669 CREATE TABLE IF NOT EXISTS `userd` (
1670 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1671 `username` varchar(255) NOT NULL COMMENT '',
1673 INDEX `username` (`username`(32))
1674 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1677 -- TABLE user-contact
1679 CREATE TABLE IF NOT EXISTS `user-contact` (
1680 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1681 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1682 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
1683 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1684 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1685 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1686 `hidden` boolean COMMENT 'This contact is hidden from the others',
1687 `is-blocked` boolean COMMENT 'User is blocked by this contact',
1688 `pending` boolean COMMENT '',
1689 `rel` tinyint unsigned COMMENT 'The kind of the relation between the user and the contact',
1690 `info` mediumtext COMMENT '',
1691 `notify_new_posts` boolean COMMENT '',
1692 `remote_self` boolean COMMENT '',
1693 `fetch_further_information` tinyint unsigned COMMENT '',
1694 `ffi_keyword_denylist` text COMMENT '',
1695 `subhub` boolean COMMENT '',
1696 `hub-verify` varchar(255) COMMENT '',
1697 `protocol` char(4) COMMENT 'Protocol of the contact',
1698 `rating` tinyint COMMENT 'Automatically detected feed poll frequency',
1699 `priority` tinyint unsigned COMMENT 'Feed poll priority',
1700 PRIMARY KEY(`uid`,`cid`),
1701 INDEX `cid` (`cid`),
1702 UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
1703 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1704 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1705 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1706 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1711 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1712 `key` int NOT NULL COMMENT '',
1713 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1715 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1718 -- VIEW application-view
1720 DROP VIEW IF EXISTS `application-view`;
1721 CREATE VIEW `application-view` AS SELECT
1722 `application`.`id` AS `id`,
1723 `application-token`.`uid` AS `uid`,
1724 `application`.`name` AS `name`,
1725 `application`.`redirect_uri` AS `redirect_uri`,
1726 `application`.`website` AS `website`,
1727 `application`.`client_id` AS `client_id`,
1728 `application`.`client_secret` AS `client_secret`,
1729 `application-token`.`code` AS `code`,
1730 `application-token`.`access_token` AS `access_token`,
1731 `application-token`.`created_at` AS `created_at`,
1732 `application-token`.`scopes` AS `scopes`,
1733 `application-token`.`read` AS `read`,
1734 `application-token`.`write` AS `write`,
1735 `application-token`.`follow` AS `follow`,
1736 `application-token`.`push` AS `push`
1737 FROM `application-token`
1738 INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`;
1741 -- VIEW post-user-view
1743 DROP VIEW IF EXISTS `post-user-view`;
1744 CREATE VIEW `post-user-view` AS SELECT
1745 `post-user`.`id` AS `id`,
1746 `post-user`.`id` AS `post-user-id`,
1747 `post-user`.`uid` AS `uid`,
1748 `parent-post`.`id` AS `parent`,
1749 `item-uri`.`uri` AS `uri`,
1750 `post-user`.`uri-id` AS `uri-id`,
1751 `parent-item-uri`.`uri` AS `parent-uri`,
1752 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1753 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1754 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1755 `conversation-item-uri`.`uri` AS `conversation`,
1756 `post-thread-user`.`conversation-id` AS `conversation-id`,
1757 `item-uri`.`guid` AS `guid`,
1758 `post-user`.`wall` AS `wall`,
1759 `post-user`.`gravity` AS `gravity`,
1760 `external-item-uri`.`uri` AS `extid`,
1761 `post-user`.`external-id` AS `external-id`,
1762 `post-user`.`created` AS `created`,
1763 `post-user`.`edited` AS `edited`,
1764 `post-thread-user`.`commented` AS `commented`,
1765 `post-user`.`received` AS `received`,
1766 `post-thread-user`.`changed` AS `changed`,
1767 `post-user`.`post-type` AS `post-type`,
1768 `post-user`.`post-reason` AS `post-reason`,
1769 `post-user`.`private` AS `private`,
1770 `post-thread-user`.`pubmail` AS `pubmail`,
1771 `post-user`.`visible` AS `visible`,
1772 `post-thread-user`.`starred` AS `starred`,
1773 `post-user`.`unseen` AS `unseen`,
1774 `post-user`.`deleted` AS `deleted`,
1775 `post-user`.`origin` AS `origin`,
1776 `post-thread-user`.`origin` AS `parent-origin`,
1777 `post-thread-user`.`mention` AS `mention`,
1778 `post-user`.`global` AS `global`,
1779 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-user`.`uri-id`) AS `featured`,
1780 `post-user`.`network` AS `network`,
1781 `post-user`.`vid` AS `vid`,
1782 `post-user`.`psid` AS `psid`,
1783 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1784 `post-content`.`title` AS `title`,
1785 `post-content`.`content-warning` AS `content-warning`,
1786 `post-content`.`raw-body` AS `raw-body`,
1787 IFNULL (`post-content`.`body`, '') AS `body`,
1788 `post-content`.`rendered-hash` AS `rendered-hash`,
1789 `post-content`.`rendered-html` AS `rendered-html`,
1790 `post-content`.`language` AS `language`,
1791 `post-content`.`plink` AS `plink`,
1792 `post-content`.`location` AS `location`,
1793 `post-content`.`coord` AS `coord`,
1794 `post-content`.`app` AS `app`,
1795 `post-content`.`object-type` AS `object-type`,
1796 `post-content`.`object` AS `object`,
1797 `post-content`.`target-type` AS `target-type`,
1798 `post-content`.`target` AS `target`,
1799 `post-content`.`resource-id` AS `resource-id`,
1800 `post-user`.`contact-id` AS `contact-id`,
1801 `contact`.`uri-id` AS `contact-uri-id`,
1802 `contact`.`url` AS `contact-link`,
1803 `contact`.`addr` AS `contact-addr`,
1804 `contact`.`name` AS `contact-name`,
1805 `contact`.`nick` AS `contact-nick`,
1806 `contact`.`thumb` AS `contact-avatar`,
1807 `contact`.`network` AS `contact-network`,
1808 `contact`.`blocked` AS `contact-blocked`,
1809 `contact`.`hidden` AS `contact-hidden`,
1810 `contact`.`readonly` AS `contact-readonly`,
1811 `contact`.`archive` AS `contact-archive`,
1812 `contact`.`pending` AS `contact-pending`,
1813 `contact`.`rel` AS `contact-rel`,
1814 `contact`.`uid` AS `contact-uid`,
1815 `contact`.`contact-type` AS `contact-contact-type`,
1816 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1817 `contact`.`self` AS `self`,
1818 `contact`.`id` AS `cid`,
1819 `contact`.`alias` AS `alias`,
1820 `contact`.`photo` AS `photo`,
1821 `contact`.`name-date` AS `name-date`,
1822 `contact`.`uri-date` AS `uri-date`,
1823 `contact`.`avatar-date` AS `avatar-date`,
1824 `contact`.`thumb` AS `thumb`,
1825 `post-user`.`author-id` AS `author-id`,
1826 `author`.`uri-id` AS `author-uri-id`,
1827 `author`.`url` AS `author-link`,
1828 `author`.`addr` AS `author-addr`,
1829 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1830 `author`.`nick` AS `author-nick`,
1831 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1832 `author`.`network` AS `author-network`,
1833 `author`.`blocked` AS `author-blocked`,
1834 `author`.`hidden` AS `author-hidden`,
1835 `author`.`updated` AS `author-updated`,
1836 `author`.`gsid` AS `author-gsid`,
1837 `post-user`.`owner-id` AS `owner-id`,
1838 `owner`.`uri-id` AS `owner-uri-id`,
1839 `owner`.`url` AS `owner-link`,
1840 `owner`.`addr` AS `owner-addr`,
1841 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1842 `owner`.`nick` AS `owner-nick`,
1843 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1844 `owner`.`network` AS `owner-network`,
1845 `owner`.`blocked` AS `owner-blocked`,
1846 `owner`.`hidden` AS `owner-hidden`,
1847 `owner`.`updated` AS `owner-updated`,
1848 `owner`.`contact-type` AS `owner-contact-type`,
1849 `post-user`.`causer-id` AS `causer-id`,
1850 `causer`.`uri-id` AS `causer-uri-id`,
1851 `causer`.`url` AS `causer-link`,
1852 `causer`.`addr` AS `causer-addr`,
1853 `causer`.`name` AS `causer-name`,
1854 `causer`.`nick` AS `causer-nick`,
1855 `causer`.`thumb` AS `causer-avatar`,
1856 `causer`.`network` AS `causer-network`,
1857 `causer`.`blocked` AS `causer-blocked`,
1858 `causer`.`hidden` AS `causer-hidden`,
1859 `causer`.`contact-type` AS `causer-contact-type`,
1860 `post-delivery-data`.`postopts` AS `postopts`,
1861 `post-delivery-data`.`inform` AS `inform`,
1862 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1863 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1864 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1865 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1866 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1867 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1868 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1869 `post-user`.`event-id` AS `event-id`,
1870 `event`.`created` AS `event-created`,
1871 `event`.`edited` AS `event-edited`,
1872 `event`.`start` AS `event-start`,
1873 `event`.`finish` AS `event-finish`,
1874 `event`.`summary` AS `event-summary`,
1875 `event`.`desc` AS `event-desc`,
1876 `event`.`location` AS `event-location`,
1877 `event`.`type` AS `event-type`,
1878 `event`.`nofinish` AS `event-nofinish`,
1879 `event`.`ignore` AS `event-ignore`,
1880 `post-question`.`id` AS `question-id`,
1881 `post-question`.`multiple` AS `question-multiple`,
1882 `post-question`.`voters` AS `question-voters`,
1883 `post-question`.`end-time` AS `question-end-time`,
1884 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`,
1885 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-user`.`uri-id`) AS `has-media`,
1886 `diaspora-interaction`.`interaction` AS `signed_text`,
1887 `parent-item-uri`.`guid` AS `parent-guid`,
1888 `parent-post`.`network` AS `parent-network`,
1889 `parent-post`.`author-id` AS `parent-author-id`,
1890 `parent-post-author`.`url` AS `parent-author-link`,
1891 `parent-post-author`.`name` AS `parent-author-name`,
1892 `parent-post-author`.`nick` AS `parent-author-nick`,
1893 `parent-post-author`.`network` AS `parent-author-network`,
1894 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1895 `parent-post-author`.`hidden` AS `parent-author-hidden`
1897 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
1898 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
1899 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
1900 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
1901 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
1902 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
1903 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1904 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1905 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
1906 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1907 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1908 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1909 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
1910 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
1911 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
1912 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-user`.`uri-id`
1913 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
1914 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
1915 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1918 -- VIEW post-thread-user-view
1920 DROP VIEW IF EXISTS `post-thread-user-view`;
1921 CREATE VIEW `post-thread-user-view` AS SELECT
1922 `post-user`.`id` AS `id`,
1923 `post-user`.`id` AS `post-user-id`,
1924 `post-thread-user`.`uid` AS `uid`,
1925 `parent-post`.`id` AS `parent`,
1926 `item-uri`.`uri` AS `uri`,
1927 `post-thread-user`.`uri-id` AS `uri-id`,
1928 `parent-item-uri`.`uri` AS `parent-uri`,
1929 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1930 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1931 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1932 `conversation-item-uri`.`uri` AS `conversation`,
1933 `post-thread-user`.`conversation-id` AS `conversation-id`,
1934 `item-uri`.`guid` AS `guid`,
1935 `post-thread-user`.`wall` AS `wall`,
1936 `post-user`.`gravity` AS `gravity`,
1937 `external-item-uri`.`uri` AS `extid`,
1938 `post-user`.`external-id` AS `external-id`,
1939 `post-thread-user`.`created` AS `created`,
1940 `post-user`.`edited` AS `edited`,
1941 `post-thread-user`.`commented` AS `commented`,
1942 `post-thread-user`.`received` AS `received`,
1943 `post-thread-user`.`changed` AS `changed`,
1944 `post-user`.`post-type` AS `post-type`,
1945 `post-user`.`post-reason` AS `post-reason`,
1946 `post-user`.`private` AS `private`,
1947 `post-thread-user`.`pubmail` AS `pubmail`,
1948 `post-thread-user`.`ignored` AS `ignored`,
1949 `post-user`.`visible` AS `visible`,
1950 `post-thread-user`.`starred` AS `starred`,
1951 `post-thread-user`.`unseen` AS `unseen`,
1952 `post-user`.`deleted` AS `deleted`,
1953 `post-thread-user`.`origin` AS `origin`,
1954 `post-thread-user`.`mention` AS `mention`,
1955 `post-user`.`global` AS `global`,
1956 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread-user`.`uri-id`) AS `featured`,
1957 `post-thread-user`.`network` AS `network`,
1958 `post-user`.`vid` AS `vid`,
1959 `post-thread-user`.`psid` AS `psid`,
1960 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1961 `post-content`.`title` AS `title`,
1962 `post-content`.`content-warning` AS `content-warning`,
1963 `post-content`.`raw-body` AS `raw-body`,
1964 `post-content`.`body` AS `body`,
1965 `post-content`.`rendered-hash` AS `rendered-hash`,
1966 `post-content`.`rendered-html` AS `rendered-html`,
1967 `post-content`.`language` AS `language`,
1968 `post-content`.`plink` AS `plink`,
1969 `post-content`.`location` AS `location`,
1970 `post-content`.`coord` AS `coord`,
1971 `post-content`.`app` AS `app`,
1972 `post-content`.`object-type` AS `object-type`,
1973 `post-content`.`object` AS `object`,
1974 `post-content`.`target-type` AS `target-type`,
1975 `post-content`.`target` AS `target`,
1976 `post-content`.`resource-id` AS `resource-id`,
1977 `post-thread-user`.`contact-id` AS `contact-id`,
1978 `contact`.`uri-id` AS `contact-uri-id`,
1979 `contact`.`url` AS `contact-link`,
1980 `contact`.`addr` AS `contact-addr`,
1981 `contact`.`name` AS `contact-name`,
1982 `contact`.`nick` AS `contact-nick`,
1983 `contact`.`thumb` AS `contact-avatar`,
1984 `contact`.`network` AS `contact-network`,
1985 `contact`.`blocked` AS `contact-blocked`,
1986 `contact`.`hidden` AS `contact-hidden`,
1987 `contact`.`readonly` AS `contact-readonly`,
1988 `contact`.`archive` AS `contact-archive`,
1989 `contact`.`pending` AS `contact-pending`,
1990 `contact`.`rel` AS `contact-rel`,
1991 `contact`.`uid` AS `contact-uid`,
1992 `contact`.`contact-type` AS `contact-contact-type`,
1993 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1994 `contact`.`self` AS `self`,
1995 `contact`.`id` AS `cid`,
1996 `contact`.`alias` AS `alias`,
1997 `contact`.`photo` AS `photo`,
1998 `contact`.`name-date` AS `name-date`,
1999 `contact`.`uri-date` AS `uri-date`,
2000 `contact`.`avatar-date` AS `avatar-date`,
2001 `contact`.`thumb` AS `thumb`,
2002 `post-thread-user`.`author-id` AS `author-id`,
2003 `author`.`uri-id` AS `author-uri-id`,
2004 `author`.`url` AS `author-link`,
2005 `author`.`addr` AS `author-addr`,
2006 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
2007 `author`.`nick` AS `author-nick`,
2008 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
2009 `author`.`network` AS `author-network`,
2010 `author`.`blocked` AS `author-blocked`,
2011 `author`.`hidden` AS `author-hidden`,
2012 `author`.`updated` AS `author-updated`,
2013 `author`.`gsid` AS `author-gsid`,
2014 `post-thread-user`.`owner-id` AS `owner-id`,
2015 `owner`.`uri-id` AS `owner-uri-id`,
2016 `owner`.`url` AS `owner-link`,
2017 `owner`.`addr` AS `owner-addr`,
2018 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
2019 `owner`.`nick` AS `owner-nick`,
2020 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
2021 `owner`.`network` AS `owner-network`,
2022 `owner`.`blocked` AS `owner-blocked`,
2023 `owner`.`hidden` AS `owner-hidden`,
2024 `owner`.`updated` AS `owner-updated`,
2025 `owner`.`contact-type` AS `owner-contact-type`,
2026 `post-thread-user`.`causer-id` AS `causer-id`,
2027 `causer`.`uri-id` AS `causer-uri-id`,
2028 `causer`.`url` AS `causer-link`,
2029 `causer`.`addr` AS `causer-addr`,
2030 `causer`.`name` AS `causer-name`,
2031 `causer`.`nick` AS `causer-nick`,
2032 `causer`.`thumb` AS `causer-avatar`,
2033 `causer`.`network` AS `causer-network`,
2034 `causer`.`blocked` AS `causer-blocked`,
2035 `causer`.`hidden` AS `causer-hidden`,
2036 `causer`.`contact-type` AS `causer-contact-type`,
2037 `post-delivery-data`.`postopts` AS `postopts`,
2038 `post-delivery-data`.`inform` AS `inform`,
2039 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
2040 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
2041 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
2042 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
2043 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
2044 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
2045 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
2046 `post-user`.`event-id` AS `event-id`,
2047 `event`.`created` AS `event-created`,
2048 `event`.`edited` AS `event-edited`,
2049 `event`.`start` AS `event-start`,
2050 `event`.`finish` AS `event-finish`,
2051 `event`.`summary` AS `event-summary`,
2052 `event`.`desc` AS `event-desc`,
2053 `event`.`location` AS `event-location`,
2054 `event`.`type` AS `event-type`,
2055 `event`.`nofinish` AS `event-nofinish`,
2056 `event`.`ignore` AS `event-ignore`,
2057 `post-question`.`id` AS `question-id`,
2058 `post-question`.`multiple` AS `question-multiple`,
2059 `post-question`.`voters` AS `question-voters`,
2060 `post-question`.`end-time` AS `question-end-time`,
2061 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`,
2062 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread-user`.`uri-id`) AS `has-media`,
2063 `diaspora-interaction`.`interaction` AS `signed_text`,
2064 `parent-item-uri`.`guid` AS `parent-guid`,
2065 `parent-post`.`network` AS `parent-network`,
2066 `parent-post`.`author-id` AS `parent-author-id`,
2067 `parent-post-author`.`url` AS `parent-author-link`,
2068 `parent-post-author`.`name` AS `parent-author-name`,
2069 `parent-post-author`.`network` AS `parent-author-network`,
2070 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2071 `parent-post-author`.`hidden` AS `parent-author-hidden`
2072 FROM `post-thread-user`
2073 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2074 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2075 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
2076 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
2077 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
2078 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
2079 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
2080 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
2081 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
2082 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
2083 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
2084 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
2085 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
2086 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
2087 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
2088 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread-user`.`uri-id`
2089 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
2090 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`
2091 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2096 DROP VIEW IF EXISTS `post-view`;
2097 CREATE VIEW `post-view` AS SELECT
2098 `item-uri`.`uri` AS `uri`,
2099 `post`.`uri-id` AS `uri-id`,
2100 `parent-item-uri`.`uri` AS `parent-uri`,
2101 `post`.`parent-uri-id` AS `parent-uri-id`,
2102 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2103 `post`.`thr-parent-id` AS `thr-parent-id`,
2104 `conversation-item-uri`.`uri` AS `conversation`,
2105 `post-thread`.`conversation-id` AS `conversation-id`,
2106 `item-uri`.`guid` AS `guid`,
2107 `post`.`gravity` AS `gravity`,
2108 `external-item-uri`.`uri` AS `extid`,
2109 `post`.`external-id` AS `external-id`,
2110 `post`.`created` AS `created`,
2111 `post`.`edited` AS `edited`,
2112 `post-thread`.`commented` AS `commented`,
2113 `post`.`received` AS `received`,
2114 `post-thread`.`changed` AS `changed`,
2115 `post`.`post-type` AS `post-type`,
2116 `post`.`private` AS `private`,
2117 `post`.`visible` AS `visible`,
2118 `post`.`deleted` AS `deleted`,
2119 `post`.`global` AS `global`,
2120 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post`.`uri-id`) AS `featured`,
2121 `post`.`network` AS `network`,
2122 `post`.`vid` AS `vid`,
2123 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2124 `post-content`.`title` AS `title`,
2125 `post-content`.`content-warning` AS `content-warning`,
2126 `post-content`.`raw-body` AS `raw-body`,
2127 `post-content`.`body` AS `body`,
2128 `post-content`.`rendered-hash` AS `rendered-hash`,
2129 `post-content`.`rendered-html` AS `rendered-html`,
2130 `post-content`.`language` AS `language`,
2131 `post-content`.`plink` AS `plink`,
2132 `post-content`.`location` AS `location`,
2133 `post-content`.`coord` AS `coord`,
2134 `post-content`.`app` AS `app`,
2135 `post-content`.`object-type` AS `object-type`,
2136 `post-content`.`object` AS `object`,
2137 `post-content`.`target-type` AS `target-type`,
2138 `post-content`.`target` AS `target`,
2139 `post-content`.`resource-id` AS `resource-id`,
2140 `post`.`author-id` AS `contact-id`,
2141 `author`.`uri-id` AS `contact-uri-id`,
2142 `author`.`url` AS `contact-link`,
2143 `author`.`addr` AS `contact-addr`,
2144 `author`.`name` AS `contact-name`,
2145 `author`.`nick` AS `contact-nick`,
2146 `author`.`thumb` AS `contact-avatar`,
2147 `author`.`network` AS `contact-network`,
2148 `author`.`blocked` AS `contact-blocked`,
2149 `author`.`hidden` AS `contact-hidden`,
2150 `author`.`readonly` AS `contact-readonly`,
2151 `author`.`archive` AS `contact-archive`,
2152 `author`.`pending` AS `contact-pending`,
2153 `author`.`rel` AS `contact-rel`,
2154 `author`.`uid` AS `contact-uid`,
2155 `author`.`contact-type` AS `contact-contact-type`,
2156 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2158 `author`.`id` AS `cid`,
2159 `author`.`alias` AS `alias`,
2160 `author`.`photo` AS `photo`,
2161 `author`.`name-date` AS `name-date`,
2162 `author`.`uri-date` AS `uri-date`,
2163 `author`.`avatar-date` AS `avatar-date`,
2164 `author`.`thumb` AS `thumb`,
2165 `post`.`author-id` AS `author-id`,
2166 `author`.`uri-id` AS `author-uri-id`,
2167 `author`.`url` AS `author-link`,
2168 `author`.`addr` AS `author-addr`,
2169 `author`.`name` AS `author-name`,
2170 `author`.`nick` AS `author-nick`,
2171 `author`.`thumb` AS `author-avatar`,
2172 `author`.`network` AS `author-network`,
2173 `author`.`blocked` AS `author-blocked`,
2174 `author`.`hidden` AS `author-hidden`,
2175 `author`.`updated` AS `author-updated`,
2176 `author`.`gsid` AS `author-gsid`,
2177 `post`.`owner-id` AS `owner-id`,
2178 `owner`.`uri-id` AS `owner-uri-id`,
2179 `owner`.`url` AS `owner-link`,
2180 `owner`.`addr` AS `owner-addr`,
2181 `owner`.`name` AS `owner-name`,
2182 `owner`.`nick` AS `owner-nick`,
2183 `owner`.`thumb` AS `owner-avatar`,
2184 `owner`.`network` AS `owner-network`,
2185 `owner`.`blocked` AS `owner-blocked`,
2186 `owner`.`hidden` AS `owner-hidden`,
2187 `owner`.`updated` AS `owner-updated`,
2188 `owner`.`contact-type` AS `owner-contact-type`,
2189 `post`.`causer-id` AS `causer-id`,
2190 `causer`.`uri-id` AS `causer-uri-id`,
2191 `causer`.`url` AS `causer-link`,
2192 `causer`.`addr` AS `causer-addr`,
2193 `causer`.`name` AS `causer-name`,
2194 `causer`.`nick` AS `causer-nick`,
2195 `causer`.`thumb` AS `causer-avatar`,
2196 `causer`.`network` AS `causer-network`,
2197 `causer`.`blocked` AS `causer-blocked`,
2198 `causer`.`hidden` AS `causer-hidden`,
2199 `causer`.`contact-type` AS `causer-contact-type`,
2200 `post-question`.`id` AS `question-id`,
2201 `post-question`.`multiple` AS `question-multiple`,
2202 `post-question`.`voters` AS `question-voters`,
2203 `post-question`.`end-time` AS `question-end-time`,
2204 0 AS `has-categories`,
2205 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post`.`uri-id`) AS `has-media`,
2206 `diaspora-interaction`.`interaction` AS `signed_text`,
2207 `parent-item-uri`.`guid` AS `parent-guid`,
2208 `parent-post`.`network` AS `parent-network`,
2209 `parent-post`.`author-id` AS `parent-author-id`,
2210 `parent-post-author`.`url` AS `parent-author-link`,
2211 `parent-post-author`.`name` AS `parent-author-name`,
2212 `parent-post-author`.`network` AS `parent-author-network`,
2213 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2214 `parent-post-author`.`hidden` AS `parent-author-hidden`
2216 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
2217 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
2218 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
2219 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
2220 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
2221 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2222 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2223 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
2224 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2225 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2226 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
2227 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
2228 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post`.`uri-id`
2229 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2230 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2233 -- VIEW post-thread-view
2235 DROP VIEW IF EXISTS `post-thread-view`;
2236 CREATE VIEW `post-thread-view` AS SELECT
2237 `item-uri`.`uri` AS `uri`,
2238 `post-thread`.`uri-id` AS `uri-id`,
2239 `parent-item-uri`.`uri` AS `parent-uri`,
2240 `post`.`parent-uri-id` AS `parent-uri-id`,
2241 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2242 `post`.`thr-parent-id` AS `thr-parent-id`,
2243 `conversation-item-uri`.`uri` AS `conversation`,
2244 `post-thread`.`conversation-id` AS `conversation-id`,
2245 `item-uri`.`guid` AS `guid`,
2246 `post`.`gravity` AS `gravity`,
2247 `external-item-uri`.`uri` AS `extid`,
2248 `post`.`external-id` AS `external-id`,
2249 `post-thread`.`created` AS `created`,
2250 `post`.`edited` AS `edited`,
2251 `post-thread`.`commented` AS `commented`,
2252 `post-thread`.`received` AS `received`,
2253 `post-thread`.`changed` AS `changed`,
2254 `post`.`post-type` AS `post-type`,
2255 `post`.`private` AS `private`,
2256 `post`.`visible` AS `visible`,
2257 `post`.`deleted` AS `deleted`,
2258 `post`.`global` AS `global`,
2259 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread`.`uri-id`) AS `featured`,
2260 `post-thread`.`network` AS `network`,
2261 `post`.`vid` AS `vid`,
2262 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2263 `post-content`.`title` AS `title`,
2264 `post-content`.`content-warning` AS `content-warning`,
2265 `post-content`.`raw-body` AS `raw-body`,
2266 `post-content`.`body` AS `body`,
2267 `post-content`.`rendered-hash` AS `rendered-hash`,
2268 `post-content`.`rendered-html` AS `rendered-html`,
2269 `post-content`.`language` AS `language`,
2270 `post-content`.`plink` AS `plink`,
2271 `post-content`.`location` AS `location`,
2272 `post-content`.`coord` AS `coord`,
2273 `post-content`.`app` AS `app`,
2274 `post-content`.`object-type` AS `object-type`,
2275 `post-content`.`object` AS `object`,
2276 `post-content`.`target-type` AS `target-type`,
2277 `post-content`.`target` AS `target`,
2278 `post-content`.`resource-id` AS `resource-id`,
2279 `post-thread`.`author-id` AS `contact-id`,
2280 `author`.`uri-id` AS `contact-uri-id`,
2281 `author`.`url` AS `contact-link`,
2282 `author`.`addr` AS `contact-addr`,
2283 `author`.`name` AS `contact-name`,
2284 `author`.`nick` AS `contact-nick`,
2285 `author`.`thumb` AS `contact-avatar`,
2286 `author`.`network` AS `contact-network`,
2287 `author`.`blocked` AS `contact-blocked`,
2288 `author`.`hidden` AS `contact-hidden`,
2289 `author`.`readonly` AS `contact-readonly`,
2290 `author`.`archive` AS `contact-archive`,
2291 `author`.`pending` AS `contact-pending`,
2292 `author`.`rel` AS `contact-rel`,
2293 `author`.`uid` AS `contact-uid`,
2294 `author`.`contact-type` AS `contact-contact-type`,
2295 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2297 `author`.`id` AS `cid`,
2298 `author`.`alias` AS `alias`,
2299 `author`.`photo` AS `photo`,
2300 `author`.`name-date` AS `name-date`,
2301 `author`.`uri-date` AS `uri-date`,
2302 `author`.`avatar-date` AS `avatar-date`,
2303 `author`.`thumb` AS `thumb`,
2304 `post-thread`.`author-id` AS `author-id`,
2305 `author`.`uri-id` AS `author-uri-id`,
2306 `author`.`url` AS `author-link`,
2307 `author`.`addr` AS `author-addr`,
2308 `author`.`name` AS `author-name`,
2309 `author`.`nick` AS `author-nick`,
2310 `author`.`thumb` AS `author-avatar`,
2311 `author`.`network` AS `author-network`,
2312 `author`.`blocked` AS `author-blocked`,
2313 `author`.`hidden` AS `author-hidden`,
2314 `author`.`updated` AS `author-updated`,
2315 `author`.`gsid` AS `author-gsid`,
2316 `post-thread`.`owner-id` AS `owner-id`,
2317 `owner`.`uri-id` AS `owner-uri-id`,
2318 `owner`.`url` AS `owner-link`,
2319 `owner`.`addr` AS `owner-addr`,
2320 `owner`.`name` AS `owner-name`,
2321 `owner`.`nick` AS `owner-nick`,
2322 `owner`.`thumb` AS `owner-avatar`,
2323 `owner`.`network` AS `owner-network`,
2324 `owner`.`blocked` AS `owner-blocked`,
2325 `owner`.`hidden` AS `owner-hidden`,
2326 `owner`.`updated` AS `owner-updated`,
2327 `owner`.`contact-type` AS `owner-contact-type`,
2328 `post-thread`.`causer-id` AS `causer-id`,
2329 `causer`.`uri-id` AS `causer-uri-id`,
2330 `causer`.`url` AS `causer-link`,
2331 `causer`.`addr` AS `causer-addr`,
2332 `causer`.`name` AS `causer-name`,
2333 `causer`.`nick` AS `causer-nick`,
2334 `causer`.`thumb` AS `causer-avatar`,
2335 `causer`.`network` AS `causer-network`,
2336 `causer`.`blocked` AS `causer-blocked`,
2337 `causer`.`hidden` AS `causer-hidden`,
2338 `causer`.`contact-type` AS `causer-contact-type`,
2339 `post-question`.`id` AS `question-id`,
2340 `post-question`.`multiple` AS `question-multiple`,
2341 `post-question`.`voters` AS `question-voters`,
2342 `post-question`.`end-time` AS `question-end-time`,
2343 0 AS `has-categories`,
2344 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread`.`uri-id`) AS `has-media`,
2345 `diaspora-interaction`.`interaction` AS `signed_text`,
2346 `parent-item-uri`.`guid` AS `parent-guid`,
2347 `parent-post`.`network` AS `parent-network`,
2348 `parent-post`.`author-id` AS `parent-author-id`,
2349 `parent-post-author`.`url` AS `parent-author-link`,
2350 `parent-post-author`.`name` AS `parent-author-name`,
2351 `parent-post-author`.`network` AS `parent-author-network`,
2352 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2353 `parent-post-author`.`hidden` AS `parent-author-hidden`
2355 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
2356 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
2357 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
2358 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
2359 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
2360 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2361 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2362 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
2363 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2364 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2365 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
2366 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
2367 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread`.`uri-id`
2368 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2369 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2372 -- VIEW category-view
2374 DROP VIEW IF EXISTS `category-view`;
2375 CREATE VIEW `category-view` AS SELECT
2376 `post-category`.`uri-id` AS `uri-id`,
2377 `post-category`.`uid` AS `uid`,
2378 `post-category`.`type` AS `type`,
2379 `post-category`.`tid` AS `tid`,
2380 `tag`.`name` AS `name`,
2381 `tag`.`url` AS `url`
2382 FROM `post-category`
2383 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2386 -- VIEW collection-view
2388 DROP VIEW IF EXISTS `collection-view`;
2389 CREATE VIEW `collection-view` AS SELECT
2390 `post-collection`.`uri-id` AS `uri-id`,
2391 `post-collection`.`type` AS `type`,
2392 `post`.`author-id` AS `cid`,
2393 `post`.`received` AS `received`,
2394 `post`.`created` AS `created`,
2395 `post-thread`.`commented` AS `commented`,
2396 `post`.`private` AS `private`,
2397 `post`.`visible` AS `visible`,
2398 `post`.`deleted` AS `deleted`,
2399 `post`.`thr-parent-id` AS `thr-parent-id`,
2400 `post`.`author-id` AS `author-id`,
2401 `post`.`gravity` AS `gravity`
2402 FROM `post-collection`
2403 INNER JOIN `post` ON `post-collection`.`uri-id` = `post`.`uri-id`
2404 INNER JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`;
2409 DROP VIEW IF EXISTS `tag-view`;
2410 CREATE VIEW `tag-view` AS SELECT
2411 `post-tag`.`uri-id` AS `uri-id`,
2412 `post-tag`.`type` AS `type`,
2413 `post-tag`.`tid` AS `tid`,
2414 `post-tag`.`cid` AS `cid`,
2415 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2416 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`,
2417 CASE `cid` WHEN 0 THEN `tag`.`type` ELSE 1 END AS `tag-type`
2419 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2420 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2423 -- VIEW network-item-view
2425 DROP VIEW IF EXISTS `network-item-view`;
2426 CREATE VIEW `network-item-view` AS SELECT
2427 `post-user`.`uri-id` AS `uri-id`,
2428 `parent-post`.`id` AS `parent`,
2429 `post-user`.`received` AS `received`,
2430 `post-thread-user`.`commented` AS `commented`,
2431 `post-user`.`created` AS `created`,
2432 `post-user`.`uid` AS `uid`,
2433 `post-thread-user`.`starred` AS `starred`,
2434 `post-thread-user`.`mention` AS `mention`,
2435 `post-user`.`network` AS `network`,
2436 `post-user`.`unseen` AS `unseen`,
2437 `post-user`.`gravity` AS `gravity`,
2438 `post-user`.`contact-id` AS `contact-id`,
2439 `ownercontact`.`contact-type` AS `contact-type`
2441 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2442 INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2443 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2444 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2445 INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2446 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2447 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2448 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2449 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
2450 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2451 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2454 -- VIEW network-thread-view
2456 DROP VIEW IF EXISTS `network-thread-view`;
2457 CREATE VIEW `network-thread-view` AS SELECT
2458 `post-thread-user`.`uri-id` AS `uri-id`,
2459 `parent-post`.`id` AS `parent`,
2460 `post-thread-user`.`received` AS `received`,
2461 `post-thread-user`.`commented` AS `commented`,
2462 `post-thread-user`.`created` AS `created`,
2463 `post-thread-user`.`uid` AS `uid`,
2464 `post-thread-user`.`starred` AS `starred`,
2465 `post-thread-user`.`mention` AS `mention`,
2466 `post-thread-user`.`network` AS `network`,
2467 `post-thread-user`.`contact-id` AS `contact-id`,
2468 `ownercontact`.`contact-type` AS `contact-type`
2469 FROM `post-thread-user`
2470 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2471 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2472 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2473 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2474 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2475 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2476 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2477 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2478 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2479 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2480 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2485 DROP VIEW IF EXISTS `owner-view`;
2486 CREATE VIEW `owner-view` AS SELECT
2487 `contact`.`id` AS `id`,
2488 `contact`.`uid` AS `uid`,
2489 `contact`.`created` AS `created`,
2490 `contact`.`updated` AS `updated`,
2491 `contact`.`self` AS `self`,
2492 `contact`.`remote_self` AS `remote_self`,
2493 `contact`.`rel` AS `rel`,
2494 `contact`.`network` AS `network`,
2495 `contact`.`protocol` AS `protocol`,
2496 `contact`.`name` AS `name`,
2497 `contact`.`nick` AS `nick`,
2498 `contact`.`location` AS `location`,
2499 `contact`.`about` AS `about`,
2500 `contact`.`keywords` AS `keywords`,
2501 `contact`.`xmpp` AS `xmpp`,
2502 `contact`.`matrix` AS `matrix`,
2503 `contact`.`attag` AS `attag`,
2504 `contact`.`avatar` AS `avatar`,
2505 `contact`.`photo` AS `photo`,
2506 `contact`.`thumb` AS `thumb`,
2507 `contact`.`micro` AS `micro`,
2508 `contact`.`header` AS `header`,
2509 `contact`.`url` AS `url`,
2510 `contact`.`nurl` AS `nurl`,
2511 `contact`.`uri-id` AS `uri-id`,
2512 `contact`.`addr` AS `addr`,
2513 `contact`.`alias` AS `alias`,
2514 `contact`.`pubkey` AS `pubkey`,
2515 `contact`.`prvkey` AS `prvkey`,
2516 `contact`.`batch` AS `batch`,
2517 `contact`.`request` AS `request`,
2518 `contact`.`notify` AS `notify`,
2519 `contact`.`poll` AS `poll`,
2520 `contact`.`confirm` AS `confirm`,
2521 `contact`.`poco` AS `poco`,
2522 `contact`.`subhub` AS `subhub`,
2523 `contact`.`hub-verify` AS `hub-verify`,
2524 `contact`.`last-update` AS `last-update`,
2525 `contact`.`success_update` AS `success_update`,
2526 `contact`.`failure_update` AS `failure_update`,
2527 `contact`.`name-date` AS `name-date`,
2528 `contact`.`uri-date` AS `uri-date`,
2529 `contact`.`avatar-date` AS `avatar-date`,
2530 `contact`.`avatar-date` AS `picdate`,
2531 `contact`.`term-date` AS `term-date`,
2532 `contact`.`last-item` AS `last-item`,
2533 `contact`.`priority` AS `priority`,
2534 `user`.`blocked` AS `blocked`,
2535 `contact`.`block_reason` AS `block_reason`,
2536 `contact`.`readonly` AS `readonly`,
2537 `contact`.`writable` AS `writable`,
2538 `contact`.`forum` AS `forum`,
2539 `contact`.`prv` AS `prv`,
2540 `contact`.`contact-type` AS `contact-type`,
2541 `contact`.`manually-approve` AS `manually-approve`,
2542 `contact`.`hidden` AS `hidden`,
2543 `contact`.`archive` AS `archive`,
2544 `contact`.`pending` AS `pending`,
2545 `contact`.`deleted` AS `deleted`,
2546 `contact`.`unsearchable` AS `unsearchable`,
2547 `contact`.`sensitive` AS `sensitive`,
2548 `contact`.`baseurl` AS `baseurl`,
2549 `contact`.`reason` AS `reason`,
2550 `contact`.`info` AS `info`,
2551 `contact`.`bdyear` AS `bdyear`,
2552 `contact`.`bd` AS `bd`,
2553 `contact`.`notify_new_posts` AS `notify_new_posts`,
2554 `contact`.`fetch_further_information` AS `fetch_further_information`,
2555 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2556 `user`.`parent-uid` AS `parent-uid`,
2557 `user`.`guid` AS `guid`,
2558 `user`.`nickname` AS `nickname`,
2559 `user`.`email` AS `email`,
2560 `user`.`openid` AS `openid`,
2561 `user`.`timezone` AS `timezone`,
2562 `user`.`language` AS `language`,
2563 `user`.`register_date` AS `register_date`,
2564 `user`.`login_date` AS `login_date`,
2565 `user`.`default-location` AS `default-location`,
2566 `user`.`allow_location` AS `allow_location`,
2567 `user`.`theme` AS `theme`,
2568 `user`.`pubkey` AS `upubkey`,
2569 `user`.`prvkey` AS `uprvkey`,
2570 `user`.`sprvkey` AS `sprvkey`,
2571 `user`.`spubkey` AS `spubkey`,
2572 `user`.`verified` AS `verified`,
2573 `user`.`blockwall` AS `blockwall`,
2574 `user`.`hidewall` AS `hidewall`,
2575 `user`.`blocktags` AS `blocktags`,
2576 `user`.`unkmail` AS `unkmail`,
2577 `user`.`cntunkmail` AS `cntunkmail`,
2578 `user`.`notify-flags` AS `notify-flags`,
2579 `user`.`page-flags` AS `page-flags`,
2580 `user`.`account-type` AS `account-type`,
2581 `user`.`prvnets` AS `prvnets`,
2582 `user`.`maxreq` AS `maxreq`,
2583 `user`.`expire` AS `expire`,
2584 `user`.`account_removed` AS `account_removed`,
2585 `user`.`account_expired` AS `account_expired`,
2586 `user`.`account_expires_on` AS `account_expires_on`,
2587 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2588 `user`.`def_gid` AS `def_gid`,
2589 `user`.`allow_cid` AS `allow_cid`,
2590 `user`.`allow_gid` AS `allow_gid`,
2591 `user`.`deny_cid` AS `deny_cid`,
2592 `user`.`deny_gid` AS `deny_gid`,
2593 `user`.`openidserver` AS `openidserver`,
2594 `profile`.`publish` AS `publish`,
2595 `profile`.`net-publish` AS `net-publish`,
2596 `profile`.`hide-friends` AS `hide-friends`,
2597 `profile`.`prv_keywords` AS `prv_keywords`,
2598 `profile`.`pub_keywords` AS `pub_keywords`,
2599 `profile`.`address` AS `address`,
2600 `profile`.`locality` AS `locality`,
2601 `profile`.`region` AS `region`,
2602 `profile`.`postal-code` AS `postal-code`,
2603 `profile`.`country-name` AS `country-name`,
2604 `profile`.`homepage` AS `homepage`,
2605 `profile`.`dob` AS `dob`
2607 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2608 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2611 -- VIEW account-view
2613 DROP VIEW IF EXISTS `account-view`;
2614 CREATE VIEW `account-view` AS SELECT
2615 `contact`.`id` AS `id`,
2616 `contact`.`url` AS `url`,
2617 `contact`.`nurl` AS `nurl`,
2618 `contact`.`uri-id` AS `uri-id`,
2619 `item-uri`.`guid` AS `guid`,
2620 `contact`.`addr` AS `addr`,
2621 `contact`.`alias` AS `alias`,
2622 `contact`.`name` AS `name`,
2623 `contact`.`nick` AS `nick`,
2624 `contact`.`about` AS `about`,
2625 `contact`.`keywords` AS `keywords`,
2626 `contact`.`xmpp` AS `xmpp`,
2627 `contact`.`matrix` AS `matrix`,
2628 `contact`.`avatar` AS `avatar`,
2629 `contact`.`photo` AS `photo`,
2630 `contact`.`thumb` AS `thumb`,
2631 `contact`.`micro` AS `micro`,
2632 `contact`.`header` AS `header`,
2633 `contact`.`created` AS `created`,
2634 `contact`.`updated` AS `updated`,
2635 `contact`.`network` AS `network`,
2636 `contact`.`protocol` AS `protocol`,
2637 `contact`.`location` AS `location`,
2638 `contact`.`attag` AS `attag`,
2639 `contact`.`pubkey` AS `pubkey`,
2640 `contact`.`prvkey` AS `prvkey`,
2641 `contact`.`subscribe` AS `subscribe`,
2642 `contact`.`last-update` AS `last-update`,
2643 `contact`.`success_update` AS `success_update`,
2644 `contact`.`failure_update` AS `failure_update`,
2645 `contact`.`failed` AS `failed`,
2646 `contact`.`last-item` AS `last-item`,
2647 `contact`.`last-discovery` AS `last-discovery`,
2648 `contact`.`contact-type` AS `contact-type`,
2649 `contact`.`manually-approve` AS `manually-approve`,
2650 `contact`.`unsearchable` AS `unsearchable`,
2651 `contact`.`sensitive` AS `sensitive`,
2652 `contact`.`baseurl` AS `baseurl`,
2653 `contact`.`gsid` AS `gsid`,
2654 `contact`.`info` AS `info`,
2655 `contact`.`bdyear` AS `bdyear`,
2656 `contact`.`bd` AS `bd`,
2657 `contact`.`poco` AS `poco`,
2658 `contact`.`name-date` AS `name-date`,
2659 `contact`.`uri-date` AS `uri-date`,
2660 `contact`.`avatar-date` AS `avatar-date`,
2661 `contact`.`term-date` AS `term-date`,
2662 `contact`.`hidden` AS `global-ignored`,
2663 `contact`.`blocked` AS `global-blocked`,
2664 `contact`.`hidden` AS `hidden`,
2665 `contact`.`archive` AS `archive`,
2666 `contact`.`deleted` AS `deleted`,
2667 `contact`.`blocked` AS `blocked`,
2668 `contact`.`notify` AS `dfrn-notify`,
2669 `contact`.`poll` AS `dfrn-poll`,
2670 `fcontact`.`guid` AS `diaspora-guid`,
2671 `fcontact`.`batch` AS `diaspora-batch`,
2672 `fcontact`.`notify` AS `diaspora-notify`,
2673 `fcontact`.`poll` AS `diaspora-poll`,
2674 `fcontact`.`alias` AS `diaspora-alias`,
2675 `apcontact`.`uuid` AS `ap-uuid`,
2676 `apcontact`.`type` AS `ap-type`,
2677 `apcontact`.`following` AS `ap-following`,
2678 `apcontact`.`followers` AS `ap-followers`,
2679 `apcontact`.`inbox` AS `ap-inbox`,
2680 `apcontact`.`outbox` AS `ap-outbox`,
2681 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2682 `apcontact`.`generator` AS `ap-generator`,
2683 `apcontact`.`following_count` AS `ap-following_count`,
2684 `apcontact`.`followers_count` AS `ap-followers_count`,
2685 `apcontact`.`statuses_count` AS `ap-statuses_count`,
2686 `gserver`.`site_name` AS `site_name`,
2687 `gserver`.`platform` AS `platform`,
2688 `gserver`.`version` AS `version`
2690 LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id`
2691 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
2692 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = contact.`uri-id`
2693 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`
2694 WHERE `contact`.`uid` = 0;
2697 -- VIEW account-user-view
2699 DROP VIEW IF EXISTS `account-user-view`;
2700 CREATE VIEW `account-user-view` AS SELECT
2701 `ucontact`.`id` AS `id`,
2702 `contact`.`id` AS `pid`,
2703 `ucontact`.`uid` AS `uid`,
2704 `contact`.`url` AS `url`,
2705 `contact`.`nurl` AS `nurl`,
2706 `contact`.`uri-id` AS `uri-id`,
2707 `item-uri`.`guid` AS `guid`,
2708 `contact`.`addr` AS `addr`,
2709 `contact`.`alias` AS `alias`,
2710 `contact`.`name` AS `name`,
2711 `contact`.`nick` AS `nick`,
2712 `contact`.`about` AS `about`,
2713 `contact`.`keywords` AS `keywords`,
2714 `contact`.`xmpp` AS `xmpp`,
2715 `contact`.`matrix` AS `matrix`,
2716 `contact`.`avatar` AS `avatar`,
2717 `contact`.`photo` AS `photo`,
2718 `contact`.`thumb` AS `thumb`,
2719 `contact`.`micro` AS `micro`,
2720 `contact`.`header` AS `header`,
2721 `contact`.`created` AS `created`,
2722 `contact`.`updated` AS `updated`,
2723 `ucontact`.`self` AS `self`,
2724 `ucontact`.`remote_self` AS `remote_self`,
2725 `ucontact`.`rel` AS `rel`,
2726 `contact`.`network` AS `network`,
2727 `ucontact`.`protocol` AS `protocol`,
2728 `contact`.`location` AS `location`,
2729 `ucontact`.`attag` AS `attag`,
2730 `contact`.`pubkey` AS `pubkey`,
2731 `contact`.`prvkey` AS `prvkey`,
2732 `contact`.`subscribe` AS `subscribe`,
2733 `contact`.`last-update` AS `last-update`,
2734 `contact`.`success_update` AS `success_update`,
2735 `contact`.`failure_update` AS `failure_update`,
2736 `contact`.`failed` AS `failed`,
2737 `contact`.`last-item` AS `last-item`,
2738 `contact`.`last-discovery` AS `last-discovery`,
2739 `contact`.`contact-type` AS `contact-type`,
2740 `contact`.`manually-approve` AS `manually-approve`,
2741 `contact`.`unsearchable` AS `unsearchable`,
2742 `contact`.`sensitive` AS `sensitive`,
2743 `contact`.`baseurl` AS `baseurl`,
2744 `contact`.`gsid` AS `gsid`,
2745 `ucontact`.`info` AS `info`,
2746 `contact`.`bdyear` AS `bdyear`,
2747 `contact`.`bd` AS `bd`,
2748 `contact`.`poco` AS `poco`,
2749 `contact`.`name-date` AS `name-date`,
2750 `contact`.`uri-date` AS `uri-date`,
2751 `contact`.`avatar-date` AS `avatar-date`,
2752 `contact`.`term-date` AS `term-date`,
2753 `contact`.`hidden` AS `global-ignored`,
2754 `contact`.`blocked` AS `global-blocked`,
2755 `ucontact`.`hidden` AS `hidden`,
2756 `ucontact`.`archive` AS `archive`,
2757 `ucontact`.`pending` AS `pending`,
2758 `ucontact`.`deleted` AS `deleted`,
2759 `ucontact`.`notify_new_posts` AS `notify_new_posts`,
2760 `ucontact`.`fetch_further_information` AS `fetch_further_information`,
2761 `ucontact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2762 `ucontact`.`rating` AS `rating`,
2763 `ucontact`.`readonly` AS `readonly`,
2764 `ucontact`.`blocked` AS `blocked`,
2765 `ucontact`.`block_reason` AS `block_reason`,
2766 `ucontact`.`subhub` AS `subhub`,
2767 `ucontact`.`hub-verify` AS `hub-verify`,
2768 `ucontact`.`reason` AS `reason`,
2769 `contact`.`notify` AS `dfrn-notify`,
2770 `contact`.`poll` AS `dfrn-poll`,
2771 `fcontact`.`guid` AS `diaspora-guid`,
2772 `fcontact`.`batch` AS `diaspora-batch`,
2773 `fcontact`.`notify` AS `diaspora-notify`,
2774 `fcontact`.`poll` AS `diaspora-poll`,
2775 `fcontact`.`alias` AS `diaspora-alias`,
2776 `fcontact`.`interacting_count` AS `diaspora-interacting_count`,
2777 `fcontact`.`interacted_count` AS `diaspora-interacted_count`,
2778 `fcontact`.`post_count` AS `diaspora-post_count`,
2779 `apcontact`.`uuid` AS `ap-uuid`,
2780 `apcontact`.`type` AS `ap-type`,
2781 `apcontact`.`following` AS `ap-following`,
2782 `apcontact`.`followers` AS `ap-followers`,
2783 `apcontact`.`inbox` AS `ap-inbox`,
2784 `apcontact`.`outbox` AS `ap-outbox`,
2785 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2786 `apcontact`.`generator` AS `ap-generator`,
2787 `apcontact`.`following_count` AS `ap-following_count`,
2788 `apcontact`.`followers_count` AS `ap-followers_count`,
2789 `apcontact`.`statuses_count` AS `ap-statuses_count`,
2790 `gserver`.`site_name` AS `site_name`,
2791 `gserver`.`platform` AS `platform`,
2792 `gserver`.`version` AS `version`
2793 FROM `contact` AS `ucontact`
2794 INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
2795 LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id`
2796 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
2797 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = `ucontact`.`uri-id` AND `fcontact`.`network` = 'dspr'
2798 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`;
2801 -- VIEW pending-view
2803 DROP VIEW IF EXISTS `pending-view`;
2804 CREATE VIEW `pending-view` AS SELECT
2805 `register`.`id` AS `id`,
2806 `register`.`hash` AS `hash`,
2807 `register`.`created` AS `created`,
2808 `register`.`uid` AS `uid`,
2809 `register`.`password` AS `password`,
2810 `register`.`language` AS `language`,
2811 `register`.`note` AS `note`,
2812 `contact`.`self` AS `self`,
2813 `contact`.`name` AS `name`,
2814 `contact`.`url` AS `url`,
2815 `contact`.`micro` AS `micro`,
2816 `user`.`email` AS `email`,
2817 `contact`.`nick` AS `nick`
2819 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2820 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2823 -- VIEW tag-search-view
2825 DROP VIEW IF EXISTS `tag-search-view`;
2826 CREATE VIEW `tag-search-view` AS SELECT
2827 `post-tag`.`uri-id` AS `uri-id`,
2828 `post-user`.`uid` AS `uid`,
2829 `post-user`.`id` AS `iid`,
2830 `post-user`.`private` AS `private`,
2831 `post-user`.`wall` AS `wall`,
2832 `post-user`.`origin` AS `origin`,
2833 `post-user`.`global` AS `global`,
2834 `post-user`.`gravity` AS `gravity`,
2835 `post-user`.`received` AS `received`,
2836 `post-user`.`network` AS `network`,
2837 `post-user`.`author-id` AS `author-id`,
2838 `tag`.`name` AS `name`
2840 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
2841 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
2842 WHERE `post-tag`.`type` = 1;
2845 -- VIEW workerqueue-view
2847 DROP VIEW IF EXISTS `workerqueue-view`;
2848 CREATE VIEW `workerqueue-view` AS SELECT
2849 `process`.`pid` AS `pid`,
2850 `workerqueue`.`priority` AS `priority`
2852 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
2853 WHERE NOT `workerqueue`.`done`;
2856 -- VIEW profile_field-view
2858 DROP VIEW IF EXISTS `profile_field-view`;
2859 CREATE VIEW `profile_field-view` AS SELECT
2860 `profile_field`.`id` AS `id`,
2861 `profile_field`.`uid` AS `uid`,
2862 `profile_field`.`label` AS `label`,
2863 `profile_field`.`value` AS `value`,
2864 `profile_field`.`order` AS `order`,
2865 `profile_field`.`psid` AS `psid`,
2866 `permissionset`.`allow_cid` AS `allow_cid`,
2867 `permissionset`.`allow_gid` AS `allow_gid`,
2868 `permissionset`.`deny_cid` AS `deny_cid`,
2869 `permissionset`.`deny_gid` AS `deny_gid`,
2870 `profile_field`.`created` AS `created`,
2871 `profile_field`.`edited` AS `edited`
2872 FROM `profile_field`
2873 INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`;