1 -- ------------------------------------------
2 -- Friendica 2022.12-dev (Giant Rhubarb)
3 -- DB_UPDATE_VERSION 1486
4 -- ------------------------------------------
10 CREATE TABLE IF NOT EXISTS `gserver` (
11 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
12 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
13 `nurl` varbinary(383) 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` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
26 `noscrape` varbinary(383) 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(383) 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` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
131 `header` varbinary(383) COMMENT 'Header picture',
132 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
133 `nurl` varbinary(383) 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` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
137 `pubkey` text COMMENT 'RSA public key 4096 bit',
138 `prvkey` text COMMENT 'RSA private key 4096 bit',
139 `batch` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
140 `notify` varbinary(383) COMMENT '',
141 `poll` varbinary(383) COMMENT '',
142 `subscribe` varbinary(383) 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 `next-update` datetime COMMENT 'Next connection request',
145 `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
146 `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
147 `failed` boolean COMMENT 'Connection failed',
148 `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
149 `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
150 `last-discovery` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last follower discovery',
151 `local-data` boolean COMMENT 'Is true when there are posts with this contact on the system',
152 `blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
153 `block_reason` text COMMENT 'Node-wide block reason',
154 `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
155 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Person, organisation, news, community, relay',
156 `manually-approve` boolean COMMENT 'Contact requests have to be approved manually',
157 `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
158 `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
159 `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
160 `baseurl` varbinary(383) DEFAULT '' COMMENT 'baseurl of the contact',
161 `gsid` int unsigned COMMENT 'Global Server ID',
162 `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
163 `reason` text COMMENT '',
164 `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
165 `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
166 `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
167 `protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
168 `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
169 `hub-verify` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
170 `rating` tinyint NOT NULL DEFAULT 0 COMMENT 'Automatically detected feed poll frequency',
171 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Feed poll priority',
172 `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
173 `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
174 `pending` boolean NOT NULL DEFAULT '1' COMMENT 'Contact request is pending',
175 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
176 `info` mediumtext COMMENT '',
177 `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
178 `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
179 `ffi_keyword_denylist` text COMMENT '',
180 `photo` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
181 `thumb` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
182 `micro` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
183 `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
184 `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
185 `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
186 `request` varbinary(383) COMMENT '',
187 `confirm` varbinary(383) COMMENT '',
188 `poco` varbinary(383) COMMENT '',
189 `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
190 `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = false instead',
191 `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = true instead',
192 `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
193 `site-pubkey` text COMMENT 'Deprecated',
194 `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
195 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
196 `issued-id` varbinary(383) NOT NULL DEFAULT '' COMMENT 'Deprecated',
197 `dfrn-id` varbinary(383) NOT NULL DEFAULT '' COMMENT 'Deprecated',
198 `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
199 `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
200 `usehub` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
201 `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT 'Deprecated',
202 `profile-id` int unsigned COMMENT 'Deprecated',
204 INDEX `uid_name` (`uid`,`name`(190)),
205 INDEX `self_uid` (`self`,`uid`),
206 INDEX `alias_uid` (`alias`(128),`uid`),
207 INDEX `pending_uid` (`pending`,`uid`),
208 INDEX `blocked_uid` (`blocked`,`uid`),
209 INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
210 INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
211 INDEX `batch_contact-type` (`batch`(64),`contact-type`),
212 INDEX `addr_uid` (`addr`(128),`uid`),
213 INDEX `nurl_uid` (`nurl`(128),`uid`),
214 INDEX `nick_uid` (`nick`(128),`uid`),
215 INDEX `attag_uid` (`attag`(96),`uid`),
216 INDEX `network_uid_lastupdate` (`network`,`uid`,`last-update`),
217 INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`),
218 INDEX `next-update` (`next-update`),
219 INDEX `local-data-next-update` (`local-data`,`next-update`),
220 INDEX `uid_lastitem` (`uid`,`last-item`),
221 INDEX `baseurl` (`baseurl`(64)),
222 INDEX `uid_contact-type` (`uid`,`contact-type`),
223 INDEX `uid_self_contact-type` (`uid`,`self`,`contact-type`),
224 INDEX `self_network_uid` (`self`,`network`,`uid`),
225 INDEX `gsid_uid_failed` (`gsid`,`uid`,`failed`),
226 INDEX `uri-id` (`uri-id`),
227 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
228 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
229 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
230 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
235 CREATE TABLE IF NOT EXISTS `tag` (
236 `id` int unsigned NOT NULL auto_increment COMMENT '',
237 `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
238 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
239 `type` tinyint unsigned COMMENT 'Type of the tag (Unknown, General Collection, Follower Collection or Account)',
241 UNIQUE INDEX `type_name_url` (`name`,`url`),
243 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
246 -- TABLE permissionset
248 CREATE TABLE IF NOT EXISTS `permissionset` (
249 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
250 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
251 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
252 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
253 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
254 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
256 INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`uid`,`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30)),
257 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
258 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
263 CREATE TABLE IF NOT EXISTS `verb` (
264 `id` smallint unsigned NOT NULL auto_increment,
265 `name` varchar(100) NOT NULL DEFAULT '' COMMENT '',
267 INDEX `name` (`name`)
268 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activity Verbs';
271 -- TABLE 2fa_app_specific_password
273 CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
274 `id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
275 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
276 `description` varchar(255) COMMENT 'Description of the usage of the password',
277 `hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
278 `generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
279 `last_used` datetime COMMENT 'Datetime the password was last used',
281 INDEX `uid_description` (`uid`,`description`(190)),
282 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
283 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
286 -- TABLE 2fa_recovery_codes
288 CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
289 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
290 `code` varchar(50) NOT NULL COMMENT 'Recovery code string',
291 `generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
292 `used` datetime COMMENT 'Datetime the code was used',
293 PRIMARY KEY(`uid`,`code`),
294 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
295 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
298 -- TABLE 2fa_trusted_browser
300 CREATE TABLE IF NOT EXISTS `2fa_trusted_browser` (
301 `cookie_hash` varchar(80) NOT NULL COMMENT 'Trusted cookie hash',
302 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
303 `user_agent` text COMMENT 'User agent string',
304 `trusted` boolean NOT NULL DEFAULT '1' COMMENT 'Whenever this browser should be trusted or not',
305 `created` datetime NOT NULL COMMENT 'Datetime the trusted browser was recorded',
306 `last_used` datetime COMMENT 'Datetime the trusted browser was last used',
307 PRIMARY KEY(`cookie_hash`),
309 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
310 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication trusted browsers';
313 -- TABLE account-user
315 CREATE TABLE IF NOT EXISTS `account-user` (
316 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
317 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the account url',
318 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
320 UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
321 INDEX `uid_uri-id` (`uid`,`uri-id`),
322 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
323 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
324 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Remote and local accounts';
329 CREATE TABLE IF NOT EXISTS `addon` (
330 `id` int unsigned NOT NULL auto_increment COMMENT '',
331 `name` varchar(50) NOT NULL DEFAULT '' COMMENT 'addon base (file)name',
332 `version` varchar(50) NOT NULL DEFAULT '' COMMENT 'currently unused',
333 `installed` boolean NOT NULL DEFAULT '0' COMMENT 'currently always 1',
334 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'currently unused',
335 `timestamp` int unsigned NOT NULL DEFAULT 0 COMMENT 'file timestamp to check for reloads',
336 `plugin_admin` boolean NOT NULL DEFAULT '0' COMMENT '1 = has admin config, 0 = has no admin config',
338 INDEX `installed_name` (`installed`,`name`),
339 UNIQUE INDEX `name` (`name`)
340 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registered addons';
345 CREATE TABLE IF NOT EXISTS `apcontact` (
346 `url` varbinary(383) NOT NULL COMMENT 'URL of the contact',
347 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
348 `uuid` varbinary(255) COMMENT '',
349 `type` varchar(20) NOT NULL COMMENT '',
350 `following` varbinary(383) COMMENT '',
351 `followers` varbinary(383) COMMENT '',
352 `inbox` varbinary(383) NOT NULL COMMENT '',
353 `outbox` varbinary(383) COMMENT '',
354 `sharedinbox` varbinary(383) COMMENT '',
355 `featured` varbinary(383) COMMENT 'Address for the collection of featured posts',
356 `featured-tags` varbinary(383) COMMENT 'Address for the collection of featured tags',
357 `manually-approve` boolean COMMENT '',
358 `discoverable` boolean COMMENT 'Mastodon extension: true if profile is published in their directory',
359 `suspended` boolean COMMENT 'Mastodon extension: true if profile is suspended',
360 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
361 `name` varchar(255) COMMENT '',
362 `about` text COMMENT '',
363 `xmpp` varchar(255) COMMENT 'XMPP address',
364 `matrix` varchar(255) COMMENT 'Matrix address',
365 `photo` varbinary(383) COMMENT '',
366 `header` varbinary(383) COMMENT 'Header picture',
367 `addr` varchar(255) COMMENT '',
368 `alias` varbinary(383) COMMENT '',
369 `pubkey` text COMMENT '',
370 `subscribe` varbinary(383) COMMENT '',
371 `baseurl` varbinary(383) COMMENT 'baseurl of the ap contact',
372 `gsid` int unsigned COMMENT 'Global Server ID',
373 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
374 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
375 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
376 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
377 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
379 INDEX `addr` (`addr`(32)),
380 INDEX `alias` (`alias`(190)),
381 INDEX `followers` (`followers`(190)),
382 INDEX `baseurl` (`baseurl`(190)),
383 INDEX `sharedinbox` (`sharedinbox`(190)),
384 INDEX `gsid` (`gsid`),
385 UNIQUE INDEX `uri-id` (`uri-id`),
386 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
387 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
388 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
393 CREATE TABLE IF NOT EXISTS `application` (
394 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
395 `client_id` varchar(64) NOT NULL COMMENT '',
396 `client_secret` varchar(64) NOT NULL COMMENT '',
397 `name` varchar(255) NOT NULL COMMENT '',
398 `redirect_uri` varbinary(383) NOT NULL COMMENT '',
399 `website` varbinary(383) COMMENT '',
400 `scopes` varchar(255) COMMENT '',
401 `read` boolean COMMENT 'Read scope',
402 `write` boolean COMMENT 'Write scope',
403 `follow` boolean COMMENT 'Follow scope',
404 `push` boolean COMMENT 'Push scope',
406 UNIQUE INDEX `client_id` (`client_id`)
407 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth application';
410 -- TABLE application-marker
412 CREATE TABLE IF NOT EXISTS `application-marker` (
413 `application-id` int unsigned NOT NULL COMMENT '',
414 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
415 `timeline` varchar(64) NOT NULL COMMENT 'Marker (home, notifications)',
416 `last_read_id` varbinary(383) COMMENT 'Marker id for the timeline',
417 `version` smallint unsigned COMMENT 'Version number',
418 `updated_at` datetime COMMENT 'creation time',
419 PRIMARY KEY(`application-id`,`uid`,`timeline`),
420 INDEX `uid_id` (`uid`),
421 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
422 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
423 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Timeline marker';
426 -- TABLE application-token
428 CREATE TABLE IF NOT EXISTS `application-token` (
429 `application-id` int unsigned NOT NULL COMMENT '',
430 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
431 `code` varchar(64) NOT NULL COMMENT '',
432 `access_token` varchar(64) NOT NULL COMMENT '',
433 `created_at` datetime NOT NULL COMMENT 'creation time',
434 `scopes` varchar(255) COMMENT '',
435 `read` boolean COMMENT 'Read scope',
436 `write` boolean COMMENT 'Write scope',
437 `follow` boolean COMMENT 'Follow scope',
438 `push` boolean COMMENT 'Push scope',
439 PRIMARY KEY(`application-id`,`uid`),
440 INDEX `uid_id` (`uid`,`application-id`),
441 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
442 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
443 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth user token';
448 CREATE TABLE IF NOT EXISTS `attach` (
449 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
450 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
451 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
452 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
453 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
454 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
455 `data` longblob NOT NULL COMMENT 'file data',
456 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
457 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
458 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
459 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
460 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
461 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
462 `backend-class` tinytext COMMENT 'Storage backend class',
463 `backend-ref` text COMMENT 'Storage backend data reference',
466 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
467 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
472 CREATE TABLE IF NOT EXISTS `cache` (
473 `k` varbinary(255) NOT NULL COMMENT 'cache key',
474 `v` mediumtext COMMENT 'cached serialized value',
475 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
476 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
478 INDEX `k_expires` (`k`,`expires`)
479 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
484 CREATE TABLE IF NOT EXISTS `config` (
485 `id` int unsigned NOT NULL auto_increment COMMENT '',
486 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
487 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
488 `v` mediumtext COMMENT '',
490 UNIQUE INDEX `cat_k` (`cat`,`k`)
491 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
494 -- TABLE contact-relation
496 CREATE TABLE IF NOT EXISTS `contact-relation` (
497 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
498 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
499 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
500 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
501 `follows` boolean NOT NULL DEFAULT '0' COMMENT '',
502 PRIMARY KEY(`cid`,`relation-cid`),
503 INDEX `relation-cid` (`relation-cid`),
504 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
505 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
506 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
511 CREATE TABLE IF NOT EXISTS `conv` (
512 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
513 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
514 `recips` text COMMENT 'sender_handle;recipient_handle',
515 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
516 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
517 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
518 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
519 `subject` text COMMENT 'subject of initial message',
522 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
523 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
528 CREATE TABLE IF NOT EXISTS `workerqueue` (
529 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
530 `command` varchar(100) COMMENT 'Task command',
531 `parameter` mediumtext COMMENT 'Task parameter',
532 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
533 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
534 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
535 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
536 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
537 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
538 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
540 INDEX `command` (`command`),
541 INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
542 INDEX `done_executed` (`done`,`executed`),
543 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
544 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
545 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
546 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
547 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
548 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
551 -- TABLE delayed-post
553 CREATE TABLE IF NOT EXISTS `delayed-post` (
554 `id` int unsigned NOT NULL auto_increment,
555 `uri` varbinary(383) COMMENT 'URI of the post that will be distributed later',
556 `uid` mediumint unsigned COMMENT 'Owner User id',
557 `delayed` datetime COMMENT 'delay time',
558 `wid` int unsigned COMMENT 'Workerqueue id',
560 UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
562 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
563 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
564 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
567 -- TABLE diaspora-interaction
569 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
570 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
571 `interaction` mediumtext COMMENT 'The Diaspora interaction',
572 PRIMARY KEY(`uri-id`),
573 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
574 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
579 CREATE TABLE IF NOT EXISTS `endpoint` (
580 `url` varbinary(383) NOT NULL COMMENT 'URL of the contact',
581 `type` varchar(20) NOT NULL COMMENT '',
582 `owner-uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
584 UNIQUE INDEX `owner-uri-id_type` (`owner-uri-id`,`type`),
585 FOREIGN KEY (`owner-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
586 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub endpoints - used in the ActivityPub implementation';
591 CREATE TABLE IF NOT EXISTS `event` (
592 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
593 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
594 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
595 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
596 `uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
597 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the event uri',
598 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
599 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
600 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
601 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
602 `summary` text COMMENT 'short description or title of the event',
603 `desc` text COMMENT 'event description',
604 `location` text COMMENT 'event location',
605 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
606 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
607 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
608 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
609 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
610 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
611 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
613 INDEX `uid_start` (`uid`,`start`),
615 INDEX `uri-id` (`uri-id`),
616 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
617 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
618 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
619 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
624 CREATE TABLE IF NOT EXISTS `fcontact` (
625 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
626 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'unique id',
627 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
628 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the fcontact url',
629 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
630 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
631 `request` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
632 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
633 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
634 `batch` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
635 `notify` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
636 `poll` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
637 `confirm` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
638 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
639 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
640 `alias` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
641 `pubkey` text COMMENT '',
642 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
643 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
644 `interacting_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts this contact interactes with',
645 `interacted_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts that interacted with this contact',
646 `post_count` int unsigned DEFAULT 0 COMMENT 'Number of posts and comments',
648 INDEX `addr` (`addr`(32)),
649 UNIQUE INDEX `url` (`url`(190)),
650 UNIQUE INDEX `uri-id` (`uri-id`),
651 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
652 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
657 CREATE TABLE IF NOT EXISTS `fetch-entry` (
658 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
659 `url` varbinary(383) COMMENT 'url that awaiting to be fetched',
660 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of the fetch request',
661 `wid` int unsigned COMMENT 'Workerqueue id',
663 UNIQUE INDEX `url` (`url`),
664 INDEX `created` (`created`),
666 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
667 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
672 CREATE TABLE IF NOT EXISTS `fsuggest` (
673 `id` int unsigned NOT NULL auto_increment COMMENT '',
674 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
675 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
676 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
677 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
678 `request` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
679 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
680 `note` text COMMENT '',
681 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
685 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
686 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
687 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
692 CREATE TABLE IF NOT EXISTS `group` (
693 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
694 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
695 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
696 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
697 `cid` int unsigned COMMENT 'Contact id of forum. When this field is filled then the members are synced automatically.',
698 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
702 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
703 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
704 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
707 -- TABLE group_member
709 CREATE TABLE IF NOT EXISTS `group_member` (
710 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
711 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
712 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
714 INDEX `contactid` (`contact-id`),
715 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
716 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
717 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
718 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
723 CREATE TABLE IF NOT EXISTS `gserver-tag` (
724 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
725 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
726 PRIMARY KEY(`gserver-id`,`tag`),
728 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
729 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
734 CREATE TABLE IF NOT EXISTS `hook` (
735 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
736 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
737 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
738 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
739 `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',
741 INDEX `priority` (`priority`),
742 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
743 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
748 CREATE TABLE IF NOT EXISTS `inbox-entry` (
749 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
750 `activity-id` varbinary(383) COMMENT 'id of the incoming activity',
751 `object-id` varbinary(383) COMMENT '',
752 `in-reply-to-id` varbinary(383) COMMENT '',
753 `conversation` varbinary(383) COMMENT '',
754 `type` varchar(64) COMMENT 'Type of the activity',
755 `object-type` varchar(64) COMMENT 'Type of the object activity',
756 `object-object-type` varchar(64) COMMENT 'Type of the object\'s object activity',
757 `received` datetime COMMENT 'Receiving date',
758 `activity` mediumtext COMMENT 'The JSON activity',
759 `signer` varchar(255) COMMENT '',
760 `push` boolean COMMENT 'Is the entry pushed or have pulled it?',
761 `trust` boolean COMMENT 'Do we trust this entry?',
762 `wid` int unsigned COMMENT 'Workerqueue id',
764 UNIQUE INDEX `activity-id` (`activity-id`),
765 INDEX `object-id` (`object-id`),
766 INDEX `received` (`received`),
768 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
769 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Incoming activity';
772 -- TABLE inbox-entry-receiver
774 CREATE TABLE IF NOT EXISTS `inbox-entry-receiver` (
775 `queue-id` int unsigned NOT NULL COMMENT '',
776 `uid` mediumint unsigned NOT NULL COMMENT 'User id',
777 PRIMARY KEY(`queue-id`,`uid`),
779 FOREIGN KEY (`queue-id`) REFERENCES `inbox-entry` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
780 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
781 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Receiver for the incoming activity';
784 -- TABLE inbox-status
786 CREATE TABLE IF NOT EXISTS `inbox-status` (
787 `url` varbinary(383) NOT NULL COMMENT 'URL of the inbox',
788 `uri-id` int unsigned COMMENT 'Item-uri id of inbox url',
789 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
790 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
791 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
792 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
793 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
794 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
796 INDEX `uri-id` (`uri-id`),
797 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
798 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
803 CREATE TABLE IF NOT EXISTS `intro` (
804 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
805 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
806 `fid` int unsigned COMMENT 'deprecated',
807 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
808 `suggest-cid` int unsigned COMMENT 'Suggested contact',
809 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
810 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
811 `note` text COMMENT '',
812 `hash` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
813 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
814 `blocked` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
815 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
817 INDEX `contact-id` (`contact-id`),
818 INDEX `suggest-cid` (`suggest-cid`),
820 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
821 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
822 FOREIGN KEY (`suggest-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
823 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
828 CREATE TABLE IF NOT EXISTS `locks` (
829 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
830 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
831 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
832 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
833 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
835 INDEX `name_expires` (`name`,`expires`)
836 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
841 CREATE TABLE IF NOT EXISTS `mail` (
842 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
843 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
844 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
845 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
846 `from-photo` varbinary(383) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
847 `from-url` varbinary(383) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
848 `contact-id` varbinary(255) COMMENT 'contact.id',
849 `author-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the author of the mail',
850 `convid` int unsigned COMMENT 'conv.id',
851 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
852 `body` mediumtext COMMENT '',
853 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
854 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
855 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
856 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
857 `uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
858 `uri-id` int unsigned COMMENT 'Item-uri id of the related mail',
859 `parent-uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
860 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related mail',
861 `thr-parent` varbinary(383) COMMENT '',
862 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
863 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
865 INDEX `uid_seen` (`uid`,`seen`),
866 INDEX `convid` (`convid`),
867 INDEX `uri` (`uri`(64)),
868 INDEX `parent-uri` (`parent-uri`(64)),
869 INDEX `contactid` (`contact-id`(32)),
870 INDEX `author-id` (`author-id`),
871 INDEX `uri-id` (`uri-id`),
872 INDEX `parent-uri-id` (`parent-uri-id`),
873 INDEX `thr-parent-id` (`thr-parent-id`),
874 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
875 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
876 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
877 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
878 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
879 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
884 CREATE TABLE IF NOT EXISTS `mailacct` (
885 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
886 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
887 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
888 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
889 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
890 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
891 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
892 `pass` text COMMENT '',
893 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
894 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
895 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
896 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
897 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
900 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
901 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
906 CREATE TABLE IF NOT EXISTS `manage` (
907 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
908 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
909 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
911 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
913 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
914 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
915 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
918 -- TABLE notification
920 CREATE TABLE IF NOT EXISTS `notification` (
921 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
922 `uid` mediumint unsigned COMMENT 'Owner User id',
923 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
924 `type` smallint unsigned COMMENT '',
925 `actor-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the actor that caused the notification',
926 `target-uri-id` int unsigned COMMENT 'Item-uri id of the related post',
927 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
928 `created` datetime COMMENT '',
929 `seen` boolean DEFAULT '0' COMMENT 'Seen on the desktop',
930 `dismissed` boolean DEFAULT '0' COMMENT 'Dismissed via the API',
932 UNIQUE INDEX `uid_vid_type_actor-id_target-uri-id` (`uid`,`vid`,`type`,`actor-id`,`target-uri-id`),
934 INDEX `actor-id` (`actor-id`),
935 INDEX `target-uri-id` (`target-uri-id`),
936 INDEX `parent-uri-id` (`parent-uri-id`),
937 INDEX `seen_uid` (`seen`,`uid`),
938 INDEX `uid_type_parent-uri-id_actor-id` (`uid`,`type`,`parent-uri-id`,`actor-id`),
939 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
940 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
941 FOREIGN KEY (`actor-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
942 FOREIGN KEY (`target-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
943 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
944 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
949 CREATE TABLE IF NOT EXISTS `notify` (
950 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
951 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
952 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
953 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
954 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
955 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
956 `msg` mediumtext COMMENT '',
957 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
958 `link` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
959 `iid` int unsigned COMMENT '',
960 `parent` int unsigned COMMENT '',
961 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
962 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
963 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
964 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
965 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
966 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
967 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
969 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
970 INDEX `uid_date` (`uid`,`date`),
971 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
972 INDEX `uri-id` (`uri-id`),
973 INDEX `parent-uri-id` (`parent-uri-id`),
974 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
975 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
976 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
977 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='[Deprecated] User notifications';
980 -- TABLE notify-threads
982 CREATE TABLE IF NOT EXISTS `notify-threads` (
983 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
984 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
985 `master-parent-item` int unsigned COMMENT 'Deprecated',
986 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
987 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
988 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
990 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
991 INDEX `receiver-uid` (`receiver-uid`),
992 INDEX `notify-id` (`notify-id`),
993 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
994 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
995 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
996 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1001 CREATE TABLE IF NOT EXISTS `oembed` (
1002 `url` varbinary(383) NOT NULL COMMENT 'page url',
1003 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
1004 `content` mediumtext COMMENT 'OEmbed data of the page',
1005 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1006 PRIMARY KEY(`url`,`maxwidth`),
1007 INDEX `created` (`created`)
1008 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
1011 -- TABLE openwebauth-token
1013 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
1014 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1015 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
1016 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
1017 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
1018 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1019 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1021 INDEX `uid` (`uid`),
1022 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1023 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
1028 CREATE TABLE IF NOT EXISTS `parsed_url` (
1029 `url_hash` binary(64) NOT NULL COMMENT 'page url hash',
1030 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
1031 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
1032 `url` text NOT NULL COMMENT 'page url',
1033 `content` mediumtext COMMENT 'page data',
1034 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1035 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration',
1036 PRIMARY KEY(`url_hash`,`guessing`,`oembed`),
1037 INDEX `created` (`created`),
1038 INDEX `expires` (`expires`)
1039 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
1044 CREATE TABLE IF NOT EXISTS `pconfig` (
1045 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
1046 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1047 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
1048 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
1049 `v` mediumtext COMMENT 'Value',
1051 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
1052 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1053 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
1058 CREATE TABLE IF NOT EXISTS `photo` (
1059 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1060 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1061 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1062 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
1063 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
1064 `hash` char(32) COMMENT 'hash value of the photo',
1065 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
1066 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
1067 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1068 `desc` text COMMENT '',
1069 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
1070 `photo-type` tinyint unsigned COMMENT 'User avatar, user banner, contact avatar, contact banner or default',
1071 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1072 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
1073 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1074 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1075 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1076 `data` mediumblob NOT NULL COMMENT '',
1077 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1078 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
1079 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
1080 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
1081 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
1082 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
1083 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
1084 `backend-class` tinytext COMMENT 'Storage backend class',
1085 `backend-ref` text COMMENT 'Storage backend data reference',
1086 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1088 INDEX `contactid` (`contact-id`),
1089 INDEX `uid_contactid` (`uid`,`contact-id`),
1090 INDEX `uid_profile` (`uid`,`profile`),
1091 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
1092 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
1093 INDEX `resource-id` (`resource-id`),
1094 INDEX `uid_photo-type` (`uid`,`photo-type`),
1095 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1096 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1097 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1102 CREATE TABLE IF NOT EXISTS `post` (
1103 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1104 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1105 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1106 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1107 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1108 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1109 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1110 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1111 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1112 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1113 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1114 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1115 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1116 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1117 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1118 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1119 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1120 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1121 PRIMARY KEY(`uri-id`),
1122 INDEX `parent-uri-id` (`parent-uri-id`),
1123 INDEX `thr-parent-id` (`thr-parent-id`),
1124 INDEX `external-id` (`external-id`),
1125 INDEX `owner-id` (`owner-id`),
1126 INDEX `author-id` (`author-id`),
1127 INDEX `causer-id` (`causer-id`),
1128 INDEX `vid` (`vid`),
1129 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1130 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1131 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1132 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1133 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1134 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1135 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1136 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1137 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
1140 -- TABLE post-activity
1142 CREATE TABLE IF NOT EXISTS `post-activity` (
1143 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1144 `activity` mediumtext COMMENT 'Original activity',
1145 `received` datetime COMMENT '',
1146 PRIMARY KEY(`uri-id`),
1147 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1148 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Original remote activity';
1151 -- TABLE post-category
1153 CREATE TABLE IF NOT EXISTS `post-category` (
1154 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1155 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1156 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1157 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1158 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1159 INDEX `tid` (`tid`),
1160 INDEX `uid_uri-id` (`uid`,`uri-id`),
1161 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1162 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1163 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1164 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1167 -- TABLE post-collection
1169 CREATE TABLE IF NOT EXISTS `post-collection` (
1170 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1171 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0 - Featured',
1172 `author-id` int unsigned COMMENT 'Author of the featured post',
1173 PRIMARY KEY(`uri-id`,`type`),
1174 INDEX `type` (`type`),
1175 INDEX `author-id` (`author-id`),
1176 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1177 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1178 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Collection of posts';
1181 -- TABLE post-content
1183 CREATE TABLE IF NOT EXISTS `post-content` (
1184 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1185 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1186 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1187 `body` mediumtext COMMENT 'item body content',
1188 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1189 `quote-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the quoted uri',
1190 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1191 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1192 `language` text COMMENT 'Language information about this post',
1193 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1194 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1195 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1196 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1197 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1198 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1199 `target` text COMMENT 'JSON encoded target structure if used',
1200 `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',
1201 `plink` varbinary(383) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1202 PRIMARY KEY(`uri-id`),
1203 INDEX `plink` (`plink`(191)),
1204 INDEX `resource-id` (`resource-id`),
1205 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
1206 INDEX `quote-uri-id` (`quote-uri-id`),
1207 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1208 FOREIGN KEY (`quote-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1209 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1212 -- TABLE post-delivery
1214 CREATE TABLE IF NOT EXISTS `post-delivery` (
1215 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1216 `inbox-id` int unsigned NOT NULL COMMENT 'Item-uri id of inbox url',
1217 `uid` mediumint unsigned COMMENT 'Delivering user',
1218 `created` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
1219 `command` varbinary(32) COMMENT '',
1220 `failed` tinyint DEFAULT 0 COMMENT 'Number of times the delivery has failed',
1221 `receivers` mediumtext COMMENT 'JSON encoded array with the receiving contacts',
1222 PRIMARY KEY(`uri-id`,`inbox-id`),
1223 INDEX `inbox-id_created` (`inbox-id`,`created`),
1224 INDEX `uid` (`uid`),
1225 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1226 FOREIGN KEY (`inbox-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1227 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1228 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for posts for the batch processing';
1231 -- TABLE post-delivery-data
1233 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1234 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1235 `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',
1236 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1237 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1238 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1239 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1240 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1241 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1242 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1243 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1244 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1245 PRIMARY KEY(`uri-id`),
1246 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1247 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1250 -- TABLE post-history
1252 CREATE TABLE IF NOT EXISTS `post-history` (
1253 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1254 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of edit',
1255 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1256 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1257 `body` mediumtext COMMENT 'item body content',
1258 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1259 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1260 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1261 `language` text COMMENT 'Language information about this post',
1262 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1263 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1264 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1265 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1266 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1267 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1268 `target` text COMMENT 'JSON encoded target structure if used',
1269 `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',
1270 `plink` varbinary(383) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1271 PRIMARY KEY(`uri-id`,`edited`),
1272 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1273 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post history';
1278 CREATE TABLE IF NOT EXISTS `post-link` (
1279 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1280 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1281 `url` varbinary(511) NOT NULL COMMENT 'External URL',
1282 `mimetype` varchar(60) COMMENT '',
1284 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1285 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1286 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post related external links';
1291 CREATE TABLE IF NOT EXISTS `post-media` (
1292 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1293 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1294 `url` varbinary(1024) NOT NULL COMMENT 'Media URL',
1295 `media-uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the activities uri-id',
1296 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1297 `mimetype` varchar(60) COMMENT '',
1298 `height` smallint unsigned COMMENT 'Height of the media',
1299 `width` smallint unsigned COMMENT 'Width of the media',
1300 `size` bigint unsigned COMMENT 'Media size',
1301 `preview` varbinary(512) COMMENT 'Preview URL',
1302 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1303 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1304 `description` text COMMENT '',
1305 `name` varchar(255) COMMENT 'Name of the media',
1306 `author-url` varbinary(383) COMMENT 'URL of the author of the media',
1307 `author-name` varchar(255) COMMENT 'Name of the author of the media',
1308 `author-image` varbinary(383) COMMENT 'Image of the author of the media',
1309 `publisher-url` varbinary(383) COMMENT 'URL of the publisher of the media',
1310 `publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
1311 `publisher-image` varbinary(383) COMMENT 'Image of the publisher of the media',
1313 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`(512)),
1314 INDEX `uri-id-id` (`uri-id`,`id`),
1315 INDEX `media-uri-id` (`media-uri-id`),
1316 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1317 FOREIGN KEY (`media-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1318 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1321 -- TABLE post-question
1323 CREATE TABLE IF NOT EXISTS `post-question` (
1324 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1325 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1326 `multiple` boolean NOT NULL DEFAULT '0' COMMENT 'Multiple choice',
1327 `voters` int unsigned COMMENT 'Number of voters for this question',
1328 `end-time` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Question end time',
1330 UNIQUE INDEX `uri-id` (`uri-id`),
1331 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1332 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question';
1335 -- TABLE post-question-option
1337 CREATE TABLE IF NOT EXISTS `post-question-option` (
1338 `id` int unsigned NOT NULL COMMENT 'Id of the question',
1339 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1340 `name` varchar(255) COMMENT 'Name of the option',
1341 `replies` int unsigned COMMENT 'Number of replies for this question option',
1342 PRIMARY KEY(`uri-id`,`id`),
1343 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1344 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question option';
1349 CREATE TABLE IF NOT EXISTS `post-tag` (
1350 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1351 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1352 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1353 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1354 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1355 INDEX `tid` (`tid`),
1356 INDEX `cid` (`cid`),
1357 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1358 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1359 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1360 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1363 -- TABLE post-thread
1365 CREATE TABLE IF NOT EXISTS `post-thread` (
1366 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1367 `conversation-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the conversation uri',
1368 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1369 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1370 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1371 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1372 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1373 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1374 `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',
1375 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1376 PRIMARY KEY(`uri-id`),
1377 INDEX `conversation-id` (`conversation-id`),
1378 INDEX `owner-id` (`owner-id`),
1379 INDEX `author-id` (`author-id`),
1380 INDEX `causer-id` (`causer-id`),
1381 INDEX `received` (`received`),
1382 INDEX `commented` (`commented`),
1383 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1384 FOREIGN KEY (`conversation-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1385 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1386 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1387 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1388 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1393 CREATE TABLE IF NOT EXISTS `post-user` (
1394 `id` int unsigned NOT NULL auto_increment,
1395 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1396 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1397 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1398 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1399 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1400 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1401 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1402 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1403 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1404 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1405 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1406 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1407 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1408 `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
1409 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1410 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1411 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1412 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1413 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1414 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1415 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1416 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1417 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1418 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1419 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1420 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1421 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1422 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1423 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1425 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1426 INDEX `uri-id` (`uri-id`),
1427 INDEX `parent-uri-id` (`parent-uri-id`),
1428 INDEX `thr-parent-id` (`thr-parent-id`),
1429 INDEX `external-id` (`external-id`),
1430 INDEX `owner-id` (`owner-id`),
1431 INDEX `author-id` (`author-id`),
1432 INDEX `causer-id` (`causer-id`),
1433 INDEX `vid` (`vid`),
1434 INDEX `contact-id` (`contact-id`),
1435 INDEX `event-id` (`event-id`),
1436 INDEX `psid` (`psid`),
1437 INDEX `author-id_uid` (`author-id`,`uid`),
1438 INDEX `author-id_received` (`author-id`,`received`),
1439 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1440 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1441 INDEX `uid_contactid` (`uid`,`contact-id`),
1442 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1443 INDEX `uid_unseen` (`uid`,`unseen`),
1444 INDEX `uid_hidden_uri-id` (`uid`,`hidden`,`uri-id`),
1445 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1446 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1447 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1448 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1449 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1450 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1451 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1452 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1453 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1454 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1455 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1456 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1457 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1460 -- TABLE post-thread-user
1462 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1463 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1464 `conversation-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the conversation uri',
1465 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1466 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1467 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1468 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1469 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1470 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1471 `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',
1472 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1473 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1474 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
1475 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1476 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1477 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1478 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1479 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1480 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Deprecated',
1481 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1482 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1483 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1484 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1485 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1486 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1487 PRIMARY KEY(`uid`,`uri-id`),
1488 INDEX `uri-id` (`uri-id`),
1489 INDEX `conversation-id` (`conversation-id`),
1490 INDEX `owner-id` (`owner-id`),
1491 INDEX `author-id` (`author-id`),
1492 INDEX `causer-id` (`causer-id`),
1493 INDEX `uid` (`uid`),
1494 INDEX `contact-id` (`contact-id`),
1495 INDEX `psid` (`psid`),
1496 INDEX `post-user-id` (`post-user-id`),
1497 INDEX `commented` (`commented`),
1498 INDEX `uid_received` (`uid`,`received`),
1499 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1500 INDEX `uid_commented` (`uid`,`commented`),
1501 INDEX `uid_starred` (`uid`,`starred`),
1502 INDEX `uid_mention` (`uid`,`mention`),
1503 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1504 FOREIGN KEY (`conversation-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1505 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1506 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1507 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1508 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1509 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1510 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1511 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1512 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1515 -- TABLE post-user-notification
1517 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1518 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1519 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1520 `notification-type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1521 PRIMARY KEY(`uid`,`uri-id`),
1522 INDEX `uri-id` (`uri-id`),
1523 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1524 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1525 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1530 CREATE TABLE IF NOT EXISTS `process` (
1531 `pid` int unsigned NOT NULL COMMENT 'The ID of the process',
1532 `hostname` varchar(32) NOT NULL COMMENT 'The name of the host the process is ran on',
1533 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1534 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1535 PRIMARY KEY(`pid`,`hostname`),
1536 INDEX `command` (`command`)
1537 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1542 CREATE TABLE IF NOT EXISTS `profile` (
1543 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1544 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1545 `profile-name` varchar(255) COMMENT 'Deprecated',
1546 `is-default` boolean COMMENT 'Deprecated',
1547 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1548 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1549 `pdesc` varchar(255) COMMENT 'Deprecated',
1550 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1551 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1552 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1553 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1554 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1555 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1556 `hometown` varchar(255) COMMENT 'Deprecated',
1557 `gender` varchar(32) COMMENT 'Deprecated',
1558 `marital` varchar(255) COMMENT 'Deprecated',
1559 `with` text COMMENT 'Deprecated',
1560 `howlong` datetime COMMENT 'Deprecated',
1561 `sexual` varchar(255) COMMENT 'Deprecated',
1562 `politic` varchar(255) COMMENT 'Deprecated',
1563 `religion` varchar(255) COMMENT 'Deprecated',
1564 `pub_keywords` text COMMENT '',
1565 `prv_keywords` text COMMENT '',
1566 `likes` text COMMENT 'Deprecated',
1567 `dislikes` text COMMENT 'Deprecated',
1568 `about` text COMMENT 'Profile description',
1569 `summary` varchar(255) COMMENT 'Deprecated',
1570 `music` text COMMENT 'Deprecated',
1571 `book` text COMMENT 'Deprecated',
1572 `tv` text COMMENT 'Deprecated',
1573 `film` text COMMENT 'Deprecated',
1574 `interest` text COMMENT 'Deprecated',
1575 `romance` text COMMENT 'Deprecated',
1576 `work` text COMMENT 'Deprecated',
1577 `education` text COMMENT 'Deprecated',
1578 `contact` text COMMENT 'Deprecated',
1579 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1580 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
1581 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
1582 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1583 `thumb` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1584 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1585 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1587 INDEX `uid_is-default` (`uid`,`is-default`),
1588 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1589 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1590 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1593 -- TABLE profile_field
1595 CREATE TABLE IF NOT EXISTS `profile_field` (
1596 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1597 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1598 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1599 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1600 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1601 `value` text COMMENT 'Value of the field',
1602 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1603 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1605 INDEX `uid` (`uid`),
1606 INDEX `order` (`order`),
1607 INDEX `psid` (`psid`),
1608 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1609 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1610 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1613 -- TABLE push_subscriber
1615 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1616 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1617 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1618 `callback_url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1619 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1620 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1621 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1622 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1623 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1624 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1625 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1627 INDEX `next_try` (`next_try`),
1628 INDEX `uid` (`uid`),
1629 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1630 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1635 CREATE TABLE IF NOT EXISTS `register` (
1636 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1637 `hash` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1638 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1639 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1640 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1641 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1642 `note` text COMMENT '',
1644 INDEX `uid` (`uid`),
1645 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1646 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1651 CREATE TABLE IF NOT EXISTS `search` (
1652 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1653 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1654 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1656 INDEX `uid_term` (`uid`,`term`(64)),
1657 INDEX `term` (`term`(64)),
1658 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1659 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1664 CREATE TABLE IF NOT EXISTS `session` (
1665 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1666 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1667 `data` text COMMENT '',
1668 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1670 INDEX `sid` (`sid`(64)),
1671 INDEX `expire` (`expire`)
1672 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1677 CREATE TABLE IF NOT EXISTS `storage` (
1678 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1679 `data` longblob NOT NULL COMMENT 'file data',
1681 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1684 -- TABLE subscription
1686 CREATE TABLE IF NOT EXISTS `subscription` (
1687 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1688 `application-id` int unsigned NOT NULL COMMENT '',
1689 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
1690 `endpoint` varchar(511) COMMENT 'Endpoint URL',
1691 `pubkey` varchar(127) COMMENT 'User agent public key',
1692 `secret` varchar(32) COMMENT 'Auth secret',
1693 `follow` boolean COMMENT '',
1694 `favourite` boolean COMMENT '',
1695 `reblog` boolean COMMENT '',
1696 `mention` boolean COMMENT '',
1697 `poll` boolean COMMENT '',
1698 `follow_request` boolean COMMENT '',
1699 `status` boolean COMMENT '',
1701 UNIQUE INDEX `application-id_uid` (`application-id`,`uid`),
1702 INDEX `uid_application-id` (`uid`,`application-id`),
1703 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1704 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1705 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Push Subscription for the API';
1710 CREATE TABLE IF NOT EXISTS `userd` (
1711 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1712 `username` varchar(255) NOT NULL COMMENT '',
1714 INDEX `username` (`username`(32))
1715 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1718 -- TABLE user-contact
1720 CREATE TABLE IF NOT EXISTS `user-contact` (
1721 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1722 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1723 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
1724 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1725 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1726 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1727 `hidden` boolean COMMENT 'This contact is hidden from the others',
1728 `is-blocked` boolean COMMENT 'User is blocked by this contact',
1729 `pending` boolean COMMENT '',
1730 `rel` tinyint unsigned COMMENT 'The kind of the relation between the user and the contact',
1731 `info` mediumtext COMMENT '',
1732 `notify_new_posts` boolean COMMENT '',
1733 `remote_self` boolean COMMENT '',
1734 `fetch_further_information` tinyint unsigned COMMENT '',
1735 `ffi_keyword_denylist` text COMMENT '',
1736 `subhub` boolean COMMENT '',
1737 `hub-verify` varbinary(383) COMMENT '',
1738 `protocol` char(4) COMMENT 'Protocol of the contact',
1739 `rating` tinyint COMMENT 'Automatically detected feed poll frequency',
1740 `priority` tinyint unsigned COMMENT 'Feed poll priority',
1741 PRIMARY KEY(`uid`,`cid`),
1742 INDEX `cid` (`cid`),
1743 UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
1744 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1745 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1746 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1747 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1750 -- TABLE arrived-activity
1752 CREATE TABLE IF NOT EXISTS `arrived-activity` (
1753 `object-id` varbinary(383) NOT NULL COMMENT 'object id of the incoming activity',
1754 `received` datetime COMMENT 'Receiving date',
1755 PRIMARY KEY(`object-id`)
1756 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Id of arrived activities';
1759 -- TABLE fetched-activity
1761 CREATE TABLE IF NOT EXISTS `fetched-activity` (
1762 `object-id` varbinary(383) NOT NULL COMMENT 'object id of fetched activity',
1763 `received` datetime COMMENT 'Receiving date',
1764 PRIMARY KEY(`object-id`)
1765 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Id of fetched activities';
1770 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1771 `key` int NOT NULL COMMENT '',
1772 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1774 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1777 -- VIEW application-view
1779 DROP VIEW IF EXISTS `application-view`;
1780 CREATE VIEW `application-view` AS SELECT
1781 `application`.`id` AS `id`,
1782 `application-token`.`uid` AS `uid`,
1783 `application`.`name` AS `name`,
1784 `application`.`redirect_uri` AS `redirect_uri`,
1785 `application`.`website` AS `website`,
1786 `application`.`client_id` AS `client_id`,
1787 `application`.`client_secret` AS `client_secret`,
1788 `application-token`.`code` AS `code`,
1789 `application-token`.`access_token` AS `access_token`,
1790 `application-token`.`created_at` AS `created_at`,
1791 `application-token`.`scopes` AS `scopes`,
1792 `application-token`.`read` AS `read`,
1793 `application-token`.`write` AS `write`,
1794 `application-token`.`follow` AS `follow`,
1795 `application-token`.`push` AS `push`
1796 FROM `application-token`
1797 INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`;
1800 -- VIEW post-user-view
1802 DROP VIEW IF EXISTS `post-user-view`;
1803 CREATE VIEW `post-user-view` AS SELECT
1804 `post-user`.`id` AS `id`,
1805 `post-user`.`id` AS `post-user-id`,
1806 `post-user`.`uid` AS `uid`,
1807 `parent-post`.`id` AS `parent`,
1808 `item-uri`.`uri` AS `uri`,
1809 `post-user`.`uri-id` AS `uri-id`,
1810 `parent-item-uri`.`uri` AS `parent-uri`,
1811 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1812 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1813 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1814 `conversation-item-uri`.`uri` AS `conversation`,
1815 `post-thread-user`.`conversation-id` AS `conversation-id`,
1816 `quote-item-uri`.`uri` AS `quote-uri`,
1817 `post-content`.`quote-uri-id` AS `quote-uri-id`,
1818 `item-uri`.`guid` AS `guid`,
1819 `post-user`.`wall` AS `wall`,
1820 `post-user`.`gravity` AS `gravity`,
1821 `external-item-uri`.`uri` AS `extid`,
1822 `post-user`.`external-id` AS `external-id`,
1823 `post-user`.`created` AS `created`,
1824 `post-user`.`edited` AS `edited`,
1825 `post-thread-user`.`commented` AS `commented`,
1826 `post-user`.`received` AS `received`,
1827 `post-thread-user`.`changed` AS `changed`,
1828 `post-user`.`post-type` AS `post-type`,
1829 `post-user`.`post-reason` AS `post-reason`,
1830 `post-user`.`private` AS `private`,
1831 `post-thread-user`.`pubmail` AS `pubmail`,
1832 `post-user`.`visible` AS `visible`,
1833 `post-thread-user`.`starred` AS `starred`,
1834 `post-user`.`unseen` AS `unseen`,
1835 `post-user`.`deleted` AS `deleted`,
1836 `post-user`.`origin` AS `origin`,
1837 `post-thread-user`.`origin` AS `parent-origin`,
1838 `post-thread-user`.`mention` AS `mention`,
1839 `post-user`.`global` AS `global`,
1840 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-user`.`uri-id`) AS `featured`,
1841 `post-user`.`network` AS `network`,
1842 `post-user`.`protocol` AS `protocol`,
1843 `post-user`.`vid` AS `vid`,
1844 `post-user`.`psid` AS `psid`,
1845 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1846 `post-content`.`title` AS `title`,
1847 `post-content`.`content-warning` AS `content-warning`,
1848 `post-content`.`raw-body` AS `raw-body`,
1849 IFNULL (`post-content`.`body`, '') AS `body`,
1850 `post-content`.`rendered-hash` AS `rendered-hash`,
1851 `post-content`.`rendered-html` AS `rendered-html`,
1852 `post-content`.`language` AS `language`,
1853 `post-content`.`plink` AS `plink`,
1854 `post-content`.`location` AS `location`,
1855 `post-content`.`coord` AS `coord`,
1856 `post-content`.`app` AS `app`,
1857 `post-content`.`object-type` AS `object-type`,
1858 `post-content`.`object` AS `object`,
1859 `post-content`.`target-type` AS `target-type`,
1860 `post-content`.`target` AS `target`,
1861 `post-content`.`resource-id` AS `resource-id`,
1862 `post-user`.`contact-id` AS `contact-id`,
1863 `contact`.`uri-id` AS `contact-uri-id`,
1864 `contact`.`url` AS `contact-link`,
1865 `contact`.`addr` AS `contact-addr`,
1866 `contact`.`name` AS `contact-name`,
1867 `contact`.`nick` AS `contact-nick`,
1868 `contact`.`thumb` AS `contact-avatar`,
1869 `contact`.`network` AS `contact-network`,
1870 `contact`.`blocked` AS `contact-blocked`,
1871 `contact`.`hidden` AS `contact-hidden`,
1872 `contact`.`readonly` AS `contact-readonly`,
1873 `contact`.`archive` AS `contact-archive`,
1874 `contact`.`pending` AS `contact-pending`,
1875 `contact`.`rel` AS `contact-rel`,
1876 `contact`.`uid` AS `contact-uid`,
1877 `contact`.`contact-type` AS `contact-contact-type`,
1878 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1879 `contact`.`self` AS `self`,
1880 `contact`.`id` AS `cid`,
1881 `contact`.`alias` AS `alias`,
1882 `contact`.`photo` AS `photo`,
1883 `contact`.`name-date` AS `name-date`,
1884 `contact`.`uri-date` AS `uri-date`,
1885 `contact`.`avatar-date` AS `avatar-date`,
1886 `contact`.`thumb` AS `thumb`,
1887 `post-user`.`author-id` AS `author-id`,
1888 `author`.`uri-id` AS `author-uri-id`,
1889 `author`.`url` AS `author-link`,
1890 `author`.`addr` AS `author-addr`,
1891 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1892 `author`.`nick` AS `author-nick`,
1893 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1894 `author`.`network` AS `author-network`,
1895 `author`.`blocked` AS `author-blocked`,
1896 `author`.`hidden` AS `author-hidden`,
1897 `author`.`updated` AS `author-updated`,
1898 `author`.`gsid` AS `author-gsid`,
1899 `post-user`.`owner-id` AS `owner-id`,
1900 `owner`.`uri-id` AS `owner-uri-id`,
1901 `owner`.`url` AS `owner-link`,
1902 `owner`.`addr` AS `owner-addr`,
1903 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1904 `owner`.`nick` AS `owner-nick`,
1905 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1906 `owner`.`network` AS `owner-network`,
1907 `owner`.`blocked` AS `owner-blocked`,
1908 `owner`.`hidden` AS `owner-hidden`,
1909 `owner`.`updated` AS `owner-updated`,
1910 `owner`.`contact-type` AS `owner-contact-type`,
1911 `post-user`.`causer-id` AS `causer-id`,
1912 `causer`.`uri-id` AS `causer-uri-id`,
1913 `causer`.`url` AS `causer-link`,
1914 `causer`.`addr` AS `causer-addr`,
1915 `causer`.`name` AS `causer-name`,
1916 `causer`.`nick` AS `causer-nick`,
1917 `causer`.`thumb` AS `causer-avatar`,
1918 `causer`.`network` AS `causer-network`,
1919 `causer`.`blocked` AS `causer-blocked`,
1920 `causer`.`hidden` AS `causer-hidden`,
1921 `causer`.`contact-type` AS `causer-contact-type`,
1922 `post-delivery-data`.`postopts` AS `postopts`,
1923 `post-delivery-data`.`inform` AS `inform`,
1924 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1925 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1926 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1927 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1928 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1929 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1930 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1931 `post-user`.`event-id` AS `event-id`,
1932 `event`.`created` AS `event-created`,
1933 `event`.`edited` AS `event-edited`,
1934 `event`.`start` AS `event-start`,
1935 `event`.`finish` AS `event-finish`,
1936 `event`.`summary` AS `event-summary`,
1937 `event`.`desc` AS `event-desc`,
1938 `event`.`location` AS `event-location`,
1939 `event`.`type` AS `event-type`,
1940 `event`.`nofinish` AS `event-nofinish`,
1941 `event`.`ignore` AS `event-ignore`,
1942 `post-question`.`id` AS `question-id`,
1943 `post-question`.`multiple` AS `question-multiple`,
1944 `post-question`.`voters` AS `question-voters`,
1945 `post-question`.`end-time` AS `question-end-time`,
1946 EXISTS(SELECT `uri-id` FROM `post-category` WHERE `post-category`.`uri-id` = `post-user`.`uri-id` AND `post-category`.`uid` = `post-user`.`uid`) AS `has-categories`,
1947 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-user`.`uri-id`) AS `has-media`,
1948 `diaspora-interaction`.`interaction` AS `signed_text`,
1949 `parent-item-uri`.`guid` AS `parent-guid`,
1950 `parent-post`.`network` AS `parent-network`,
1951 `parent-post`.`author-id` AS `parent-author-id`,
1952 `parent-post-author`.`url` AS `parent-author-link`,
1953 `parent-post-author`.`name` AS `parent-author-name`,
1954 `parent-post-author`.`nick` AS `parent-author-nick`,
1955 `parent-post-author`.`network` AS `parent-author-network`,
1956 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1957 `parent-post-author`.`hidden` AS `parent-author-hidden`
1959 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
1960 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
1961 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
1962 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
1963 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
1964 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
1965 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1966 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1967 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
1968 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1969 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1970 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1971 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
1972 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
1973 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
1974 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
1975 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-user`.`uri-id`
1976 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
1977 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
1978 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1981 -- VIEW post-thread-user-view
1983 DROP VIEW IF EXISTS `post-thread-user-view`;
1984 CREATE VIEW `post-thread-user-view` AS SELECT
1985 `post-user`.`id` AS `id`,
1986 `post-user`.`id` AS `post-user-id`,
1987 `post-thread-user`.`uid` AS `uid`,
1988 `parent-post`.`id` AS `parent`,
1989 `item-uri`.`uri` AS `uri`,
1990 `post-thread-user`.`uri-id` AS `uri-id`,
1991 `parent-item-uri`.`uri` AS `parent-uri`,
1992 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1993 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1994 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1995 `conversation-item-uri`.`uri` AS `conversation`,
1996 `post-thread-user`.`conversation-id` AS `conversation-id`,
1997 `quote-item-uri`.`uri` AS `quote-uri`,
1998 `post-content`.`quote-uri-id` AS `quote-uri-id`,
1999 `item-uri`.`guid` AS `guid`,
2000 `post-thread-user`.`wall` AS `wall`,
2001 `post-user`.`gravity` AS `gravity`,
2002 `external-item-uri`.`uri` AS `extid`,
2003 `post-user`.`external-id` AS `external-id`,
2004 `post-thread-user`.`created` AS `created`,
2005 `post-user`.`edited` AS `edited`,
2006 `post-thread-user`.`commented` AS `commented`,
2007 `post-thread-user`.`received` AS `received`,
2008 `post-thread-user`.`changed` AS `changed`,
2009 `post-user`.`post-type` AS `post-type`,
2010 `post-user`.`post-reason` AS `post-reason`,
2011 `post-user`.`private` AS `private`,
2012 `post-thread-user`.`pubmail` AS `pubmail`,
2013 `post-thread-user`.`ignored` AS `ignored`,
2014 `post-user`.`visible` AS `visible`,
2015 `post-thread-user`.`starred` AS `starred`,
2016 `post-thread-user`.`unseen` AS `unseen`,
2017 `post-user`.`deleted` AS `deleted`,
2018 `post-thread-user`.`origin` AS `origin`,
2019 `post-thread-user`.`mention` AS `mention`,
2020 `post-user`.`global` AS `global`,
2021 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread-user`.`uri-id`) AS `featured`,
2022 `post-thread-user`.`network` AS `network`,
2023 `post-user`.`vid` AS `vid`,
2024 `post-thread-user`.`psid` AS `psid`,
2025 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2026 `post-content`.`title` AS `title`,
2027 `post-content`.`content-warning` AS `content-warning`,
2028 `post-content`.`raw-body` AS `raw-body`,
2029 `post-content`.`body` AS `body`,
2030 `post-content`.`rendered-hash` AS `rendered-hash`,
2031 `post-content`.`rendered-html` AS `rendered-html`,
2032 `post-content`.`language` AS `language`,
2033 `post-content`.`plink` AS `plink`,
2034 `post-content`.`location` AS `location`,
2035 `post-content`.`coord` AS `coord`,
2036 `post-content`.`app` AS `app`,
2037 `post-content`.`object-type` AS `object-type`,
2038 `post-content`.`object` AS `object`,
2039 `post-content`.`target-type` AS `target-type`,
2040 `post-content`.`target` AS `target`,
2041 `post-content`.`resource-id` AS `resource-id`,
2042 `post-thread-user`.`contact-id` AS `contact-id`,
2043 `contact`.`uri-id` AS `contact-uri-id`,
2044 `contact`.`url` AS `contact-link`,
2045 `contact`.`addr` AS `contact-addr`,
2046 `contact`.`name` AS `contact-name`,
2047 `contact`.`nick` AS `contact-nick`,
2048 `contact`.`thumb` AS `contact-avatar`,
2049 `contact`.`network` AS `contact-network`,
2050 `contact`.`blocked` AS `contact-blocked`,
2051 `contact`.`hidden` AS `contact-hidden`,
2052 `contact`.`readonly` AS `contact-readonly`,
2053 `contact`.`archive` AS `contact-archive`,
2054 `contact`.`pending` AS `contact-pending`,
2055 `contact`.`rel` AS `contact-rel`,
2056 `contact`.`uid` AS `contact-uid`,
2057 `contact`.`contact-type` AS `contact-contact-type`,
2058 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
2059 `contact`.`self` AS `self`,
2060 `contact`.`id` AS `cid`,
2061 `contact`.`alias` AS `alias`,
2062 `contact`.`photo` AS `photo`,
2063 `contact`.`name-date` AS `name-date`,
2064 `contact`.`uri-date` AS `uri-date`,
2065 `contact`.`avatar-date` AS `avatar-date`,
2066 `contact`.`thumb` AS `thumb`,
2067 `post-thread-user`.`author-id` AS `author-id`,
2068 `author`.`uri-id` AS `author-uri-id`,
2069 `author`.`url` AS `author-link`,
2070 `author`.`addr` AS `author-addr`,
2071 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
2072 `author`.`nick` AS `author-nick`,
2073 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
2074 `author`.`network` AS `author-network`,
2075 `author`.`blocked` AS `author-blocked`,
2076 `author`.`hidden` AS `author-hidden`,
2077 `author`.`updated` AS `author-updated`,
2078 `author`.`gsid` AS `author-gsid`,
2079 `post-thread-user`.`owner-id` AS `owner-id`,
2080 `owner`.`uri-id` AS `owner-uri-id`,
2081 `owner`.`url` AS `owner-link`,
2082 `owner`.`addr` AS `owner-addr`,
2083 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
2084 `owner`.`nick` AS `owner-nick`,
2085 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
2086 `owner`.`network` AS `owner-network`,
2087 `owner`.`blocked` AS `owner-blocked`,
2088 `owner`.`hidden` AS `owner-hidden`,
2089 `owner`.`updated` AS `owner-updated`,
2090 `owner`.`contact-type` AS `owner-contact-type`,
2091 `post-thread-user`.`causer-id` AS `causer-id`,
2092 `causer`.`uri-id` AS `causer-uri-id`,
2093 `causer`.`url` AS `causer-link`,
2094 `causer`.`addr` AS `causer-addr`,
2095 `causer`.`name` AS `causer-name`,
2096 `causer`.`nick` AS `causer-nick`,
2097 `causer`.`thumb` AS `causer-avatar`,
2098 `causer`.`network` AS `causer-network`,
2099 `causer`.`blocked` AS `causer-blocked`,
2100 `causer`.`hidden` AS `causer-hidden`,
2101 `causer`.`contact-type` AS `causer-contact-type`,
2102 `post-delivery-data`.`postopts` AS `postopts`,
2103 `post-delivery-data`.`inform` AS `inform`,
2104 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
2105 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
2106 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
2107 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
2108 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
2109 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
2110 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
2111 `post-user`.`event-id` AS `event-id`,
2112 `event`.`created` AS `event-created`,
2113 `event`.`edited` AS `event-edited`,
2114 `event`.`start` AS `event-start`,
2115 `event`.`finish` AS `event-finish`,
2116 `event`.`summary` AS `event-summary`,
2117 `event`.`desc` AS `event-desc`,
2118 `event`.`location` AS `event-location`,
2119 `event`.`type` AS `event-type`,
2120 `event`.`nofinish` AS `event-nofinish`,
2121 `event`.`ignore` AS `event-ignore`,
2122 `post-question`.`id` AS `question-id`,
2123 `post-question`.`multiple` AS `question-multiple`,
2124 `post-question`.`voters` AS `question-voters`,
2125 `post-question`.`end-time` AS `question-end-time`,
2126 EXISTS(SELECT `uri-id` FROM `post-category` WHERE `post-category`.`uri-id` = `post-thread-user`.`uri-id` AND `post-category`.`uid` = `post-thread-user`.`uid`) AS `has-categories`,
2127 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread-user`.`uri-id`) AS `has-media`,
2128 `diaspora-interaction`.`interaction` AS `signed_text`,
2129 `parent-item-uri`.`guid` AS `parent-guid`,
2130 `parent-post`.`network` AS `parent-network`,
2131 `parent-post`.`author-id` AS `parent-author-id`,
2132 `parent-post-author`.`url` AS `parent-author-link`,
2133 `parent-post-author`.`name` AS `parent-author-name`,
2134 `parent-post-author`.`network` AS `parent-author-network`,
2135 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2136 `parent-post-author`.`hidden` AS `parent-author-hidden`
2137 FROM `post-thread-user`
2138 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2139 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2140 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
2141 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
2142 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
2143 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
2144 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
2145 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
2146 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
2147 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
2148 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
2149 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
2150 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
2151 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
2152 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2153 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
2154 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread-user`.`uri-id`
2155 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
2156 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`
2157 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2162 DROP VIEW IF EXISTS `post-view`;
2163 CREATE VIEW `post-view` AS SELECT
2164 `item-uri`.`uri` AS `uri`,
2165 `post`.`uri-id` AS `uri-id`,
2166 `parent-item-uri`.`uri` AS `parent-uri`,
2167 `post`.`parent-uri-id` AS `parent-uri-id`,
2168 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2169 `post`.`thr-parent-id` AS `thr-parent-id`,
2170 `conversation-item-uri`.`uri` AS `conversation`,
2171 `post-thread`.`conversation-id` AS `conversation-id`,
2172 `quote-item-uri`.`uri` AS `quote-uri`,
2173 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2174 `item-uri`.`guid` AS `guid`,
2175 `post`.`gravity` AS `gravity`,
2176 `external-item-uri`.`uri` AS `extid`,
2177 `post`.`external-id` AS `external-id`,
2178 `post`.`created` AS `created`,
2179 `post`.`edited` AS `edited`,
2180 `post-thread`.`commented` AS `commented`,
2181 `post`.`received` AS `received`,
2182 `post-thread`.`changed` AS `changed`,
2183 `post`.`post-type` AS `post-type`,
2184 `post`.`private` AS `private`,
2185 `post`.`visible` AS `visible`,
2186 `post`.`deleted` AS `deleted`,
2187 `post`.`global` AS `global`,
2188 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post`.`uri-id`) AS `featured`,
2189 `post`.`network` AS `network`,
2190 `post`.`vid` AS `vid`,
2191 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2192 `post-content`.`title` AS `title`,
2193 `post-content`.`content-warning` AS `content-warning`,
2194 `post-content`.`raw-body` AS `raw-body`,
2195 `post-content`.`body` AS `body`,
2196 `post-content`.`rendered-hash` AS `rendered-hash`,
2197 `post-content`.`rendered-html` AS `rendered-html`,
2198 `post-content`.`language` AS `language`,
2199 `post-content`.`plink` AS `plink`,
2200 `post-content`.`location` AS `location`,
2201 `post-content`.`coord` AS `coord`,
2202 `post-content`.`app` AS `app`,
2203 `post-content`.`object-type` AS `object-type`,
2204 `post-content`.`object` AS `object`,
2205 `post-content`.`target-type` AS `target-type`,
2206 `post-content`.`target` AS `target`,
2207 `post-content`.`resource-id` AS `resource-id`,
2208 `post`.`author-id` AS `contact-id`,
2209 `author`.`uri-id` AS `contact-uri-id`,
2210 `author`.`url` AS `contact-link`,
2211 `author`.`addr` AS `contact-addr`,
2212 `author`.`name` AS `contact-name`,
2213 `author`.`nick` AS `contact-nick`,
2214 `author`.`thumb` AS `contact-avatar`,
2215 `author`.`network` AS `contact-network`,
2216 `author`.`blocked` AS `contact-blocked`,
2217 `author`.`hidden` AS `contact-hidden`,
2218 `author`.`readonly` AS `contact-readonly`,
2219 `author`.`archive` AS `contact-archive`,
2220 `author`.`pending` AS `contact-pending`,
2221 `author`.`rel` AS `contact-rel`,
2222 `author`.`uid` AS `contact-uid`,
2223 `author`.`contact-type` AS `contact-contact-type`,
2224 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2226 `author`.`id` AS `cid`,
2227 `author`.`alias` AS `alias`,
2228 `author`.`photo` AS `photo`,
2229 `author`.`name-date` AS `name-date`,
2230 `author`.`uri-date` AS `uri-date`,
2231 `author`.`avatar-date` AS `avatar-date`,
2232 `author`.`thumb` AS `thumb`,
2233 `post`.`author-id` AS `author-id`,
2234 `author`.`uri-id` AS `author-uri-id`,
2235 `author`.`url` AS `author-link`,
2236 `author`.`addr` AS `author-addr`,
2237 `author`.`name` AS `author-name`,
2238 `author`.`nick` AS `author-nick`,
2239 `author`.`thumb` AS `author-avatar`,
2240 `author`.`network` AS `author-network`,
2241 `author`.`blocked` AS `author-blocked`,
2242 `author`.`hidden` AS `author-hidden`,
2243 `author`.`updated` AS `author-updated`,
2244 `author`.`gsid` AS `author-gsid`,
2245 `post`.`owner-id` AS `owner-id`,
2246 `owner`.`uri-id` AS `owner-uri-id`,
2247 `owner`.`url` AS `owner-link`,
2248 `owner`.`addr` AS `owner-addr`,
2249 `owner`.`name` AS `owner-name`,
2250 `owner`.`nick` AS `owner-nick`,
2251 `owner`.`thumb` AS `owner-avatar`,
2252 `owner`.`network` AS `owner-network`,
2253 `owner`.`blocked` AS `owner-blocked`,
2254 `owner`.`hidden` AS `owner-hidden`,
2255 `owner`.`updated` AS `owner-updated`,
2256 `owner`.`contact-type` AS `owner-contact-type`,
2257 `post`.`causer-id` AS `causer-id`,
2258 `causer`.`uri-id` AS `causer-uri-id`,
2259 `causer`.`url` AS `causer-link`,
2260 `causer`.`addr` AS `causer-addr`,
2261 `causer`.`name` AS `causer-name`,
2262 `causer`.`nick` AS `causer-nick`,
2263 `causer`.`thumb` AS `causer-avatar`,
2264 `causer`.`network` AS `causer-network`,
2265 `causer`.`blocked` AS `causer-blocked`,
2266 `causer`.`hidden` AS `causer-hidden`,
2267 `causer`.`contact-type` AS `causer-contact-type`,
2268 `post-question`.`id` AS `question-id`,
2269 `post-question`.`multiple` AS `question-multiple`,
2270 `post-question`.`voters` AS `question-voters`,
2271 `post-question`.`end-time` AS `question-end-time`,
2272 0 AS `has-categories`,
2273 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post`.`uri-id`) AS `has-media`,
2274 `diaspora-interaction`.`interaction` AS `signed_text`,
2275 `parent-item-uri`.`guid` AS `parent-guid`,
2276 `parent-post`.`network` AS `parent-network`,
2277 `parent-post`.`author-id` AS `parent-author-id`,
2278 `parent-post-author`.`url` AS `parent-author-link`,
2279 `parent-post-author`.`name` AS `parent-author-name`,
2280 `parent-post-author`.`network` AS `parent-author-network`,
2281 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2282 `parent-post-author`.`hidden` AS `parent-author-hidden`
2284 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
2285 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
2286 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
2287 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
2288 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
2289 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2290 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2291 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
2292 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2293 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2294 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
2295 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
2296 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2297 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post`.`uri-id`
2298 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2299 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2302 -- VIEW post-thread-view
2304 DROP VIEW IF EXISTS `post-thread-view`;
2305 CREATE VIEW `post-thread-view` AS SELECT
2306 `item-uri`.`uri` AS `uri`,
2307 `post-thread`.`uri-id` AS `uri-id`,
2308 `parent-item-uri`.`uri` AS `parent-uri`,
2309 `post`.`parent-uri-id` AS `parent-uri-id`,
2310 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2311 `post`.`thr-parent-id` AS `thr-parent-id`,
2312 `conversation-item-uri`.`uri` AS `conversation`,
2313 `post-thread`.`conversation-id` AS `conversation-id`,
2314 `quote-item-uri`.`uri` AS `quote-uri`,
2315 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2316 `item-uri`.`guid` AS `guid`,
2317 `post`.`gravity` AS `gravity`,
2318 `external-item-uri`.`uri` AS `extid`,
2319 `post`.`external-id` AS `external-id`,
2320 `post-thread`.`created` AS `created`,
2321 `post`.`edited` AS `edited`,
2322 `post-thread`.`commented` AS `commented`,
2323 `post-thread`.`received` AS `received`,
2324 `post-thread`.`changed` AS `changed`,
2325 `post`.`post-type` AS `post-type`,
2326 `post`.`private` AS `private`,
2327 `post`.`visible` AS `visible`,
2328 `post`.`deleted` AS `deleted`,
2329 `post`.`global` AS `global`,
2330 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread`.`uri-id`) AS `featured`,
2331 `post-thread`.`network` AS `network`,
2332 `post`.`vid` AS `vid`,
2333 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2334 `post-content`.`title` AS `title`,
2335 `post-content`.`content-warning` AS `content-warning`,
2336 `post-content`.`raw-body` AS `raw-body`,
2337 `post-content`.`body` AS `body`,
2338 `post-content`.`rendered-hash` AS `rendered-hash`,
2339 `post-content`.`rendered-html` AS `rendered-html`,
2340 `post-content`.`language` AS `language`,
2341 `post-content`.`plink` AS `plink`,
2342 `post-content`.`location` AS `location`,
2343 `post-content`.`coord` AS `coord`,
2344 `post-content`.`app` AS `app`,
2345 `post-content`.`object-type` AS `object-type`,
2346 `post-content`.`object` AS `object`,
2347 `post-content`.`target-type` AS `target-type`,
2348 `post-content`.`target` AS `target`,
2349 `post-content`.`resource-id` AS `resource-id`,
2350 `post-thread`.`author-id` AS `contact-id`,
2351 `author`.`uri-id` AS `contact-uri-id`,
2352 `author`.`url` AS `contact-link`,
2353 `author`.`addr` AS `contact-addr`,
2354 `author`.`name` AS `contact-name`,
2355 `author`.`nick` AS `contact-nick`,
2356 `author`.`thumb` AS `contact-avatar`,
2357 `author`.`network` AS `contact-network`,
2358 `author`.`blocked` AS `contact-blocked`,
2359 `author`.`hidden` AS `contact-hidden`,
2360 `author`.`readonly` AS `contact-readonly`,
2361 `author`.`archive` AS `contact-archive`,
2362 `author`.`pending` AS `contact-pending`,
2363 `author`.`rel` AS `contact-rel`,
2364 `author`.`uid` AS `contact-uid`,
2365 `author`.`contact-type` AS `contact-contact-type`,
2366 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2368 `author`.`id` AS `cid`,
2369 `author`.`alias` AS `alias`,
2370 `author`.`photo` AS `photo`,
2371 `author`.`name-date` AS `name-date`,
2372 `author`.`uri-date` AS `uri-date`,
2373 `author`.`avatar-date` AS `avatar-date`,
2374 `author`.`thumb` AS `thumb`,
2375 `post-thread`.`author-id` AS `author-id`,
2376 `author`.`uri-id` AS `author-uri-id`,
2377 `author`.`url` AS `author-link`,
2378 `author`.`addr` AS `author-addr`,
2379 `author`.`name` AS `author-name`,
2380 `author`.`nick` AS `author-nick`,
2381 `author`.`thumb` AS `author-avatar`,
2382 `author`.`network` AS `author-network`,
2383 `author`.`blocked` AS `author-blocked`,
2384 `author`.`hidden` AS `author-hidden`,
2385 `author`.`updated` AS `author-updated`,
2386 `author`.`gsid` AS `author-gsid`,
2387 `post-thread`.`owner-id` AS `owner-id`,
2388 `owner`.`uri-id` AS `owner-uri-id`,
2389 `owner`.`url` AS `owner-link`,
2390 `owner`.`addr` AS `owner-addr`,
2391 `owner`.`name` AS `owner-name`,
2392 `owner`.`nick` AS `owner-nick`,
2393 `owner`.`thumb` AS `owner-avatar`,
2394 `owner`.`network` AS `owner-network`,
2395 `owner`.`blocked` AS `owner-blocked`,
2396 `owner`.`hidden` AS `owner-hidden`,
2397 `owner`.`updated` AS `owner-updated`,
2398 `owner`.`contact-type` AS `owner-contact-type`,
2399 `post-thread`.`causer-id` AS `causer-id`,
2400 `causer`.`uri-id` AS `causer-uri-id`,
2401 `causer`.`url` AS `causer-link`,
2402 `causer`.`addr` AS `causer-addr`,
2403 `causer`.`name` AS `causer-name`,
2404 `causer`.`nick` AS `causer-nick`,
2405 `causer`.`thumb` AS `causer-avatar`,
2406 `causer`.`network` AS `causer-network`,
2407 `causer`.`blocked` AS `causer-blocked`,
2408 `causer`.`hidden` AS `causer-hidden`,
2409 `causer`.`contact-type` AS `causer-contact-type`,
2410 `post-question`.`id` AS `question-id`,
2411 `post-question`.`multiple` AS `question-multiple`,
2412 `post-question`.`voters` AS `question-voters`,
2413 `post-question`.`end-time` AS `question-end-time`,
2414 0 AS `has-categories`,
2415 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread`.`uri-id`) AS `has-media`,
2416 `diaspora-interaction`.`interaction` AS `signed_text`,
2417 `parent-item-uri`.`guid` AS `parent-guid`,
2418 `parent-post`.`network` AS `parent-network`,
2419 `parent-post`.`author-id` AS `parent-author-id`,
2420 `parent-post-author`.`url` AS `parent-author-link`,
2421 `parent-post-author`.`name` AS `parent-author-name`,
2422 `parent-post-author`.`network` AS `parent-author-network`,
2423 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2424 `parent-post-author`.`hidden` AS `parent-author-hidden`
2426 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
2427 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
2428 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
2429 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
2430 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
2431 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2432 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2433 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
2434 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2435 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2436 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
2437 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
2438 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2439 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread`.`uri-id`
2440 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2441 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2444 -- VIEW category-view
2446 DROP VIEW IF EXISTS `category-view`;
2447 CREATE VIEW `category-view` AS SELECT
2448 `post-category`.`uri-id` AS `uri-id`,
2449 `post-category`.`uid` AS `uid`,
2450 `post-category`.`type` AS `type`,
2451 `post-category`.`tid` AS `tid`,
2452 `tag`.`name` AS `name`,
2453 `tag`.`url` AS `url`
2454 FROM `post-category`
2455 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2458 -- VIEW collection-view
2460 DROP VIEW IF EXISTS `collection-view`;
2461 CREATE VIEW `collection-view` AS SELECT
2462 `post-collection`.`uri-id` AS `uri-id`,
2463 `post-collection`.`type` AS `type`,
2464 `post-collection`.`author-id` AS `cid`,
2465 `post`.`received` AS `received`,
2466 `post`.`created` AS `created`,
2467 `post-thread`.`commented` AS `commented`,
2468 `post`.`private` AS `private`,
2469 `post`.`visible` AS `visible`,
2470 `post`.`deleted` AS `deleted`,
2471 `post`.`thr-parent-id` AS `thr-parent-id`,
2472 `post-collection`.`author-id` AS `author-id`,
2473 `post`.`gravity` AS `gravity`
2474 FROM `post-collection`
2475 INNER JOIN `post` ON `post-collection`.`uri-id` = `post`.`uri-id`
2476 INNER JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`;
2481 DROP VIEW IF EXISTS `tag-view`;
2482 CREATE VIEW `tag-view` AS SELECT
2483 `post-tag`.`uri-id` AS `uri-id`,
2484 `post-tag`.`type` AS `type`,
2485 `post-tag`.`tid` AS `tid`,
2486 `post-tag`.`cid` AS `cid`,
2487 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2488 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`,
2489 CASE `cid` WHEN 0 THEN `tag`.`type` ELSE 1 END AS `tag-type`
2491 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2492 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2495 -- VIEW network-item-view
2497 DROP VIEW IF EXISTS `network-item-view`;
2498 CREATE VIEW `network-item-view` AS SELECT
2499 `post-user`.`uri-id` AS `uri-id`,
2500 `parent-post`.`id` AS `parent`,
2501 `post-user`.`received` AS `received`,
2502 `post-thread-user`.`commented` AS `commented`,
2503 `post-user`.`created` AS `created`,
2504 `post-user`.`uid` AS `uid`,
2505 `post-thread-user`.`starred` AS `starred`,
2506 `post-thread-user`.`mention` AS `mention`,
2507 `post-user`.`network` AS `network`,
2508 `post-user`.`unseen` AS `unseen`,
2509 `post-user`.`gravity` AS `gravity`,
2510 `post-user`.`contact-id` AS `contact-id`,
2511 `ownercontact`.`contact-type` AS `contact-type`
2513 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2514 INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2515 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2516 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2517 INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2518 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2519 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2520 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2521 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
2522 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2523 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2526 -- VIEW network-thread-view
2528 DROP VIEW IF EXISTS `network-thread-view`;
2529 CREATE VIEW `network-thread-view` AS SELECT
2530 `post-thread-user`.`uri-id` AS `uri-id`,
2531 `parent-post`.`id` AS `parent`,
2532 `post-thread-user`.`received` AS `received`,
2533 `post-thread-user`.`commented` AS `commented`,
2534 `post-thread-user`.`created` AS `created`,
2535 `post-thread-user`.`uid` AS `uid`,
2536 `post-thread-user`.`starred` AS `starred`,
2537 `post-thread-user`.`mention` AS `mention`,
2538 `post-thread-user`.`network` AS `network`,
2539 `post-thread-user`.`contact-id` AS `contact-id`,
2540 `ownercontact`.`contact-type` AS `contact-type`
2541 FROM `post-thread-user`
2542 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2543 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2544 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2545 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2546 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2547 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2548 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2549 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2550 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2551 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2552 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2557 DROP VIEW IF EXISTS `owner-view`;
2558 CREATE VIEW `owner-view` AS SELECT
2559 `contact`.`id` AS `id`,
2560 `contact`.`uid` AS `uid`,
2561 `contact`.`created` AS `created`,
2562 `contact`.`updated` AS `updated`,
2563 `contact`.`self` AS `self`,
2564 `contact`.`remote_self` AS `remote_self`,
2565 `contact`.`rel` AS `rel`,
2566 `contact`.`network` AS `network`,
2567 `contact`.`protocol` AS `protocol`,
2568 `contact`.`name` AS `name`,
2569 `contact`.`nick` AS `nick`,
2570 `contact`.`location` AS `location`,
2571 `contact`.`about` AS `about`,
2572 `contact`.`keywords` AS `keywords`,
2573 `contact`.`xmpp` AS `xmpp`,
2574 `contact`.`matrix` AS `matrix`,
2575 `contact`.`attag` AS `attag`,
2576 `contact`.`avatar` AS `avatar`,
2577 `contact`.`photo` AS `photo`,
2578 `contact`.`thumb` AS `thumb`,
2579 `contact`.`micro` AS `micro`,
2580 `contact`.`header` AS `header`,
2581 `contact`.`url` AS `url`,
2582 `contact`.`nurl` AS `nurl`,
2583 `contact`.`uri-id` AS `uri-id`,
2584 `contact`.`addr` AS `addr`,
2585 `contact`.`alias` AS `alias`,
2586 `contact`.`pubkey` AS `pubkey`,
2587 `contact`.`prvkey` AS `prvkey`,
2588 `contact`.`batch` AS `batch`,
2589 `contact`.`request` AS `request`,
2590 `contact`.`notify` AS `notify`,
2591 `contact`.`poll` AS `poll`,
2592 `contact`.`confirm` AS `confirm`,
2593 `contact`.`poco` AS `poco`,
2594 `contact`.`subhub` AS `subhub`,
2595 `contact`.`hub-verify` AS `hub-verify`,
2596 `contact`.`last-update` AS `last-update`,
2597 `contact`.`success_update` AS `success_update`,
2598 `contact`.`failure_update` AS `failure_update`,
2599 `contact`.`name-date` AS `name-date`,
2600 `contact`.`uri-date` AS `uri-date`,
2601 `contact`.`avatar-date` AS `avatar-date`,
2602 `contact`.`avatar-date` AS `picdate`,
2603 `contact`.`term-date` AS `term-date`,
2604 `contact`.`last-item` AS `last-item`,
2605 `contact`.`priority` AS `priority`,
2606 `user`.`blocked` AS `blocked`,
2607 `contact`.`block_reason` AS `block_reason`,
2608 `contact`.`readonly` AS `readonly`,
2609 `contact`.`writable` AS `writable`,
2610 `contact`.`forum` AS `forum`,
2611 `contact`.`prv` AS `prv`,
2612 `contact`.`contact-type` AS `contact-type`,
2613 `contact`.`manually-approve` AS `manually-approve`,
2614 `contact`.`hidden` AS `hidden`,
2615 `contact`.`archive` AS `archive`,
2616 `contact`.`pending` AS `pending`,
2617 `contact`.`deleted` AS `deleted`,
2618 `contact`.`unsearchable` AS `unsearchable`,
2619 `contact`.`sensitive` AS `sensitive`,
2620 `contact`.`baseurl` AS `baseurl`,
2621 `contact`.`reason` AS `reason`,
2622 `contact`.`info` AS `info`,
2623 `contact`.`bdyear` AS `bdyear`,
2624 `contact`.`bd` AS `bd`,
2625 `contact`.`notify_new_posts` AS `notify_new_posts`,
2626 `contact`.`fetch_further_information` AS `fetch_further_information`,
2627 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2628 `user`.`parent-uid` AS `parent-uid`,
2629 `user`.`guid` AS `guid`,
2630 `user`.`nickname` AS `nickname`,
2631 `user`.`email` AS `email`,
2632 `user`.`openid` AS `openid`,
2633 `user`.`timezone` AS `timezone`,
2634 `user`.`language` AS `language`,
2635 `user`.`register_date` AS `register_date`,
2636 `user`.`login_date` AS `login_date`,
2637 `user`.`default-location` AS `default-location`,
2638 `user`.`allow_location` AS `allow_location`,
2639 `user`.`theme` AS `theme`,
2640 `user`.`pubkey` AS `upubkey`,
2641 `user`.`prvkey` AS `uprvkey`,
2642 `user`.`sprvkey` AS `sprvkey`,
2643 `user`.`spubkey` AS `spubkey`,
2644 `user`.`verified` AS `verified`,
2645 `user`.`blockwall` AS `blockwall`,
2646 `user`.`hidewall` AS `hidewall`,
2647 `user`.`blocktags` AS `blocktags`,
2648 `user`.`unkmail` AS `unkmail`,
2649 `user`.`cntunkmail` AS `cntunkmail`,
2650 `user`.`notify-flags` AS `notify-flags`,
2651 `user`.`page-flags` AS `page-flags`,
2652 `user`.`account-type` AS `account-type`,
2653 `user`.`prvnets` AS `prvnets`,
2654 `user`.`maxreq` AS `maxreq`,
2655 `user`.`expire` AS `expire`,
2656 `user`.`account_removed` AS `account_removed`,
2657 `user`.`account_expired` AS `account_expired`,
2658 `user`.`account_expires_on` AS `account_expires_on`,
2659 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2660 `user`.`def_gid` AS `def_gid`,
2661 `user`.`allow_cid` AS `allow_cid`,
2662 `user`.`allow_gid` AS `allow_gid`,
2663 `user`.`deny_cid` AS `deny_cid`,
2664 `user`.`deny_gid` AS `deny_gid`,
2665 `user`.`openidserver` AS `openidserver`,
2666 `profile`.`publish` AS `publish`,
2667 `profile`.`net-publish` AS `net-publish`,
2668 `profile`.`hide-friends` AS `hide-friends`,
2669 `profile`.`prv_keywords` AS `prv_keywords`,
2670 `profile`.`pub_keywords` AS `pub_keywords`,
2671 `profile`.`address` AS `address`,
2672 `profile`.`locality` AS `locality`,
2673 `profile`.`region` AS `region`,
2674 `profile`.`postal-code` AS `postal-code`,
2675 `profile`.`country-name` AS `country-name`,
2676 `profile`.`homepage` AS `homepage`,
2677 `profile`.`dob` AS `dob`
2679 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2680 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2683 -- VIEW account-view
2685 DROP VIEW IF EXISTS `account-view`;
2686 CREATE VIEW `account-view` AS SELECT
2687 `contact`.`id` AS `id`,
2688 `contact`.`url` AS `url`,
2689 `contact`.`nurl` AS `nurl`,
2690 `contact`.`uri-id` AS `uri-id`,
2691 `item-uri`.`guid` AS `guid`,
2692 `contact`.`addr` AS `addr`,
2693 `contact`.`alias` AS `alias`,
2694 `contact`.`name` AS `name`,
2695 `contact`.`nick` AS `nick`,
2696 `contact`.`about` AS `about`,
2697 `contact`.`keywords` AS `keywords`,
2698 `contact`.`xmpp` AS `xmpp`,
2699 `contact`.`matrix` AS `matrix`,
2700 `contact`.`avatar` AS `avatar`,
2701 `contact`.`photo` AS `photo`,
2702 `contact`.`thumb` AS `thumb`,
2703 `contact`.`micro` AS `micro`,
2704 `contact`.`header` AS `header`,
2705 `contact`.`created` AS `created`,
2706 `contact`.`updated` AS `updated`,
2707 `contact`.`network` AS `network`,
2708 `contact`.`protocol` AS `protocol`,
2709 `contact`.`location` AS `location`,
2710 `contact`.`attag` AS `attag`,
2711 `contact`.`pubkey` AS `pubkey`,
2712 `contact`.`prvkey` AS `prvkey`,
2713 `contact`.`subscribe` AS `subscribe`,
2714 `contact`.`last-update` AS `last-update`,
2715 `contact`.`success_update` AS `success_update`,
2716 `contact`.`failure_update` AS `failure_update`,
2717 `contact`.`failed` AS `failed`,
2718 `contact`.`last-item` AS `last-item`,
2719 `contact`.`last-discovery` AS `last-discovery`,
2720 `contact`.`contact-type` AS `contact-type`,
2721 `contact`.`manually-approve` AS `manually-approve`,
2722 `contact`.`unsearchable` AS `unsearchable`,
2723 `contact`.`sensitive` AS `sensitive`,
2724 `contact`.`baseurl` AS `baseurl`,
2725 `contact`.`gsid` AS `gsid`,
2726 `contact`.`info` AS `info`,
2727 `contact`.`bdyear` AS `bdyear`,
2728 `contact`.`bd` AS `bd`,
2729 `contact`.`poco` AS `poco`,
2730 `contact`.`name-date` AS `name-date`,
2731 `contact`.`uri-date` AS `uri-date`,
2732 `contact`.`avatar-date` AS `avatar-date`,
2733 `contact`.`term-date` AS `term-date`,
2734 `contact`.`hidden` AS `global-ignored`,
2735 `contact`.`blocked` AS `global-blocked`,
2736 `contact`.`hidden` AS `hidden`,
2737 `contact`.`archive` AS `archive`,
2738 `contact`.`deleted` AS `deleted`,
2739 `contact`.`blocked` AS `blocked`,
2740 `contact`.`notify` AS `dfrn-notify`,
2741 `contact`.`poll` AS `dfrn-poll`,
2742 `fcontact`.`guid` AS `diaspora-guid`,
2743 `fcontact`.`batch` AS `diaspora-batch`,
2744 `fcontact`.`notify` AS `diaspora-notify`,
2745 `fcontact`.`poll` AS `diaspora-poll`,
2746 `fcontact`.`alias` AS `diaspora-alias`,
2747 `apcontact`.`uuid` AS `ap-uuid`,
2748 `apcontact`.`type` AS `ap-type`,
2749 `apcontact`.`following` AS `ap-following`,
2750 `apcontact`.`followers` AS `ap-followers`,
2751 `apcontact`.`inbox` AS `ap-inbox`,
2752 `apcontact`.`outbox` AS `ap-outbox`,
2753 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2754 `apcontact`.`generator` AS `ap-generator`,
2755 `apcontact`.`following_count` AS `ap-following_count`,
2756 `apcontact`.`followers_count` AS `ap-followers_count`,
2757 `apcontact`.`statuses_count` AS `ap-statuses_count`,
2758 `gserver`.`site_name` AS `site_name`,
2759 `gserver`.`platform` AS `platform`,
2760 `gserver`.`version` AS `version`
2762 LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id`
2763 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
2764 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = contact.`uri-id`
2765 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`
2766 WHERE `contact`.`uid` = 0;
2769 -- VIEW account-user-view
2771 DROP VIEW IF EXISTS `account-user-view`;
2772 CREATE VIEW `account-user-view` AS SELECT
2773 `ucontact`.`id` AS `id`,
2774 `contact`.`id` AS `pid`,
2775 `ucontact`.`uid` AS `uid`,
2776 `contact`.`url` AS `url`,
2777 `contact`.`nurl` AS `nurl`,
2778 `contact`.`uri-id` AS `uri-id`,
2779 `item-uri`.`guid` AS `guid`,
2780 `contact`.`addr` AS `addr`,
2781 `contact`.`alias` AS `alias`,
2782 `contact`.`name` AS `name`,
2783 `contact`.`nick` AS `nick`,
2784 `contact`.`about` AS `about`,
2785 `contact`.`keywords` AS `keywords`,
2786 `contact`.`xmpp` AS `xmpp`,
2787 `contact`.`matrix` AS `matrix`,
2788 `contact`.`avatar` AS `avatar`,
2789 `contact`.`photo` AS `photo`,
2790 `contact`.`thumb` AS `thumb`,
2791 `contact`.`micro` AS `micro`,
2792 `contact`.`header` AS `header`,
2793 `contact`.`created` AS `created`,
2794 `contact`.`updated` AS `updated`,
2795 `ucontact`.`self` AS `self`,
2796 `ucontact`.`remote_self` AS `remote_self`,
2797 `ucontact`.`rel` AS `rel`,
2798 `contact`.`network` AS `network`,
2799 `ucontact`.`protocol` AS `protocol`,
2800 `contact`.`location` AS `location`,
2801 `ucontact`.`attag` AS `attag`,
2802 `contact`.`pubkey` AS `pubkey`,
2803 `contact`.`prvkey` AS `prvkey`,
2804 `contact`.`subscribe` AS `subscribe`,
2805 `contact`.`last-update` AS `last-update`,
2806 `contact`.`success_update` AS `success_update`,
2807 `contact`.`failure_update` AS `failure_update`,
2808 `contact`.`failed` AS `failed`,
2809 `contact`.`last-item` AS `last-item`,
2810 `contact`.`last-discovery` AS `last-discovery`,
2811 `contact`.`contact-type` AS `contact-type`,
2812 `contact`.`manually-approve` AS `manually-approve`,
2813 `contact`.`unsearchable` AS `unsearchable`,
2814 `contact`.`sensitive` AS `sensitive`,
2815 `contact`.`baseurl` AS `baseurl`,
2816 `contact`.`gsid` AS `gsid`,
2817 `ucontact`.`info` AS `info`,
2818 `contact`.`bdyear` AS `bdyear`,
2819 `contact`.`bd` AS `bd`,
2820 `contact`.`poco` AS `poco`,
2821 `contact`.`name-date` AS `name-date`,
2822 `contact`.`uri-date` AS `uri-date`,
2823 `contact`.`avatar-date` AS `avatar-date`,
2824 `contact`.`term-date` AS `term-date`,
2825 `contact`.`hidden` AS `global-ignored`,
2826 `contact`.`blocked` AS `global-blocked`,
2827 `ucontact`.`hidden` AS `hidden`,
2828 `ucontact`.`archive` AS `archive`,
2829 `ucontact`.`pending` AS `pending`,
2830 `ucontact`.`deleted` AS `deleted`,
2831 `ucontact`.`notify_new_posts` AS `notify_new_posts`,
2832 `ucontact`.`fetch_further_information` AS `fetch_further_information`,
2833 `ucontact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2834 `ucontact`.`rating` AS `rating`,
2835 `ucontact`.`readonly` AS `readonly`,
2836 `ucontact`.`blocked` AS `blocked`,
2837 `ucontact`.`block_reason` AS `block_reason`,
2838 `ucontact`.`subhub` AS `subhub`,
2839 `ucontact`.`hub-verify` AS `hub-verify`,
2840 `ucontact`.`reason` AS `reason`,
2841 `contact`.`notify` AS `dfrn-notify`,
2842 `contact`.`poll` AS `dfrn-poll`,
2843 `fcontact`.`guid` AS `diaspora-guid`,
2844 `fcontact`.`batch` AS `diaspora-batch`,
2845 `fcontact`.`notify` AS `diaspora-notify`,
2846 `fcontact`.`poll` AS `diaspora-poll`,
2847 `fcontact`.`alias` AS `diaspora-alias`,
2848 `fcontact`.`interacting_count` AS `diaspora-interacting_count`,
2849 `fcontact`.`interacted_count` AS `diaspora-interacted_count`,
2850 `fcontact`.`post_count` AS `diaspora-post_count`,
2851 `apcontact`.`uuid` AS `ap-uuid`,
2852 `apcontact`.`type` AS `ap-type`,
2853 `apcontact`.`following` AS `ap-following`,
2854 `apcontact`.`followers` AS `ap-followers`,
2855 `apcontact`.`inbox` AS `ap-inbox`,
2856 `apcontact`.`outbox` AS `ap-outbox`,
2857 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2858 `apcontact`.`generator` AS `ap-generator`,
2859 `apcontact`.`following_count` AS `ap-following_count`,
2860 `apcontact`.`followers_count` AS `ap-followers_count`,
2861 `apcontact`.`statuses_count` AS `ap-statuses_count`,
2862 `gserver`.`site_name` AS `site_name`,
2863 `gserver`.`platform` AS `platform`,
2864 `gserver`.`version` AS `version`
2865 FROM `contact` AS `ucontact`
2866 INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
2867 LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id`
2868 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
2869 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = `ucontact`.`uri-id` AND `fcontact`.`network` = 'dspr'
2870 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`;
2873 -- VIEW pending-view
2875 DROP VIEW IF EXISTS `pending-view`;
2876 CREATE VIEW `pending-view` AS SELECT
2877 `register`.`id` AS `id`,
2878 `register`.`hash` AS `hash`,
2879 `register`.`created` AS `created`,
2880 `register`.`uid` AS `uid`,
2881 `register`.`password` AS `password`,
2882 `register`.`language` AS `language`,
2883 `register`.`note` AS `note`,
2884 `contact`.`self` AS `self`,
2885 `contact`.`name` AS `name`,
2886 `contact`.`url` AS `url`,
2887 `contact`.`micro` AS `micro`,
2888 `user`.`email` AS `email`,
2889 `contact`.`nick` AS `nick`
2891 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2892 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2895 -- VIEW tag-search-view
2897 DROP VIEW IF EXISTS `tag-search-view`;
2898 CREATE VIEW `tag-search-view` AS SELECT
2899 `post-tag`.`uri-id` AS `uri-id`,
2900 `post-user`.`uid` AS `uid`,
2901 `post-user`.`id` AS `iid`,
2902 `post-user`.`private` AS `private`,
2903 `post-user`.`wall` AS `wall`,
2904 `post-user`.`origin` AS `origin`,
2905 `post-user`.`global` AS `global`,
2906 `post-user`.`gravity` AS `gravity`,
2907 `post-user`.`received` AS `received`,
2908 `post-user`.`network` AS `network`,
2909 `post-user`.`author-id` AS `author-id`,
2910 `tag`.`name` AS `name`
2912 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
2913 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
2914 WHERE `post-tag`.`type` = 1;
2917 -- VIEW workerqueue-view
2919 DROP VIEW IF EXISTS `workerqueue-view`;
2920 CREATE VIEW `workerqueue-view` AS SELECT
2921 `process`.`pid` AS `pid`,
2922 `workerqueue`.`priority` AS `priority`
2924 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
2925 WHERE NOT `workerqueue`.`done`;
2928 -- VIEW profile_field-view
2930 DROP VIEW IF EXISTS `profile_field-view`;
2931 CREATE VIEW `profile_field-view` AS SELECT
2932 `profile_field`.`id` AS `id`,
2933 `profile_field`.`uid` AS `uid`,
2934 `profile_field`.`label` AS `label`,
2935 `profile_field`.`value` AS `value`,
2936 `profile_field`.`order` AS `order`,
2937 `profile_field`.`psid` AS `psid`,
2938 `permissionset`.`allow_cid` AS `allow_cid`,
2939 `permissionset`.`allow_gid` AS `allow_gid`,
2940 `permissionset`.`deny_cid` AS `deny_cid`,
2941 `permissionset`.`deny_gid` AS `deny_gid`,
2942 `profile_field`.`created` AS `created`,
2943 `profile_field`.`edited` AS `edited`
2944 FROM `profile_field`
2945 INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`;