1 -- ------------------------------------------
2 -- Friendica 2022.05-rc (Siberian Iris)
3 -- DB_UPDATE_VERSION 1462
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 `created` datetime NOT NULL COMMENT 'Datetime the trusted browser was recorded',
301 `last_used` datetime COMMENT 'Datetime the trusted browser was last used',
302 PRIMARY KEY(`cookie_hash`),
304 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
305 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication trusted browsers';
310 CREATE TABLE IF NOT EXISTS `addon` (
311 `id` int unsigned NOT NULL auto_increment COMMENT '',
312 `name` varchar(50) NOT NULL DEFAULT '' COMMENT 'addon base (file)name',
313 `version` varchar(50) NOT NULL DEFAULT '' COMMENT 'currently unused',
314 `installed` boolean NOT NULL DEFAULT '0' COMMENT 'currently always 1',
315 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'currently unused',
316 `timestamp` int unsigned NOT NULL DEFAULT 0 COMMENT 'file timestamp to check for reloads',
317 `plugin_admin` boolean NOT NULL DEFAULT '0' COMMENT '1 = has admin config, 0 = has no admin config',
319 INDEX `installed_name` (`installed`,`name`),
320 UNIQUE INDEX `name` (`name`)
321 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registered addons';
326 CREATE TABLE IF NOT EXISTS `apcontact` (
327 `url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
328 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
329 `uuid` varchar(255) COMMENT '',
330 `type` varchar(20) NOT NULL COMMENT '',
331 `following` varchar(255) COMMENT '',
332 `followers` varchar(255) COMMENT '',
333 `inbox` varchar(255) NOT NULL COMMENT '',
334 `outbox` varchar(255) COMMENT '',
335 `sharedinbox` varchar(255) COMMENT '',
336 `featured` varchar(255) COMMENT 'Address for the collection of featured posts',
337 `featured-tags` varchar(255) COMMENT 'Address for the collection of featured tags',
338 `manually-approve` boolean COMMENT '',
339 `discoverable` boolean COMMENT 'Mastodon extension: true if profile is published in their directory',
340 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
341 `name` varchar(255) COMMENT '',
342 `about` text COMMENT '',
343 `xmpp` varchar(255) COMMENT 'XMPP address',
344 `matrix` varchar(255) COMMENT 'Matrix address',
345 `photo` varchar(255) COMMENT '',
346 `header` varchar(255) COMMENT 'Header picture',
347 `addr` varchar(255) COMMENT '',
348 `alias` varchar(255) COMMENT '',
349 `pubkey` text COMMENT '',
350 `subscribe` varchar(255) COMMENT '',
351 `baseurl` varchar(255) COMMENT 'baseurl of the ap contact',
352 `gsid` int unsigned COMMENT 'Global Server ID',
353 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
354 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
355 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
356 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
357 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
359 INDEX `addr` (`addr`(32)),
360 INDEX `alias` (`alias`(190)),
361 INDEX `followers` (`followers`(190)),
362 INDEX `baseurl` (`baseurl`(190)),
363 INDEX `sharedinbox` (`sharedinbox`(190)),
364 INDEX `gsid` (`gsid`),
365 UNIQUE INDEX `uri-id` (`uri-id`),
366 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
367 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
368 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
373 CREATE TABLE IF NOT EXISTS `application` (
374 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
375 `client_id` varchar(64) NOT NULL COMMENT '',
376 `client_secret` varchar(64) NOT NULL COMMENT '',
377 `name` varchar(255) NOT NULL COMMENT '',
378 `redirect_uri` varchar(255) NOT NULL COMMENT '',
379 `website` varchar(255) COMMENT '',
380 `scopes` varchar(255) COMMENT '',
381 `read` boolean COMMENT 'Read scope',
382 `write` boolean COMMENT 'Write scope',
383 `follow` boolean COMMENT 'Follow scope',
384 `push` boolean COMMENT 'Push scope',
386 UNIQUE INDEX `client_id` (`client_id`)
387 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth application';
390 -- TABLE application-token
392 CREATE TABLE IF NOT EXISTS `application-token` (
393 `application-id` int unsigned NOT NULL COMMENT '',
394 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
395 `code` varchar(64) NOT NULL COMMENT '',
396 `access_token` varchar(64) NOT NULL COMMENT '',
397 `created_at` datetime NOT NULL COMMENT 'creation time',
398 `scopes` varchar(255) COMMENT '',
399 `read` boolean COMMENT 'Read scope',
400 `write` boolean COMMENT 'Write scope',
401 `follow` boolean COMMENT 'Follow scope',
402 `push` boolean COMMENT 'Push scope',
403 PRIMARY KEY(`application-id`,`uid`),
404 INDEX `uid_id` (`uid`,`application-id`),
405 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
406 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
407 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth user token';
412 CREATE TABLE IF NOT EXISTS `attach` (
413 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
414 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
415 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
416 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
417 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
418 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
419 `data` longblob NOT NULL COMMENT 'file data',
420 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
421 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
422 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
423 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
424 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
425 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
426 `backend-class` tinytext COMMENT 'Storage backend class',
427 `backend-ref` text COMMENT 'Storage backend data reference',
430 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
431 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
436 CREATE TABLE IF NOT EXISTS `cache` (
437 `k` varbinary(255) NOT NULL COMMENT 'cache key',
438 `v` mediumtext COMMENT 'cached serialized value',
439 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
440 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
442 INDEX `k_expires` (`k`,`expires`)
443 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
448 CREATE TABLE IF NOT EXISTS `config` (
449 `id` int unsigned NOT NULL auto_increment COMMENT '',
450 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
451 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
452 `v` mediumtext COMMENT '',
454 UNIQUE INDEX `cat_k` (`cat`,`k`)
455 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
458 -- TABLE contact-relation
460 CREATE TABLE IF NOT EXISTS `contact-relation` (
461 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
462 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
463 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
464 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
465 `follows` boolean NOT NULL DEFAULT '0' COMMENT '',
466 PRIMARY KEY(`cid`,`relation-cid`),
467 INDEX `relation-cid` (`relation-cid`),
468 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
469 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
470 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
475 CREATE TABLE IF NOT EXISTS `conv` (
476 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
477 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
478 `recips` text COMMENT 'sender_handle;recipient_handle',
479 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
480 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
481 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
482 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
483 `subject` text COMMENT 'subject of initial message',
486 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
487 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
490 -- TABLE conversation
492 CREATE TABLE IF NOT EXISTS `conversation` (
493 `item-uri` varbinary(255) NOT NULL COMMENT 'Original URI of the item - unrelated to the table with the same name',
494 `reply-to-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'URI to which this item is a reply',
495 `conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI',
496 `conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link',
497 `protocol` tinyint unsigned NOT NULL DEFAULT 255 COMMENT 'The protocol of the item',
498 `direction` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'How the message arrived here: 1=push, 2=pull',
499 `source` mediumtext COMMENT 'Original source',
500 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Receiving date',
501 PRIMARY KEY(`item-uri`),
502 INDEX `conversation-uri` (`conversation-uri`),
503 INDEX `received` (`received`)
504 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Raw data and structure information for messages';
509 CREATE TABLE IF NOT EXISTS `workerqueue` (
510 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
511 `command` varchar(100) COMMENT 'Task command',
512 `parameter` mediumtext COMMENT 'Task parameter',
513 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
514 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
515 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
516 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
517 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
518 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
519 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
521 INDEX `command` (`command`),
522 INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
523 INDEX `done_executed` (`done`,`executed`),
524 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
525 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
526 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
527 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
528 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
529 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
532 -- TABLE delayed-post
534 CREATE TABLE IF NOT EXISTS `delayed-post` (
535 `id` int unsigned NOT NULL auto_increment,
536 `uri` varchar(255) COMMENT 'URI of the post that will be distributed later',
537 `uid` mediumint unsigned COMMENT 'Owner User id',
538 `delayed` datetime COMMENT 'delay time',
539 `wid` int unsigned COMMENT 'Workerqueue id',
541 UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
543 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
544 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
545 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
548 -- TABLE diaspora-interaction
550 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
551 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
552 `interaction` mediumtext COMMENT 'The Diaspora interaction',
553 PRIMARY KEY(`uri-id`),
554 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
555 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
560 CREATE TABLE IF NOT EXISTS `endpoint` (
561 `url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
562 `type` varchar(20) NOT NULL COMMENT '',
563 `owner-uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
565 UNIQUE INDEX `owner-uri-id_type` (`owner-uri-id`,`type`),
566 FOREIGN KEY (`owner-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
567 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub endpoints - used in the ActivityPub implementation';
572 CREATE TABLE IF NOT EXISTS `event` (
573 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
574 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
575 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
576 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
577 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
578 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the event uri',
579 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
580 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
581 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
582 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
583 `summary` text COMMENT 'short description or title of the event',
584 `desc` text COMMENT 'event description',
585 `location` text COMMENT 'event location',
586 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
587 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
588 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
589 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
590 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
591 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
592 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
594 INDEX `uid_start` (`uid`,`start`),
596 INDEX `uri-id` (`uri-id`),
597 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
598 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
599 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
600 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
605 CREATE TABLE IF NOT EXISTS `fcontact` (
606 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
607 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
608 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
609 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the fcontact url',
610 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
611 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
612 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
613 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
614 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
615 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
616 `notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
617 `poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
618 `confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
619 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
620 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
621 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
622 `pubkey` text COMMENT '',
623 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
624 `interacting_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts this contact interactes with',
625 `interacted_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts that interacted with this contact',
626 `post_count` int unsigned DEFAULT 0 COMMENT 'Number of posts and comments',
628 INDEX `addr` (`addr`(32)),
629 UNIQUE INDEX `url` (`url`(190)),
630 UNIQUE INDEX `uri-id` (`uri-id`),
631 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
632 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
637 CREATE TABLE IF NOT EXISTS `fsuggest` (
638 `id` int unsigned NOT NULL auto_increment COMMENT '',
639 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
640 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
641 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
642 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
643 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
644 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
645 `note` text COMMENT '',
646 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
650 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
651 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
652 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
657 CREATE TABLE IF NOT EXISTS `group` (
658 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
659 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
660 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
661 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
662 `cid` int unsigned COMMENT 'Contact id of forum. When this field is filled then the members are synced automatically.',
663 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
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='privacy groups, group info';
672 -- TABLE group_member
674 CREATE TABLE IF NOT EXISTS `group_member` (
675 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
676 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
677 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
679 INDEX `contactid` (`contact-id`),
680 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
681 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
682 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
683 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
688 CREATE TABLE IF NOT EXISTS `gserver-tag` (
689 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
690 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
691 PRIMARY KEY(`gserver-id`,`tag`),
693 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
694 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
699 CREATE TABLE IF NOT EXISTS `hook` (
700 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
701 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
702 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
703 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
704 `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',
706 INDEX `priority` (`priority`),
707 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
708 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
711 -- TABLE inbox-status
713 CREATE TABLE IF NOT EXISTS `inbox-status` (
714 `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
715 `uri-id` int unsigned COMMENT 'Item-uri id of inbox url',
716 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
717 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
718 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
719 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
720 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
721 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
723 INDEX `uri-id` (`uri-id`),
724 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
725 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
730 CREATE TABLE IF NOT EXISTS `intro` (
731 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
732 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
733 `fid` int unsigned COMMENT 'deprecated',
734 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
735 `suggest-cid` int unsigned COMMENT 'Suggested contact',
736 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
737 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
738 `note` text COMMENT '',
739 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
740 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
741 `blocked` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
742 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
744 INDEX `contact-id` (`contact-id`),
745 INDEX `suggest-cid` (`suggest-cid`),
747 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
748 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
749 FOREIGN KEY (`suggest-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
750 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
755 CREATE TABLE IF NOT EXISTS `locks` (
756 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
757 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
758 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
759 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
760 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
762 INDEX `name_expires` (`name`,`expires`)
763 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
768 CREATE TABLE IF NOT EXISTS `mail` (
769 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
770 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
771 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
772 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
773 `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
774 `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
775 `contact-id` varchar(255) COMMENT 'contact.id',
776 `author-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the author of the mail',
777 `convid` int unsigned COMMENT 'conv.id',
778 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
779 `body` mediumtext COMMENT '',
780 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
781 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
782 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
783 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
784 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
785 `uri-id` int unsigned COMMENT 'Item-uri id of the related mail',
786 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
787 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related mail',
788 `thr-parent` varchar(255) COMMENT '',
789 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
790 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
792 INDEX `uid_seen` (`uid`,`seen`),
793 INDEX `convid` (`convid`),
794 INDEX `uri` (`uri`(64)),
795 INDEX `parent-uri` (`parent-uri`(64)),
796 INDEX `contactid` (`contact-id`(32)),
797 INDEX `author-id` (`author-id`),
798 INDEX `uri-id` (`uri-id`),
799 INDEX `parent-uri-id` (`parent-uri-id`),
800 INDEX `thr-parent-id` (`thr-parent-id`),
801 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
802 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
803 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
804 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
805 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
806 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
811 CREATE TABLE IF NOT EXISTS `mailacct` (
812 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
813 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
814 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
815 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
816 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
817 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
818 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
819 `pass` text COMMENT '',
820 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
821 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
822 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
823 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
824 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
827 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
828 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
833 CREATE TABLE IF NOT EXISTS `manage` (
834 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
835 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
836 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
838 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
840 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
841 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
842 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
845 -- TABLE notification
847 CREATE TABLE IF NOT EXISTS `notification` (
848 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
849 `uid` mediumint unsigned COMMENT 'Owner User id',
850 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
851 `type` tinyint unsigned COMMENT '',
852 `actor-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the actor that caused the notification',
853 `target-uri-id` int unsigned COMMENT 'Item-uri id of the related post',
854 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
855 `created` datetime COMMENT '',
856 `seen` boolean DEFAULT '0' COMMENT 'Seen on the desktop',
857 `dismissed` boolean DEFAULT '0' COMMENT 'Dismissed via the API',
859 UNIQUE INDEX `uid_vid_type_actor-id_target-uri-id` (`uid`,`vid`,`type`,`actor-id`,`target-uri-id`),
861 INDEX `actor-id` (`actor-id`),
862 INDEX `target-uri-id` (`target-uri-id`),
863 INDEX `parent-uri-id` (`parent-uri-id`),
864 INDEX `seen_uid` (`seen`,`uid`),
865 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
866 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
867 FOREIGN KEY (`actor-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
868 FOREIGN KEY (`target-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
869 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
870 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
875 CREATE TABLE IF NOT EXISTS `notify` (
876 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
877 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
878 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
879 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
880 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
881 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
882 `msg` mediumtext COMMENT '',
883 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
884 `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
885 `iid` int unsigned COMMENT '',
886 `parent` int unsigned COMMENT '',
887 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
888 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
889 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
890 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
891 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
892 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
893 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
895 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
896 INDEX `uid_date` (`uid`,`date`),
897 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
898 INDEX `uri-id` (`uri-id`),
899 INDEX `parent-uri-id` (`parent-uri-id`),
900 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
901 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
902 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
903 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='[Deprecated] User notifications';
906 -- TABLE notify-threads
908 CREATE TABLE IF NOT EXISTS `notify-threads` (
909 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
910 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
911 `master-parent-item` int unsigned COMMENT 'Deprecated',
912 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
913 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
914 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
916 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
917 INDEX `receiver-uid` (`receiver-uid`),
918 INDEX `notify-id` (`notify-id`),
919 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
920 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
921 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
922 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
927 CREATE TABLE IF NOT EXISTS `oembed` (
928 `url` varbinary(255) NOT NULL COMMENT 'page url',
929 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
930 `content` mediumtext COMMENT 'OEmbed data of the page',
931 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
932 PRIMARY KEY(`url`,`maxwidth`),
933 INDEX `created` (`created`)
934 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
937 -- TABLE openwebauth-token
939 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
940 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
941 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
942 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
943 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
944 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
945 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
948 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
949 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
954 CREATE TABLE IF NOT EXISTS `parsed_url` (
955 `url_hash` binary(64) NOT NULL COMMENT 'page url hash',
956 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
957 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
958 `url` text NOT NULL COMMENT 'page url',
959 `content` mediumtext COMMENT 'page data',
960 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
961 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration',
962 PRIMARY KEY(`url_hash`,`guessing`,`oembed`),
963 INDEX `created` (`created`),
964 INDEX `expires` (`expires`)
965 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
970 CREATE TABLE IF NOT EXISTS `pconfig` (
971 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
972 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
973 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
974 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
975 `v` mediumtext COMMENT 'Value',
977 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
978 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
979 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
984 CREATE TABLE IF NOT EXISTS `photo` (
985 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
986 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
987 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
988 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
989 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
990 `hash` char(32) COMMENT 'hash value of the photo',
991 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
992 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
993 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
994 `desc` text COMMENT '',
995 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
996 `photo-type` tinyint unsigned COMMENT 'User avatar, user banner, contact avatar, contact banner or default',
997 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
998 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
999 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1000 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1001 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1002 `data` mediumblob NOT NULL COMMENT '',
1003 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1004 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
1005 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
1006 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
1007 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
1008 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
1009 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
1010 `backend-class` tinytext COMMENT 'Storage backend class',
1011 `backend-ref` text COMMENT 'Storage backend data reference',
1012 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1014 INDEX `contactid` (`contact-id`),
1015 INDEX `uid_contactid` (`uid`,`contact-id`),
1016 INDEX `uid_profile` (`uid`,`profile`),
1017 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
1018 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
1019 INDEX `resource-id` (`resource-id`),
1020 INDEX `uid_photo-type` (`uid`,`photo-type`),
1021 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1022 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1023 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1028 CREATE TABLE IF NOT EXISTS `post` (
1029 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1030 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1031 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1032 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1033 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1034 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1035 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1036 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1037 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1038 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1039 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1040 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1041 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1042 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1043 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1044 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1045 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1046 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1047 PRIMARY KEY(`uri-id`),
1048 INDEX `parent-uri-id` (`parent-uri-id`),
1049 INDEX `thr-parent-id` (`thr-parent-id`),
1050 INDEX `external-id` (`external-id`),
1051 INDEX `owner-id` (`owner-id`),
1052 INDEX `author-id` (`author-id`),
1053 INDEX `causer-id` (`causer-id`),
1054 INDEX `vid` (`vid`),
1055 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1056 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1057 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1058 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1059 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1060 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1061 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1062 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1063 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
1066 -- TABLE post-category
1068 CREATE TABLE IF NOT EXISTS `post-category` (
1069 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1070 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1071 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1072 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1073 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1074 INDEX `tid` (`tid`),
1075 INDEX `uid_uri-id` (`uid`,`uri-id`),
1076 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1077 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1078 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1079 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1082 -- TABLE post-collection
1084 CREATE TABLE IF NOT EXISTS `post-collection` (
1085 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1086 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0 - Featured',
1087 PRIMARY KEY(`uri-id`,`type`),
1088 INDEX `type` (`type`),
1089 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1090 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Collection of posts';
1093 -- TABLE post-content
1095 CREATE TABLE IF NOT EXISTS `post-content` (
1096 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1097 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1098 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1099 `body` mediumtext COMMENT 'item body content',
1100 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1101 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1102 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1103 `language` text COMMENT 'Language information about this post',
1104 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1105 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1106 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1107 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1108 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1109 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1110 `target` text COMMENT 'JSON encoded target structure if used',
1111 `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',
1112 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1113 PRIMARY KEY(`uri-id`),
1114 INDEX `plink` (`plink`(191)),
1115 INDEX `resource-id` (`resource-id`),
1116 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
1117 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1118 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1121 -- TABLE post-delivery
1123 CREATE TABLE IF NOT EXISTS `post-delivery` (
1124 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1125 `inbox-id` int unsigned NOT NULL COMMENT 'Item-uri id of inbox url',
1126 `uid` mediumint unsigned COMMENT 'Delivering user',
1127 `created` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
1128 `command` varbinary(32) COMMENT '',
1129 `failed` tinyint DEFAULT 0 COMMENT 'Number of times the delivery has failed',
1130 PRIMARY KEY(`uri-id`,`inbox-id`),
1131 INDEX `inbox-id_created` (`inbox-id`,`created`),
1132 INDEX `uid` (`uid`),
1133 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1134 FOREIGN KEY (`inbox-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1135 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1136 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for posts for the batch processing';
1139 -- TABLE post-delivery-data
1141 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1142 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1143 `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',
1144 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1145 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1146 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1147 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1148 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1149 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1150 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1151 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1152 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1153 PRIMARY KEY(`uri-id`),
1154 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1155 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1160 CREATE TABLE IF NOT EXISTS `post-link` (
1161 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1162 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1163 `url` varbinary(511) NOT NULL COMMENT 'External URL',
1164 `mimetype` varchar(60) COMMENT '',
1166 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1167 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1168 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post related external links';
1173 CREATE TABLE IF NOT EXISTS `post-media` (
1174 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1175 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1176 `url` varbinary(511) NOT NULL COMMENT 'Media URL',
1177 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1178 `mimetype` varchar(60) COMMENT '',
1179 `height` smallint unsigned COMMENT 'Height of the media',
1180 `width` smallint unsigned COMMENT 'Width of the media',
1181 `size` int unsigned COMMENT 'Media size',
1182 `preview` varbinary(255) COMMENT 'Preview URL',
1183 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1184 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1185 `description` text COMMENT '',
1186 `name` varchar(255) COMMENT 'Name of the media',
1187 `author-url` varbinary(255) COMMENT 'URL of the author of the media',
1188 `author-name` varchar(255) COMMENT 'Name of the author of the media',
1189 `author-image` varbinary(255) COMMENT 'Image of the author of the media',
1190 `publisher-url` varbinary(255) COMMENT 'URL of the publisher of the media',
1191 `publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
1192 `publisher-image` varbinary(255) COMMENT 'Image of the publisher of the media',
1194 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1195 INDEX `uri-id-id` (`uri-id`,`id`),
1196 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1197 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1200 -- TABLE post-question
1202 CREATE TABLE IF NOT EXISTS `post-question` (
1203 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1204 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1205 `multiple` boolean NOT NULL DEFAULT '0' COMMENT 'Multiple choice',
1206 `voters` int unsigned COMMENT 'Number of voters for this question',
1207 `end-time` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Question end time',
1209 UNIQUE INDEX `uri-id` (`uri-id`),
1210 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1211 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question';
1214 -- TABLE post-question-option
1216 CREATE TABLE IF NOT EXISTS `post-question-option` (
1217 `id` int unsigned NOT NULL COMMENT 'Id of the question',
1218 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1219 `name` varchar(255) COMMENT 'Name of the option',
1220 `replies` int unsigned COMMENT 'Number of replies for this question option',
1221 PRIMARY KEY(`uri-id`,`id`),
1222 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1223 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question option';
1228 CREATE TABLE IF NOT EXISTS `post-tag` (
1229 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1230 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1231 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1232 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1233 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1234 INDEX `tid` (`tid`),
1235 INDEX `cid` (`cid`),
1236 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1237 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1238 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1239 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1242 -- TABLE post-thread
1244 CREATE TABLE IF NOT EXISTS `post-thread` (
1245 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1246 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1247 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1248 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1249 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1250 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1251 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1252 `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',
1253 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1254 PRIMARY KEY(`uri-id`),
1255 INDEX `owner-id` (`owner-id`),
1256 INDEX `author-id` (`author-id`),
1257 INDEX `causer-id` (`causer-id`),
1258 INDEX `received` (`received`),
1259 INDEX `commented` (`commented`),
1260 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1261 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1262 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1263 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1264 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1269 CREATE TABLE IF NOT EXISTS `post-user` (
1270 `id` int unsigned NOT NULL auto_increment,
1271 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1272 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1273 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1274 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1275 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1276 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1277 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1278 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1279 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1280 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1281 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1282 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1283 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1284 `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
1285 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1286 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1287 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1288 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1289 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1290 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1291 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1292 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1293 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1294 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1295 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1296 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1297 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1298 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1299 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1301 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1302 INDEX `uri-id` (`uri-id`),
1303 INDEX `parent-uri-id` (`parent-uri-id`),
1304 INDEX `thr-parent-id` (`thr-parent-id`),
1305 INDEX `external-id` (`external-id`),
1306 INDEX `owner-id` (`owner-id`),
1307 INDEX `author-id` (`author-id`),
1308 INDEX `causer-id` (`causer-id`),
1309 INDEX `vid` (`vid`),
1310 INDEX `contact-id` (`contact-id`),
1311 INDEX `event-id` (`event-id`),
1312 INDEX `psid` (`psid`),
1313 INDEX `author-id_uid` (`author-id`,`uid`),
1314 INDEX `author-id_received` (`author-id`,`received`),
1315 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1316 INDEX `uid_contactid` (`uid`,`contact-id`),
1317 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1318 INDEX `uid_unseen` (`uid`,`unseen`),
1319 INDEX `uid_hidden_uri-id` (`uid`,`hidden`,`uri-id`),
1320 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1321 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1322 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1323 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1324 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1325 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1326 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1327 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1328 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1329 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1330 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1331 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1332 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1335 -- TABLE post-thread-user
1337 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1338 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1339 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1340 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1341 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1342 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1343 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1344 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1345 `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date that something in the conversation changed, indicating clients should fetch the conversation again',
1346 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1347 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1348 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
1349 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1350 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1351 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1352 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1353 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1354 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Deprecated',
1355 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1356 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1357 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1358 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1359 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1360 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1361 PRIMARY KEY(`uid`,`uri-id`),
1362 INDEX `uri-id` (`uri-id`),
1363 INDEX `owner-id` (`owner-id`),
1364 INDEX `author-id` (`author-id`),
1365 INDEX `causer-id` (`causer-id`),
1366 INDEX `uid` (`uid`),
1367 INDEX `contact-id` (`contact-id`),
1368 INDEX `psid` (`psid`),
1369 INDEX `post-user-id` (`post-user-id`),
1370 INDEX `commented` (`commented`),
1371 INDEX `uid_received` (`uid`,`received`),
1372 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1373 INDEX `uid_commented` (`uid`,`commented`),
1374 INDEX `uid_starred` (`uid`,`starred`),
1375 INDEX `uid_mention` (`uid`,`mention`),
1376 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1377 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1378 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1379 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1380 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1381 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1382 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1383 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1384 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1387 -- TABLE post-user-notification
1389 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1390 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1391 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1392 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1393 PRIMARY KEY(`uid`,`uri-id`),
1394 INDEX `uri-id` (`uri-id`),
1395 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1396 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1397 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1402 CREATE TABLE IF NOT EXISTS `process` (
1403 `pid` int unsigned NOT NULL COMMENT 'The ID of the process',
1404 `hostname` varchar(32) NOT NULL COMMENT 'The name of the host the process is ran on',
1405 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1406 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1407 PRIMARY KEY(`pid`,`hostname`),
1408 INDEX `command` (`command`)
1409 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1414 CREATE TABLE IF NOT EXISTS `profile` (
1415 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1416 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1417 `profile-name` varchar(255) COMMENT 'Deprecated',
1418 `is-default` boolean COMMENT 'Deprecated',
1419 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1420 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1421 `pdesc` varchar(255) COMMENT 'Deprecated',
1422 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1423 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1424 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1425 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1426 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1427 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1428 `hometown` varchar(255) COMMENT 'Deprecated',
1429 `gender` varchar(32) COMMENT 'Deprecated',
1430 `marital` varchar(255) COMMENT 'Deprecated',
1431 `with` text COMMENT 'Deprecated',
1432 `howlong` datetime COMMENT 'Deprecated',
1433 `sexual` varchar(255) COMMENT 'Deprecated',
1434 `politic` varchar(255) COMMENT 'Deprecated',
1435 `religion` varchar(255) COMMENT 'Deprecated',
1436 `pub_keywords` text COMMENT '',
1437 `prv_keywords` text COMMENT '',
1438 `likes` text COMMENT 'Deprecated',
1439 `dislikes` text COMMENT 'Deprecated',
1440 `about` text COMMENT 'Profile description',
1441 `summary` varchar(255) COMMENT 'Deprecated',
1442 `music` text COMMENT 'Deprecated',
1443 `book` text COMMENT 'Deprecated',
1444 `tv` text COMMENT 'Deprecated',
1445 `film` text COMMENT 'Deprecated',
1446 `interest` text COMMENT 'Deprecated',
1447 `romance` text COMMENT 'Deprecated',
1448 `work` text COMMENT 'Deprecated',
1449 `education` text COMMENT 'Deprecated',
1450 `contact` text COMMENT 'Deprecated',
1451 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1452 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
1453 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
1454 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1455 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1456 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1457 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1459 INDEX `uid_is-default` (`uid`,`is-default`),
1460 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1461 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1462 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1465 -- TABLE profile_field
1467 CREATE TABLE IF NOT EXISTS `profile_field` (
1468 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1469 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1470 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1471 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1472 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1473 `value` text COMMENT 'Value of the field',
1474 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1475 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1477 INDEX `uid` (`uid`),
1478 INDEX `order` (`order`),
1479 INDEX `psid` (`psid`),
1480 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1481 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1482 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1485 -- TABLE push_subscriber
1487 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1488 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1489 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1490 `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1491 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1492 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1493 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1494 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1495 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1496 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1497 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1499 INDEX `next_try` (`next_try`),
1500 INDEX `uid` (`uid`),
1501 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1502 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1507 CREATE TABLE IF NOT EXISTS `register` (
1508 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1509 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1510 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1511 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1512 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1513 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1514 `note` text COMMENT '',
1516 INDEX `uid` (`uid`),
1517 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1518 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1523 CREATE TABLE IF NOT EXISTS `search` (
1524 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1525 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1526 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1528 INDEX `uid_term` (`uid`,`term`(64)),
1529 INDEX `term` (`term`(64)),
1530 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1531 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1536 CREATE TABLE IF NOT EXISTS `session` (
1537 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1538 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1539 `data` text COMMENT '',
1540 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1542 INDEX `sid` (`sid`(64)),
1543 INDEX `expire` (`expire`)
1544 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1549 CREATE TABLE IF NOT EXISTS `storage` (
1550 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1551 `data` longblob NOT NULL COMMENT 'file data',
1553 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1556 -- TABLE subscription
1558 CREATE TABLE IF NOT EXISTS `subscription` (
1559 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1560 `application-id` int unsigned NOT NULL COMMENT '',
1561 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
1562 `endpoint` varchar(511) COMMENT 'Endpoint URL',
1563 `pubkey` varchar(127) COMMENT 'User agent public key',
1564 `secret` varchar(32) COMMENT 'Auth secret',
1565 `follow` boolean COMMENT '',
1566 `favourite` boolean COMMENT '',
1567 `reblog` boolean COMMENT '',
1568 `mention` boolean COMMENT '',
1569 `poll` boolean COMMENT '',
1570 `follow_request` boolean COMMENT '',
1571 `status` boolean COMMENT '',
1573 UNIQUE INDEX `application-id_uid` (`application-id`,`uid`),
1574 INDEX `uid_application-id` (`uid`,`application-id`),
1575 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1576 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1577 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Push Subscription for the API';
1582 CREATE TABLE IF NOT EXISTS `userd` (
1583 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1584 `username` varchar(255) NOT NULL COMMENT '',
1586 INDEX `username` (`username`(32))
1587 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1590 -- TABLE user-contact
1592 CREATE TABLE IF NOT EXISTS `user-contact` (
1593 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1594 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1595 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
1596 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1597 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1598 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1599 `hidden` boolean COMMENT 'This contact is hidden from the others',
1600 `is-blocked` boolean COMMENT 'User is blocked by this contact',
1601 `pending` boolean COMMENT '',
1602 `rel` tinyint unsigned COMMENT 'The kind of the relation between the user and the contact',
1603 `info` mediumtext COMMENT '',
1604 `notify_new_posts` boolean COMMENT '',
1605 `remote_self` boolean COMMENT '',
1606 `fetch_further_information` tinyint unsigned COMMENT '',
1607 `ffi_keyword_denylist` text COMMENT '',
1608 `subhub` boolean COMMENT '',
1609 `hub-verify` varchar(255) COMMENT '',
1610 `protocol` char(4) COMMENT 'Protocol of the contact',
1611 `rating` tinyint COMMENT 'Automatically detected feed poll frequency',
1612 `priority` tinyint unsigned COMMENT 'Feed poll priority',
1613 PRIMARY KEY(`uid`,`cid`),
1614 INDEX `cid` (`cid`),
1615 UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
1616 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1617 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1618 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1619 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1624 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1625 `key` int NOT NULL COMMENT '',
1626 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1628 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1631 -- VIEW application-view
1633 DROP VIEW IF EXISTS `application-view`;
1634 CREATE VIEW `application-view` AS SELECT
1635 `application`.`id` AS `id`,
1636 `application-token`.`uid` AS `uid`,
1637 `application`.`name` AS `name`,
1638 `application`.`redirect_uri` AS `redirect_uri`,
1639 `application`.`website` AS `website`,
1640 `application`.`client_id` AS `client_id`,
1641 `application`.`client_secret` AS `client_secret`,
1642 `application-token`.`code` AS `code`,
1643 `application-token`.`access_token` AS `access_token`,
1644 `application-token`.`created_at` AS `created_at`,
1645 `application-token`.`scopes` AS `scopes`,
1646 `application-token`.`read` AS `read`,
1647 `application-token`.`write` AS `write`,
1648 `application-token`.`follow` AS `follow`,
1649 `application-token`.`push` AS `push`
1650 FROM `application-token`
1651 INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`;
1654 -- VIEW post-user-view
1656 DROP VIEW IF EXISTS `post-user-view`;
1657 CREATE VIEW `post-user-view` AS SELECT
1658 `post-user`.`id` AS `id`,
1659 `post-user`.`id` AS `post-user-id`,
1660 `post-user`.`uid` AS `uid`,
1661 `parent-post`.`id` AS `parent`,
1662 `item-uri`.`uri` AS `uri`,
1663 `post-user`.`uri-id` AS `uri-id`,
1664 `parent-item-uri`.`uri` AS `parent-uri`,
1665 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1666 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1667 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1668 `item-uri`.`guid` AS `guid`,
1669 `post-user`.`wall` AS `wall`,
1670 `post-user`.`gravity` AS `gravity`,
1671 `external-item-uri`.`uri` AS `extid`,
1672 `post-user`.`external-id` AS `external-id`,
1673 `post-user`.`created` AS `created`,
1674 `post-user`.`edited` AS `edited`,
1675 `post-thread-user`.`commented` AS `commented`,
1676 `post-user`.`received` AS `received`,
1677 `post-thread-user`.`changed` AS `changed`,
1678 `post-user`.`post-type` AS `post-type`,
1679 `post-user`.`post-reason` AS `post-reason`,
1680 `post-user`.`private` AS `private`,
1681 `post-thread-user`.`pubmail` AS `pubmail`,
1682 `post-user`.`visible` AS `visible`,
1683 `post-thread-user`.`starred` AS `starred`,
1684 `post-user`.`unseen` AS `unseen`,
1685 `post-user`.`deleted` AS `deleted`,
1686 `post-user`.`origin` AS `origin`,
1687 `post-thread-user`.`origin` AS `parent-origin`,
1688 `post-thread-user`.`mention` AS `mention`,
1689 `post-user`.`global` AS `global`,
1690 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-user`.`uri-id`) AS `featured`,
1691 `post-user`.`network` AS `network`,
1692 `post-user`.`vid` AS `vid`,
1693 `post-user`.`psid` AS `psid`,
1694 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1695 `post-content`.`title` AS `title`,
1696 `post-content`.`content-warning` AS `content-warning`,
1697 `post-content`.`raw-body` AS `raw-body`,
1698 IFNULL (`post-content`.`body`, '') AS `body`,
1699 `post-content`.`rendered-hash` AS `rendered-hash`,
1700 `post-content`.`rendered-html` AS `rendered-html`,
1701 `post-content`.`language` AS `language`,
1702 `post-content`.`plink` AS `plink`,
1703 `post-content`.`location` AS `location`,
1704 `post-content`.`coord` AS `coord`,
1705 `post-content`.`app` AS `app`,
1706 `post-content`.`object-type` AS `object-type`,
1707 `post-content`.`object` AS `object`,
1708 `post-content`.`target-type` AS `target-type`,
1709 `post-content`.`target` AS `target`,
1710 `post-content`.`resource-id` AS `resource-id`,
1711 `post-user`.`contact-id` AS `contact-id`,
1712 `contact`.`url` AS `contact-link`,
1713 `contact`.`addr` AS `contact-addr`,
1714 `contact`.`name` AS `contact-name`,
1715 `contact`.`nick` AS `contact-nick`,
1716 `contact`.`thumb` AS `contact-avatar`,
1717 `contact`.`network` AS `contact-network`,
1718 `contact`.`blocked` AS `contact-blocked`,
1719 `contact`.`hidden` AS `contact-hidden`,
1720 `contact`.`readonly` AS `contact-readonly`,
1721 `contact`.`archive` AS `contact-archive`,
1722 `contact`.`pending` AS `contact-pending`,
1723 `contact`.`rel` AS `contact-rel`,
1724 `contact`.`uid` AS `contact-uid`,
1725 `contact`.`contact-type` AS `contact-contact-type`,
1726 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1727 `contact`.`self` AS `self`,
1728 `contact`.`id` AS `cid`,
1729 `contact`.`alias` AS `alias`,
1730 `contact`.`photo` AS `photo`,
1731 `contact`.`name-date` AS `name-date`,
1732 `contact`.`uri-date` AS `uri-date`,
1733 `contact`.`avatar-date` AS `avatar-date`,
1734 `contact`.`thumb` AS `thumb`,
1735 `post-user`.`author-id` AS `author-id`,
1736 `author`.`url` AS `author-link`,
1737 `author`.`addr` AS `author-addr`,
1738 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1739 `author`.`nick` AS `author-nick`,
1740 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1741 `author`.`network` AS `author-network`,
1742 `author`.`blocked` AS `author-blocked`,
1743 `author`.`hidden` AS `author-hidden`,
1744 `author`.`updated` AS `author-updated`,
1745 `author`.`gsid` AS `author-gsid`,
1746 `author`.`uri-id` AS `author-uri-id`,
1747 `post-user`.`owner-id` AS `owner-id`,
1748 `owner`.`url` AS `owner-link`,
1749 `owner`.`addr` AS `owner-addr`,
1750 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1751 `owner`.`nick` AS `owner-nick`,
1752 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1753 `owner`.`network` AS `owner-network`,
1754 `owner`.`blocked` AS `owner-blocked`,
1755 `owner`.`hidden` AS `owner-hidden`,
1756 `owner`.`updated` AS `owner-updated`,
1757 `owner`.`contact-type` AS `owner-contact-type`,
1758 `post-user`.`causer-id` AS `causer-id`,
1759 `causer`.`url` AS `causer-link`,
1760 `causer`.`addr` AS `causer-addr`,
1761 `causer`.`name` AS `causer-name`,
1762 `causer`.`nick` AS `causer-nick`,
1763 `causer`.`thumb` AS `causer-avatar`,
1764 `causer`.`network` AS `causer-network`,
1765 `causer`.`blocked` AS `causer-blocked`,
1766 `causer`.`hidden` AS `causer-hidden`,
1767 `causer`.`contact-type` AS `causer-contact-type`,
1768 `post-delivery-data`.`postopts` AS `postopts`,
1769 `post-delivery-data`.`inform` AS `inform`,
1770 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1771 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1772 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1773 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1774 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1775 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1776 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1777 `post-user`.`event-id` AS `event-id`,
1778 `event`.`created` AS `event-created`,
1779 `event`.`edited` AS `event-edited`,
1780 `event`.`start` AS `event-start`,
1781 `event`.`finish` AS `event-finish`,
1782 `event`.`summary` AS `event-summary`,
1783 `event`.`desc` AS `event-desc`,
1784 `event`.`location` AS `event-location`,
1785 `event`.`type` AS `event-type`,
1786 `event`.`nofinish` AS `event-nofinish`,
1787 `event`.`ignore` AS `event-ignore`,
1788 `post-question`.`id` AS `question-id`,
1789 `post-question`.`multiple` AS `question-multiple`,
1790 `post-question`.`voters` AS `question-voters`,
1791 `post-question`.`end-time` AS `question-end-time`,
1792 `diaspora-interaction`.`interaction` AS `signed_text`,
1793 `parent-item-uri`.`guid` AS `parent-guid`,
1794 `parent-post`.`network` AS `parent-network`,
1795 `parent-post`.`author-id` AS `parent-author-id`,
1796 `parent-post-author`.`url` AS `parent-author-link`,
1797 `parent-post-author`.`name` AS `parent-author-name`,
1798 `parent-post-author`.`nick` AS `parent-author-nick`,
1799 `parent-post-author`.`network` AS `parent-author-network`,
1800 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1801 `parent-post-author`.`hidden` AS `parent-author-hidden`
1803 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
1804 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
1805 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
1806 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
1807 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
1808 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
1809 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1810 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1811 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1812 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1813 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1814 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
1815 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
1816 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
1817 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-user`.`uri-id`
1818 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
1819 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
1820 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1823 -- VIEW post-thread-user-view
1825 DROP VIEW IF EXISTS `post-thread-user-view`;
1826 CREATE VIEW `post-thread-user-view` AS SELECT
1827 `post-user`.`id` AS `id`,
1828 `post-user`.`id` AS `post-user-id`,
1829 `post-thread-user`.`uid` AS `uid`,
1830 `parent-post`.`id` AS `parent`,
1831 `item-uri`.`uri` AS `uri`,
1832 `post-thread-user`.`uri-id` AS `uri-id`,
1833 `parent-item-uri`.`uri` AS `parent-uri`,
1834 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1835 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1836 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1837 `item-uri`.`guid` AS `guid`,
1838 `post-thread-user`.`wall` AS `wall`,
1839 `post-user`.`gravity` AS `gravity`,
1840 `external-item-uri`.`uri` AS `extid`,
1841 `post-user`.`external-id` AS `external-id`,
1842 `post-thread-user`.`created` AS `created`,
1843 `post-user`.`edited` AS `edited`,
1844 `post-thread-user`.`commented` AS `commented`,
1845 `post-thread-user`.`received` AS `received`,
1846 `post-thread-user`.`changed` AS `changed`,
1847 `post-user`.`post-type` AS `post-type`,
1848 `post-user`.`post-reason` AS `post-reason`,
1849 `post-user`.`private` AS `private`,
1850 `post-thread-user`.`pubmail` AS `pubmail`,
1851 `post-thread-user`.`ignored` AS `ignored`,
1852 `post-user`.`visible` AS `visible`,
1853 `post-thread-user`.`starred` AS `starred`,
1854 `post-thread-user`.`unseen` AS `unseen`,
1855 `post-user`.`deleted` AS `deleted`,
1856 `post-thread-user`.`origin` AS `origin`,
1857 `post-thread-user`.`mention` AS `mention`,
1858 `post-user`.`global` AS `global`,
1859 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread-user`.`uri-id`) AS `featured`,
1860 `post-thread-user`.`network` AS `network`,
1861 `post-user`.`vid` AS `vid`,
1862 `post-thread-user`.`psid` AS `psid`,
1863 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1864 `post-content`.`title` AS `title`,
1865 `post-content`.`content-warning` AS `content-warning`,
1866 `post-content`.`raw-body` AS `raw-body`,
1867 `post-content`.`body` AS `body`,
1868 `post-content`.`rendered-hash` AS `rendered-hash`,
1869 `post-content`.`rendered-html` AS `rendered-html`,
1870 `post-content`.`language` AS `language`,
1871 `post-content`.`plink` AS `plink`,
1872 `post-content`.`location` AS `location`,
1873 `post-content`.`coord` AS `coord`,
1874 `post-content`.`app` AS `app`,
1875 `post-content`.`object-type` AS `object-type`,
1876 `post-content`.`object` AS `object`,
1877 `post-content`.`target-type` AS `target-type`,
1878 `post-content`.`target` AS `target`,
1879 `post-content`.`resource-id` AS `resource-id`,
1880 `post-thread-user`.`contact-id` AS `contact-id`,
1881 `contact`.`url` AS `contact-link`,
1882 `contact`.`addr` AS `contact-addr`,
1883 `contact`.`name` AS `contact-name`,
1884 `contact`.`nick` AS `contact-nick`,
1885 `contact`.`thumb` AS `contact-avatar`,
1886 `contact`.`network` AS `contact-network`,
1887 `contact`.`blocked` AS `contact-blocked`,
1888 `contact`.`hidden` AS `contact-hidden`,
1889 `contact`.`readonly` AS `contact-readonly`,
1890 `contact`.`archive` AS `contact-archive`,
1891 `contact`.`pending` AS `contact-pending`,
1892 `contact`.`rel` AS `contact-rel`,
1893 `contact`.`uid` AS `contact-uid`,
1894 `contact`.`contact-type` AS `contact-contact-type`,
1895 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1896 `contact`.`self` AS `self`,
1897 `contact`.`id` AS `cid`,
1898 `contact`.`alias` AS `alias`,
1899 `contact`.`photo` AS `photo`,
1900 `contact`.`name-date` AS `name-date`,
1901 `contact`.`uri-date` AS `uri-date`,
1902 `contact`.`avatar-date` AS `avatar-date`,
1903 `contact`.`thumb` AS `thumb`,
1904 `post-thread-user`.`author-id` AS `author-id`,
1905 `author`.`url` AS `author-link`,
1906 `author`.`addr` AS `author-addr`,
1907 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1908 `author`.`nick` AS `author-nick`,
1909 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1910 `author`.`network` AS `author-network`,
1911 `author`.`blocked` AS `author-blocked`,
1912 `author`.`hidden` AS `author-hidden`,
1913 `author`.`updated` AS `author-updated`,
1914 `author`.`gsid` AS `author-gsid`,
1915 `author`.`uri-id` AS `author-uri-id`,
1916 `post-thread-user`.`owner-id` AS `owner-id`,
1917 `owner`.`url` AS `owner-link`,
1918 `owner`.`addr` AS `owner-addr`,
1919 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1920 `owner`.`nick` AS `owner-nick`,
1921 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1922 `owner`.`network` AS `owner-network`,
1923 `owner`.`blocked` AS `owner-blocked`,
1924 `owner`.`hidden` AS `owner-hidden`,
1925 `owner`.`updated` AS `owner-updated`,
1926 `owner`.`contact-type` AS `owner-contact-type`,
1927 `post-thread-user`.`causer-id` AS `causer-id`,
1928 `causer`.`url` AS `causer-link`,
1929 `causer`.`addr` AS `causer-addr`,
1930 `causer`.`name` AS `causer-name`,
1931 `causer`.`nick` AS `causer-nick`,
1932 `causer`.`thumb` AS `causer-avatar`,
1933 `causer`.`network` AS `causer-network`,
1934 `causer`.`blocked` AS `causer-blocked`,
1935 `causer`.`hidden` AS `causer-hidden`,
1936 `causer`.`contact-type` AS `causer-contact-type`,
1937 `post-delivery-data`.`postopts` AS `postopts`,
1938 `post-delivery-data`.`inform` AS `inform`,
1939 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1940 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1941 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1942 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1943 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1944 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1945 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1946 `post-user`.`event-id` AS `event-id`,
1947 `event`.`created` AS `event-created`,
1948 `event`.`edited` AS `event-edited`,
1949 `event`.`start` AS `event-start`,
1950 `event`.`finish` AS `event-finish`,
1951 `event`.`summary` AS `event-summary`,
1952 `event`.`desc` AS `event-desc`,
1953 `event`.`location` AS `event-location`,
1954 `event`.`type` AS `event-type`,
1955 `event`.`nofinish` AS `event-nofinish`,
1956 `event`.`ignore` AS `event-ignore`,
1957 `post-question`.`id` AS `question-id`,
1958 `post-question`.`multiple` AS `question-multiple`,
1959 `post-question`.`voters` AS `question-voters`,
1960 `post-question`.`end-time` AS `question-end-time`,
1961 `diaspora-interaction`.`interaction` AS `signed_text`,
1962 `parent-item-uri`.`guid` AS `parent-guid`,
1963 `parent-post`.`network` AS `parent-network`,
1964 `parent-post`.`author-id` AS `parent-author-id`,
1965 `parent-post-author`.`url` AS `parent-author-link`,
1966 `parent-post-author`.`name` AS `parent-author-name`,
1967 `parent-post-author`.`network` AS `parent-author-network`,
1968 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1969 `parent-post-author`.`hidden` AS `parent-author-hidden`
1970 FROM `post-thread-user`
1971 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
1972 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
1973 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
1974 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
1975 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
1976 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
1977 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1978 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1979 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1980 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1981 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1982 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
1983 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
1984 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
1985 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread-user`.`uri-id`
1986 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
1987 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`
1988 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1993 DROP VIEW IF EXISTS `post-view`;
1994 CREATE VIEW `post-view` AS SELECT
1995 `item-uri`.`uri` AS `uri`,
1996 `post`.`uri-id` AS `uri-id`,
1997 `parent-item-uri`.`uri` AS `parent-uri`,
1998 `post`.`parent-uri-id` AS `parent-uri-id`,
1999 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2000 `post`.`thr-parent-id` AS `thr-parent-id`,
2001 `item-uri`.`guid` AS `guid`,
2002 `post`.`gravity` AS `gravity`,
2003 `external-item-uri`.`uri` AS `extid`,
2004 `post`.`external-id` AS `external-id`,
2005 `post`.`created` AS `created`,
2006 `post`.`edited` AS `edited`,
2007 `post-thread`.`commented` AS `commented`,
2008 `post`.`received` AS `received`,
2009 `post-thread`.`changed` AS `changed`,
2010 `post`.`post-type` AS `post-type`,
2011 `post`.`private` AS `private`,
2012 `post`.`visible` AS `visible`,
2013 `post`.`deleted` AS `deleted`,
2014 `post`.`global` AS `global`,
2015 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post`.`uri-id`) AS `featured`,
2016 `post`.`network` AS `network`,
2017 `post`.`vid` AS `vid`,
2018 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2019 `post-content`.`title` AS `title`,
2020 `post-content`.`content-warning` AS `content-warning`,
2021 `post-content`.`raw-body` AS `raw-body`,
2022 `post-content`.`body` AS `body`,
2023 `post-content`.`rendered-hash` AS `rendered-hash`,
2024 `post-content`.`rendered-html` AS `rendered-html`,
2025 `post-content`.`language` AS `language`,
2026 `post-content`.`plink` AS `plink`,
2027 `post-content`.`location` AS `location`,
2028 `post-content`.`coord` AS `coord`,
2029 `post-content`.`app` AS `app`,
2030 `post-content`.`object-type` AS `object-type`,
2031 `post-content`.`object` AS `object`,
2032 `post-content`.`target-type` AS `target-type`,
2033 `post-content`.`target` AS `target`,
2034 `post-content`.`resource-id` AS `resource-id`,
2035 `post`.`author-id` AS `contact-id`,
2036 `author`.`url` AS `contact-link`,
2037 `author`.`addr` AS `contact-addr`,
2038 `author`.`name` AS `contact-name`,
2039 `author`.`nick` AS `contact-nick`,
2040 `author`.`thumb` AS `contact-avatar`,
2041 `author`.`network` AS `contact-network`,
2042 `author`.`blocked` AS `contact-blocked`,
2043 `author`.`hidden` AS `contact-hidden`,
2044 `author`.`readonly` AS `contact-readonly`,
2045 `author`.`archive` AS `contact-archive`,
2046 `author`.`pending` AS `contact-pending`,
2047 `author`.`rel` AS `contact-rel`,
2048 `author`.`uid` AS `contact-uid`,
2049 `author`.`contact-type` AS `contact-contact-type`,
2050 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2052 `author`.`id` AS `cid`,
2053 `author`.`alias` AS `alias`,
2054 `author`.`photo` AS `photo`,
2055 `author`.`name-date` AS `name-date`,
2056 `author`.`uri-date` AS `uri-date`,
2057 `author`.`avatar-date` AS `avatar-date`,
2058 `author`.`thumb` AS `thumb`,
2059 `post`.`author-id` AS `author-id`,
2060 `author`.`url` AS `author-link`,
2061 `author`.`addr` AS `author-addr`,
2062 `author`.`name` AS `author-name`,
2063 `author`.`nick` AS `author-nick`,
2064 `author`.`thumb` AS `author-avatar`,
2065 `author`.`network` AS `author-network`,
2066 `author`.`blocked` AS `author-blocked`,
2067 `author`.`hidden` AS `author-hidden`,
2068 `author`.`updated` AS `author-updated`,
2069 `author`.`gsid` AS `author-gsid`,
2070 `author`.`uri-id` AS `author-uri-id`,
2071 `post`.`owner-id` AS `owner-id`,
2072 `owner`.`url` AS `owner-link`,
2073 `owner`.`addr` AS `owner-addr`,
2074 `owner`.`name` AS `owner-name`,
2075 `owner`.`nick` AS `owner-nick`,
2076 `owner`.`thumb` AS `owner-avatar`,
2077 `owner`.`network` AS `owner-network`,
2078 `owner`.`blocked` AS `owner-blocked`,
2079 `owner`.`hidden` AS `owner-hidden`,
2080 `owner`.`updated` AS `owner-updated`,
2081 `owner`.`contact-type` AS `owner-contact-type`,
2082 `post`.`causer-id` AS `causer-id`,
2083 `causer`.`url` AS `causer-link`,
2084 `causer`.`addr` AS `causer-addr`,
2085 `causer`.`name` AS `causer-name`,
2086 `causer`.`nick` AS `causer-nick`,
2087 `causer`.`thumb` AS `causer-avatar`,
2088 `causer`.`network` AS `causer-network`,
2089 `causer`.`blocked` AS `causer-blocked`,
2090 `causer`.`hidden` AS `causer-hidden`,
2091 `causer`.`contact-type` AS `causer-contact-type`,
2092 `post-question`.`id` AS `question-id`,
2093 `post-question`.`multiple` AS `question-multiple`,
2094 `post-question`.`voters` AS `question-voters`,
2095 `post-question`.`end-time` AS `question-end-time`,
2096 `diaspora-interaction`.`interaction` AS `signed_text`,
2097 `parent-item-uri`.`guid` AS `parent-guid`,
2098 `parent-post`.`network` AS `parent-network`,
2099 `parent-post`.`author-id` AS `parent-author-id`,
2100 `parent-post-author`.`url` AS `parent-author-link`,
2101 `parent-post-author`.`name` AS `parent-author-name`,
2102 `parent-post-author`.`network` AS `parent-author-network`,
2103 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2104 `parent-post-author`.`hidden` AS `parent-author-hidden`
2106 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
2107 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
2108 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
2109 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
2110 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
2111 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2112 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2113 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2114 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2115 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
2116 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
2117 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post`.`uri-id`
2118 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2119 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2122 -- VIEW post-thread-view
2124 DROP VIEW IF EXISTS `post-thread-view`;
2125 CREATE VIEW `post-thread-view` AS SELECT
2126 `item-uri`.`uri` AS `uri`,
2127 `post-thread`.`uri-id` AS `uri-id`,
2128 `parent-item-uri`.`uri` AS `parent-uri`,
2129 `post`.`parent-uri-id` AS `parent-uri-id`,
2130 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2131 `post`.`thr-parent-id` AS `thr-parent-id`,
2132 `item-uri`.`guid` AS `guid`,
2133 `post`.`gravity` AS `gravity`,
2134 `external-item-uri`.`uri` AS `extid`,
2135 `post`.`external-id` AS `external-id`,
2136 `post-thread`.`created` AS `created`,
2137 `post`.`edited` AS `edited`,
2138 `post-thread`.`commented` AS `commented`,
2139 `post-thread`.`received` AS `received`,
2140 `post-thread`.`changed` AS `changed`,
2141 `post`.`post-type` AS `post-type`,
2142 `post`.`private` AS `private`,
2143 `post`.`visible` AS `visible`,
2144 `post`.`deleted` AS `deleted`,
2145 `post`.`global` AS `global`,
2146 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread`.`uri-id`) AS `featured`,
2147 `post-thread`.`network` AS `network`,
2148 `post`.`vid` AS `vid`,
2149 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2150 `post-content`.`title` AS `title`,
2151 `post-content`.`content-warning` AS `content-warning`,
2152 `post-content`.`raw-body` AS `raw-body`,
2153 `post-content`.`body` AS `body`,
2154 `post-content`.`rendered-hash` AS `rendered-hash`,
2155 `post-content`.`rendered-html` AS `rendered-html`,
2156 `post-content`.`language` AS `language`,
2157 `post-content`.`plink` AS `plink`,
2158 `post-content`.`location` AS `location`,
2159 `post-content`.`coord` AS `coord`,
2160 `post-content`.`app` AS `app`,
2161 `post-content`.`object-type` AS `object-type`,
2162 `post-content`.`object` AS `object`,
2163 `post-content`.`target-type` AS `target-type`,
2164 `post-content`.`target` AS `target`,
2165 `post-content`.`resource-id` AS `resource-id`,
2166 `post-thread`.`author-id` AS `contact-id`,
2167 `author`.`url` AS `contact-link`,
2168 `author`.`addr` AS `contact-addr`,
2169 `author`.`name` AS `contact-name`,
2170 `author`.`nick` AS `contact-nick`,
2171 `author`.`thumb` AS `contact-avatar`,
2172 `author`.`network` AS `contact-network`,
2173 `author`.`blocked` AS `contact-blocked`,
2174 `author`.`hidden` AS `contact-hidden`,
2175 `author`.`readonly` AS `contact-readonly`,
2176 `author`.`archive` AS `contact-archive`,
2177 `author`.`pending` AS `contact-pending`,
2178 `author`.`rel` AS `contact-rel`,
2179 `author`.`uid` AS `contact-uid`,
2180 `author`.`contact-type` AS `contact-contact-type`,
2181 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2183 `author`.`id` AS `cid`,
2184 `author`.`alias` AS `alias`,
2185 `author`.`photo` AS `photo`,
2186 `author`.`name-date` AS `name-date`,
2187 `author`.`uri-date` AS `uri-date`,
2188 `author`.`avatar-date` AS `avatar-date`,
2189 `author`.`thumb` AS `thumb`,
2190 `post-thread`.`author-id` AS `author-id`,
2191 `author`.`url` AS `author-link`,
2192 `author`.`addr` AS `author-addr`,
2193 `author`.`name` AS `author-name`,
2194 `author`.`nick` AS `author-nick`,
2195 `author`.`thumb` AS `author-avatar`,
2196 `author`.`network` AS `author-network`,
2197 `author`.`blocked` AS `author-blocked`,
2198 `author`.`hidden` AS `author-hidden`,
2199 `author`.`updated` AS `author-updated`,
2200 `author`.`gsid` AS `author-gsid`,
2201 `author`.`uri-id` AS `author-uri-id`,
2202 `post-thread`.`owner-id` AS `owner-id`,
2203 `owner`.`url` AS `owner-link`,
2204 `owner`.`addr` AS `owner-addr`,
2205 `owner`.`name` AS `owner-name`,
2206 `owner`.`nick` AS `owner-nick`,
2207 `owner`.`thumb` AS `owner-avatar`,
2208 `owner`.`network` AS `owner-network`,
2209 `owner`.`blocked` AS `owner-blocked`,
2210 `owner`.`hidden` AS `owner-hidden`,
2211 `owner`.`updated` AS `owner-updated`,
2212 `owner`.`contact-type` AS `owner-contact-type`,
2213 `post-thread`.`causer-id` AS `causer-id`,
2214 `causer`.`url` AS `causer-link`,
2215 `causer`.`addr` AS `causer-addr`,
2216 `causer`.`name` AS `causer-name`,
2217 `causer`.`nick` AS `causer-nick`,
2218 `causer`.`thumb` AS `causer-avatar`,
2219 `causer`.`network` AS `causer-network`,
2220 `causer`.`blocked` AS `causer-blocked`,
2221 `causer`.`hidden` AS `causer-hidden`,
2222 `causer`.`contact-type` AS `causer-contact-type`,
2223 `post-question`.`id` AS `question-id`,
2224 `post-question`.`multiple` AS `question-multiple`,
2225 `post-question`.`voters` AS `question-voters`,
2226 `post-question`.`end-time` AS `question-end-time`,
2227 `diaspora-interaction`.`interaction` AS `signed_text`,
2228 `parent-item-uri`.`guid` AS `parent-guid`,
2229 `parent-post`.`network` AS `parent-network`,
2230 `parent-post`.`author-id` AS `parent-author-id`,
2231 `parent-post-author`.`url` AS `parent-author-link`,
2232 `parent-post-author`.`name` AS `parent-author-name`,
2233 `parent-post-author`.`network` AS `parent-author-network`,
2234 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2235 `parent-post-author`.`hidden` AS `parent-author-hidden`
2237 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
2238 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
2239 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
2240 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
2241 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
2242 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2243 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2244 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2245 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2246 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
2247 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
2248 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread`.`uri-id`
2249 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2250 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2253 -- VIEW category-view
2255 DROP VIEW IF EXISTS `category-view`;
2256 CREATE VIEW `category-view` AS SELECT
2257 `post-category`.`uri-id` AS `uri-id`,
2258 `post-category`.`uid` AS `uid`,
2259 `post-category`.`type` AS `type`,
2260 `post-category`.`tid` AS `tid`,
2261 `tag`.`name` AS `name`,
2262 `tag`.`url` AS `url`
2263 FROM `post-category`
2264 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2267 -- VIEW collection-view
2269 DROP VIEW IF EXISTS `collection-view`;
2270 CREATE VIEW `collection-view` AS SELECT
2271 `post-collection`.`uri-id` AS `uri-id`,
2272 `post-collection`.`type` AS `type`,
2273 `post`.`author-id` AS `cid`,
2274 `post`.`received` AS `received`,
2275 `post`.`created` AS `created`,
2276 `post-thread`.`commented` AS `commented`,
2277 `post`.`thr-parent-id` AS `thr-parent-id`,
2278 `post`.`author-id` AS `author-id`,
2279 `post`.`gravity` AS `gravity`
2280 FROM `post-collection`
2281 INNER JOIN `post` ON `post-collection`.`uri-id` = `post`.`uri-id`
2282 INNER JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`;
2287 DROP VIEW IF EXISTS `tag-view`;
2288 CREATE VIEW `tag-view` AS SELECT
2289 `post-tag`.`uri-id` AS `uri-id`,
2290 `post-tag`.`type` AS `type`,
2291 `post-tag`.`tid` AS `tid`,
2292 `post-tag`.`cid` AS `cid`,
2293 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2294 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`,
2295 CASE `cid` WHEN 0 THEN `tag`.`type` ELSE 1 END AS `tag-type`
2297 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2298 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2301 -- VIEW network-item-view
2303 DROP VIEW IF EXISTS `network-item-view`;
2304 CREATE VIEW `network-item-view` AS SELECT
2305 `post-user`.`uri-id` AS `uri-id`,
2306 `parent-post`.`id` AS `parent`,
2307 `post-user`.`received` AS `received`,
2308 `post-thread-user`.`commented` AS `commented`,
2309 `post-user`.`created` AS `created`,
2310 `post-user`.`uid` AS `uid`,
2311 `post-thread-user`.`starred` AS `starred`,
2312 `post-thread-user`.`mention` AS `mention`,
2313 `post-user`.`network` AS `network`,
2314 `post-user`.`unseen` AS `unseen`,
2315 `post-user`.`gravity` AS `gravity`,
2316 `post-user`.`contact-id` AS `contact-id`,
2317 `ownercontact`.`contact-type` AS `contact-type`
2319 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2320 INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2321 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2322 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2323 INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2324 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2325 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2326 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2327 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
2328 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2329 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2332 -- VIEW network-thread-view
2334 DROP VIEW IF EXISTS `network-thread-view`;
2335 CREATE VIEW `network-thread-view` AS SELECT
2336 `post-thread-user`.`uri-id` AS `uri-id`,
2337 `parent-post`.`id` AS `parent`,
2338 `post-thread-user`.`received` AS `received`,
2339 `post-thread-user`.`commented` AS `commented`,
2340 `post-thread-user`.`created` AS `created`,
2341 `post-thread-user`.`uid` AS `uid`,
2342 `post-thread-user`.`starred` AS `starred`,
2343 `post-thread-user`.`mention` AS `mention`,
2344 `post-thread-user`.`network` AS `network`,
2345 `post-thread-user`.`contact-id` AS `contact-id`,
2346 `ownercontact`.`contact-type` AS `contact-type`
2347 FROM `post-thread-user`
2348 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2349 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2350 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2351 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2352 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2353 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2354 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2355 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2356 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2357 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2358 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2363 DROP VIEW IF EXISTS `owner-view`;
2364 CREATE VIEW `owner-view` AS SELECT
2365 `contact`.`id` AS `id`,
2366 `contact`.`uid` AS `uid`,
2367 `contact`.`created` AS `created`,
2368 `contact`.`updated` AS `updated`,
2369 `contact`.`self` AS `self`,
2370 `contact`.`remote_self` AS `remote_self`,
2371 `contact`.`rel` AS `rel`,
2372 `contact`.`network` AS `network`,
2373 `contact`.`protocol` AS `protocol`,
2374 `contact`.`name` AS `name`,
2375 `contact`.`nick` AS `nick`,
2376 `contact`.`location` AS `location`,
2377 `contact`.`about` AS `about`,
2378 `contact`.`keywords` AS `keywords`,
2379 `contact`.`xmpp` AS `xmpp`,
2380 `contact`.`matrix` AS `matrix`,
2381 `contact`.`attag` AS `attag`,
2382 `contact`.`avatar` AS `avatar`,
2383 `contact`.`photo` AS `photo`,
2384 `contact`.`thumb` AS `thumb`,
2385 `contact`.`micro` AS `micro`,
2386 `contact`.`header` AS `header`,
2387 `contact`.`url` AS `url`,
2388 `contact`.`nurl` AS `nurl`,
2389 `contact`.`uri-id` AS `uri-id`,
2390 `contact`.`addr` AS `addr`,
2391 `contact`.`alias` AS `alias`,
2392 `contact`.`pubkey` AS `pubkey`,
2393 `contact`.`prvkey` AS `prvkey`,
2394 `contact`.`batch` AS `batch`,
2395 `contact`.`request` AS `request`,
2396 `contact`.`notify` AS `notify`,
2397 `contact`.`poll` AS `poll`,
2398 `contact`.`confirm` AS `confirm`,
2399 `contact`.`poco` AS `poco`,
2400 `contact`.`subhub` AS `subhub`,
2401 `contact`.`hub-verify` AS `hub-verify`,
2402 `contact`.`last-update` AS `last-update`,
2403 `contact`.`success_update` AS `success_update`,
2404 `contact`.`failure_update` AS `failure_update`,
2405 `contact`.`name-date` AS `name-date`,
2406 `contact`.`uri-date` AS `uri-date`,
2407 `contact`.`avatar-date` AS `avatar-date`,
2408 `contact`.`avatar-date` AS `picdate`,
2409 `contact`.`term-date` AS `term-date`,
2410 `contact`.`last-item` AS `last-item`,
2411 `contact`.`priority` AS `priority`,
2412 `user`.`blocked` AS `blocked`,
2413 `contact`.`block_reason` AS `block_reason`,
2414 `contact`.`readonly` AS `readonly`,
2415 `contact`.`writable` AS `writable`,
2416 `contact`.`forum` AS `forum`,
2417 `contact`.`prv` AS `prv`,
2418 `contact`.`contact-type` AS `contact-type`,
2419 `contact`.`manually-approve` AS `manually-approve`,
2420 `contact`.`hidden` AS `hidden`,
2421 `contact`.`archive` AS `archive`,
2422 `contact`.`pending` AS `pending`,
2423 `contact`.`deleted` AS `deleted`,
2424 `contact`.`unsearchable` AS `unsearchable`,
2425 `contact`.`sensitive` AS `sensitive`,
2426 `contact`.`baseurl` AS `baseurl`,
2427 `contact`.`reason` AS `reason`,
2428 `contact`.`info` AS `info`,
2429 `contact`.`bdyear` AS `bdyear`,
2430 `contact`.`bd` AS `bd`,
2431 `contact`.`notify_new_posts` AS `notify_new_posts`,
2432 `contact`.`fetch_further_information` AS `fetch_further_information`,
2433 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2434 `user`.`parent-uid` AS `parent-uid`,
2435 `user`.`guid` AS `guid`,
2436 `user`.`nickname` AS `nickname`,
2437 `user`.`email` AS `email`,
2438 `user`.`openid` AS `openid`,
2439 `user`.`timezone` AS `timezone`,
2440 `user`.`language` AS `language`,
2441 `user`.`register_date` AS `register_date`,
2442 `user`.`login_date` AS `login_date`,
2443 `user`.`default-location` AS `default-location`,
2444 `user`.`allow_location` AS `allow_location`,
2445 `user`.`theme` AS `theme`,
2446 `user`.`pubkey` AS `upubkey`,
2447 `user`.`prvkey` AS `uprvkey`,
2448 `user`.`sprvkey` AS `sprvkey`,
2449 `user`.`spubkey` AS `spubkey`,
2450 `user`.`verified` AS `verified`,
2451 `user`.`blockwall` AS `blockwall`,
2452 `user`.`hidewall` AS `hidewall`,
2453 `user`.`blocktags` AS `blocktags`,
2454 `user`.`unkmail` AS `unkmail`,
2455 `user`.`cntunkmail` AS `cntunkmail`,
2456 `user`.`notify-flags` AS `notify-flags`,
2457 `user`.`page-flags` AS `page-flags`,
2458 `user`.`account-type` AS `account-type`,
2459 `user`.`prvnets` AS `prvnets`,
2460 `user`.`maxreq` AS `maxreq`,
2461 `user`.`expire` AS `expire`,
2462 `user`.`account_removed` AS `account_removed`,
2463 `user`.`account_expired` AS `account_expired`,
2464 `user`.`account_expires_on` AS `account_expires_on`,
2465 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2466 `user`.`def_gid` AS `def_gid`,
2467 `user`.`allow_cid` AS `allow_cid`,
2468 `user`.`allow_gid` AS `allow_gid`,
2469 `user`.`deny_cid` AS `deny_cid`,
2470 `user`.`deny_gid` AS `deny_gid`,
2471 `user`.`openidserver` AS `openidserver`,
2472 `profile`.`publish` AS `publish`,
2473 `profile`.`net-publish` AS `net-publish`,
2474 `profile`.`hide-friends` AS `hide-friends`,
2475 `profile`.`prv_keywords` AS `prv_keywords`,
2476 `profile`.`pub_keywords` AS `pub_keywords`,
2477 `profile`.`address` AS `address`,
2478 `profile`.`locality` AS `locality`,
2479 `profile`.`region` AS `region`,
2480 `profile`.`postal-code` AS `postal-code`,
2481 `profile`.`country-name` AS `country-name`,
2482 `profile`.`homepage` AS `homepage`,
2483 `profile`.`dob` AS `dob`
2485 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2486 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2489 -- VIEW account-view
2491 DROP VIEW IF EXISTS `account-view`;
2492 CREATE VIEW `account-view` AS SELECT
2493 `contact`.`id` AS `id`,
2494 `contact`.`url` AS `url`,
2495 `contact`.`nurl` AS `nurl`,
2496 `contact`.`uri-id` AS `uri-id`,
2497 `item-uri`.`guid` AS `guid`,
2498 `contact`.`addr` AS `addr`,
2499 `contact`.`alias` AS `alias`,
2500 `contact`.`name` AS `name`,
2501 `contact`.`nick` AS `nick`,
2502 `contact`.`about` AS `about`,
2503 `contact`.`keywords` AS `keywords`,
2504 `contact`.`xmpp` AS `xmpp`,
2505 `contact`.`matrix` AS `matrix`,
2506 `contact`.`avatar` AS `avatar`,
2507 `contact`.`photo` AS `photo`,
2508 `contact`.`thumb` AS `thumb`,
2509 `contact`.`micro` AS `micro`,
2510 `contact`.`header` AS `header`,
2511 `contact`.`created` AS `created`,
2512 `contact`.`updated` AS `updated`,
2513 `contact`.`network` AS `network`,
2514 `contact`.`protocol` AS `protocol`,
2515 `contact`.`location` AS `location`,
2516 `contact`.`attag` AS `attag`,
2517 `contact`.`pubkey` AS `pubkey`,
2518 `contact`.`prvkey` AS `prvkey`,
2519 `contact`.`subscribe` AS `subscribe`,
2520 `contact`.`last-update` AS `last-update`,
2521 `contact`.`success_update` AS `success_update`,
2522 `contact`.`failure_update` AS `failure_update`,
2523 `contact`.`failed` AS `failed`,
2524 `contact`.`last-item` AS `last-item`,
2525 `contact`.`last-discovery` AS `last-discovery`,
2526 `contact`.`contact-type` AS `contact-type`,
2527 `contact`.`manually-approve` AS `manually-approve`,
2528 `contact`.`unsearchable` AS `unsearchable`,
2529 `contact`.`sensitive` AS `sensitive`,
2530 `contact`.`baseurl` AS `baseurl`,
2531 `contact`.`gsid` AS `gsid`,
2532 `contact`.`info` AS `info`,
2533 `contact`.`bdyear` AS `bdyear`,
2534 `contact`.`bd` AS `bd`,
2535 `contact`.`poco` AS `poco`,
2536 `contact`.`name-date` AS `name-date`,
2537 `contact`.`uri-date` AS `uri-date`,
2538 `contact`.`avatar-date` AS `avatar-date`,
2539 `contact`.`term-date` AS `term-date`,
2540 `contact`.`hidden` AS `global-ignored`,
2541 `contact`.`blocked` AS `global-blocked`,
2542 `contact`.`hidden` AS `hidden`,
2543 `contact`.`archive` AS `archive`,
2544 `contact`.`deleted` AS `deleted`,
2545 `contact`.`blocked` AS `blocked`,
2546 `contact`.`notify` AS `dfrn-notify`,
2547 `contact`.`poll` AS `dfrn-poll`,
2548 `fcontact`.`guid` AS `diaspora-guid`,
2549 `fcontact`.`batch` AS `diaspora-batch`,
2550 `fcontact`.`notify` AS `diaspora-notify`,
2551 `fcontact`.`poll` AS `diaspora-poll`,
2552 `fcontact`.`alias` AS `diaspora-alias`,
2553 `apcontact`.`uuid` AS `ap-uuid`,
2554 `apcontact`.`type` AS `ap-type`,
2555 `apcontact`.`following` AS `ap-following`,
2556 `apcontact`.`followers` AS `ap-followers`,
2557 `apcontact`.`inbox` AS `ap-inbox`,
2558 `apcontact`.`outbox` AS `ap-outbox`,
2559 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2560 `apcontact`.`generator` AS `ap-generator`,
2561 `apcontact`.`following_count` AS `ap-following_count`,
2562 `apcontact`.`followers_count` AS `ap-followers_count`,
2563 `apcontact`.`statuses_count` AS `ap-statuses_count`,
2564 `gserver`.`site_name` AS `site_name`,
2565 `gserver`.`platform` AS `platform`,
2566 `gserver`.`version` AS `version`
2568 LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id`
2569 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
2570 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = contact.`uri-id`
2571 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`
2572 WHERE `contact`.`uid` = 0;
2575 -- VIEW account-user-view
2577 DROP VIEW IF EXISTS `account-user-view`;
2578 CREATE VIEW `account-user-view` AS SELECT
2579 `ucontact`.`id` AS `id`,
2580 `contact`.`id` AS `pid`,
2581 `ucontact`.`uid` AS `uid`,
2582 `contact`.`url` AS `url`,
2583 `contact`.`nurl` AS `nurl`,
2584 `contact`.`uri-id` AS `uri-id`,
2585 `item-uri`.`guid` AS `guid`,
2586 `contact`.`addr` AS `addr`,
2587 `contact`.`alias` AS `alias`,
2588 `contact`.`name` AS `name`,
2589 `contact`.`nick` AS `nick`,
2590 `contact`.`about` AS `about`,
2591 `contact`.`keywords` AS `keywords`,
2592 `contact`.`xmpp` AS `xmpp`,
2593 `contact`.`matrix` AS `matrix`,
2594 `contact`.`avatar` AS `avatar`,
2595 `contact`.`photo` AS `photo`,
2596 `contact`.`thumb` AS `thumb`,
2597 `contact`.`micro` AS `micro`,
2598 `contact`.`header` AS `header`,
2599 `contact`.`created` AS `created`,
2600 `contact`.`updated` AS `updated`,
2601 `ucontact`.`self` AS `self`,
2602 `ucontact`.`remote_self` AS `remote_self`,
2603 `ucontact`.`rel` AS `rel`,
2604 `contact`.`network` AS `network`,
2605 `ucontact`.`protocol` AS `protocol`,
2606 `contact`.`location` AS `location`,
2607 `ucontact`.`attag` AS `attag`,
2608 `contact`.`pubkey` AS `pubkey`,
2609 `contact`.`prvkey` AS `prvkey`,
2610 `contact`.`subscribe` AS `subscribe`,
2611 `contact`.`last-update` AS `last-update`,
2612 `contact`.`success_update` AS `success_update`,
2613 `contact`.`failure_update` AS `failure_update`,
2614 `contact`.`failed` AS `failed`,
2615 `contact`.`last-item` AS `last-item`,
2616 `contact`.`last-discovery` AS `last-discovery`,
2617 `contact`.`contact-type` AS `contact-type`,
2618 `contact`.`manually-approve` AS `manually-approve`,
2619 `contact`.`unsearchable` AS `unsearchable`,
2620 `contact`.`sensitive` AS `sensitive`,
2621 `contact`.`baseurl` AS `baseurl`,
2622 `contact`.`gsid` AS `gsid`,
2623 `ucontact`.`info` AS `info`,
2624 `contact`.`bdyear` AS `bdyear`,
2625 `contact`.`bd` AS `bd`,
2626 `contact`.`poco` AS `poco`,
2627 `contact`.`name-date` AS `name-date`,
2628 `contact`.`uri-date` AS `uri-date`,
2629 `contact`.`avatar-date` AS `avatar-date`,
2630 `contact`.`term-date` AS `term-date`,
2631 `contact`.`hidden` AS `global-ignored`,
2632 `contact`.`blocked` AS `global-blocked`,
2633 `ucontact`.`hidden` AS `hidden`,
2634 `ucontact`.`archive` AS `archive`,
2635 `ucontact`.`pending` AS `pending`,
2636 `ucontact`.`deleted` AS `deleted`,
2637 `ucontact`.`notify_new_posts` AS `notify_new_posts`,
2638 `ucontact`.`fetch_further_information` AS `fetch_further_information`,
2639 `ucontact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2640 `ucontact`.`rating` AS `rating`,
2641 `ucontact`.`readonly` AS `readonly`,
2642 `ucontact`.`blocked` AS `blocked`,
2643 `ucontact`.`block_reason` AS `block_reason`,
2644 `ucontact`.`subhub` AS `subhub`,
2645 `ucontact`.`hub-verify` AS `hub-verify`,
2646 `ucontact`.`reason` AS `reason`,
2647 `contact`.`notify` AS `dfrn-notify`,
2648 `contact`.`poll` AS `dfrn-poll`,
2649 `fcontact`.`guid` AS `diaspora-guid`,
2650 `fcontact`.`batch` AS `diaspora-batch`,
2651 `fcontact`.`notify` AS `diaspora-notify`,
2652 `fcontact`.`poll` AS `diaspora-poll`,
2653 `fcontact`.`alias` AS `diaspora-alias`,
2654 `apcontact`.`uuid` AS `ap-uuid`,
2655 `apcontact`.`type` AS `ap-type`,
2656 `apcontact`.`following` AS `ap-following`,
2657 `apcontact`.`followers` AS `ap-followers`,
2658 `apcontact`.`inbox` AS `ap-inbox`,
2659 `apcontact`.`outbox` AS `ap-outbox`,
2660 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2661 `apcontact`.`generator` AS `ap-generator`,
2662 `apcontact`.`following_count` AS `ap-following_count`,
2663 `apcontact`.`followers_count` AS `ap-followers_count`,
2664 `apcontact`.`statuses_count` AS `ap-statuses_count`,
2665 `gserver`.`site_name` AS `site_name`,
2666 `gserver`.`platform` AS `platform`,
2667 `gserver`.`version` AS `version`
2668 FROM `contact` AS `ucontact`
2669 INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
2670 LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id`
2671 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
2672 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = `ucontact`.`uri-id` AND `fcontact`.`network` = 'dspr'
2673 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`;
2676 -- VIEW pending-view
2678 DROP VIEW IF EXISTS `pending-view`;
2679 CREATE VIEW `pending-view` AS SELECT
2680 `register`.`id` AS `id`,
2681 `register`.`hash` AS `hash`,
2682 `register`.`created` AS `created`,
2683 `register`.`uid` AS `uid`,
2684 `register`.`password` AS `password`,
2685 `register`.`language` AS `language`,
2686 `register`.`note` AS `note`,
2687 `contact`.`self` AS `self`,
2688 `contact`.`name` AS `name`,
2689 `contact`.`url` AS `url`,
2690 `contact`.`micro` AS `micro`,
2691 `user`.`email` AS `email`,
2692 `contact`.`nick` AS `nick`
2694 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2695 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2698 -- VIEW tag-search-view
2700 DROP VIEW IF EXISTS `tag-search-view`;
2701 CREATE VIEW `tag-search-view` AS SELECT
2702 `post-tag`.`uri-id` AS `uri-id`,
2703 `post-user`.`uid` AS `uid`,
2704 `post-user`.`id` AS `iid`,
2705 `post-user`.`private` AS `private`,
2706 `post-user`.`wall` AS `wall`,
2707 `post-user`.`origin` AS `origin`,
2708 `post-user`.`global` AS `global`,
2709 `post-user`.`gravity` AS `gravity`,
2710 `post-user`.`received` AS `received`,
2711 `post-user`.`network` AS `network`,
2712 `post-user`.`author-id` AS `author-id`,
2713 `tag`.`name` AS `name`
2715 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
2716 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
2717 WHERE `post-tag`.`type` = 1;
2720 -- VIEW workerqueue-view
2722 DROP VIEW IF EXISTS `workerqueue-view`;
2723 CREATE VIEW `workerqueue-view` AS SELECT
2724 `process`.`pid` AS `pid`,
2725 `workerqueue`.`priority` AS `priority`
2727 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
2728 WHERE NOT `workerqueue`.`done`;
2731 -- VIEW profile_field-view
2733 DROP VIEW IF EXISTS `profile_field-view`;
2734 CREATE VIEW `profile_field-view` AS SELECT
2735 `profile_field`.`id` AS `id`,
2736 `profile_field`.`uid` AS `uid`,
2737 `profile_field`.`label` AS `label`,
2738 `profile_field`.`value` AS `value`,
2739 `profile_field`.`order` AS `order`,
2740 `profile_field`.`psid` AS `psid`,
2741 `permissionset`.`allow_cid` AS `allow_cid`,
2742 `permissionset`.`allow_gid` AS `allow_gid`,
2743 `permissionset`.`deny_cid` AS `deny_cid`,
2744 `permissionset`.`deny_gid` AS `deny_gid`,
2745 `profile_field`.`created` AS `created`,
2746 `profile_field`.`edited` AS `edited`
2747 FROM `profile_field`
2748 INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`;