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