1 -- ------------------------------------------
2 -- Friendica 2024.06-dev (Yellow Archangel)
3 -- DB_UPDATE_VERSION 1559
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 `blocked` boolean COMMENT 'Server is blocked',
38 `failed` boolean COMMENT 'Connection failed',
39 `next_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Next connection request',
41 UNIQUE INDEX `nurl` (`nurl`(190)),
42 INDEX `next_contact` (`next_contact`),
43 INDEX `network` (`network`)
44 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Global servers';
49 CREATE TABLE IF NOT EXISTS `user` (
50 `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
51 `parent-uid` mediumint unsigned COMMENT 'The parent user that has full control about this user',
52 `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
53 `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
54 `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
55 `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
56 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
57 `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
58 `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
59 `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
60 `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
61 `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
62 `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
63 `last-activity` date COMMENT 'Day of the last activity',
64 `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
65 `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
66 `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
67 `pubkey` text COMMENT 'RSA public key 4096 bit',
68 `prvkey` text COMMENT 'RSA private key 4096 bit',
69 `spubkey` text COMMENT '',
70 `sprvkey` text COMMENT '',
71 `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
72 `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
73 `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
74 `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unknown viewers',
75 `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
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 'Delay in days before deleting user-related posts. Scope is controlled by pConfig.',
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';
103 -- TABLE user-gserver
105 CREATE TABLE IF NOT EXISTS `user-gserver` (
106 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
107 `gsid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Gserver id',
108 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'server accounts are ignored for the user',
109 PRIMARY KEY(`uid`,`gsid`),
110 INDEX `gsid` (`gsid`),
111 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
112 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
113 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User settings about remote servers';
118 CREATE TABLE IF NOT EXISTS `item-uri` (
119 `id` int unsigned NOT NULL auto_increment,
120 `uri` varbinary(383) NOT NULL COMMENT 'URI of an item',
121 `guid` varbinary(255) COMMENT 'A unique identifier for an item',
123 UNIQUE INDEX `uri` (`uri`),
124 INDEX `guid` (`guid`)
125 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
130 CREATE TABLE IF NOT EXISTS `contact` (
131 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
132 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
133 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
134 `updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last contact update',
135 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network of the contact',
136 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
137 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
138 `location` varchar(255) DEFAULT '' COMMENT '',
139 `about` text COMMENT '',
140 `keywords` text COMMENT 'public keywords (interests) of the contact',
141 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
142 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
143 `avatar` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
144 `blurhash` varbinary(255) COMMENT 'BlurHash representation of the avatar',
145 `header` varbinary(383) COMMENT 'Header picture',
146 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
147 `nurl` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
148 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
149 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
150 `alias` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
151 `pubkey` text COMMENT 'RSA public key 4096 bit',
152 `prvkey` text COMMENT 'RSA private key 4096 bit',
153 `batch` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
154 `notify` varbinary(383) COMMENT '',
155 `poll` varbinary(383) COMMENT '',
156 `subscribe` varbinary(383) COMMENT '',
157 `last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
158 `next-update` datetime COMMENT 'Next connection request',
159 `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
160 `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
161 `failed` boolean COMMENT 'Connection failed',
162 `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
163 `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
164 `last-discovery` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last follower discovery',
165 `local-data` boolean COMMENT 'Is true when there are posts with this contact on the system',
166 `blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
167 `block_reason` text COMMENT 'Node-wide block reason',
168 `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
169 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Person, organisation, news, community, relay',
170 `manually-approve` boolean COMMENT 'Contact requests have to be approved manually',
171 `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
172 `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
173 `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
174 `baseurl` varbinary(383) DEFAULT '' COMMENT 'baseurl of the contact from the gserver record, can be missing',
175 `gsid` int unsigned COMMENT 'Global Server ID, can be missing',
176 `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
177 `reason` text COMMENT '',
178 `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
179 `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
180 `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
181 `protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
182 `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
183 `hub-verify` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
184 `rating` tinyint NOT NULL DEFAULT 0 COMMENT 'Automatically detected feed poll frequency',
185 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Feed poll priority',
186 `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
187 `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
188 `pending` boolean NOT NULL DEFAULT '1' COMMENT 'Contact request is pending',
189 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
190 `info` mediumtext COMMENT '',
191 `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
192 `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
193 `ffi_keyword_denylist` text COMMENT '',
194 `photo` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
195 `thumb` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
196 `micro` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
197 `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
198 `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
199 `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
200 `request` varbinary(383) COMMENT '',
201 `confirm` varbinary(383) COMMENT '',
202 `poco` varbinary(383) COMMENT '',
203 `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
204 `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a group. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = false instead',
205 `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = true instead',
206 `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
207 `site-pubkey` text COMMENT 'Deprecated',
208 `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
209 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
210 `issued-id` varbinary(383) NOT NULL DEFAULT '' COMMENT 'Deprecated',
211 `dfrn-id` varbinary(383) NOT NULL DEFAULT '' COMMENT 'Deprecated',
212 `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
213 `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
214 `usehub` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
215 `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT 'Deprecated',
216 `profile-id` int unsigned COMMENT 'Deprecated',
218 INDEX `uid_name` (`uid`,`name`(190)),
219 INDEX `self_uid` (`self`,`uid`),
220 INDEX `alias_uid` (`alias`(128),`uid`),
221 INDEX `pending_uid` (`pending`,`uid`),
222 INDEX `blocked_uid` (`blocked`,`uid`),
223 INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
224 INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
225 INDEX `batch_contact-type` (`batch`(64),`contact-type`),
226 INDEX `addr_uid` (`addr`(128),`uid`),
227 INDEX `nurl_uid` (`nurl`(128),`uid`),
228 INDEX `nick_uid` (`nick`(128),`uid`),
229 INDEX `attag_uid` (`attag`(96),`uid`),
230 INDEX `network_uid_lastupdate` (`network`,`uid`,`last-update`),
231 INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`),
232 INDEX `next-update` (`next-update`),
233 INDEX `local-data-next-update` (`local-data`,`next-update`),
234 INDEX `uid_lastitem` (`uid`,`last-item`),
235 INDEX `baseurl` (`baseurl`(64)),
236 INDEX `uid_contact-type` (`uid`,`contact-type`),
237 INDEX `uid_self_contact-type` (`uid`,`self`,`contact-type`),
238 INDEX `self_network_uid` (`self`,`network`,`uid`),
239 INDEX `gsid_uid_failed` (`gsid`,`uid`,`failed`),
240 INDEX `uri-id` (`uri-id`),
241 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
242 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
243 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
244 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
249 CREATE TABLE IF NOT EXISTS `tag` (
250 `id` int unsigned NOT NULL auto_increment COMMENT '',
251 `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
252 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
253 `type` tinyint unsigned COMMENT 'Type of the tag (Unknown, General Collection, Follower Collection or Account)',
255 UNIQUE INDEX `type_name_url` (`name`,`url`),
257 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
260 -- TABLE permissionset
262 CREATE TABLE IF NOT EXISTS `permissionset` (
263 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
264 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
265 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
266 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed circles',
267 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
268 `deny_gid` mediumtext COMMENT 'Access Control - list of denied circles',
270 INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`uid`,`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30)),
271 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
272 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
277 CREATE TABLE IF NOT EXISTS `verb` (
278 `id` smallint unsigned NOT NULL auto_increment,
279 `name` varchar(100) NOT NULL DEFAULT '' COMMENT '',
281 INDEX `name` (`name`)
282 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activity Verbs';
285 -- TABLE 2fa_app_specific_password
287 CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
288 `id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
289 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
290 `description` varchar(255) COMMENT 'Description of the usage of the password',
291 `hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
292 `generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
293 `last_used` datetime COMMENT 'Datetime the password was last used',
295 INDEX `uid_description` (`uid`,`description`(190)),
296 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
297 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
300 -- TABLE 2fa_recovery_codes
302 CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
303 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
304 `code` varchar(50) NOT NULL COMMENT 'Recovery code string',
305 `generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
306 `used` datetime COMMENT 'Datetime the code was used',
307 PRIMARY KEY(`uid`,`code`),
308 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
309 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
312 -- TABLE 2fa_trusted_browser
314 CREATE TABLE IF NOT EXISTS `2fa_trusted_browser` (
315 `cookie_hash` varchar(80) NOT NULL COMMENT 'Trusted cookie hash',
316 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
317 `user_agent` text COMMENT 'User agent string',
318 `trusted` boolean NOT NULL DEFAULT '1' COMMENT 'Whenever this browser should be trusted or not',
319 `created` datetime NOT NULL COMMENT 'Datetime the trusted browser was recorded',
320 `last_used` datetime COMMENT 'Datetime the trusted browser was last used',
321 PRIMARY KEY(`cookie_hash`),
323 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
324 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication trusted browsers';
327 -- TABLE account-suggestion
329 CREATE TABLE IF NOT EXISTS `account-suggestion` (
330 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the account url',
331 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
332 `level` smallint unsigned COMMENT 'level of closeness',
333 `ignore` boolean NOT NULL DEFAULT '0' COMMENT 'If set, this account will not be suggested again',
334 PRIMARY KEY(`uid`,`uri-id`),
335 INDEX `uri-id_uid` (`uri-id`,`uid`),
336 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
337 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
338 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Account suggestion';
341 -- TABLE account-user
343 CREATE TABLE IF NOT EXISTS `account-user` (
344 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
345 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the account url',
346 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
348 UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
349 INDEX `uid_uri-id` (`uid`,`uri-id`),
350 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
351 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
352 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Remote and local accounts';
357 CREATE TABLE IF NOT EXISTS `apcontact` (
358 `url` varbinary(383) NOT NULL COMMENT 'URL of the contact',
359 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
360 `uuid` varbinary(255) COMMENT '',
361 `type` varchar(20) NOT NULL COMMENT '',
362 `following` varbinary(383) COMMENT '',
363 `followers` varbinary(383) COMMENT '',
364 `inbox` varbinary(383) NOT NULL COMMENT '',
365 `outbox` varbinary(383) COMMENT '',
366 `sharedinbox` varbinary(383) COMMENT '',
367 `featured` varbinary(383) COMMENT 'Address for the collection of featured posts',
368 `featured-tags` varbinary(383) COMMENT 'Address for the collection of featured tags',
369 `manually-approve` boolean COMMENT '',
370 `discoverable` boolean COMMENT 'Mastodon extension: true if profile is published in their directory',
371 `suspended` boolean COMMENT 'Mastodon extension: true if profile is suspended',
372 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
373 `name` varchar(255) COMMENT '',
374 `about` text COMMENT '',
375 `xmpp` varchar(255) COMMENT 'XMPP address',
376 `matrix` varchar(255) COMMENT 'Matrix address',
377 `photo` varbinary(383) COMMENT '',
378 `header` varbinary(383) COMMENT 'Header picture',
379 `addr` varchar(255) COMMENT '',
380 `alias` varbinary(383) COMMENT '',
381 `pubkey` text COMMENT '',
382 `subscribe` varbinary(383) COMMENT '',
383 `baseurl` varbinary(383) COMMENT 'baseurl of the ap contact',
384 `gsid` int unsigned COMMENT 'Global Server ID',
385 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
386 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
387 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
388 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
389 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
391 INDEX `addr` (`addr`(32)),
392 INDEX `alias` (`alias`(190)),
393 INDEX `followers` (`followers`(190)),
394 INDEX `baseurl` (`baseurl`(190)),
395 INDEX `sharedinbox` (`sharedinbox`(190)),
396 INDEX `gsid` (`gsid`),
397 UNIQUE INDEX `uri-id` (`uri-id`),
398 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
399 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
400 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
405 CREATE TABLE IF NOT EXISTS `application` (
406 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
407 `client_id` varchar(64) NOT NULL COMMENT '',
408 `client_secret` varchar(64) NOT NULL COMMENT '',
409 `name` varchar(255) NOT NULL COMMENT '',
410 `redirect_uri` varbinary(383) NOT NULL COMMENT '',
411 `website` varbinary(383) COMMENT '',
412 `scopes` varchar(255) COMMENT '',
413 `read` boolean COMMENT 'Read scope',
414 `write` boolean COMMENT 'Write scope',
415 `follow` boolean COMMENT 'Follow scope',
416 `push` boolean COMMENT 'Push scope',
418 UNIQUE INDEX `client_id` (`client_id`)
419 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth application';
422 -- TABLE application-marker
424 CREATE TABLE IF NOT EXISTS `application-marker` (
425 `application-id` int unsigned NOT NULL COMMENT '',
426 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
427 `timeline` varchar(64) NOT NULL COMMENT 'Marker (home, notifications)',
428 `last_read_id` varbinary(383) COMMENT 'Marker id for the timeline',
429 `version` smallint unsigned COMMENT 'Version number',
430 `updated_at` datetime COMMENT 'creation time',
431 PRIMARY KEY(`application-id`,`uid`,`timeline`),
432 INDEX `uid_id` (`uid`),
433 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
434 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
435 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Timeline marker';
438 -- TABLE application-token
440 CREATE TABLE IF NOT EXISTS `application-token` (
441 `application-id` int unsigned NOT NULL COMMENT '',
442 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
443 `code` varchar(64) NOT NULL COMMENT '',
444 `access_token` varchar(64) NOT NULL COMMENT '',
445 `created_at` datetime NOT NULL COMMENT 'creation time',
446 `scopes` varchar(255) COMMENT '',
447 `read` boolean COMMENT 'Read scope',
448 `write` boolean COMMENT 'Write scope',
449 `follow` boolean COMMENT 'Follow scope',
450 `push` boolean COMMENT 'Push scope',
451 PRIMARY KEY(`application-id`,`uid`),
452 INDEX `uid_id` (`uid`,`application-id`),
453 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
454 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
455 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth user token';
460 CREATE TABLE IF NOT EXISTS `attach` (
461 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
462 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
463 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
464 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
465 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
466 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
467 `data` longblob NOT NULL COMMENT 'file data',
468 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
469 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
470 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
471 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed circles',
472 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
473 `deny_gid` mediumtext COMMENT 'Access Control - list of denied circles',
474 `backend-class` tinytext COMMENT 'Storage backend class',
475 `backend-ref` text COMMENT 'Storage backend data reference',
478 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
479 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
484 CREATE TABLE IF NOT EXISTS `cache` (
485 `k` varbinary(255) NOT NULL COMMENT 'cache key',
486 `v` mediumtext COMMENT 'cached serialized value',
487 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
488 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
490 INDEX `k_expires` (`k`,`expires`)
491 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
496 CREATE TABLE IF NOT EXISTS `channel` (
497 `id` int unsigned NOT NULL auto_increment COMMENT '',
498 `uid` mediumint unsigned NOT NULL COMMENT 'User id',
499 `label` varchar(64) NOT NULL COMMENT 'Channel label',
500 `description` varchar(64) COMMENT 'Channel description',
501 `circle` int COMMENT 'Circle or channel that this channel is based on',
502 `access-key` varchar(1) COMMENT 'Access key',
503 `include-tags` varchar(1023) COMMENT 'Comma separated list of tags that will be included in the channel',
504 `exclude-tags` varchar(1023) COMMENT 'Comma separated list of tags that aren\'t allowed in the channel',
505 `min-size` int unsigned COMMENT 'Minimum post size',
506 `max-size` int unsigned COMMENT 'Maximum post size',
507 `full-text-search` varchar(1023) COMMENT 'Full text search pattern, see https://mariadb.com/kb/en/full-text-index-overview/#in-boolean-mode',
508 `media-type` smallint unsigned COMMENT 'Filtered media types',
509 `languages` mediumtext COMMENT 'Desired languages',
510 `publish` boolean COMMENT 'publish channel content',
511 `valid` boolean COMMENT 'Set, when the full-text-search is valid',
514 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
515 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User defined Channels';
520 CREATE TABLE IF NOT EXISTS `config` (
521 `id` int unsigned NOT NULL auto_increment COMMENT '',
522 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT 'The category of the entry',
523 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT 'The key of the entry',
524 `v` mediumtext COMMENT '',
526 UNIQUE INDEX `cat_k` (`cat`,`k`)
527 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
530 -- TABLE contact-relation
532 CREATE TABLE IF NOT EXISTS `contact-relation` (
533 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
534 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
535 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction by relation-cid on cid',
536 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
537 `follows` boolean NOT NULL DEFAULT '0' COMMENT 'if true, relation-cid follows cid',
538 `score` smallint unsigned COMMENT 'score for interactions of cid on relation-cid',
539 `relation-score` smallint unsigned COMMENT 'score for interactions of relation-cid on cid',
540 `thread-score` smallint unsigned COMMENT 'score for interactions of cid on threads of relation-cid',
541 `relation-thread-score` smallint unsigned COMMENT 'score for interactions of relation-cid on threads of cid',
542 `post-score` smallint unsigned COMMENT 'score for the amount of posts from cid that can be seen by relation-cid',
543 PRIMARY KEY(`cid`,`relation-cid`),
544 INDEX `relation-cid` (`relation-cid`),
545 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
546 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
547 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
552 CREATE TABLE IF NOT EXISTS `conv` (
553 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
554 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
555 `recips` text COMMENT 'sender_handle;recipient_handle',
556 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
557 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
558 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
559 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
560 `subject` text COMMENT 'subject of initial message',
563 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
564 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
569 CREATE TABLE IF NOT EXISTS `workerqueue` (
570 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
571 `command` varchar(100) COMMENT 'Task command',
572 `parameter` mediumtext COMMENT 'Task parameter',
573 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
574 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
575 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
576 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
577 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
578 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
579 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
581 INDEX `command` (`command`),
582 INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
583 INDEX `done_executed` (`done`,`executed`),
584 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
585 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
586 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
587 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
588 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
589 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
592 -- TABLE delayed-post
594 CREATE TABLE IF NOT EXISTS `delayed-post` (
595 `id` int unsigned NOT NULL auto_increment,
596 `uri` varbinary(383) COMMENT 'URI of the post that will be distributed later',
597 `uid` mediumint unsigned COMMENT 'Owner User id',
598 `delayed` datetime COMMENT 'delay time',
599 `wid` int unsigned COMMENT 'Workerqueue id',
601 UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
603 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
604 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
605 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
608 -- TABLE delivery-queue
610 CREATE TABLE IF NOT EXISTS `delivery-queue` (
611 `gsid` int unsigned NOT NULL COMMENT 'Target server',
612 `uri-id` int unsigned NOT NULL COMMENT 'Delivered post',
613 `created` datetime COMMENT '',
614 `command` varbinary(32) COMMENT '',
615 `cid` int unsigned COMMENT 'Target contact',
616 `uid` mediumint unsigned COMMENT 'Delivering user',
617 `failed` tinyint DEFAULT 0 COMMENT 'Number of times the delivery has failed',
618 PRIMARY KEY(`uri-id`,`gsid`),
619 INDEX `gsid_created` (`gsid`,`created`),
622 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
623 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
624 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
625 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
626 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for posts for the batch processing';
629 -- TABLE diaspora-contact
631 CREATE TABLE IF NOT EXISTS `diaspora-contact` (
632 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the contact URL',
633 `addr` varchar(255) COMMENT '',
634 `alias` varchar(255) COMMENT '',
635 `nick` varchar(255) COMMENT '',
636 `name` varchar(255) COMMENT '',
637 `given-name` varchar(255) COMMENT '',
638 `family-name` varchar(255) COMMENT '',
639 `photo` varchar(255) COMMENT '',
640 `photo-medium` varchar(255) COMMENT '',
641 `photo-small` varchar(255) COMMENT '',
642 `batch` varchar(255) COMMENT '',
643 `notify` varchar(255) COMMENT '',
644 `poll` varchar(255) COMMENT '',
645 `subscribe` varchar(255) COMMENT '',
646 `searchable` boolean COMMENT '',
647 `pubkey` text COMMENT '',
648 `gsid` int unsigned COMMENT 'Global Server ID',
649 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
650 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
651 `interacting_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts this contact interacts with',
652 `interacted_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts that interacted with this contact',
653 `post_count` int unsigned DEFAULT 0 COMMENT 'Number of posts and comments',
654 PRIMARY KEY(`uri-id`),
655 UNIQUE INDEX `addr` (`addr`),
656 INDEX `alias` (`alias`),
657 INDEX `gsid` (`gsid`),
658 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
659 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
660 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
663 -- TABLE diaspora-interaction
665 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
666 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
667 `interaction` mediumtext COMMENT 'The Diaspora interaction',
668 PRIMARY KEY(`uri-id`),
669 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
670 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
675 CREATE TABLE IF NOT EXISTS `endpoint` (
676 `url` varbinary(383) NOT NULL COMMENT 'URL of the contact',
677 `type` varchar(20) NOT NULL COMMENT '',
678 `owner-uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
680 UNIQUE INDEX `owner-uri-id_type` (`owner-uri-id`,`type`),
681 FOREIGN KEY (`owner-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
682 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub endpoints - used in the ActivityPub implementation';
687 CREATE TABLE IF NOT EXISTS `event` (
688 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
689 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
690 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
691 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
692 `uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
693 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the event uri',
694 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
695 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
696 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
697 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
698 `summary` text COMMENT 'short description or title of the event',
699 `desc` text COMMENT 'event description',
700 `location` text COMMENT 'event location',
701 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
702 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
703 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
704 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
705 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed circles',
706 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
707 `deny_gid` mediumtext COMMENT 'Access Control - list of denied circles',
709 INDEX `uid_start` (`uid`,`start`),
711 INDEX `uri-id` (`uri-id`),
712 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
713 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
714 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
715 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
720 CREATE TABLE IF NOT EXISTS `fetch-entry` (
721 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
722 `url` varbinary(383) COMMENT 'url that awaiting to be fetched',
723 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of the fetch request',
724 `wid` int unsigned COMMENT 'Workerqueue id',
726 UNIQUE INDEX `url` (`url`),
727 INDEX `created` (`created`),
729 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
730 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
735 CREATE TABLE IF NOT EXISTS `fsuggest` (
736 `id` int unsigned NOT NULL auto_increment COMMENT '',
737 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
738 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
739 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
740 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
741 `request` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
742 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
743 `note` text COMMENT '',
744 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
748 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
749 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
750 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
755 CREATE TABLE IF NOT EXISTS `group` (
756 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
757 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
758 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
759 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the circle has been deleted',
760 `cid` int unsigned COMMENT 'Contact id of group. When this field is filled then the members are synced automatically.',
761 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of circle',
765 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
766 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
767 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy circles, circle info';
770 -- TABLE group_member
772 CREATE TABLE IF NOT EXISTS `group_member` (
773 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
774 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'group.id of the associated circle',
775 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated circle',
777 INDEX `contactid` (`contact-id`),
778 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
779 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
780 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
781 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy circles, member info';
786 CREATE TABLE IF NOT EXISTS `gserver-tag` (
787 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
788 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
789 PRIMARY KEY(`gserver-id`,`tag`),
791 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
792 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
797 CREATE TABLE IF NOT EXISTS `hook` (
798 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
799 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
800 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
801 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
802 `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',
804 INDEX `priority` (`priority`),
805 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
806 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
811 CREATE TABLE IF NOT EXISTS `inbox-entry` (
812 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
813 `activity-id` varbinary(383) COMMENT 'id of the incoming activity',
814 `object-id` varbinary(383) COMMENT '',
815 `in-reply-to-id` varbinary(383) COMMENT '',
816 `conversation` varbinary(383) COMMENT '',
817 `type` varchar(64) COMMENT 'Type of the activity',
818 `object-type` varchar(64) COMMENT 'Type of the object activity',
819 `object-object-type` varchar(64) COMMENT 'Type of the object\'s object activity',
820 `received` datetime COMMENT 'Receiving date',
821 `activity` mediumtext COMMENT 'The JSON activity',
822 `signer` varchar(255) COMMENT '',
823 `push` boolean COMMENT 'Is the entry pushed or have pulled it?',
824 `trust` boolean COMMENT 'Do we trust this entry?',
825 `wid` int unsigned COMMENT 'Workerqueue id',
827 UNIQUE INDEX `activity-id` (`activity-id`),
828 INDEX `object-id` (`object-id`),
829 INDEX `received` (`received`),
831 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
832 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Incoming activity';
835 -- TABLE inbox-entry-receiver
837 CREATE TABLE IF NOT EXISTS `inbox-entry-receiver` (
838 `queue-id` int unsigned NOT NULL COMMENT '',
839 `uid` mediumint unsigned NOT NULL COMMENT 'User id',
840 PRIMARY KEY(`queue-id`,`uid`),
842 FOREIGN KEY (`queue-id`) REFERENCES `inbox-entry` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
843 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
844 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Receiver for the incoming activity';
847 -- TABLE inbox-status
849 CREATE TABLE IF NOT EXISTS `inbox-status` (
850 `url` varbinary(383) NOT NULL COMMENT 'URL of the inbox',
851 `uri-id` int unsigned COMMENT 'Item-uri id of inbox url',
852 `gsid` int unsigned COMMENT 'ID of the related server',
853 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
854 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
855 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
856 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
857 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
858 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
860 INDEX `uri-id` (`uri-id`),
861 INDEX `gsid` (`gsid`),
862 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
863 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
864 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
869 CREATE TABLE IF NOT EXISTS `intro` (
870 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
871 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
872 `fid` int unsigned COMMENT 'deprecated',
873 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
874 `suggest-cid` int unsigned COMMENT 'Suggested contact',
875 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
876 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
877 `note` text COMMENT '',
878 `hash` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
879 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
880 `blocked` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
881 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
883 INDEX `contact-id` (`contact-id`),
884 INDEX `suggest-cid` (`suggest-cid`),
886 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
887 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
888 FOREIGN KEY (`suggest-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
889 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
894 CREATE TABLE IF NOT EXISTS `key-value` (
895 `k` varbinary(50) NOT NULL COMMENT '',
896 `v` mediumtext COMMENT '',
897 `updated_at` int unsigned NOT NULL COMMENT 'timestamp of the last update',
899 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='A key value storage';
904 CREATE TABLE IF NOT EXISTS `locks` (
905 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
906 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
907 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
908 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
909 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
911 INDEX `name_expires` (`name`,`expires`)
912 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
917 CREATE TABLE IF NOT EXISTS `mail` (
918 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
919 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
920 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
921 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
922 `from-photo` varbinary(383) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
923 `from-url` varbinary(383) NOT NULL DEFAULT '' COMMENT 'profile link of the sender',
924 `contact-id` varbinary(255) COMMENT 'contact.id',
925 `author-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the author of the mail',
926 `convid` int unsigned COMMENT 'conv.id',
927 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
928 `body` mediumtext COMMENT '',
929 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
930 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
931 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
932 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
933 `uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
934 `uri-id` int unsigned COMMENT 'Item-uri id of the related mail',
935 `parent-uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
936 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related mail',
937 `thr-parent` varbinary(383) COMMENT '',
938 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
939 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
941 INDEX `uid_seen` (`uid`,`seen`),
942 INDEX `convid` (`convid`),
943 INDEX `uri` (`uri`(64)),
944 INDEX `parent-uri` (`parent-uri`(64)),
945 INDEX `contactid` (`contact-id`(32)),
946 INDEX `author-id` (`author-id`),
947 INDEX `uri-id` (`uri-id`),
948 INDEX `parent-uri-id` (`parent-uri-id`),
949 INDEX `thr-parent-id` (`thr-parent-id`),
950 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
951 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
952 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
953 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
954 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
955 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
960 CREATE TABLE IF NOT EXISTS `mailacct` (
961 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
962 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
963 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
964 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
965 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
966 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
967 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
968 `pass` text COMMENT '',
969 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
970 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
971 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
972 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
973 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
976 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
977 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
982 CREATE TABLE IF NOT EXISTS `manage` (
983 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
984 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
985 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
987 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
989 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
990 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
991 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
994 -- TABLE notification
996 CREATE TABLE IF NOT EXISTS `notification` (
997 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
998 `uid` mediumint unsigned COMMENT 'Owner User id',
999 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1000 `type` smallint unsigned COMMENT '',
1001 `actor-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the actor that caused the notification',
1002 `target-uri-id` int unsigned COMMENT 'Item-uri id of the related post',
1003 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
1004 `created` datetime COMMENT '',
1005 `seen` boolean DEFAULT '0' COMMENT 'Seen on the desktop',
1006 `dismissed` boolean DEFAULT '0' COMMENT 'Dismissed via the API',
1008 UNIQUE INDEX `uid_vid_type_actor-id_target-uri-id` (`uid`,`vid`,`type`,`actor-id`,`target-uri-id`),
1009 INDEX `vid` (`vid`),
1010 INDEX `actor-id` (`actor-id`),
1011 INDEX `target-uri-id` (`target-uri-id`),
1012 INDEX `parent-uri-id` (`parent-uri-id`),
1013 INDEX `seen_uid` (`seen`,`uid`),
1014 INDEX `uid_type_parent-uri-id_actor-id` (`uid`,`type`,`parent-uri-id`,`actor-id`),
1015 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1016 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1017 FOREIGN KEY (`actor-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1018 FOREIGN KEY (`target-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1019 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1020 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
1025 CREATE TABLE IF NOT EXISTS `notify` (
1026 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1027 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1028 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1029 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1030 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1031 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1032 `msg` mediumtext COMMENT '',
1033 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1034 `link` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1035 `iid` int unsigned COMMENT '',
1036 `parent` int unsigned COMMENT '',
1037 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
1038 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
1039 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
1040 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
1041 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
1042 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
1043 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
1045 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
1046 INDEX `uid_date` (`uid`,`date`),
1047 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
1048 INDEX `uri-id` (`uri-id`),
1049 INDEX `parent-uri-id` (`parent-uri-id`),
1050 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1051 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1052 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1053 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='[Deprecated] User notifications';
1056 -- TABLE notify-threads
1058 CREATE TABLE IF NOT EXISTS `notify-threads` (
1059 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1060 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1061 `master-parent-item` int unsigned COMMENT 'Deprecated',
1062 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
1063 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1064 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1066 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
1067 INDEX `receiver-uid` (`receiver-uid`),
1068 INDEX `notify-id` (`notify-id`),
1069 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1070 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1071 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1072 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1077 CREATE TABLE IF NOT EXISTS `oembed` (
1078 `url` varbinary(383) NOT NULL COMMENT 'page url',
1079 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
1080 `content` mediumtext COMMENT 'OEmbed data of the page',
1081 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1082 PRIMARY KEY(`url`,`maxwidth`),
1083 INDEX `created` (`created`)
1084 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
1087 -- TABLE openwebauth-token
1089 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
1090 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1091 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
1092 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
1093 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
1094 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1095 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1097 INDEX `uid` (`uid`),
1098 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1099 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
1104 CREATE TABLE IF NOT EXISTS `parsed_url` (
1105 `url_hash` binary(64) NOT NULL COMMENT 'page url hash',
1106 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
1107 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
1108 `url` text NOT NULL COMMENT 'page url',
1109 `content` mediumtext COMMENT 'page data',
1110 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1111 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration',
1112 PRIMARY KEY(`url_hash`,`guessing`,`oembed`),
1113 INDEX `created` (`created`),
1114 INDEX `expires` (`expires`)
1115 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
1120 CREATE TABLE IF NOT EXISTS `pconfig` (
1121 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
1122 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1123 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
1124 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
1125 `v` mediumtext COMMENT 'Value',
1127 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
1128 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1129 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
1134 CREATE TABLE IF NOT EXISTS `photo` (
1135 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1136 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1137 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1138 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
1139 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
1140 `hash` char(32) COMMENT 'hash value of the photo',
1141 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
1142 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
1143 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1144 `desc` text COMMENT '',
1145 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
1146 `photo-type` tinyint unsigned COMMENT 'User avatar, user banner, contact avatar, contact banner or default',
1147 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1148 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
1149 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1150 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1151 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1152 `blurhash` varbinary(255) COMMENT 'BlurHash representation of the photo',
1153 `data` mediumblob NOT NULL COMMENT '',
1154 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1155 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
1156 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
1157 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed circles',
1158 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
1159 `deny_gid` mediumtext COMMENT 'Access Control - list of denied circles',
1160 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
1161 `backend-class` tinytext COMMENT 'Storage backend class',
1162 `backend-ref` text COMMENT 'Storage backend data reference',
1163 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1165 INDEX `contactid` (`contact-id`),
1166 INDEX `uid_contactid` (`uid`,`contact-id`),
1167 INDEX `uid_profile` (`uid`,`profile`),
1168 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
1169 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
1170 INDEX `resource-id` (`resource-id`),
1171 INDEX `uid_photo-type` (`uid`,`photo-type`),
1172 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1173 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1174 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1179 CREATE TABLE IF NOT EXISTS `post` (
1180 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1181 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1182 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1183 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1184 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1185 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1186 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1187 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1188 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1189 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1190 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1191 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1192 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1193 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1194 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1195 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1196 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1197 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1198 PRIMARY KEY(`uri-id`),
1199 INDEX `parent-uri-id` (`parent-uri-id`),
1200 INDEX `thr-parent-id` (`thr-parent-id`),
1201 INDEX `external-id` (`external-id`),
1202 INDEX `owner-id` (`owner-id`),
1203 INDEX `author-id` (`author-id`),
1204 INDEX `causer-id` (`causer-id`),
1205 INDEX `vid` (`vid`),
1206 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1207 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1208 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1209 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1210 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1211 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1212 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1213 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1214 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
1217 -- TABLE post-activity
1219 CREATE TABLE IF NOT EXISTS `post-activity` (
1220 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1221 `activity` mediumtext COMMENT 'Original activity',
1222 `received` datetime COMMENT '',
1223 PRIMARY KEY(`uri-id`),
1224 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1225 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Original remote activity';
1228 -- TABLE post-category
1230 CREATE TABLE IF NOT EXISTS `post-category` (
1231 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1232 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1233 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1234 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1235 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1236 INDEX `tid` (`tid`),
1237 INDEX `uid_uri-id` (`uid`,`uri-id`),
1238 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1239 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1240 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1241 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1244 -- TABLE post-counts
1246 CREATE TABLE IF NOT EXISTS `post-counts` (
1247 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1248 `vid` smallint unsigned NOT NULL COMMENT 'Id of the verb table entry that contains the activity verbs',
1249 `reaction` varchar(4) NOT NULL COMMENT 'Emoji Reaction',
1250 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1251 `count` int unsigned DEFAULT 0 COMMENT 'Number of activities',
1252 PRIMARY KEY(`uri-id`,`vid`,`reaction`),
1253 INDEX `vid` (`vid`),
1254 INDEX `parent-uri-id` (`parent-uri-id`),
1255 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1256 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1257 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1258 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Original remote activity';
1261 -- TABLE post-collection
1263 CREATE TABLE IF NOT EXISTS `post-collection` (
1264 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1265 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0 - Featured',
1266 `author-id` int unsigned COMMENT 'Author of the featured post',
1267 PRIMARY KEY(`uri-id`,`type`),
1268 INDEX `type` (`type`),
1269 INDEX `author-id` (`author-id`),
1270 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1271 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1272 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Collection of posts';
1275 -- TABLE post-content
1277 CREATE TABLE IF NOT EXISTS `post-content` (
1278 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1279 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1280 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1281 `body` mediumtext COMMENT 'item body content',
1282 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1283 `quote-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the quoted uri',
1284 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1285 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1286 `language` text COMMENT 'Language information about this post',
1287 `sensitive` boolean COMMENT 'If true, this post contains sensitive content',
1288 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1289 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1290 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1291 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1292 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1293 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1294 `target` text COMMENT 'JSON encoded target structure if used',
1295 `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',
1296 `plink` varbinary(383) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1297 PRIMARY KEY(`uri-id`),
1298 INDEX `plink` (`plink`(191)),
1299 INDEX `resource-id` (`resource-id`),
1300 INDEX `quote-uri-id` (`quote-uri-id`),
1301 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1302 FOREIGN KEY (`quote-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1303 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1306 -- TABLE post-delivery
1308 CREATE TABLE IF NOT EXISTS `post-delivery` (
1309 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1310 `inbox-id` int unsigned NOT NULL COMMENT 'Item-uri id of inbox url',
1311 `uid` mediumint unsigned COMMENT 'Delivering user',
1312 `created` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
1313 `command` varbinary(32) COMMENT '',
1314 `failed` tinyint DEFAULT 0 COMMENT 'Number of times the delivery has failed',
1315 `receivers` mediumtext COMMENT 'JSON encoded array with the receiving contacts',
1316 PRIMARY KEY(`uri-id`,`inbox-id`),
1317 INDEX `inbox-id_created` (`inbox-id`,`created`),
1318 INDEX `uid` (`uid`),
1319 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1320 FOREIGN KEY (`inbox-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1321 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1322 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for posts for the batch processing';
1325 -- TABLE post-delivery-data
1327 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1328 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1329 `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',
1330 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1331 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1332 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1333 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1334 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1335 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1336 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1337 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1338 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1339 PRIMARY KEY(`uri-id`),
1340 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1341 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1344 -- TABLE post-engagement
1346 CREATE TABLE IF NOT EXISTS `post-engagement` (
1347 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1348 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1349 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Person, organisation, news, community, relay',
1350 `media-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Type of media in a bit array (1 = image, 2 = video, 4 = audio)',
1351 `language` char(2) COMMENT 'Language information about this post in the ISO 639-1 format',
1352 `searchtext` mediumtext COMMENT 'Simplified text for the full text search',
1353 `size` int unsigned COMMENT 'Body size',
1354 `created` datetime COMMENT '',
1355 `network` char(4) COMMENT '',
1356 `restricted` boolean NOT NULL DEFAULT '0' COMMENT 'If true, this post is either unlisted or not from a federated network',
1357 `comments` mediumint unsigned COMMENT 'Number of comments',
1358 `activities` mediumint unsigned COMMENT 'Number of activities (like, dislike, ...)',
1359 PRIMARY KEY(`uri-id`),
1360 INDEX `owner-id` (`owner-id`),
1361 INDEX `created` (`created`),
1362 FULLTEXT INDEX `searchtext` (`searchtext`),
1363 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1364 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1365 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Engagement data per post';
1368 -- TABLE post-history
1370 CREATE TABLE IF NOT EXISTS `post-history` (
1371 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1372 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of edit',
1373 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1374 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1375 `body` mediumtext COMMENT 'item body content',
1376 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1377 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1378 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1379 `language` text COMMENT 'Language information about this post',
1380 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1381 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1382 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1383 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1384 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1385 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1386 `target` text COMMENT 'JSON encoded target structure if used',
1387 `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',
1388 `plink` varbinary(383) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1389 PRIMARY KEY(`uri-id`,`edited`),
1390 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1391 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post history';
1396 CREATE TABLE IF NOT EXISTS `post-link` (
1397 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1398 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1399 `url` varbinary(511) NOT NULL COMMENT 'External URL',
1400 `mimetype` varchar(60) COMMENT '',
1401 `height` smallint unsigned COMMENT 'Height of the media',
1402 `width` smallint unsigned COMMENT 'Width of the media',
1403 `blurhash` varbinary(255) COMMENT 'BlurHash representation of the link',
1405 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1406 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1407 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post related external links';
1412 CREATE TABLE IF NOT EXISTS `post-media` (
1413 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1414 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1415 `url` varbinary(1024) NOT NULL COMMENT 'Media URL',
1416 `media-uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the activities uri-id',
1417 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1418 `mimetype` varchar(60) COMMENT '',
1419 `height` smallint unsigned COMMENT 'Height of the media',
1420 `width` smallint unsigned COMMENT 'Width of the media',
1421 `size` bigint unsigned COMMENT 'Media size',
1422 `blurhash` varbinary(255) COMMENT 'BlurHash representation of the image',
1423 `preview` varbinary(512) COMMENT 'Preview URL',
1424 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1425 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1426 `description` text COMMENT '',
1427 `name` varchar(255) COMMENT 'Name of the media',
1428 `author-url` varbinary(383) COMMENT 'URL of the author of the media',
1429 `author-name` varchar(255) COMMENT 'Name of the author of the media',
1430 `author-image` varbinary(383) COMMENT 'Image of the author of the media',
1431 `publisher-url` varbinary(383) COMMENT 'URL of the publisher of the media',
1432 `publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
1433 `publisher-image` varbinary(383) COMMENT 'Image of the publisher of the media',
1435 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`(512)),
1436 INDEX `uri-id-id` (`uri-id`,`id`),
1437 INDEX `media-uri-id` (`media-uri-id`),
1438 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1439 FOREIGN KEY (`media-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1440 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1443 -- TABLE post-question
1445 CREATE TABLE IF NOT EXISTS `post-question` (
1446 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1447 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1448 `multiple` boolean NOT NULL DEFAULT '0' COMMENT 'Multiple choice',
1449 `voters` int unsigned COMMENT 'Number of voters for this question',
1450 `end-time` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Question end time',
1452 UNIQUE INDEX `uri-id` (`uri-id`),
1453 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1454 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question';
1457 -- TABLE post-question-option
1459 CREATE TABLE IF NOT EXISTS `post-question-option` (
1460 `id` int unsigned NOT NULL COMMENT 'Id of the question',
1461 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1462 `name` varchar(255) COMMENT 'Name of the option',
1463 `replies` int unsigned COMMENT 'Number of replies for this question option',
1464 PRIMARY KEY(`uri-id`,`id`),
1465 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1466 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question option';
1469 -- TABLE post-searchindex
1471 CREATE TABLE IF NOT EXISTS `post-searchindex` (
1472 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1473 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1474 `media-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Type of media in a bit array (1 = image, 2 = video, 4 = audio)',
1475 `language` char(2) COMMENT 'Language information about this post in the ISO 639-1 format',
1476 `searchtext` mediumtext COMMENT 'Simplified text for the full text search',
1477 `size` int unsigned COMMENT 'Body size',
1478 `created` datetime COMMENT '',
1479 `restricted` boolean NOT NULL DEFAULT '0' COMMENT 'If true, this post is either unlisted or not from a federated network',
1480 PRIMARY KEY(`uri-id`),
1481 INDEX `owner-id` (`owner-id`),
1482 INDEX `created` (`created`),
1483 FULLTEXT INDEX `searchtext` (`searchtext`),
1484 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1485 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1486 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1491 CREATE TABLE IF NOT EXISTS `post-tag` (
1492 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1493 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1494 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1495 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1496 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1497 INDEX `tid` (`tid`),
1498 INDEX `cid` (`cid`),
1499 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1500 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1501 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1502 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1505 -- TABLE post-thread
1507 CREATE TABLE IF NOT EXISTS `post-thread` (
1508 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1509 `conversation-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the conversation uri',
1510 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1511 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1512 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1513 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1514 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1515 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1516 `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',
1517 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1518 PRIMARY KEY(`uri-id`),
1519 INDEX `conversation-id` (`conversation-id`),
1520 INDEX `owner-id` (`owner-id`),
1521 INDEX `author-id` (`author-id`),
1522 INDEX `causer-id` (`causer-id`),
1523 INDEX `received` (`received`),
1524 INDEX `commented` (`commented`),
1525 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1526 FOREIGN KEY (`conversation-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1527 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1528 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1529 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1530 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1535 CREATE TABLE IF NOT EXISTS `post-user` (
1536 `id` int unsigned NOT NULL auto_increment,
1537 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1538 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1539 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1540 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1541 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1542 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1543 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1544 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1545 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1546 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1547 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1548 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1549 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1550 `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
1551 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1552 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1553 `restrictions` tinyint unsigned COMMENT 'Bit array of post restrictions (1 = Reply, 2 = Like, 4 = Announce)',
1554 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1555 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1556 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1557 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1558 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1559 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1560 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1561 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1562 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1563 `notification-type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1564 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1565 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1566 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1568 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1569 INDEX `uri-id` (`uri-id`),
1570 INDEX `parent-uri-id` (`parent-uri-id`),
1571 INDEX `thr-parent-id` (`thr-parent-id`),
1572 INDEX `external-id` (`external-id`),
1573 INDEX `owner-id` (`owner-id`),
1574 INDEX `author-id` (`author-id`),
1575 INDEX `causer-id` (`causer-id`),
1576 INDEX `vid` (`vid`),
1577 INDEX `contact-id` (`contact-id`),
1578 INDEX `event-id` (`event-id`),
1579 INDEX `psid` (`psid`),
1580 INDEX `author-id_uid` (`author-id`,`uid`),
1581 INDEX `author-id_created` (`author-id`,`created`),
1582 INDEX `owner-id_created` (`owner-id`,`created`),
1583 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1584 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1585 INDEX `uid_contactid` (`uid`,`contact-id`),
1586 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1587 INDEX `uid_unseen` (`uid`,`unseen`),
1588 INDEX `uid_hidden_uri-id` (`uid`,`hidden`,`uri-id`),
1589 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1590 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1591 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1592 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1593 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1594 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1595 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1596 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1597 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1598 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1599 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1600 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1601 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1604 -- TABLE post-thread-user
1606 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1607 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1608 `conversation-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the conversation uri',
1609 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1610 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1611 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1612 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1613 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1614 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1615 `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',
1616 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1617 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1618 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
1619 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1620 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1621 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1622 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1623 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1624 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Deprecated',
1625 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1626 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1627 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1628 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1629 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1630 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1631 PRIMARY KEY(`uid`,`uri-id`),
1632 INDEX `uri-id` (`uri-id`),
1633 INDEX `conversation-id` (`conversation-id`),
1634 INDEX `owner-id` (`owner-id`),
1635 INDEX `author-id` (`author-id`),
1636 INDEX `causer-id` (`causer-id`),
1637 INDEX `uid` (`uid`),
1638 INDEX `contact-id` (`contact-id`),
1639 INDEX `psid` (`psid`),
1640 INDEX `post-user-id` (`post-user-id`),
1641 INDEX `commented` (`commented`),
1642 INDEX `received` (`received`),
1643 INDEX `author-id_created` (`author-id`,`created`),
1644 INDEX `owner-id_created` (`owner-id`,`created`),
1645 INDEX `uid_received` (`uid`,`received`),
1646 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1647 INDEX `uid_commented` (`uid`,`commented`),
1648 INDEX `uid_created` (`uid`,`created`),
1649 INDEX `uid_starred` (`uid`,`starred`),
1650 INDEX `uid_mention` (`uid`,`mention`),
1651 INDEX `contact-id_commented` (`contact-id`,`commented`),
1652 INDEX `contact-id_received` (`contact-id`,`received`),
1653 INDEX `contact-id_created` (`contact-id`,`created`),
1654 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1655 FOREIGN KEY (`conversation-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1656 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1657 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1658 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1659 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1660 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1661 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1662 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1663 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1666 -- TABLE post-user-notification
1668 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1669 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1670 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1671 `notification-type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1672 PRIMARY KEY(`uid`,`uri-id`),
1673 INDEX `uri-id` (`uri-id`),
1674 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1675 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1676 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1681 CREATE TABLE IF NOT EXISTS `process` (
1682 `pid` int unsigned NOT NULL COMMENT 'The ID of the process',
1683 `hostname` varchar(255) NOT NULL COMMENT 'The name of the host the process is ran on',
1684 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1685 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1686 PRIMARY KEY(`pid`,`hostname`),
1687 INDEX `command` (`command`)
1688 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1693 CREATE TABLE IF NOT EXISTS `profile` (
1694 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1695 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1696 `profile-name` varchar(255) COMMENT 'Deprecated',
1697 `is-default` boolean COMMENT 'Deprecated',
1698 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1699 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Unused in favor of user.username',
1700 `pdesc` varchar(255) COMMENT 'Deprecated',
1701 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1702 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1703 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1704 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1705 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1706 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1707 `hometown` varchar(255) COMMENT 'Deprecated',
1708 `gender` varchar(32) COMMENT 'Deprecated',
1709 `marital` varchar(255) COMMENT 'Deprecated',
1710 `with` text COMMENT 'Deprecated',
1711 `howlong` datetime COMMENT 'Deprecated',
1712 `sexual` varchar(255) COMMENT 'Deprecated',
1713 `politic` varchar(255) COMMENT 'Deprecated',
1714 `religion` varchar(255) COMMENT 'Deprecated',
1715 `pub_keywords` text COMMENT '',
1716 `prv_keywords` text COMMENT '',
1717 `likes` text COMMENT 'Deprecated',
1718 `dislikes` text COMMENT 'Deprecated',
1719 `about` text COMMENT 'Profile description',
1720 `summary` varchar(255) COMMENT 'Deprecated',
1721 `music` text COMMENT 'Deprecated',
1722 `book` text COMMENT 'Deprecated',
1723 `tv` text COMMENT 'Deprecated',
1724 `film` text COMMENT 'Deprecated',
1725 `interest` text COMMENT 'Deprecated',
1726 `romance` text COMMENT 'Deprecated',
1727 `work` text COMMENT 'Deprecated',
1728 `education` text COMMENT 'Deprecated',
1729 `contact` text COMMENT 'Deprecated',
1730 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1731 `homepage_verified` boolean NOT NULL DEFAULT '0' COMMENT 'was the homepage verified by a rel-me link back to the profile',
1732 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
1733 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
1734 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1735 `thumb` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1736 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1737 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1739 INDEX `uid_is-default` (`uid`,`is-default`),
1740 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1741 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1744 -- TABLE profile_field
1746 CREATE TABLE IF NOT EXISTS `profile_field` (
1747 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1748 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1749 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1750 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1751 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1752 `value` text COMMENT 'Value of the field',
1753 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1754 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1756 INDEX `uid` (`uid`),
1757 INDEX `order` (`order`),
1758 INDEX `psid` (`psid`),
1759 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1760 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1761 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1764 -- TABLE push_subscriber
1766 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1767 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1768 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1769 `callback_url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1770 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1771 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1772 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1773 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1774 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1775 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1776 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1778 INDEX `next_try` (`next_try`),
1779 INDEX `uid` (`uid`),
1780 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1781 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1786 CREATE TABLE IF NOT EXISTS `register` (
1787 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1788 `hash` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1789 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1790 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1791 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1792 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1793 `note` text COMMENT '',
1795 INDEX `uid` (`uid`),
1796 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1797 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1802 CREATE TABLE IF NOT EXISTS `report` (
1803 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1804 `uid` mediumint unsigned COMMENT 'Reporting user',
1805 `reporter-id` int unsigned COMMENT 'Reporting contact',
1806 `cid` int unsigned NOT NULL COMMENT 'Reported contact',
1807 `gsid` int unsigned COMMENT 'Reported contact server',
1808 `comment` text COMMENT 'Report',
1809 `category-id` int unsigned NOT NULL DEFAULT 1 COMMENT 'Report category, one of Entity Report::CATEGORY_*',
1810 `forward` boolean COMMENT 'Forward the report to the remote server',
1811 `public-remarks` text COMMENT 'Remarks shared with the reporter',
1812 `private-remarks` text COMMENT 'Remarks shared with the moderation team',
1813 `last-editor-uid` mediumint unsigned COMMENT 'Last editor user',
1814 `assigned-uid` mediumint unsigned COMMENT 'Assigned moderator user',
1815 `status` tinyint unsigned NOT NULL COMMENT 'Status of the report, one of Entity Report::STATUS_*',
1816 `resolution` tinyint unsigned COMMENT 'Resolution of the report, one of Entity Report::RESOLUTION_*',
1817 `created` datetime(6) NOT NULL DEFAULT '0001-01-01 00:00:00.000000' COMMENT '',
1818 `edited` datetime(6) COMMENT 'Last time the report has been edited',
1820 INDEX `uid` (`uid`),
1821 INDEX `cid` (`cid`),
1822 INDEX `reporter-id` (`reporter-id`),
1823 INDEX `gsid` (`gsid`),
1824 INDEX `last-editor-uid` (`last-editor-uid`),
1825 INDEX `assigned-uid` (`assigned-uid`),
1826 INDEX `status-resolution` (`status`,`resolution`),
1827 INDEX `created` (`created`),
1828 INDEX `edited` (`edited`),
1829 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1830 FOREIGN KEY (`reporter-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1831 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1832 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1833 FOREIGN KEY (`last-editor-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1834 FOREIGN KEY (`assigned-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1835 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1838 -- TABLE report-post
1840 CREATE TABLE IF NOT EXISTS `report-post` (
1841 `rid` int unsigned NOT NULL COMMENT 'Report id',
1842 `uri-id` int unsigned NOT NULL COMMENT 'Uri-id of the reported post',
1843 `status` tinyint unsigned COMMENT 'Status of the reported post',
1844 PRIMARY KEY(`rid`,`uri-id`),
1845 INDEX `uri-id` (`uri-id`),
1846 FOREIGN KEY (`rid`) REFERENCES `report` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1847 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1848 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Individual posts attached to a moderation report';
1851 -- TABLE report-rule
1853 CREATE TABLE IF NOT EXISTS `report-rule` (
1854 `rid` int unsigned NOT NULL COMMENT 'Report id',
1855 `line-id` int unsigned NOT NULL COMMENT 'Terms of service rule line number, may become invalid after a TOS change.',
1856 `text` text NOT NULL COMMENT 'Terms of service rule text recorded at the time of the report',
1857 PRIMARY KEY(`rid`,`line-id`),
1858 FOREIGN KEY (`rid`) REFERENCES `report` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1859 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Terms of service rule lines relevant to a moderation report';
1864 CREATE TABLE IF NOT EXISTS `search` (
1865 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1866 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1867 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1869 INDEX `uid_term` (`uid`,`term`(64)),
1870 INDEX `term` (`term`(64)),
1871 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1872 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1877 CREATE TABLE IF NOT EXISTS `session` (
1878 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1879 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1880 `data` text COMMENT '',
1881 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1883 INDEX `sid` (`sid`(64)),
1884 INDEX `expire` (`expire`)
1885 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1890 CREATE TABLE IF NOT EXISTS `storage` (
1891 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1892 `data` longblob NOT NULL COMMENT 'file data',
1894 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1897 -- TABLE subscription
1899 CREATE TABLE IF NOT EXISTS `subscription` (
1900 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1901 `application-id` int unsigned NOT NULL COMMENT '',
1902 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
1903 `endpoint` varchar(511) COMMENT 'Endpoint URL',
1904 `pubkey` varchar(127) COMMENT 'User agent public key',
1905 `secret` varchar(32) COMMENT 'Auth secret',
1906 `follow` boolean COMMENT '',
1907 `favourite` boolean COMMENT '',
1908 `reblog` boolean COMMENT '',
1909 `mention` boolean COMMENT '',
1910 `poll` boolean COMMENT '',
1911 `follow_request` boolean COMMENT '',
1912 `status` boolean COMMENT '',
1914 UNIQUE INDEX `application-id_uid` (`application-id`,`uid`),
1915 INDEX `uid_application-id` (`uid`,`application-id`),
1916 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1917 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1918 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Push Subscription for the API';
1921 -- TABLE check-full-text-search
1923 CREATE TABLE IF NOT EXISTS `check-full-text-search` (
1924 `pid` int unsigned NOT NULL COMMENT 'The ID of the process',
1925 `searchtext` mediumtext COMMENT 'Simplified text for the full text search',
1927 FULLTEXT INDEX `searchtext` (`searchtext`)
1928 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Check for a full text search match in user defined channels before storing the message in the system';
1933 CREATE TABLE IF NOT EXISTS `userd` (
1934 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1935 `username` varchar(255) NOT NULL COMMENT '',
1937 INDEX `username` (`username`(32))
1938 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1941 -- TABLE user-contact
1943 CREATE TABLE IF NOT EXISTS `user-contact` (
1944 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1945 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1946 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
1947 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1948 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1949 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1950 `hidden` boolean COMMENT 'This contact is hidden from the others',
1951 `channel-only` boolean COMMENT 'This contact is displayed only in channels, but not in the network stream.',
1952 `is-blocked` boolean COMMENT 'User is blocked by this contact',
1953 `channel-frequency` tinyint unsigned COMMENT 'Controls the frequency of the appearance of this contact in channels',
1954 `pending` boolean COMMENT '',
1955 `rel` tinyint unsigned COMMENT 'The kind of the relation between the user and the contact',
1956 `info` mediumtext COMMENT '',
1957 `notify_new_posts` boolean COMMENT '',
1958 `remote_self` tinyint unsigned COMMENT '0 => No mirroring, 1-2 => Mirror as own post, 3 => Mirror as reshare',
1959 `fetch_further_information` tinyint unsigned COMMENT '0 => None, 1 => Fetch information, 3 => Fetch keywords, 2 => Fetch both',
1960 `ffi_keyword_denylist` text COMMENT '',
1961 `subhub` boolean COMMENT '',
1962 `hub-verify` varbinary(383) COMMENT '',
1963 `protocol` char(4) COMMENT 'Protocol of the contact',
1964 `rating` tinyint COMMENT 'Automatically detected feed poll frequency',
1965 `priority` tinyint unsigned COMMENT 'Feed poll priority',
1966 PRIMARY KEY(`uid`,`cid`),
1967 INDEX `cid` (`cid`),
1968 UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
1969 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1970 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1971 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1972 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1975 -- TABLE arrived-activity
1977 CREATE TABLE IF NOT EXISTS `arrived-activity` (
1978 `object-id` varbinary(383) NOT NULL COMMENT 'object id of the incoming activity',
1979 `received` datetime COMMENT 'Receiving date',
1980 PRIMARY KEY(`object-id`)
1981 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Id of arrived activities';
1984 -- TABLE fetched-activity
1986 CREATE TABLE IF NOT EXISTS `fetched-activity` (
1987 `object-id` varbinary(383) NOT NULL COMMENT 'object id of fetched activity',
1988 `received` datetime COMMENT 'Receiving date',
1989 PRIMARY KEY(`object-id`)
1990 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Id of fetched activities';
1995 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1996 `key` int NOT NULL COMMENT '',
1997 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1999 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
2002 -- VIEW application-view
2004 DROP VIEW IF EXISTS `application-view`;
2005 CREATE VIEW `application-view` AS SELECT
2006 `application`.`id` AS `id`,
2007 `application-token`.`uid` AS `uid`,
2008 `application`.`name` AS `name`,
2009 `application`.`redirect_uri` AS `redirect_uri`,
2010 `application`.`website` AS `website`,
2011 `application`.`client_id` AS `client_id`,
2012 `application`.`client_secret` AS `client_secret`,
2013 `application-token`.`code` AS `code`,
2014 `application-token`.`access_token` AS `access_token`,
2015 `application-token`.`created_at` AS `created_at`,
2016 `application-token`.`scopes` AS `scopes`,
2017 `application-token`.`read` AS `read`,
2018 `application-token`.`write` AS `write`,
2019 `application-token`.`follow` AS `follow`,
2020 `application-token`.`push` AS `push`
2021 FROM `application-token`
2022 INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`
2023 INNER JOIN `user` ON `user`.`uid` = `application-token`.`uid` AND `user`.`verified` AND NOT `user`.`blocked` AND NOT `user`.`account_removed` AND NOT `user`.`account_expired`;
2026 -- VIEW circle-member-view
2028 DROP VIEW IF EXISTS `circle-member-view`;
2029 CREATE VIEW `circle-member-view` AS SELECT
2030 `group_member`.`id` AS `id`,
2031 `group`.`uid` AS `uid`,
2032 `group_member`.`contact-id` AS `contact-id`,
2033 `contact`.`uri-id` AS `contact-uri-id`,
2034 `contact`.`url` AS `contact-link`,
2035 `contact`.`addr` AS `contact-addr`,
2036 `contact`.`name` AS `contact-name`,
2037 `contact`.`nick` AS `contact-nick`,
2038 `contact`.`thumb` AS `contact-avatar`,
2039 `contact`.`network` AS `contact-network`,
2040 `contact`.`blocked` AS `contact-blocked`,
2041 `contact`.`hidden` AS `contact-hidden`,
2042 `contact`.`readonly` AS `contact-readonly`,
2043 `contact`.`archive` AS `contact-archive`,
2044 `contact`.`pending` AS `contact-pending`,
2045 `contact`.`self` AS `contact-self`,
2046 `contact`.`rel` AS `contact-rel`,
2047 `contact`.`contact-type` AS `contact-contact-type`,
2048 `group_member`.`gid` AS `circle-id`,
2049 `group`.`visible` AS `circle-visible`,
2050 `group`.`deleted` AS `circle-deleted`,
2051 `group`.`name` AS `circle-name`
2053 INNER JOIN `contact` ON `group_member`.`contact-id` = `contact`.`id`
2054 INNER JOIN `group` ON `group_member`.`gid` = `group`.`id`;
2057 -- VIEW post-counts-view
2059 DROP VIEW IF EXISTS `post-counts-view`;
2060 CREATE VIEW `post-counts-view` AS SELECT
2061 `post-counts`.`uri-id` AS `uri-id`,
2062 `post-counts`.`vid` AS `vid`,
2063 `verb`.`name` AS `verb`,
2064 `post-counts`.`reaction` AS `reaction`,
2065 `post-counts`.`parent-uri-id` AS `parent-uri-id`,
2066 `post-counts`.`count` AS `count`
2068 INNER JOIN `verb` ON `verb`.`id` = `post-counts`.`vid`;
2071 -- VIEW post-timeline-view
2073 DROP VIEW IF EXISTS `post-timeline-view`;
2074 CREATE VIEW `post-timeline-view` AS SELECT
2075 `post-user`.`uid` AS `uid`,
2076 `post-user`.`uri-id` AS `uri-id`,
2077 `post-user`.`gravity` AS `gravity`,
2078 `post-user`.`created` AS `created`,
2079 `post-user`.`edited` AS `edited`,
2080 `post-thread-user`.`commented` AS `commented`,
2081 `post-user`.`received` AS `received`,
2082 `post-thread-user`.`changed` AS `changed`,
2083 `post-user`.`private` AS `private`,
2084 `post-user`.`visible` AS `visible`,
2085 `post-user`.`deleted` AS `deleted`,
2086 `post-user`.`origin` AS `origin`,
2087 `post-user`.`global` AS `global`,
2088 `post-user`.`network` AS `network`,
2089 `post-user`.`protocol` AS `protocol`,
2090 `post-user`.`vid` AS `vid`,
2091 `post-user`.`contact-id` AS `contact-id`,
2092 `contact`.`blocked` AS `contact-blocked`,
2093 `contact`.`readonly` AS `contact-readonly`,
2094 `contact`.`pending` AS `contact-pending`,
2095 `contact`.`rel` AS `contact-rel`,
2096 `contact`.`uid` AS `contact-uid`,
2097 `contact`.`self` AS `self`,
2098 `post-user`.`author-id` AS `author-id`,
2099 `author`.`blocked` AS `author-blocked`,
2100 `author`.`hidden` AS `author-hidden`,
2101 `author`.`gsid` AS `author-gsid`,
2102 `post-user`.`owner-id` AS `owner-id`,
2103 `owner`.`blocked` AS `owner-blocked`,
2104 `owner`.`gsid` AS `owner-gsid`,
2105 `post-user`.`causer-id` AS `causer-id`,
2106 `causer`.`blocked` AS `causer-blocked`,
2107 `causer`.`gsid` AS `causer-gsid`
2109 LEFT JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2110 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
2111 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
2112 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
2113 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`;
2116 -- VIEW post-searchindex-user-view
2118 DROP VIEW IF EXISTS `post-searchindex-user-view`;
2119 CREATE VIEW `post-searchindex-user-view` AS SELECT
2120 `post-thread-user`.`uid` AS `uid`,
2121 `post-searchindex`.`uri-id` AS `uri-id`,
2122 `post-searchindex`.`owner-id` AS `owner-id`,
2123 `post-searchindex`.`media-type` AS `media-type`,
2124 `post-searchindex`.`language` AS `language`,
2125 `post-searchindex`.`searchtext` AS `searchtext`,
2126 `post-searchindex`.`size` AS `size`,
2127 `post-thread-user`.`commented` AS `commented`,
2128 `post-thread-user`.`received` AS `received`,
2129 `post-thread-user`.`created` AS `created`,
2130 `post-thread-user`.`network` AS `network`,
2131 `post-searchindex`.`language` AS `restricted`,
2134 FROM `post-thread-user`
2135 INNER JOIN `post-searchindex` ON `post-searchindex`.`uri-id` = `post-thread-user`.`uri-id`
2136 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2137 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2138 STRAIGHT_JOIN `contact` AS `authorcontact` ON `authorcontact`.`id` = `post-thread-user`.`author-id`
2139 STRAIGHT_JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2140 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2141 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2142 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2143 AND NOT `authorcontact`.`blocked` AND NOT `ownercontact`.`blocked`
2144 AND NOT EXISTS(SELECT `cid` FROM `user-contact` WHERE `uid` = `post-thread-user`.`uid` AND `cid` IN (`authorcontact`.`id`, `ownercontact`.`id`) AND (`blocked` OR `ignored`))
2145 AND NOT EXISTS(SELECT `gsid` FROM `user-gserver` WHERE `uid` = `post-thread-user`.`uid` AND `gsid` IN (`authorcontact`.`gsid`, `ownercontact`.`gsid`) AND `ignored`);
2148 -- VIEW post-user-view
2150 DROP VIEW IF EXISTS `post-user-view`;
2151 CREATE VIEW `post-user-view` AS SELECT
2152 `post-user`.`id` AS `id`,
2153 `post-user`.`id` AS `post-user-id`,
2154 `post-user`.`uid` AS `uid`,
2155 `post-thread-user`.`post-user-id` AS `parent`,
2156 `item-uri`.`uri` AS `uri`,
2157 `post-user`.`uri-id` AS `uri-id`,
2158 `parent-item-uri`.`uri` AS `parent-uri`,
2159 `post-user`.`parent-uri-id` AS `parent-uri-id`,
2160 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2161 `post-user`.`thr-parent-id` AS `thr-parent-id`,
2162 `conversation-item-uri`.`uri` AS `conversation`,
2163 `post-thread-user`.`conversation-id` AS `conversation-id`,
2164 `quote-item-uri`.`uri` AS `quote-uri`,
2165 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2166 `item-uri`.`guid` AS `guid`,
2167 `post-user`.`wall` AS `wall`,
2168 `post-user`.`gravity` AS `gravity`,
2169 `external-item-uri`.`uri` AS `extid`,
2170 `post-user`.`external-id` AS `external-id`,
2171 `post-user`.`created` AS `created`,
2172 `post-user`.`edited` AS `edited`,
2173 `post-thread-user`.`commented` AS `commented`,
2174 `post-user`.`received` AS `received`,
2175 `post-thread-user`.`changed` AS `changed`,
2176 `post-user`.`post-type` AS `post-type`,
2177 `post-user`.`post-reason` AS `post-reason`,
2178 `post-user`.`private` AS `private`,
2179 `post-thread-user`.`pubmail` AS `pubmail`,
2180 `post-user`.`visible` AS `visible`,
2181 `post-thread-user`.`starred` AS `starred`,
2182 `post-user`.`unseen` AS `unseen`,
2183 `post-user`.`deleted` AS `deleted`,
2184 `post-user`.`origin` AS `origin`,
2185 `post-thread-user`.`origin` AS `parent-origin`,
2186 `post-thread-user`.`mention` AS `mention`,
2187 `post-user`.`global` AS `global`,
2188 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-user`.`uri-id`) AS `featured`,
2189 `post-user`.`network` AS `network`,
2190 `post-user`.`protocol` AS `protocol`,
2191 `post-user`.`vid` AS `vid`,
2192 `post-user`.`psid` AS `psid`,
2193 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2194 `post-content`.`title` AS `title`,
2195 `post-content`.`content-warning` AS `content-warning`,
2196 `post-content`.`raw-body` AS `raw-body`,
2197 IFNULL (`post-content`.`body`, '') AS `body`,
2198 `post-content`.`rendered-hash` AS `rendered-hash`,
2199 `post-content`.`rendered-html` AS `rendered-html`,
2200 `post-content`.`language` AS `language`,
2201 `post-content`.`plink` AS `plink`,
2202 `post-content`.`location` AS `location`,
2203 `post-content`.`coord` AS `coord`,
2204 `post-content`.`sensitive` AS `sensitive`,
2205 `post-user`.`restrictions` AS `restrictions`,
2206 `post-content`.`app` AS `app`,
2207 `post-content`.`object-type` AS `object-type`,
2208 `post-content`.`object` AS `object`,
2209 `post-content`.`target-type` AS `target-type`,
2210 `post-content`.`target` AS `target`,
2211 `post-content`.`resource-id` AS `resource-id`,
2212 `post-user`.`contact-id` AS `contact-id`,
2213 `contact`.`uri-id` AS `contact-uri-id`,
2214 `contact`.`url` AS `contact-link`,
2215 `contact`.`addr` AS `contact-addr`,
2216 `contact`.`name` AS `contact-name`,
2217 `contact`.`nick` AS `contact-nick`,
2218 `contact`.`thumb` AS `contact-avatar`,
2219 `contact`.`network` AS `contact-network`,
2220 `contact`.`blocked` AS `contact-blocked`,
2221 `contact`.`hidden` AS `contact-hidden`,
2222 `contact`.`readonly` AS `contact-readonly`,
2223 `contact`.`archive` AS `contact-archive`,
2224 `contact`.`pending` AS `contact-pending`,
2225 `contact`.`rel` AS `contact-rel`,
2226 `contact`.`uid` AS `contact-uid`,
2227 `contact`.`contact-type` AS `contact-contact-type`,
2228 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
2229 `contact`.`self` AS `self`,
2230 `contact`.`id` AS `cid`,
2231 `contact`.`alias` AS `alias`,
2232 `contact`.`photo` AS `photo`,
2233 `contact`.`name-date` AS `name-date`,
2234 `contact`.`uri-date` AS `uri-date`,
2235 `contact`.`avatar-date` AS `avatar-date`,
2236 `contact`.`thumb` AS `thumb`,
2237 `post-user`.`author-id` AS `author-id`,
2238 `author`.`uri-id` AS `author-uri-id`,
2239 `author`.`url` AS `author-link`,
2240 `author`.`addr` AS `author-addr`,
2241 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
2242 `author`.`nick` AS `author-nick`,
2243 `author`.`alias` AS `author-alias`,
2244 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
2245 `author`.`network` AS `author-network`,
2246 `author`.`blocked` AS `author-blocked`,
2247 `author`.`hidden` AS `author-hidden`,
2248 `author`.`updated` AS `author-updated`,
2249 `author`.`contact-type` AS `author-contact-type`,
2250 `author`.`gsid` AS `author-gsid`,
2251 `author`.`baseurl` AS `author-baseurl`,
2252 `post-user`.`owner-id` AS `owner-id`,
2253 `owner`.`uri-id` AS `owner-uri-id`,
2254 `owner`.`url` AS `owner-link`,
2255 `owner`.`addr` AS `owner-addr`,
2256 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
2257 `owner`.`nick` AS `owner-nick`,
2258 `owner`.`alias` AS `owner-alias`,
2259 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
2260 `owner`.`network` AS `owner-network`,
2261 `owner`.`blocked` AS `owner-blocked`,
2262 `owner`.`hidden` AS `owner-hidden`,
2263 `owner`.`updated` AS `owner-updated`,
2264 `owner`.`gsid` AS `owner-gsid`,
2265 `owner`.`contact-type` AS `owner-contact-type`,
2266 `post-user`.`causer-id` AS `causer-id`,
2267 `causer`.`uri-id` AS `causer-uri-id`,
2268 `causer`.`url` AS `causer-link`,
2269 `causer`.`addr` AS `causer-addr`,
2270 `causer`.`name` AS `causer-name`,
2271 `causer`.`nick` AS `causer-nick`,
2272 `causer`.`alias` AS `causer-alias`,
2273 `causer`.`thumb` AS `causer-avatar`,
2274 `causer`.`network` AS `causer-network`,
2275 `causer`.`blocked` AS `causer-blocked`,
2276 `causer`.`hidden` AS `causer-hidden`,
2277 `causer`.`gsid` AS `causer-gsid`,
2278 `causer`.`contact-type` AS `causer-contact-type`,
2279 `post-delivery-data`.`postopts` AS `postopts`,
2280 `post-delivery-data`.`inform` AS `inform`,
2281 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
2282 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
2283 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
2284 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
2285 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
2286 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
2287 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
2288 `post-user`.`event-id` AS `event-id`,
2289 `event`.`created` AS `event-created`,
2290 `event`.`edited` AS `event-edited`,
2291 `event`.`start` AS `event-start`,
2292 `event`.`finish` AS `event-finish`,
2293 `event`.`summary` AS `event-summary`,
2294 `event`.`desc` AS `event-desc`,
2295 `event`.`location` AS `event-location`,
2296 `event`.`type` AS `event-type`,
2297 `event`.`nofinish` AS `event-nofinish`,
2298 `event`.`ignore` AS `event-ignore`,
2299 `post-question`.`id` AS `question-id`,
2300 `post-question`.`multiple` AS `question-multiple`,
2301 `post-question`.`voters` AS `question-voters`,
2302 `post-question`.`end-time` AS `question-end-time`,
2303 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`,
2304 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-user`.`uri-id`) AS `has-media`,
2305 `diaspora-interaction`.`interaction` AS `signed_text`,
2306 `parent-item-uri`.`guid` AS `parent-guid`,
2307 `post-thread-user`.`network` AS `parent-network`,
2308 `post-thread-user`.`author-id` AS `parent-author-id`,
2309 `parent-post-author`.`url` AS `parent-author-link`,
2310 `parent-post-author`.`name` AS `parent-author-name`,
2311 `parent-post-author`.`nick` AS `parent-author-nick`,
2312 `parent-post-author`.`network` AS `parent-author-network`
2314 INNER JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2315 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
2316 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
2317 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
2318 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
2319 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
2320 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
2321 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
2322 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
2323 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
2324 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
2325 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
2326 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
2327 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
2328 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2329 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
2330 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-user`.`uri-id`
2331 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
2332 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `post-thread-user`.`author-id`;
2335 -- VIEW post-thread-user-view
2337 DROP VIEW IF EXISTS `post-thread-user-view`;
2338 CREATE VIEW `post-thread-user-view` AS SELECT
2339 `post-user`.`id` AS `id`,
2340 `post-user`.`id` AS `post-user-id`,
2341 `post-thread-user`.`uid` AS `uid`,
2342 `post-thread-user`.`post-user-id` AS `parent`,
2343 `item-uri`.`uri` AS `uri`,
2344 `post-thread-user`.`uri-id` AS `uri-id`,
2345 `parent-item-uri`.`uri` AS `parent-uri`,
2346 `post-user`.`parent-uri-id` AS `parent-uri-id`,
2347 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2348 `post-user`.`thr-parent-id` AS `thr-parent-id`,
2349 `conversation-item-uri`.`uri` AS `conversation`,
2350 `post-thread-user`.`conversation-id` AS `conversation-id`,
2351 `quote-item-uri`.`uri` AS `quote-uri`,
2352 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2353 `item-uri`.`guid` AS `guid`,
2354 `post-thread-user`.`wall` AS `wall`,
2355 `post-user`.`gravity` AS `gravity`,
2356 `external-item-uri`.`uri` AS `extid`,
2357 `post-user`.`external-id` AS `external-id`,
2358 `post-thread-user`.`created` AS `created`,
2359 `post-user`.`edited` AS `edited`,
2360 `post-thread-user`.`commented` AS `commented`,
2361 `post-thread-user`.`received` AS `received`,
2362 `post-thread-user`.`changed` AS `changed`,
2363 `post-user`.`post-type` AS `post-type`,
2364 `post-user`.`post-reason` AS `post-reason`,
2365 `post-user`.`private` AS `private`,
2366 `post-thread-user`.`pubmail` AS `pubmail`,
2367 `post-thread-user`.`ignored` AS `ignored`,
2368 `post-user`.`visible` AS `visible`,
2369 `post-thread-user`.`starred` AS `starred`,
2370 `post-thread-user`.`unseen` AS `unseen`,
2371 `post-user`.`deleted` AS `deleted`,
2372 `post-thread-user`.`origin` AS `origin`,
2373 `post-thread-user`.`mention` AS `mention`,
2374 `post-user`.`global` AS `global`,
2375 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread-user`.`uri-id`) AS `featured`,
2376 `post-thread-user`.`network` AS `network`,
2377 `post-user`.`vid` AS `vid`,
2378 `post-thread-user`.`psid` AS `psid`,
2379 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2380 `post-content`.`title` AS `title`,
2381 `post-content`.`content-warning` AS `content-warning`,
2382 `post-content`.`raw-body` AS `raw-body`,
2383 `post-content`.`body` AS `body`,
2384 `post-content`.`rendered-hash` AS `rendered-hash`,
2385 `post-content`.`rendered-html` AS `rendered-html`,
2386 `post-content`.`language` AS `language`,
2387 `post-content`.`plink` AS `plink`,
2388 `post-content`.`location` AS `location`,
2389 `post-content`.`coord` AS `coord`,
2390 `post-content`.`sensitive` AS `sensitive`,
2391 `post-user`.`restrictions` AS `restrictions`,
2392 `post-content`.`app` AS `app`,
2393 `post-content`.`object-type` AS `object-type`,
2394 `post-content`.`object` AS `object`,
2395 `post-content`.`target-type` AS `target-type`,
2396 `post-content`.`target` AS `target`,
2397 `post-content`.`resource-id` AS `resource-id`,
2398 `post-thread-user`.`contact-id` AS `contact-id`,
2399 `contact`.`uri-id` AS `contact-uri-id`,
2400 `contact`.`url` AS `contact-link`,
2401 `contact`.`addr` AS `contact-addr`,
2402 `contact`.`name` AS `contact-name`,
2403 `contact`.`nick` AS `contact-nick`,
2404 `contact`.`thumb` AS `contact-avatar`,
2405 `contact`.`network` AS `contact-network`,
2406 `contact`.`blocked` AS `contact-blocked`,
2407 `contact`.`hidden` AS `contact-hidden`,
2408 `contact`.`readonly` AS `contact-readonly`,
2409 `contact`.`archive` AS `contact-archive`,
2410 `contact`.`pending` AS `contact-pending`,
2411 `contact`.`rel` AS `contact-rel`,
2412 `contact`.`uid` AS `contact-uid`,
2413 `contact`.`gsid` AS `contact-gsid`,
2414 `contact`.`contact-type` AS `contact-contact-type`,
2415 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
2416 `contact`.`self` AS `self`,
2417 `contact`.`id` AS `cid`,
2418 `contact`.`alias` AS `alias`,
2419 `contact`.`photo` AS `photo`,
2420 `contact`.`name-date` AS `name-date`,
2421 `contact`.`uri-date` AS `uri-date`,
2422 `contact`.`avatar-date` AS `avatar-date`,
2423 `contact`.`thumb` AS `thumb`,
2424 `post-thread-user`.`author-id` AS `author-id`,
2425 `author`.`uri-id` AS `author-uri-id`,
2426 `author`.`url` AS `author-link`,
2427 `author`.`addr` AS `author-addr`,
2428 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
2429 `author`.`nick` AS `author-nick`,
2430 `author`.`alias` AS `author-alias`,
2431 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
2432 `author`.`network` AS `author-network`,
2433 `author`.`blocked` AS `author-blocked`,
2434 `author`.`hidden` AS `author-hidden`,
2435 `author`.`updated` AS `author-updated`,
2436 `author`.`contact-type` AS `author-contact-type`,
2437 `author`.`gsid` AS `author-gsid`,
2438 `post-thread-user`.`owner-id` AS `owner-id`,
2439 `owner`.`uri-id` AS `owner-uri-id`,
2440 `owner`.`url` AS `owner-link`,
2441 `owner`.`addr` AS `owner-addr`,
2442 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
2443 `owner`.`nick` AS `owner-nick`,
2444 `owner`.`alias` AS `owner-alias`,
2445 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
2446 `owner`.`network` AS `owner-network`,
2447 `owner`.`blocked` AS `owner-blocked`,
2448 `owner`.`hidden` AS `owner-hidden`,
2449 `owner`.`updated` AS `owner-updated`,
2450 `owner`.`gsid` AS `owner-gsid`,
2451 `owner`.`contact-type` AS `owner-contact-type`,
2452 `post-thread-user`.`causer-id` AS `causer-id`,
2453 `causer`.`uri-id` AS `causer-uri-id`,
2454 `causer`.`url` AS `causer-link`,
2455 `causer`.`addr` AS `causer-addr`,
2456 `causer`.`name` AS `causer-name`,
2457 `causer`.`nick` AS `causer-nick`,
2458 `causer`.`alias` AS `causer-alias`,
2459 `causer`.`thumb` AS `causer-avatar`,
2460 `causer`.`network` AS `causer-network`,
2461 `causer`.`blocked` AS `causer-blocked`,
2462 `causer`.`hidden` AS `causer-hidden`,
2463 `causer`.`gsid` AS `causer-gsid`,
2464 `causer`.`contact-type` AS `causer-contact-type`,
2465 `post-delivery-data`.`postopts` AS `postopts`,
2466 `post-delivery-data`.`inform` AS `inform`,
2467 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
2468 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
2469 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
2470 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
2471 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
2472 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
2473 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
2474 `post-user`.`event-id` AS `event-id`,
2475 `event`.`created` AS `event-created`,
2476 `event`.`edited` AS `event-edited`,
2477 `event`.`start` AS `event-start`,
2478 `event`.`finish` AS `event-finish`,
2479 `event`.`summary` AS `event-summary`,
2480 `event`.`desc` AS `event-desc`,
2481 `event`.`location` AS `event-location`,
2482 `event`.`type` AS `event-type`,
2483 `event`.`nofinish` AS `event-nofinish`,
2484 `event`.`ignore` AS `event-ignore`,
2485 `post-question`.`id` AS `question-id`,
2486 `post-question`.`multiple` AS `question-multiple`,
2487 `post-question`.`voters` AS `question-voters`,
2488 `post-question`.`end-time` AS `question-end-time`,
2489 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`,
2490 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread-user`.`uri-id`) AS `has-media`,
2491 `diaspora-interaction`.`interaction` AS `signed_text`,
2492 `parent-item-uri`.`guid` AS `parent-guid`,
2493 `post-thread-user`.`network` AS `parent-network`,
2494 `post-thread-user`.`author-id` AS `parent-author-id`,
2495 `author`.`url` AS `parent-author-link`,
2496 `author`.`name` AS `parent-author-name`,
2497 `author`.`nick` AS `parent-author-nick`,
2498 `author`.`network` AS `parent-author-network`
2499 FROM `post-thread-user`
2500 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2501 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2502 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
2503 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
2504 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
2505 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
2506 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
2507 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
2508 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
2509 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
2510 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
2511 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
2512 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
2513 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
2514 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2515 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
2516 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread-user`.`uri-id`
2517 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`;
2522 DROP VIEW IF EXISTS `post-view`;
2523 CREATE VIEW `post-view` AS SELECT
2524 `item-uri`.`uri` AS `uri`,
2525 `post`.`uri-id` AS `uri-id`,
2526 `parent-item-uri`.`uri` AS `parent-uri`,
2527 `post`.`parent-uri-id` AS `parent-uri-id`,
2528 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2529 `post`.`thr-parent-id` AS `thr-parent-id`,
2530 `conversation-item-uri`.`uri` AS `conversation`,
2531 `post-thread`.`conversation-id` AS `conversation-id`,
2532 `quote-item-uri`.`uri` AS `quote-uri`,
2533 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2534 `item-uri`.`guid` AS `guid`,
2535 `post`.`gravity` AS `gravity`,
2536 `external-item-uri`.`uri` AS `extid`,
2537 `post`.`external-id` AS `external-id`,
2538 `post`.`created` AS `created`,
2539 `post`.`edited` AS `edited`,
2540 `post-thread`.`commented` AS `commented`,
2541 `post`.`received` AS `received`,
2542 `post-thread`.`changed` AS `changed`,
2543 `post`.`post-type` AS `post-type`,
2544 `post`.`private` AS `private`,
2545 `post`.`visible` AS `visible`,
2546 `post`.`deleted` AS `deleted`,
2547 `post`.`global` AS `global`,
2548 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post`.`uri-id`) AS `featured`,
2549 `post`.`network` AS `network`,
2550 `post`.`vid` AS `vid`,
2551 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2552 `post-content`.`title` AS `title`,
2553 `post-content`.`content-warning` AS `content-warning`,
2554 `post-content`.`raw-body` AS `raw-body`,
2555 `post-content`.`body` AS `body`,
2556 `post-content`.`rendered-hash` AS `rendered-hash`,
2557 `post-content`.`rendered-html` AS `rendered-html`,
2558 `post-content`.`language` AS `language`,
2559 `post-content`.`plink` AS `plink`,
2560 `post-content`.`location` AS `location`,
2561 `post-content`.`coord` AS `coord`,
2562 `post-content`.`sensitive` AS `sensitive`,
2563 `post-content`.`app` AS `app`,
2564 `post-content`.`object-type` AS `object-type`,
2565 `post-content`.`object` AS `object`,
2566 `post-content`.`target-type` AS `target-type`,
2567 `post-content`.`target` AS `target`,
2568 `post-content`.`resource-id` AS `resource-id`,
2569 `post`.`author-id` AS `contact-id`,
2570 `author`.`uri-id` AS `contact-uri-id`,
2571 `author`.`url` AS `contact-link`,
2572 `author`.`addr` AS `contact-addr`,
2573 `author`.`name` AS `contact-name`,
2574 `author`.`nick` AS `contact-nick`,
2575 `author`.`thumb` AS `contact-avatar`,
2576 `author`.`network` AS `contact-network`,
2577 `author`.`blocked` AS `contact-blocked`,
2578 `author`.`hidden` AS `contact-hidden`,
2579 `author`.`readonly` AS `contact-readonly`,
2580 `author`.`archive` AS `contact-archive`,
2581 `author`.`pending` AS `contact-pending`,
2582 `author`.`rel` AS `contact-rel`,
2583 `author`.`uid` AS `contact-uid`,
2584 `author`.`contact-type` AS `contact-contact-type`,
2585 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2587 `author`.`id` AS `cid`,
2588 `author`.`alias` AS `alias`,
2589 `author`.`photo` AS `photo`,
2590 `author`.`name-date` AS `name-date`,
2591 `author`.`uri-date` AS `uri-date`,
2592 `author`.`avatar-date` AS `avatar-date`,
2593 `author`.`thumb` AS `thumb`,
2594 `post`.`author-id` AS `author-id`,
2595 `author`.`uri-id` AS `author-uri-id`,
2596 `author`.`url` AS `author-link`,
2597 `author`.`addr` AS `author-addr`,
2598 `author`.`name` AS `author-name`,
2599 `author`.`nick` AS `author-nick`,
2600 `author`.`alias` AS `author-alias`,
2601 `author`.`thumb` AS `author-avatar`,
2602 `author`.`network` AS `author-network`,
2603 `author`.`blocked` AS `author-blocked`,
2604 `author`.`hidden` AS `author-hidden`,
2605 `author`.`updated` AS `author-updated`,
2606 `author`.`contact-type` AS `author-contact-type`,
2607 `author`.`gsid` AS `author-gsid`,
2608 `post`.`owner-id` AS `owner-id`,
2609 `owner`.`uri-id` AS `owner-uri-id`,
2610 `owner`.`url` AS `owner-link`,
2611 `owner`.`addr` AS `owner-addr`,
2612 `owner`.`name` AS `owner-name`,
2613 `owner`.`nick` AS `owner-nick`,
2614 `owner`.`alias` AS `owner-alias`,
2615 `owner`.`thumb` AS `owner-avatar`,
2616 `owner`.`network` AS `owner-network`,
2617 `owner`.`blocked` AS `owner-blocked`,
2618 `owner`.`hidden` AS `owner-hidden`,
2619 `owner`.`updated` AS `owner-updated`,
2620 `owner`.`contact-type` AS `owner-contact-type`,
2621 `owner`.`gsid` AS `owner-gsid`,
2622 `post`.`causer-id` AS `causer-id`,
2623 `causer`.`uri-id` AS `causer-uri-id`,
2624 `causer`.`url` AS `causer-link`,
2625 `causer`.`addr` AS `causer-addr`,
2626 `causer`.`name` AS `causer-name`,
2627 `causer`.`nick` AS `causer-nick`,
2628 `causer`.`alias` AS `causer-alias`,
2629 `causer`.`thumb` AS `causer-avatar`,
2630 `causer`.`network` AS `causer-network`,
2631 `causer`.`blocked` AS `causer-blocked`,
2632 `causer`.`hidden` AS `causer-hidden`,
2633 `causer`.`contact-type` AS `causer-contact-type`,
2634 `causer`.`gsid` AS `causer-gsid`,
2635 `post-question`.`id` AS `question-id`,
2636 `post-question`.`multiple` AS `question-multiple`,
2637 `post-question`.`voters` AS `question-voters`,
2638 `post-question`.`end-time` AS `question-end-time`,
2639 0 AS `has-categories`,
2640 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post`.`uri-id`) AS `has-media`,
2641 `diaspora-interaction`.`interaction` AS `signed_text`,
2642 `parent-item-uri`.`guid` AS `parent-guid`,
2643 `post-thread`.`network` AS `parent-network`,
2644 `post-thread`.`author-id` AS `parent-author-id`,
2645 `parent-post-author`.`url` AS `parent-author-link`,
2646 `parent-post-author`.`name` AS `parent-author-name`,
2647 `parent-post-author`.`nick` AS `parent-author-nick`,
2648 `parent-post-author`.`network` AS `parent-author-network`
2650 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
2651 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
2652 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
2653 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
2654 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
2655 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2656 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2657 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
2658 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2659 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2660 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
2661 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
2662 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2663 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post`.`uri-id`
2664 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `post-thread`.`author-id`;
2667 -- VIEW post-thread-view
2669 DROP VIEW IF EXISTS `post-thread-view`;
2670 CREATE VIEW `post-thread-view` AS SELECT
2671 `item-uri`.`uri` AS `uri`,
2672 `post-thread`.`uri-id` AS `uri-id`,
2673 `parent-item-uri`.`uri` AS `parent-uri`,
2674 `post`.`parent-uri-id` AS `parent-uri-id`,
2675 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2676 `post`.`thr-parent-id` AS `thr-parent-id`,
2677 `conversation-item-uri`.`uri` AS `conversation`,
2678 `post-thread`.`conversation-id` AS `conversation-id`,
2679 `quote-item-uri`.`uri` AS `quote-uri`,
2680 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2681 `item-uri`.`guid` AS `guid`,
2682 `post`.`gravity` AS `gravity`,
2683 `external-item-uri`.`uri` AS `extid`,
2684 `post`.`external-id` AS `external-id`,
2685 `post-thread`.`created` AS `created`,
2686 `post`.`edited` AS `edited`,
2687 `post-thread`.`commented` AS `commented`,
2688 `post-thread`.`received` AS `received`,
2689 `post-thread`.`changed` AS `changed`,
2690 `post`.`post-type` AS `post-type`,
2691 `post`.`private` AS `private`,
2692 `post`.`visible` AS `visible`,
2693 `post`.`deleted` AS `deleted`,
2694 `post`.`global` AS `global`,
2695 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread`.`uri-id`) AS `featured`,
2696 `post-thread`.`network` AS `network`,
2697 `post`.`vid` AS `vid`,
2698 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2699 `post-content`.`title` AS `title`,
2700 `post-content`.`content-warning` AS `content-warning`,
2701 `post-content`.`raw-body` AS `raw-body`,
2702 `post-content`.`body` AS `body`,
2703 `post-content`.`rendered-hash` AS `rendered-hash`,
2704 `post-content`.`rendered-html` AS `rendered-html`,
2705 `post-content`.`language` AS `language`,
2706 `post-content`.`plink` AS `plink`,
2707 `post-content`.`location` AS `location`,
2708 `post-content`.`coord` AS `coord`,
2709 `post-content`.`sensitive` AS `sensitive`,
2710 `post-content`.`app` AS `app`,
2711 `post-content`.`object-type` AS `object-type`,
2712 `post-content`.`object` AS `object`,
2713 `post-content`.`target-type` AS `target-type`,
2714 `post-content`.`target` AS `target`,
2715 `post-content`.`resource-id` AS `resource-id`,
2716 `post-thread`.`author-id` AS `contact-id`,
2717 `author`.`uri-id` AS `contact-uri-id`,
2718 `author`.`url` AS `contact-link`,
2719 `author`.`addr` AS `contact-addr`,
2720 `author`.`name` AS `contact-name`,
2721 `author`.`nick` AS `contact-nick`,
2722 `author`.`thumb` AS `contact-avatar`,
2723 `author`.`network` AS `contact-network`,
2724 `author`.`blocked` AS `contact-blocked`,
2725 `author`.`hidden` AS `contact-hidden`,
2726 `author`.`readonly` AS `contact-readonly`,
2727 `author`.`archive` AS `contact-archive`,
2728 `author`.`pending` AS `contact-pending`,
2729 `author`.`rel` AS `contact-rel`,
2730 `author`.`uid` AS `contact-uid`,
2731 `author`.`contact-type` AS `contact-contact-type`,
2732 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2734 `author`.`id` AS `cid`,
2735 `author`.`alias` AS `alias`,
2736 `author`.`photo` AS `photo`,
2737 `author`.`name-date` AS `name-date`,
2738 `author`.`uri-date` AS `uri-date`,
2739 `author`.`avatar-date` AS `avatar-date`,
2740 `author`.`thumb` AS `thumb`,
2741 `post-thread`.`author-id` AS `author-id`,
2742 `author`.`uri-id` AS `author-uri-id`,
2743 `author`.`url` AS `author-link`,
2744 `author`.`addr` AS `author-addr`,
2745 `author`.`name` AS `author-name`,
2746 `author`.`nick` AS `author-nick`,
2747 `author`.`alias` AS `author-alias`,
2748 `author`.`thumb` AS `author-avatar`,
2749 `author`.`network` AS `author-network`,
2750 `author`.`blocked` AS `author-blocked`,
2751 `author`.`hidden` AS `author-hidden`,
2752 `author`.`updated` AS `author-updated`,
2753 `author`.`contact-type` AS `author-contact-type`,
2754 `author`.`gsid` AS `author-gsid`,
2755 `post-thread`.`owner-id` AS `owner-id`,
2756 `owner`.`uri-id` AS `owner-uri-id`,
2757 `owner`.`url` AS `owner-link`,
2758 `owner`.`addr` AS `owner-addr`,
2759 `owner`.`name` AS `owner-name`,
2760 `owner`.`nick` AS `owner-nick`,
2761 `owner`.`alias` AS `owner-alias`,
2762 `owner`.`thumb` AS `owner-avatar`,
2763 `owner`.`network` AS `owner-network`,
2764 `owner`.`blocked` AS `owner-blocked`,
2765 `owner`.`hidden` AS `owner-hidden`,
2766 `owner`.`updated` AS `owner-updated`,
2767 `owner`.`gsid` AS `owner-gsid`,
2768 `owner`.`contact-type` AS `owner-contact-type`,
2769 `post-thread`.`causer-id` AS `causer-id`,
2770 `causer`.`uri-id` AS `causer-uri-id`,
2771 `causer`.`url` AS `causer-link`,
2772 `causer`.`addr` AS `causer-addr`,
2773 `causer`.`name` AS `causer-name`,
2774 `causer`.`nick` AS `causer-nick`,
2775 `causer`.`alias` AS `causer-alias`,
2776 `causer`.`thumb` AS `causer-avatar`,
2777 `causer`.`network` AS `causer-network`,
2778 `causer`.`blocked` AS `causer-blocked`,
2779 `causer`.`hidden` AS `causer-hidden`,
2780 `causer`.`gsid` AS `causer-gsid`,
2781 `causer`.`contact-type` AS `causer-contact-type`,
2782 `post-question`.`id` AS `question-id`,
2783 `post-question`.`multiple` AS `question-multiple`,
2784 `post-question`.`voters` AS `question-voters`,
2785 `post-question`.`end-time` AS `question-end-time`,
2786 0 AS `has-categories`,
2787 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread`.`uri-id`) AS `has-media`,
2788 (SELECT COUNT(*) FROM `post` WHERE `parent-uri-id` = `post-thread`.`uri-id` AND `gravity` = 6) AS `total-comments`,
2789 (SELECT COUNT(DISTINCT(`author-id`)) FROM `post` WHERE `parent-uri-id` = `post-thread`.`uri-id` AND `gravity` = 6) AS `total-actors`,
2790 `diaspora-interaction`.`interaction` AS `signed_text`,
2791 `parent-item-uri`.`guid` AS `parent-guid`,
2792 `post-thread`.`network` AS `parent-network`,
2793 `post-thread`.`author-id` AS `parent-author-id`,
2794 `author`.`url` AS `parent-author-link`,
2795 `author`.`name` AS `parent-author-name`,
2796 `author`.`nick` AS `parent-author-nick`,
2797 `author`.`network` AS `parent-author-network`
2799 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
2800 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
2801 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
2802 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
2803 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
2804 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2805 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2806 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
2807 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2808 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2809 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
2810 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
2811 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2812 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread`.`uri-id`;
2815 -- VIEW category-view
2817 DROP VIEW IF EXISTS `category-view`;
2818 CREATE VIEW `category-view` AS SELECT
2819 `post-category`.`uri-id` AS `uri-id`,
2820 `post-category`.`uid` AS `uid`,
2821 `post-category`.`type` AS `type`,
2822 `post-category`.`tid` AS `tid`,
2823 `tag`.`name` AS `name`,
2824 `tag`.`url` AS `url`
2825 FROM `post-category`
2826 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2829 -- VIEW collection-view
2831 DROP VIEW IF EXISTS `collection-view`;
2832 CREATE VIEW `collection-view` AS SELECT
2833 `post-collection`.`uri-id` AS `uri-id`,
2834 `post-collection`.`type` AS `type`,
2835 `post-collection`.`author-id` AS `cid`,
2836 `post`.`received` AS `received`,
2837 `post`.`created` AS `created`,
2838 `post-thread`.`commented` AS `commented`,
2839 `post`.`private` AS `private`,
2840 `post`.`visible` AS `visible`,
2841 `post`.`deleted` AS `deleted`,
2842 `post`.`thr-parent-id` AS `thr-parent-id`,
2843 `post-collection`.`author-id` AS `author-id`,
2844 `post`.`gravity` AS `gravity`
2845 FROM `post-collection`
2846 INNER JOIN `post` ON `post-collection`.`uri-id` = `post`.`uri-id`
2847 INNER JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`;
2852 DROP VIEW IF EXISTS `media-view`;
2853 CREATE VIEW `media-view` AS SELECT
2854 `post-media`.`uri-id` AS `uri-id`,
2855 `post-media`.`type` AS `type`,
2856 `post`.`received` AS `received`,
2857 `post`.`created` AS `created`,
2858 `post`.`private` AS `private`,
2859 `post`.`visible` AS `visible`,
2860 `post`.`deleted` AS `deleted`,
2861 `post`.`thr-parent-id` AS `thr-parent-id`,
2862 `post`.`author-id` AS `author-id`,
2863 `post`.`gravity` AS `gravity`
2865 INNER JOIN `post` ON `post-media`.`uri-id` = `post`.`uri-id`;
2870 DROP VIEW IF EXISTS `tag-view`;
2871 CREATE VIEW `tag-view` AS SELECT
2872 `post-tag`.`uri-id` AS `uri-id`,
2873 `post-tag`.`type` AS `type`,
2874 `post-tag`.`tid` AS `tid`,
2875 `post-tag`.`cid` AS `cid`,
2876 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2877 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`,
2878 CASE `cid` WHEN 0 THEN `tag`.`type` ELSE 1 END AS `tag-type`
2880 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2881 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2884 -- VIEW network-thread-view
2886 DROP VIEW IF EXISTS `network-thread-view`;
2887 CREATE VIEW `network-thread-view` AS SELECT
2888 `post-thread-user`.`uri-id` AS `uri-id`,
2889 `post-thread-user`.`post-user-id` AS `parent`,
2890 `post-thread-user`.`received` AS `received`,
2891 `post-thread-user`.`commented` AS `commented`,
2892 `post-thread-user`.`created` AS `created`,
2893 `post-thread-user`.`uid` AS `uid`,
2894 `post-thread-user`.`starred` AS `starred`,
2895 `post-thread-user`.`mention` AS `mention`,
2896 `post-thread-user`.`network` AS `network`,
2897 `post-thread-user`.`contact-id` AS `contact-id`,
2898 `ownercontact`.`contact-type` AS `contact-type`
2899 FROM `post-thread-user`
2900 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2901 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2902 STRAIGHT_JOIN `contact` AS `authorcontact` ON `authorcontact`.`id` = `post-thread-user`.`author-id`
2903 STRAIGHT_JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2904 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2905 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2906 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2907 AND NOT `authorcontact`.`blocked` AND NOT `ownercontact`.`blocked`
2908 AND NOT EXISTS(SELECT `cid` FROM `user-contact` WHERE `uid` = `post-thread-user`.`uid` AND `cid` IN (`post-thread-user`.`author-id`, `post-thread-user`.`owner-id`, `post-thread-user`.`causer-id`) AND (`blocked` OR `ignored` OR `channel-only`))
2909 AND NOT EXISTS(SELECT `gsid` FROM `user-gserver` WHERE `uid` = `post-thread-user`.`uid` AND `gsid` IN (`authorcontact`.`gsid`, `ownercontact`.`gsid`) AND `ignored`);
2914 DROP VIEW IF EXISTS `owner-view`;
2915 CREATE VIEW `owner-view` AS SELECT
2916 `contact`.`id` AS `id`,
2917 `contact`.`uid` AS `uid`,
2918 `contact`.`created` AS `created`,
2919 `contact`.`updated` AS `updated`,
2920 `contact`.`self` AS `self`,
2921 `contact`.`remote_self` AS `remote_self`,
2922 `contact`.`rel` AS `rel`,
2923 `contact`.`network` AS `network`,
2924 `contact`.`protocol` AS `protocol`,
2925 `contact`.`name` AS `name`,
2926 `contact`.`nick` AS `nick`,
2927 `contact`.`location` AS `location`,
2928 `contact`.`about` AS `about`,
2929 `contact`.`keywords` AS `keywords`,
2930 `contact`.`xmpp` AS `xmpp`,
2931 `contact`.`matrix` AS `matrix`,
2932 `contact`.`attag` AS `attag`,
2933 `contact`.`avatar` AS `avatar`,
2934 `contact`.`photo` AS `photo`,
2935 `contact`.`thumb` AS `thumb`,
2936 `contact`.`micro` AS `micro`,
2937 `contact`.`header` AS `header`,
2938 `contact`.`url` AS `url`,
2939 `contact`.`nurl` AS `nurl`,
2940 `contact`.`uri-id` AS `uri-id`,
2941 `contact`.`addr` AS `addr`,
2942 `contact`.`alias` AS `alias`,
2943 `contact`.`pubkey` AS `pubkey`,
2944 `contact`.`prvkey` AS `prvkey`,
2945 `contact`.`batch` AS `batch`,
2946 `contact`.`request` AS `request`,
2947 `contact`.`notify` AS `notify`,
2948 `contact`.`poll` AS `poll`,
2949 `contact`.`confirm` AS `confirm`,
2950 `contact`.`poco` AS `poco`,
2951 `contact`.`subhub` AS `subhub`,
2952 `contact`.`hub-verify` AS `hub-verify`,
2953 `contact`.`last-update` AS `last-update`,
2954 `contact`.`success_update` AS `success_update`,
2955 `contact`.`failure_update` AS `failure_update`,
2956 `contact`.`name-date` AS `name-date`,
2957 `contact`.`uri-date` AS `uri-date`,
2958 `contact`.`avatar-date` AS `avatar-date`,
2959 `contact`.`avatar-date` AS `picdate`,
2960 `contact`.`term-date` AS `term-date`,
2961 `contact`.`last-item` AS `last-item`,
2962 `contact`.`priority` AS `priority`,
2963 `user`.`blocked` AS `blocked`,
2964 `contact`.`block_reason` AS `block_reason`,
2965 `contact`.`readonly` AS `readonly`,
2966 `contact`.`writable` AS `writable`,
2967 `contact`.`forum` AS `forum`,
2968 `contact`.`prv` AS `prv`,
2969 `contact`.`contact-type` AS `contact-type`,
2970 `contact`.`manually-approve` AS `manually-approve`,
2971 `contact`.`hidden` AS `hidden`,
2972 `contact`.`archive` AS `archive`,
2973 `contact`.`pending` AS `pending`,
2974 `contact`.`deleted` AS `deleted`,
2975 `contact`.`unsearchable` AS `unsearchable`,
2976 `contact`.`sensitive` AS `sensitive`,
2977 `contact`.`baseurl` AS `baseurl`,
2978 `contact`.`reason` AS `reason`,
2979 `contact`.`info` AS `info`,
2980 `contact`.`bdyear` AS `bdyear`,
2981 `contact`.`bd` AS `bd`,
2982 `contact`.`notify_new_posts` AS `notify_new_posts`,
2983 `contact`.`fetch_further_information` AS `fetch_further_information`,
2984 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2985 `user`.`parent-uid` AS `parent-uid`,
2986 `user`.`guid` AS `guid`,
2987 `user`.`nickname` AS `nickname`,
2988 `user`.`email` AS `email`,
2989 `user`.`openid` AS `openid`,
2990 `user`.`timezone` AS `timezone`,
2991 `user`.`language` AS `language`,
2992 `user`.`register_date` AS `register_date`,
2993 `user`.`login_date` AS `login_date`,
2994 `user`.`last-activity` AS `last-activity`,
2995 `user`.`default-location` AS `default-location`,
2996 `user`.`allow_location` AS `allow_location`,
2997 `user`.`theme` AS `theme`,
2998 `user`.`pubkey` AS `upubkey`,
2999 `user`.`prvkey` AS `uprvkey`,
3000 `user`.`sprvkey` AS `sprvkey`,
3001 `user`.`spubkey` AS `spubkey`,
3002 `user`.`verified` AS `verified`,
3003 `user`.`blockwall` AS `blockwall`,
3004 `user`.`hidewall` AS `hidewall`,
3005 `user`.`blocktags` AS `blocktags`,
3006 `user`.`notify-flags` AS `notify-flags`,
3007 `user`.`page-flags` AS `page-flags`,
3008 `user`.`account-type` AS `account-type`,
3009 `user`.`prvnets` AS `prvnets`,
3010 `user`.`maxreq` AS `maxreq`,
3011 `user`.`expire` AS `expire`,
3012 `user`.`account_removed` AS `account_removed`,
3013 `user`.`account_expired` AS `account_expired`,
3014 `user`.`account_expires_on` AS `account_expires_on`,
3015 `user`.`expire_notification_sent` AS `expire_notification_sent`,
3016 `user`.`def_gid` AS `def_gid`,
3017 `user`.`allow_cid` AS `allow_cid`,
3018 `user`.`allow_gid` AS `allow_gid`,
3019 `user`.`deny_cid` AS `deny_cid`,
3020 `user`.`deny_gid` AS `deny_gid`,
3021 `user`.`openidserver` AS `openidserver`,
3022 `profile`.`publish` AS `publish`,
3023 `profile`.`net-publish` AS `net-publish`,
3024 `profile`.`hide-friends` AS `hide-friends`,
3025 `profile`.`prv_keywords` AS `prv_keywords`,
3026 `profile`.`pub_keywords` AS `pub_keywords`,
3027 `profile`.`address` AS `address`,
3028 `profile`.`locality` AS `locality`,
3029 `profile`.`region` AS `region`,
3030 `profile`.`postal-code` AS `postal-code`,
3031 `profile`.`country-name` AS `country-name`,
3032 `profile`.`homepage` AS `homepage`,
3033 `profile`.`homepage_verified` AS `homepage_verified`,
3034 `profile`.`dob` AS `dob`
3036 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
3037 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
3040 -- VIEW account-view
3042 DROP VIEW IF EXISTS `account-view`;
3043 CREATE VIEW `account-view` AS SELECT
3044 `contact`.`id` AS `id`,
3045 `contact`.`url` AS `url`,
3046 `contact`.`nurl` AS `nurl`,
3047 `contact`.`uri-id` AS `uri-id`,
3048 `item-uri`.`guid` AS `guid`,
3049 `contact`.`addr` AS `addr`,
3050 `contact`.`alias` AS `alias`,
3051 `contact`.`name` AS `name`,
3052 `contact`.`nick` AS `nick`,
3053 `contact`.`about` AS `about`,
3054 `contact`.`keywords` AS `keywords`,
3055 `contact`.`xmpp` AS `xmpp`,
3056 `contact`.`matrix` AS `matrix`,
3057 `contact`.`avatar` AS `avatar`,
3058 `contact`.`photo` AS `photo`,
3059 `contact`.`thumb` AS `thumb`,
3060 `contact`.`micro` AS `micro`,
3061 `contact`.`header` AS `header`,
3062 `contact`.`created` AS `created`,
3063 `contact`.`updated` AS `updated`,
3064 `contact`.`network` AS `network`,
3065 `contact`.`protocol` AS `protocol`,
3066 `contact`.`location` AS `location`,
3067 `contact`.`attag` AS `attag`,
3068 `contact`.`pubkey` AS `pubkey`,
3069 `contact`.`prvkey` AS `prvkey`,
3070 `contact`.`subscribe` AS `subscribe`,
3071 `contact`.`last-update` AS `last-update`,
3072 `contact`.`success_update` AS `success_update`,
3073 `contact`.`failure_update` AS `failure_update`,
3074 `contact`.`failed` AS `failed`,
3075 `contact`.`last-item` AS `last-item`,
3076 `contact`.`last-discovery` AS `last-discovery`,
3077 `contact`.`contact-type` AS `contact-type`,
3078 `contact`.`manually-approve` AS `manually-approve`,
3079 `contact`.`unsearchable` AS `unsearchable`,
3080 `contact`.`sensitive` AS `sensitive`,
3081 `contact`.`baseurl` AS `baseurl`,
3082 `contact`.`gsid` AS `gsid`,
3083 `contact`.`info` AS `info`,
3084 `contact`.`bdyear` AS `bdyear`,
3085 `contact`.`bd` AS `bd`,
3086 `contact`.`poco` AS `poco`,
3087 `contact`.`name-date` AS `name-date`,
3088 `contact`.`uri-date` AS `uri-date`,
3089 `contact`.`avatar-date` AS `avatar-date`,
3090 `contact`.`term-date` AS `term-date`,
3091 `contact`.`hidden` AS `global-ignored`,
3092 `contact`.`blocked` AS `global-blocked`,
3093 `contact`.`hidden` AS `hidden`,
3094 `contact`.`archive` AS `archive`,
3095 `contact`.`deleted` AS `deleted`,
3096 `contact`.`blocked` AS `blocked`,
3097 `contact`.`notify` AS `dfrn-notify`,
3098 `contact`.`poll` AS `dfrn-poll`,
3099 `item-uri`.`guid` AS `diaspora-guid`,
3100 `diaspora-contact`.`batch` AS `diaspora-batch`,
3101 `diaspora-contact`.`notify` AS `diaspora-notify`,
3102 `diaspora-contact`.`poll` AS `diaspora-poll`,
3103 `diaspora-contact`.`alias` AS `diaspora-alias`,
3104 `apcontact`.`uuid` AS `ap-uuid`,
3105 `apcontact`.`type` AS `ap-type`,
3106 `apcontact`.`following` AS `ap-following`,
3107 `apcontact`.`followers` AS `ap-followers`,
3108 `apcontact`.`inbox` AS `ap-inbox`,
3109 `apcontact`.`outbox` AS `ap-outbox`,
3110 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
3111 `apcontact`.`generator` AS `ap-generator`,
3112 `apcontact`.`following_count` AS `ap-following_count`,
3113 `apcontact`.`followers_count` AS `ap-followers_count`,
3114 `apcontact`.`statuses_count` AS `ap-statuses_count`,
3115 `gserver`.`site_name` AS `site_name`,
3116 `gserver`.`platform` AS `platform`,
3117 `gserver`.`version` AS `version`,
3118 `gserver`.`blocked` AS `server-blocked`,
3119 `gserver`.`failed` AS `server-failed`
3121 LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id`
3122 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
3123 LEFT JOIN `diaspora-contact` ON `diaspora-contact`.`uri-id` = contact.`uri-id`
3124 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`
3125 WHERE `contact`.`uid` = 0;
3128 -- VIEW account-user-view
3130 DROP VIEW IF EXISTS `account-user-view`;
3131 CREATE VIEW `account-user-view` AS SELECT
3132 `ucontact`.`id` AS `id`,
3133 `contact`.`id` AS `pid`,
3134 `ucontact`.`uid` AS `uid`,
3135 `contact`.`url` AS `url`,
3136 `contact`.`nurl` AS `nurl`,
3137 `contact`.`uri-id` AS `uri-id`,
3138 `item-uri`.`guid` AS `guid`,
3139 `contact`.`addr` AS `addr`,
3140 `contact`.`alias` AS `alias`,
3141 `contact`.`name` AS `name`,
3142 `contact`.`nick` AS `nick`,
3143 `contact`.`about` AS `about`,
3144 `contact`.`keywords` AS `keywords`,
3145 `contact`.`xmpp` AS `xmpp`,
3146 `contact`.`matrix` AS `matrix`,
3147 `contact`.`avatar` AS `avatar`,
3148 `contact`.`photo` AS `photo`,
3149 `contact`.`thumb` AS `thumb`,
3150 `contact`.`micro` AS `micro`,
3151 `contact`.`header` AS `header`,
3152 `contact`.`created` AS `created`,
3153 `contact`.`updated` AS `updated`,
3154 `ucontact`.`self` AS `self`,
3155 `ucontact`.`remote_self` AS `remote_self`,
3156 `ucontact`.`rel` AS `rel`,
3157 `contact`.`network` AS `network`,
3158 `ucontact`.`protocol` AS `protocol`,
3159 `contact`.`location` AS `location`,
3160 `ucontact`.`attag` AS `attag`,
3161 `contact`.`pubkey` AS `pubkey`,
3162 `contact`.`prvkey` AS `prvkey`,
3163 `contact`.`subscribe` AS `subscribe`,
3164 `contact`.`last-update` AS `last-update`,
3165 `contact`.`success_update` AS `success_update`,
3166 `contact`.`failure_update` AS `failure_update`,
3167 `contact`.`failed` AS `failed`,
3168 `contact`.`last-item` AS `last-item`,
3169 `contact`.`last-discovery` AS `last-discovery`,
3170 `contact`.`contact-type` AS `contact-type`,
3171 `contact`.`manually-approve` AS `manually-approve`,
3172 `contact`.`unsearchable` AS `unsearchable`,
3173 `contact`.`sensitive` AS `sensitive`,
3174 `contact`.`baseurl` AS `baseurl`,
3175 `contact`.`gsid` AS `gsid`,
3176 `ucontact`.`info` AS `info`,
3177 `contact`.`bdyear` AS `bdyear`,
3178 `contact`.`bd` AS `bd`,
3179 `contact`.`poco` AS `poco`,
3180 `contact`.`name-date` AS `name-date`,
3181 `contact`.`uri-date` AS `uri-date`,
3182 `contact`.`avatar-date` AS `avatar-date`,
3183 `contact`.`term-date` AS `term-date`,
3184 `contact`.`hidden` AS `global-ignored`,
3185 `contact`.`blocked` AS `global-blocked`,
3186 `ucontact`.`hidden` AS `hidden`,
3187 `ucontact`.`archive` AS `archive`,
3188 `ucontact`.`pending` AS `pending`,
3189 `ucontact`.`deleted` AS `deleted`,
3190 `ucontact`.`notify_new_posts` AS `notify_new_posts`,
3191 `ucontact`.`fetch_further_information` AS `fetch_further_information`,
3192 `ucontact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
3193 `ucontact`.`rating` AS `rating`,
3194 `ucontact`.`readonly` AS `readonly`,
3195 `ucontact`.`blocked` AS `blocked`,
3196 `ucontact`.`block_reason` AS `block_reason`,
3197 `ucontact`.`subhub` AS `subhub`,
3198 `ucontact`.`hub-verify` AS `hub-verify`,
3199 `ucontact`.`reason` AS `reason`,
3200 `contact`.`notify` AS `dfrn-notify`,
3201 `contact`.`poll` AS `dfrn-poll`,
3202 `item-uri`.`guid` AS `diaspora-guid`,
3203 `diaspora-contact`.`batch` AS `diaspora-batch`,
3204 `diaspora-contact`.`notify` AS `diaspora-notify`,
3205 `diaspora-contact`.`poll` AS `diaspora-poll`,
3206 `diaspora-contact`.`alias` AS `diaspora-alias`,
3207 `diaspora-contact`.`interacting_count` AS `diaspora-interacting_count`,
3208 `diaspora-contact`.`interacted_count` AS `diaspora-interacted_count`,
3209 `diaspora-contact`.`post_count` AS `diaspora-post_count`,
3210 `apcontact`.`uuid` AS `ap-uuid`,
3211 `apcontact`.`type` AS `ap-type`,
3212 `apcontact`.`following` AS `ap-following`,
3213 `apcontact`.`followers` AS `ap-followers`,
3214 `apcontact`.`inbox` AS `ap-inbox`,
3215 `apcontact`.`outbox` AS `ap-outbox`,
3216 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
3217 `apcontact`.`generator` AS `ap-generator`,
3218 `apcontact`.`following_count` AS `ap-following_count`,
3219 `apcontact`.`followers_count` AS `ap-followers_count`,
3220 `apcontact`.`statuses_count` AS `ap-statuses_count`,
3221 `gserver`.`site_name` AS `site_name`,
3222 `gserver`.`platform` AS `platform`,
3223 `gserver`.`version` AS `version`,
3224 `gserver`.`blocked` AS `server-blocked`,
3225 `gserver`.`failed` AS `server-failed`
3226 FROM `contact` AS `ucontact`
3227 INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
3228 LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id`
3229 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
3230 LEFT JOIN `diaspora-contact` ON `diaspora-contact`.`uri-id` = `ucontact`.`uri-id`
3231 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`;
3234 -- VIEW pending-view
3236 DROP VIEW IF EXISTS `pending-view`;
3237 CREATE VIEW `pending-view` AS SELECT
3238 `register`.`id` AS `id`,
3239 `register`.`hash` AS `hash`,
3240 `register`.`created` AS `created`,
3241 `register`.`uid` AS `uid`,
3242 `register`.`password` AS `password`,
3243 `register`.`language` AS `language`,
3244 `register`.`note` AS `note`,
3245 `contact`.`self` AS `self`,
3246 `contact`.`name` AS `name`,
3247 `contact`.`url` AS `url`,
3248 `contact`.`micro` AS `micro`,
3249 `user`.`email` AS `email`,
3250 `contact`.`nick` AS `nick`
3252 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
3253 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
3256 -- VIEW tag-search-view
3258 DROP VIEW IF EXISTS `tag-search-view`;
3259 CREATE VIEW `tag-search-view` AS SELECT
3260 `post-tag`.`uri-id` AS `uri-id`,
3261 `post-user`.`uid` AS `uid`,
3262 `post-user`.`id` AS `iid`,
3263 `post-user`.`private` AS `private`,
3264 `post-user`.`wall` AS `wall`,
3265 `post-user`.`origin` AS `origin`,
3266 `post-user`.`global` AS `global`,
3267 `post-user`.`gravity` AS `gravity`,
3268 `post-user`.`received` AS `received`,
3269 `post-user`.`network` AS `network`,
3270 `post-user`.`author-id` AS `author-id`,
3271 `tag`.`name` AS `name`
3273 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
3274 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
3275 WHERE `post-tag`.`type` = 1;
3278 -- VIEW workerqueue-view
3280 DROP VIEW IF EXISTS `workerqueue-view`;
3281 CREATE VIEW `workerqueue-view` AS SELECT
3282 `process`.`pid` AS `pid`,
3283 `workerqueue`.`priority` AS `priority`
3285 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
3286 WHERE NOT `workerqueue`.`done`;
3289 -- VIEW profile_field-view
3291 DROP VIEW IF EXISTS `profile_field-view`;
3292 CREATE VIEW `profile_field-view` AS SELECT
3293 `profile_field`.`id` AS `id`,
3294 `profile_field`.`uid` AS `uid`,
3295 `profile_field`.`label` AS `label`,
3296 `profile_field`.`value` AS `value`,
3297 `profile_field`.`order` AS `order`,
3298 `profile_field`.`psid` AS `psid`,
3299 `permissionset`.`allow_cid` AS `allow_cid`,
3300 `permissionset`.`allow_gid` AS `allow_gid`,
3301 `permissionset`.`deny_cid` AS `deny_cid`,
3302 `permissionset`.`deny_gid` AS `deny_gid`,
3303 `profile_field`.`created` AS `created`,
3304 `profile_field`.`edited` AS `edited`
3305 FROM `profile_field`
3306 INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`;
3309 -- VIEW diaspora-contact-view
3311 DROP VIEW IF EXISTS `diaspora-contact-view`;
3312 CREATE VIEW `diaspora-contact-view` AS SELECT
3313 `diaspora-contact`.`uri-id` AS `uri-id`,
3314 `item-uri`.`uri` AS `url`,
3315 `item-uri`.`guid` AS `guid`,
3316 `diaspora-contact`.`addr` AS `addr`,
3317 `diaspora-contact`.`alias` AS `alias`,
3318 `diaspora-contact`.`nick` AS `nick`,
3319 `diaspora-contact`.`name` AS `name`,
3320 `diaspora-contact`.`given-name` AS `given-name`,
3321 `diaspora-contact`.`family-name` AS `family-name`,
3322 `diaspora-contact`.`photo` AS `photo`,
3323 `diaspora-contact`.`photo-medium` AS `photo-medium`,
3324 `diaspora-contact`.`photo-small` AS `photo-small`,
3325 `diaspora-contact`.`batch` AS `batch`,
3326 `diaspora-contact`.`notify` AS `notify`,
3327 `diaspora-contact`.`poll` AS `poll`,
3328 `diaspora-contact`.`subscribe` AS `subscribe`,
3329 `diaspora-contact`.`searchable` AS `searchable`,
3330 `diaspora-contact`.`pubkey` AS `pubkey`,
3331 `gserver`.`url` AS `baseurl`,
3332 `diaspora-contact`.`gsid` AS `gsid`,
3333 `diaspora-contact`.`created` AS `created`,
3334 `diaspora-contact`.`updated` AS `updated`,
3335 `diaspora-contact`.`interacting_count` AS `interacting_count`,
3336 `diaspora-contact`.`interacted_count` AS `interacted_count`,
3337 `diaspora-contact`.`post_count` AS `post_count`
3338 FROM `diaspora-contact`
3339 INNER JOIN `item-uri` ON `item-uri`.`id` = `diaspora-contact`.`uri-id`
3340 LEFT JOIN `gserver` ON `gserver`.`id` = `diaspora-contact`.`gsid`;