1 -- ------------------------------------------
2 -- Friendica 2023.09-dev (Giant Rhubarb)
3 -- DB_UPDATE_VERSION 1531
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 `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
77 `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
78 `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
79 `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
80 `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
81 `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
82 `pwdreset` varchar(255) COMMENT 'Password reset request token',
83 `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
84 `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
85 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT 'Delay in days before deleting user-related posts. Scope is controlled by pConfig.',
86 `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
87 `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
88 `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
89 `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
90 `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
91 `allow_cid` mediumtext COMMENT 'default permission for this user',
92 `allow_gid` mediumtext COMMENT 'default permission for this user',
93 `deny_cid` mediumtext COMMENT 'default permission for this user',
94 `deny_gid` mediumtext COMMENT 'default permission for this user',
95 `openidserver` text COMMENT '',
97 INDEX `nickname` (`nickname`(32)),
98 INDEX `parent-uid` (`parent-uid`),
99 INDEX `guid` (`guid`),
100 INDEX `email` (`email`(64)),
101 FOREIGN KEY (`parent-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
102 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
105 -- TABLE user-gserver
107 CREATE TABLE IF NOT EXISTS `user-gserver` (
108 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
109 `gsid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Gserver id',
110 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'server accounts are ignored for the user',
111 PRIMARY KEY(`uid`,`gsid`),
112 INDEX `gsid` (`gsid`),
113 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
114 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
115 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User settings about remote servers';
120 CREATE TABLE IF NOT EXISTS `item-uri` (
121 `id` int unsigned NOT NULL auto_increment,
122 `uri` varbinary(383) NOT NULL COMMENT 'URI of an item',
123 `guid` varbinary(255) COMMENT 'A unique identifier for an item',
125 UNIQUE INDEX `uri` (`uri`),
126 INDEX `guid` (`guid`)
127 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
132 CREATE TABLE IF NOT EXISTS `contact` (
133 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
134 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
135 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
136 `updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last contact update',
137 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network of the contact',
138 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
139 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
140 `location` varchar(255) DEFAULT '' COMMENT '',
141 `about` text COMMENT '',
142 `keywords` text COMMENT 'public keywords (interests) of the contact',
143 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
144 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
145 `avatar` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
146 `blurhash` varbinary(255) COMMENT 'BlurHash representation of the avatar',
147 `header` varbinary(383) COMMENT 'Header picture',
148 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
149 `nurl` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
150 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
151 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
152 `alias` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
153 `pubkey` text COMMENT 'RSA public key 4096 bit',
154 `prvkey` text COMMENT 'RSA private key 4096 bit',
155 `batch` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
156 `notify` varbinary(383) COMMENT '',
157 `poll` varbinary(383) COMMENT '',
158 `subscribe` varbinary(383) COMMENT '',
159 `last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
160 `next-update` datetime COMMENT 'Next connection request',
161 `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
162 `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
163 `failed` boolean COMMENT 'Connection failed',
164 `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
165 `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
166 `last-discovery` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last follower discovery',
167 `local-data` boolean COMMENT 'Is true when there are posts with this contact on the system',
168 `blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
169 `block_reason` text COMMENT 'Node-wide block reason',
170 `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
171 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Person, organisation, news, community, relay',
172 `manually-approve` boolean COMMENT 'Contact requests have to be approved manually',
173 `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
174 `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
175 `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
176 `baseurl` varbinary(383) DEFAULT '' COMMENT 'baseurl of the contact from the gserver record, can be missing',
177 `gsid` int unsigned COMMENT 'Global Server ID, can be missing',
178 `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
179 `reason` text COMMENT '',
180 `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
181 `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
182 `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
183 `protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
184 `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
185 `hub-verify` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
186 `rating` tinyint NOT NULL DEFAULT 0 COMMENT 'Automatically detected feed poll frequency',
187 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Feed poll priority',
188 `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
189 `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
190 `pending` boolean NOT NULL DEFAULT '1' COMMENT 'Contact request is pending',
191 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
192 `info` mediumtext COMMENT '',
193 `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
194 `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
195 `ffi_keyword_denylist` text COMMENT '',
196 `photo` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
197 `thumb` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
198 `micro` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
199 `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
200 `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
201 `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
202 `request` varbinary(383) COMMENT '',
203 `confirm` varbinary(383) COMMENT '',
204 `poco` varbinary(383) COMMENT '',
205 `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
206 `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a group. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = false instead',
207 `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = true instead',
208 `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
209 `site-pubkey` text COMMENT 'Deprecated',
210 `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
211 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
212 `issued-id` varbinary(383) NOT NULL DEFAULT '' COMMENT 'Deprecated',
213 `dfrn-id` varbinary(383) NOT NULL DEFAULT '' COMMENT 'Deprecated',
214 `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
215 `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
216 `usehub` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
217 `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT 'Deprecated',
218 `profile-id` int unsigned COMMENT 'Deprecated',
220 INDEX `uid_name` (`uid`,`name`(190)),
221 INDEX `self_uid` (`self`,`uid`),
222 INDEX `alias_uid` (`alias`(128),`uid`),
223 INDEX `pending_uid` (`pending`,`uid`),
224 INDEX `blocked_uid` (`blocked`,`uid`),
225 INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
226 INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
227 INDEX `batch_contact-type` (`batch`(64),`contact-type`),
228 INDEX `addr_uid` (`addr`(128),`uid`),
229 INDEX `nurl_uid` (`nurl`(128),`uid`),
230 INDEX `nick_uid` (`nick`(128),`uid`),
231 INDEX `attag_uid` (`attag`(96),`uid`),
232 INDEX `network_uid_lastupdate` (`network`,`uid`,`last-update`),
233 INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`),
234 INDEX `next-update` (`next-update`),
235 INDEX `local-data-next-update` (`local-data`,`next-update`),
236 INDEX `uid_lastitem` (`uid`,`last-item`),
237 INDEX `baseurl` (`baseurl`(64)),
238 INDEX `uid_contact-type` (`uid`,`contact-type`),
239 INDEX `uid_self_contact-type` (`uid`,`self`,`contact-type`),
240 INDEX `self_network_uid` (`self`,`network`,`uid`),
241 INDEX `gsid_uid_failed` (`gsid`,`uid`,`failed`),
242 INDEX `uri-id` (`uri-id`),
243 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
244 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
245 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
246 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
251 CREATE TABLE IF NOT EXISTS `tag` (
252 `id` int unsigned NOT NULL auto_increment COMMENT '',
253 `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
254 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
255 `type` tinyint unsigned COMMENT 'Type of the tag (Unknown, General Collection, Follower Collection or Account)',
257 UNIQUE INDEX `type_name_url` (`name`,`url`),
259 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
262 -- TABLE permissionset
264 CREATE TABLE IF NOT EXISTS `permissionset` (
265 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
266 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
267 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
268 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed circles',
269 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
270 `deny_gid` mediumtext COMMENT 'Access Control - list of denied circles',
272 INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`uid`,`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30)),
273 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
274 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
279 CREATE TABLE IF NOT EXISTS `verb` (
280 `id` smallint unsigned NOT NULL auto_increment,
281 `name` varchar(100) NOT NULL DEFAULT '' COMMENT '',
283 INDEX `name` (`name`)
284 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activity Verbs';
287 -- TABLE 2fa_app_specific_password
289 CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
290 `id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
291 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
292 `description` varchar(255) COMMENT 'Description of the usage of the password',
293 `hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
294 `generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
295 `last_used` datetime COMMENT 'Datetime the password was last used',
297 INDEX `uid_description` (`uid`,`description`(190)),
298 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
299 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
302 -- TABLE 2fa_recovery_codes
304 CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
305 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
306 `code` varchar(50) NOT NULL COMMENT 'Recovery code string',
307 `generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
308 `used` datetime COMMENT 'Datetime the code was used',
309 PRIMARY KEY(`uid`,`code`),
310 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
311 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
314 -- TABLE 2fa_trusted_browser
316 CREATE TABLE IF NOT EXISTS `2fa_trusted_browser` (
317 `cookie_hash` varchar(80) NOT NULL COMMENT 'Trusted cookie hash',
318 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
319 `user_agent` text COMMENT 'User agent string',
320 `trusted` boolean NOT NULL DEFAULT '1' COMMENT 'Whenever this browser should be trusted or not',
321 `created` datetime NOT NULL COMMENT 'Datetime the trusted browser was recorded',
322 `last_used` datetime COMMENT 'Datetime the trusted browser was last used',
323 PRIMARY KEY(`cookie_hash`),
325 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
326 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication trusted browsers';
329 -- TABLE account-suggestion
331 CREATE TABLE IF NOT EXISTS `account-suggestion` (
332 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the account url',
333 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
334 `level` smallint unsigned COMMENT 'level of closeness',
335 `ignore` boolean NOT NULL DEFAULT '0' COMMENT 'If set, this account will not be suggested again',
336 PRIMARY KEY(`uid`,`uri-id`),
337 INDEX `uri-id_uid` (`uri-id`,`uid`),
338 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
339 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
340 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Account suggestion';
343 -- TABLE account-user
345 CREATE TABLE IF NOT EXISTS `account-user` (
346 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
347 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the account url',
348 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
350 UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
351 INDEX `uid_uri-id` (`uid`,`uri-id`),
352 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
353 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
354 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Remote and local accounts';
359 CREATE TABLE IF NOT EXISTS `apcontact` (
360 `url` varbinary(383) NOT NULL COMMENT 'URL of the contact',
361 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
362 `uuid` varbinary(255) COMMENT '',
363 `type` varchar(20) NOT NULL COMMENT '',
364 `following` varbinary(383) COMMENT '',
365 `followers` varbinary(383) COMMENT '',
366 `inbox` varbinary(383) NOT NULL COMMENT '',
367 `outbox` varbinary(383) COMMENT '',
368 `sharedinbox` varbinary(383) COMMENT '',
369 `featured` varbinary(383) COMMENT 'Address for the collection of featured posts',
370 `featured-tags` varbinary(383) COMMENT 'Address for the collection of featured tags',
371 `manually-approve` boolean COMMENT '',
372 `discoverable` boolean COMMENT 'Mastodon extension: true if profile is published in their directory',
373 `suspended` boolean COMMENT 'Mastodon extension: true if profile is suspended',
374 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
375 `name` varchar(255) COMMENT '',
376 `about` text COMMENT '',
377 `xmpp` varchar(255) COMMENT 'XMPP address',
378 `matrix` varchar(255) COMMENT 'Matrix address',
379 `photo` varbinary(383) COMMENT '',
380 `header` varbinary(383) COMMENT 'Header picture',
381 `addr` varchar(255) COMMENT '',
382 `alias` varbinary(383) COMMENT '',
383 `pubkey` text COMMENT '',
384 `subscribe` varbinary(383) COMMENT '',
385 `baseurl` varbinary(383) COMMENT 'baseurl of the ap contact',
386 `gsid` int unsigned COMMENT 'Global Server ID',
387 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
388 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
389 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
390 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
391 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
393 INDEX `addr` (`addr`(32)),
394 INDEX `alias` (`alias`(190)),
395 INDEX `followers` (`followers`(190)),
396 INDEX `baseurl` (`baseurl`(190)),
397 INDEX `sharedinbox` (`sharedinbox`(190)),
398 INDEX `gsid` (`gsid`),
399 UNIQUE INDEX `uri-id` (`uri-id`),
400 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
401 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
402 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
407 CREATE TABLE IF NOT EXISTS `application` (
408 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
409 `client_id` varchar(64) NOT NULL COMMENT '',
410 `client_secret` varchar(64) NOT NULL COMMENT '',
411 `name` varchar(255) NOT NULL COMMENT '',
412 `redirect_uri` varbinary(383) NOT NULL COMMENT '',
413 `website` varbinary(383) COMMENT '',
414 `scopes` varchar(255) COMMENT '',
415 `read` boolean COMMENT 'Read scope',
416 `write` boolean COMMENT 'Write scope',
417 `follow` boolean COMMENT 'Follow scope',
418 `push` boolean COMMENT 'Push scope',
420 UNIQUE INDEX `client_id` (`client_id`)
421 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth application';
424 -- TABLE application-marker
426 CREATE TABLE IF NOT EXISTS `application-marker` (
427 `application-id` int unsigned NOT NULL COMMENT '',
428 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
429 `timeline` varchar(64) NOT NULL COMMENT 'Marker (home, notifications)',
430 `last_read_id` varbinary(383) COMMENT 'Marker id for the timeline',
431 `version` smallint unsigned COMMENT 'Version number',
432 `updated_at` datetime COMMENT 'creation time',
433 PRIMARY KEY(`application-id`,`uid`,`timeline`),
434 INDEX `uid_id` (`uid`),
435 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
436 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
437 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Timeline marker';
440 -- TABLE application-token
442 CREATE TABLE IF NOT EXISTS `application-token` (
443 `application-id` int unsigned NOT NULL COMMENT '',
444 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
445 `code` varchar(64) NOT NULL COMMENT '',
446 `access_token` varchar(64) NOT NULL COMMENT '',
447 `created_at` datetime NOT NULL COMMENT 'creation time',
448 `scopes` varchar(255) COMMENT '',
449 `read` boolean COMMENT 'Read scope',
450 `write` boolean COMMENT 'Write scope',
451 `follow` boolean COMMENT 'Follow scope',
452 `push` boolean COMMENT 'Push scope',
453 PRIMARY KEY(`application-id`,`uid`),
454 INDEX `uid_id` (`uid`,`application-id`),
455 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
456 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
457 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth user token';
462 CREATE TABLE IF NOT EXISTS `attach` (
463 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
464 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
465 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
466 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
467 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
468 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
469 `data` longblob NOT NULL COMMENT 'file data',
470 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
471 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
472 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
473 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed circles',
474 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
475 `deny_gid` mediumtext COMMENT 'Access Control - list of denied circles',
476 `backend-class` tinytext COMMENT 'Storage backend class',
477 `backend-ref` text COMMENT 'Storage backend data reference',
480 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
481 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
486 CREATE TABLE IF NOT EXISTS `cache` (
487 `k` varbinary(255) NOT NULL COMMENT 'cache key',
488 `v` mediumtext COMMENT 'cached serialized value',
489 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
490 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
492 INDEX `k_expires` (`k`,`expires`)
493 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
498 CREATE TABLE IF NOT EXISTS `config` (
499 `id` int unsigned NOT NULL auto_increment COMMENT '',
500 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT 'The category of the entry',
501 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT 'The key of the entry',
502 `v` mediumtext COMMENT '',
504 UNIQUE INDEX `cat_k` (`cat`,`k`)
505 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
508 -- TABLE contact-relation
510 CREATE TABLE IF NOT EXISTS `contact-relation` (
511 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
512 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
513 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
514 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
515 `follows` boolean NOT NULL DEFAULT '0' COMMENT '',
516 `score` smallint unsigned COMMENT 'score for interactions of cid on relation-cid',
517 `relation-score` smallint unsigned COMMENT 'score for interactions of relation-cid on cid',
518 `thread-score` smallint unsigned COMMENT 'score for interactions of cid on threads of relation-cid',
519 `relation-thread-score` smallint unsigned COMMENT 'score for interactions of relation-cid on threads of cid',
520 PRIMARY KEY(`cid`,`relation-cid`),
521 INDEX `relation-cid` (`relation-cid`),
522 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
523 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
524 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
529 CREATE TABLE IF NOT EXISTS `conv` (
530 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
531 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
532 `recips` text COMMENT 'sender_handle;recipient_handle',
533 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
534 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
535 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
536 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
537 `subject` text COMMENT 'subject of initial message',
540 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
541 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
546 CREATE TABLE IF NOT EXISTS `workerqueue` (
547 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
548 `command` varchar(100) COMMENT 'Task command',
549 `parameter` mediumtext COMMENT 'Task parameter',
550 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
551 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
552 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
553 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
554 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
555 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
556 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
558 INDEX `command` (`command`),
559 INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
560 INDEX `done_executed` (`done`,`executed`),
561 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
562 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
563 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
564 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
565 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
566 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
569 -- TABLE delayed-post
571 CREATE TABLE IF NOT EXISTS `delayed-post` (
572 `id` int unsigned NOT NULL auto_increment,
573 `uri` varbinary(383) COMMENT 'URI of the post that will be distributed later',
574 `uid` mediumint unsigned COMMENT 'Owner User id',
575 `delayed` datetime COMMENT 'delay time',
576 `wid` int unsigned COMMENT 'Workerqueue id',
578 UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
580 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
581 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
582 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
585 -- TABLE delivery-queue
587 CREATE TABLE IF NOT EXISTS `delivery-queue` (
588 `gsid` int unsigned NOT NULL COMMENT 'Target server',
589 `uri-id` int unsigned NOT NULL COMMENT 'Delivered post',
590 `created` datetime COMMENT '',
591 `command` varbinary(32) COMMENT '',
592 `cid` int unsigned COMMENT 'Target contact',
593 `uid` mediumint unsigned COMMENT 'Delivering user',
594 `failed` tinyint DEFAULT 0 COMMENT 'Number of times the delivery has failed',
595 PRIMARY KEY(`uri-id`,`gsid`),
596 INDEX `gsid_created` (`gsid`,`created`),
599 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
600 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
601 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
602 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
603 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for posts for the batch processing';
606 -- TABLE diaspora-contact
608 CREATE TABLE IF NOT EXISTS `diaspora-contact` (
609 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the contact URL',
610 `addr` varchar(255) COMMENT '',
611 `alias` varchar(255) COMMENT '',
612 `nick` varchar(255) COMMENT '',
613 `name` varchar(255) COMMENT '',
614 `given-name` varchar(255) COMMENT '',
615 `family-name` varchar(255) COMMENT '',
616 `photo` varchar(255) COMMENT '',
617 `photo-medium` varchar(255) COMMENT '',
618 `photo-small` varchar(255) COMMENT '',
619 `batch` varchar(255) COMMENT '',
620 `notify` varchar(255) COMMENT '',
621 `poll` varchar(255) COMMENT '',
622 `subscribe` varchar(255) COMMENT '',
623 `searchable` boolean COMMENT '',
624 `pubkey` text COMMENT '',
625 `gsid` int unsigned COMMENT 'Global Server ID',
626 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
627 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
628 `interacting_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts this contact interacts with',
629 `interacted_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts that interacted with this contact',
630 `post_count` int unsigned DEFAULT 0 COMMENT 'Number of posts and comments',
631 PRIMARY KEY(`uri-id`),
632 UNIQUE INDEX `addr` (`addr`),
633 INDEX `alias` (`alias`),
634 INDEX `gsid` (`gsid`),
635 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
636 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
637 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
640 -- TABLE diaspora-interaction
642 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
643 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
644 `interaction` mediumtext COMMENT 'The Diaspora interaction',
645 PRIMARY KEY(`uri-id`),
646 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
647 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
652 CREATE TABLE IF NOT EXISTS `endpoint` (
653 `url` varbinary(383) NOT NULL COMMENT 'URL of the contact',
654 `type` varchar(20) NOT NULL COMMENT '',
655 `owner-uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
657 UNIQUE INDEX `owner-uri-id_type` (`owner-uri-id`,`type`),
658 FOREIGN KEY (`owner-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
659 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub endpoints - used in the ActivityPub implementation';
664 CREATE TABLE IF NOT EXISTS `event` (
665 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
666 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
667 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
668 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
669 `uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
670 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the event uri',
671 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
672 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
673 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
674 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
675 `summary` text COMMENT 'short description or title of the event',
676 `desc` text COMMENT 'event description',
677 `location` text COMMENT 'event location',
678 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
679 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
680 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
681 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
682 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed circles',
683 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
684 `deny_gid` mediumtext COMMENT 'Access Control - list of denied circles',
686 INDEX `uid_start` (`uid`,`start`),
688 INDEX `uri-id` (`uri-id`),
689 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
690 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
691 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
692 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
697 CREATE TABLE IF NOT EXISTS `fetch-entry` (
698 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
699 `url` varbinary(383) COMMENT 'url that awaiting to be fetched',
700 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of the fetch request',
701 `wid` int unsigned COMMENT 'Workerqueue id',
703 UNIQUE INDEX `url` (`url`),
704 INDEX `created` (`created`),
706 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
707 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
712 CREATE TABLE IF NOT EXISTS `fsuggest` (
713 `id` int unsigned NOT NULL auto_increment COMMENT '',
714 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
715 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
716 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
717 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
718 `request` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
719 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
720 `note` text COMMENT '',
721 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
725 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
726 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
727 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
732 CREATE TABLE IF NOT EXISTS `group` (
733 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
734 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
735 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
736 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the circle has been deleted',
737 `cid` int unsigned COMMENT 'Contact id of group. When this field is filled then the members are synced automatically.',
738 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of circle',
742 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
743 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
744 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy circles, circle info';
747 -- TABLE group_member
749 CREATE TABLE IF NOT EXISTS `group_member` (
750 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
751 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'group.id of the associated circle',
752 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated circle',
754 INDEX `contactid` (`contact-id`),
755 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
756 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
757 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
758 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy circles, member info';
763 CREATE TABLE IF NOT EXISTS `gserver-tag` (
764 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
765 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
766 PRIMARY KEY(`gserver-id`,`tag`),
768 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
769 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
774 CREATE TABLE IF NOT EXISTS `hook` (
775 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
776 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
777 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
778 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
779 `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',
781 INDEX `priority` (`priority`),
782 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
783 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
788 CREATE TABLE IF NOT EXISTS `inbox-entry` (
789 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
790 `activity-id` varbinary(383) COMMENT 'id of the incoming activity',
791 `object-id` varbinary(383) COMMENT '',
792 `in-reply-to-id` varbinary(383) COMMENT '',
793 `conversation` varbinary(383) COMMENT '',
794 `type` varchar(64) COMMENT 'Type of the activity',
795 `object-type` varchar(64) COMMENT 'Type of the object activity',
796 `object-object-type` varchar(64) COMMENT 'Type of the object\'s object activity',
797 `received` datetime COMMENT 'Receiving date',
798 `activity` mediumtext COMMENT 'The JSON activity',
799 `signer` varchar(255) COMMENT '',
800 `push` boolean COMMENT 'Is the entry pushed or have pulled it?',
801 `trust` boolean COMMENT 'Do we trust this entry?',
802 `wid` int unsigned COMMENT 'Workerqueue id',
804 UNIQUE INDEX `activity-id` (`activity-id`),
805 INDEX `object-id` (`object-id`),
806 INDEX `received` (`received`),
808 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
809 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Incoming activity';
812 -- TABLE inbox-entry-receiver
814 CREATE TABLE IF NOT EXISTS `inbox-entry-receiver` (
815 `queue-id` int unsigned NOT NULL COMMENT '',
816 `uid` mediumint unsigned NOT NULL COMMENT 'User id',
817 PRIMARY KEY(`queue-id`,`uid`),
819 FOREIGN KEY (`queue-id`) REFERENCES `inbox-entry` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
820 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
821 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Receiver for the incoming activity';
824 -- TABLE inbox-status
826 CREATE TABLE IF NOT EXISTS `inbox-status` (
827 `url` varbinary(383) NOT NULL COMMENT 'URL of the inbox',
828 `uri-id` int unsigned COMMENT 'Item-uri id of inbox url',
829 `gsid` int unsigned COMMENT 'ID of the related server',
830 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
831 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
832 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
833 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
834 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
835 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
837 INDEX `uri-id` (`uri-id`),
838 INDEX `gsid` (`gsid`),
839 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
840 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
841 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
846 CREATE TABLE IF NOT EXISTS `intro` (
847 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
848 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
849 `fid` int unsigned COMMENT 'deprecated',
850 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
851 `suggest-cid` int unsigned COMMENT 'Suggested contact',
852 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
853 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
854 `note` text COMMENT '',
855 `hash` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
856 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
857 `blocked` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
858 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
860 INDEX `contact-id` (`contact-id`),
861 INDEX `suggest-cid` (`suggest-cid`),
863 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
864 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
865 FOREIGN KEY (`suggest-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
866 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
871 CREATE TABLE IF NOT EXISTS `key-value` (
872 `k` varbinary(50) NOT NULL COMMENT '',
873 `v` mediumtext COMMENT '',
874 `updated_at` int unsigned NOT NULL COMMENT 'timestamp of the last update',
876 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='A key value storage';
881 CREATE TABLE IF NOT EXISTS `locks` (
882 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
883 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
884 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
885 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
886 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
888 INDEX `name_expires` (`name`,`expires`)
889 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
894 CREATE TABLE IF NOT EXISTS `mail` (
895 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
896 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
897 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
898 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
899 `from-photo` varbinary(383) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
900 `from-url` varbinary(383) NOT NULL DEFAULT '' COMMENT 'profile link of the sender',
901 `contact-id` varbinary(255) COMMENT 'contact.id',
902 `author-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the author of the mail',
903 `convid` int unsigned COMMENT 'conv.id',
904 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
905 `body` mediumtext COMMENT '',
906 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
907 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
908 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
909 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
910 `uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
911 `uri-id` int unsigned COMMENT 'Item-uri id of the related mail',
912 `parent-uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
913 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related mail',
914 `thr-parent` varbinary(383) COMMENT '',
915 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
916 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
918 INDEX `uid_seen` (`uid`,`seen`),
919 INDEX `convid` (`convid`),
920 INDEX `uri` (`uri`(64)),
921 INDEX `parent-uri` (`parent-uri`(64)),
922 INDEX `contactid` (`contact-id`(32)),
923 INDEX `author-id` (`author-id`),
924 INDEX `uri-id` (`uri-id`),
925 INDEX `parent-uri-id` (`parent-uri-id`),
926 INDEX `thr-parent-id` (`thr-parent-id`),
927 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
928 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
929 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
930 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
931 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
932 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
937 CREATE TABLE IF NOT EXISTS `mailacct` (
938 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
939 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
940 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
941 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
942 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
943 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
944 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
945 `pass` text COMMENT '',
946 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
947 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
948 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
949 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
950 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
953 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
954 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
959 CREATE TABLE IF NOT EXISTS `manage` (
960 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
961 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
962 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
964 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
966 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
967 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
968 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
971 -- TABLE notification
973 CREATE TABLE IF NOT EXISTS `notification` (
974 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
975 `uid` mediumint unsigned COMMENT 'Owner User id',
976 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
977 `type` smallint unsigned COMMENT '',
978 `actor-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the actor that caused the notification',
979 `target-uri-id` int unsigned COMMENT 'Item-uri id of the related post',
980 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
981 `created` datetime COMMENT '',
982 `seen` boolean DEFAULT '0' COMMENT 'Seen on the desktop',
983 `dismissed` boolean DEFAULT '0' COMMENT 'Dismissed via the API',
985 UNIQUE INDEX `uid_vid_type_actor-id_target-uri-id` (`uid`,`vid`,`type`,`actor-id`,`target-uri-id`),
987 INDEX `actor-id` (`actor-id`),
988 INDEX `target-uri-id` (`target-uri-id`),
989 INDEX `parent-uri-id` (`parent-uri-id`),
990 INDEX `seen_uid` (`seen`,`uid`),
991 INDEX `uid_type_parent-uri-id_actor-id` (`uid`,`type`,`parent-uri-id`,`actor-id`),
992 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
993 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
994 FOREIGN KEY (`actor-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
995 FOREIGN KEY (`target-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
996 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
997 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
1002 CREATE TABLE IF NOT EXISTS `notify` (
1003 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1004 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1005 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1006 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1007 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1008 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1009 `msg` mediumtext COMMENT '',
1010 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1011 `link` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1012 `iid` int unsigned COMMENT '',
1013 `parent` int unsigned COMMENT '',
1014 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
1015 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
1016 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
1017 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
1018 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
1019 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
1020 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
1022 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
1023 INDEX `uid_date` (`uid`,`date`),
1024 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
1025 INDEX `uri-id` (`uri-id`),
1026 INDEX `parent-uri-id` (`parent-uri-id`),
1027 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1028 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1029 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1030 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='[Deprecated] User notifications';
1033 -- TABLE notify-threads
1035 CREATE TABLE IF NOT EXISTS `notify-threads` (
1036 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1037 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1038 `master-parent-item` int unsigned COMMENT 'Deprecated',
1039 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
1040 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1041 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1043 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
1044 INDEX `receiver-uid` (`receiver-uid`),
1045 INDEX `notify-id` (`notify-id`),
1046 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1047 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1048 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1049 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1054 CREATE TABLE IF NOT EXISTS `oembed` (
1055 `url` varbinary(383) NOT NULL COMMENT 'page url',
1056 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
1057 `content` mediumtext COMMENT 'OEmbed data of the page',
1058 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1059 PRIMARY KEY(`url`,`maxwidth`),
1060 INDEX `created` (`created`)
1061 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
1064 -- TABLE openwebauth-token
1066 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
1067 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1068 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
1069 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
1070 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
1071 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1072 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1074 INDEX `uid` (`uid`),
1075 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1076 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
1081 CREATE TABLE IF NOT EXISTS `parsed_url` (
1082 `url_hash` binary(64) NOT NULL COMMENT 'page url hash',
1083 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
1084 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
1085 `url` text NOT NULL COMMENT 'page url',
1086 `content` mediumtext COMMENT 'page data',
1087 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1088 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration',
1089 PRIMARY KEY(`url_hash`,`guessing`,`oembed`),
1090 INDEX `created` (`created`),
1091 INDEX `expires` (`expires`)
1092 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
1097 CREATE TABLE IF NOT EXISTS `pconfig` (
1098 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
1099 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1100 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
1101 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
1102 `v` mediumtext COMMENT 'Value',
1104 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
1105 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1106 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
1111 CREATE TABLE IF NOT EXISTS `photo` (
1112 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1113 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1114 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1115 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
1116 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
1117 `hash` char(32) COMMENT 'hash value of the photo',
1118 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
1119 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
1120 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1121 `desc` text COMMENT '',
1122 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
1123 `photo-type` tinyint unsigned COMMENT 'User avatar, user banner, contact avatar, contact banner or default',
1124 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1125 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
1126 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1127 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1128 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1129 `blurhash` varbinary(255) COMMENT 'BlurHash representation of the photo',
1130 `data` mediumblob NOT NULL COMMENT '',
1131 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1132 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
1133 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
1134 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed circles',
1135 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
1136 `deny_gid` mediumtext COMMENT 'Access Control - list of denied circles',
1137 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
1138 `backend-class` tinytext COMMENT 'Storage backend class',
1139 `backend-ref` text COMMENT 'Storage backend data reference',
1140 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1142 INDEX `contactid` (`contact-id`),
1143 INDEX `uid_contactid` (`uid`,`contact-id`),
1144 INDEX `uid_profile` (`uid`,`profile`),
1145 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
1146 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
1147 INDEX `resource-id` (`resource-id`),
1148 INDEX `uid_photo-type` (`uid`,`photo-type`),
1149 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1150 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1151 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1156 CREATE TABLE IF NOT EXISTS `post` (
1157 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1158 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1159 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1160 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1161 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1162 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1163 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1164 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1165 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1166 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1167 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1168 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1169 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1170 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1171 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1172 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1173 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1174 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1175 PRIMARY KEY(`uri-id`),
1176 INDEX `parent-uri-id` (`parent-uri-id`),
1177 INDEX `thr-parent-id` (`thr-parent-id`),
1178 INDEX `external-id` (`external-id`),
1179 INDEX `owner-id` (`owner-id`),
1180 INDEX `author-id` (`author-id`),
1181 INDEX `causer-id` (`causer-id`),
1182 INDEX `vid` (`vid`),
1183 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1184 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1185 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1186 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1187 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1188 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1189 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1190 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1191 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
1194 -- TABLE post-activity
1196 CREATE TABLE IF NOT EXISTS `post-activity` (
1197 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1198 `activity` mediumtext COMMENT 'Original activity',
1199 `received` datetime COMMENT '',
1200 PRIMARY KEY(`uri-id`),
1201 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1202 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Original remote activity';
1205 -- TABLE post-category
1207 CREATE TABLE IF NOT EXISTS `post-category` (
1208 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1209 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1210 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1211 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1212 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1213 INDEX `tid` (`tid`),
1214 INDEX `uid_uri-id` (`uid`,`uri-id`),
1215 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1216 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1217 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1218 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1221 -- TABLE post-collection
1223 CREATE TABLE IF NOT EXISTS `post-collection` (
1224 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1225 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0 - Featured',
1226 `author-id` int unsigned COMMENT 'Author of the featured post',
1227 PRIMARY KEY(`uri-id`,`type`),
1228 INDEX `type` (`type`),
1229 INDEX `author-id` (`author-id`),
1230 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1231 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1232 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Collection of posts';
1235 -- TABLE post-content
1237 CREATE TABLE IF NOT EXISTS `post-content` (
1238 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1239 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1240 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1241 `body` mediumtext COMMENT 'item body content',
1242 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1243 `quote-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the quoted uri',
1244 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1245 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1246 `language` text COMMENT 'Language information about this post',
1247 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1248 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1249 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1250 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1251 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1252 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1253 `target` text COMMENT 'JSON encoded target structure if used',
1254 `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',
1255 `plink` varbinary(383) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1256 PRIMARY KEY(`uri-id`),
1257 INDEX `plink` (`plink`(191)),
1258 INDEX `resource-id` (`resource-id`),
1259 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
1260 INDEX `quote-uri-id` (`quote-uri-id`),
1261 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1262 FOREIGN KEY (`quote-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1263 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1266 -- TABLE post-delivery
1268 CREATE TABLE IF NOT EXISTS `post-delivery` (
1269 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1270 `inbox-id` int unsigned NOT NULL COMMENT 'Item-uri id of inbox url',
1271 `uid` mediumint unsigned COMMENT 'Delivering user',
1272 `created` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
1273 `command` varbinary(32) COMMENT '',
1274 `failed` tinyint DEFAULT 0 COMMENT 'Number of times the delivery has failed',
1275 `receivers` mediumtext COMMENT 'JSON encoded array with the receiving contacts',
1276 PRIMARY KEY(`uri-id`,`inbox-id`),
1277 INDEX `inbox-id_created` (`inbox-id`,`created`),
1278 INDEX `uid` (`uid`),
1279 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1280 FOREIGN KEY (`inbox-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1281 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1282 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for posts for the batch processing';
1285 -- TABLE post-delivery-data
1287 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1288 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1289 `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',
1290 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1291 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1292 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1293 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1294 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1295 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1296 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1297 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1298 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1299 PRIMARY KEY(`uri-id`),
1300 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1301 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1304 -- TABLE post-engagement
1306 CREATE TABLE IF NOT EXISTS `post-engagement` (
1307 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1308 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1309 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Person, organisation, news, community, relay',
1310 `created` datetime COMMENT '',
1311 `comments` mediumint unsigned COMMENT 'Number of comments',
1312 `activities` mediumint unsigned COMMENT 'Number of activities (like, dislike, ...)',
1313 PRIMARY KEY(`uri-id`),
1314 INDEX `author-id` (`author-id`),
1315 INDEX `created` (`created`),
1316 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1317 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1318 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Engagement data per post';
1321 -- TABLE post-history
1323 CREATE TABLE IF NOT EXISTS `post-history` (
1324 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1325 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of edit',
1326 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1327 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1328 `body` mediumtext COMMENT 'item body content',
1329 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1330 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1331 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1332 `language` text COMMENT 'Language information about this post',
1333 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1334 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1335 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1336 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1337 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1338 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1339 `target` text COMMENT 'JSON encoded target structure if used',
1340 `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',
1341 `plink` varbinary(383) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1342 PRIMARY KEY(`uri-id`,`edited`),
1343 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1344 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post history';
1349 CREATE TABLE IF NOT EXISTS `post-link` (
1350 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1351 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1352 `url` varbinary(511) NOT NULL COMMENT 'External URL',
1353 `mimetype` varchar(60) COMMENT '',
1354 `height` smallint unsigned COMMENT 'Height of the media',
1355 `width` smallint unsigned COMMENT 'Width of the media',
1356 `blurhash` varbinary(255) COMMENT 'BlurHash representation of the link',
1358 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1359 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1360 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post related external links';
1365 CREATE TABLE IF NOT EXISTS `post-media` (
1366 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1367 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1368 `url` varbinary(1024) NOT NULL COMMENT 'Media URL',
1369 `media-uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the activities uri-id',
1370 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1371 `mimetype` varchar(60) COMMENT '',
1372 `height` smallint unsigned COMMENT 'Height of the media',
1373 `width` smallint unsigned COMMENT 'Width of the media',
1374 `size` bigint unsigned COMMENT 'Media size',
1375 `blurhash` varbinary(255) COMMENT 'BlurHash representation of the image',
1376 `preview` varbinary(512) COMMENT 'Preview URL',
1377 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1378 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1379 `description` text COMMENT '',
1380 `name` varchar(255) COMMENT 'Name of the media',
1381 `author-url` varbinary(383) COMMENT 'URL of the author of the media',
1382 `author-name` varchar(255) COMMENT 'Name of the author of the media',
1383 `author-image` varbinary(383) COMMENT 'Image of the author of the media',
1384 `publisher-url` varbinary(383) COMMENT 'URL of the publisher of the media',
1385 `publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
1386 `publisher-image` varbinary(383) COMMENT 'Image of the publisher of the media',
1388 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`(512)),
1389 INDEX `uri-id-id` (`uri-id`,`id`),
1390 INDEX `media-uri-id` (`media-uri-id`),
1391 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1392 FOREIGN KEY (`media-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1393 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1396 -- TABLE post-question
1398 CREATE TABLE IF NOT EXISTS `post-question` (
1399 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1400 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1401 `multiple` boolean NOT NULL DEFAULT '0' COMMENT 'Multiple choice',
1402 `voters` int unsigned COMMENT 'Number of voters for this question',
1403 `end-time` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Question end time',
1405 UNIQUE INDEX `uri-id` (`uri-id`),
1406 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1407 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question';
1410 -- TABLE post-question-option
1412 CREATE TABLE IF NOT EXISTS `post-question-option` (
1413 `id` int unsigned NOT NULL COMMENT 'Id of the question',
1414 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1415 `name` varchar(255) COMMENT 'Name of the option',
1416 `replies` int unsigned COMMENT 'Number of replies for this question option',
1417 PRIMARY KEY(`uri-id`,`id`),
1418 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1419 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question option';
1424 CREATE TABLE IF NOT EXISTS `post-tag` (
1425 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1426 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1427 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1428 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1429 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1430 INDEX `tid` (`tid`),
1431 INDEX `cid` (`cid`),
1432 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1433 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1434 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1435 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1438 -- TABLE post-thread
1440 CREATE TABLE IF NOT EXISTS `post-thread` (
1441 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1442 `conversation-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the conversation uri',
1443 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1444 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1445 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1446 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1447 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1448 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1449 `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',
1450 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1451 PRIMARY KEY(`uri-id`),
1452 INDEX `conversation-id` (`conversation-id`),
1453 INDEX `owner-id` (`owner-id`),
1454 INDEX `author-id` (`author-id`),
1455 INDEX `causer-id` (`causer-id`),
1456 INDEX `received` (`received`),
1457 INDEX `commented` (`commented`),
1458 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1459 FOREIGN KEY (`conversation-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1460 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1461 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1462 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1463 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1468 CREATE TABLE IF NOT EXISTS `post-user` (
1469 `id` int unsigned NOT NULL auto_increment,
1470 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1471 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1472 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1473 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1474 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1475 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1476 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1477 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1478 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1479 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1480 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1481 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1482 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1483 `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
1484 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1485 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1486 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1487 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1488 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1489 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1490 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1491 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1492 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1493 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1494 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1495 `notification-type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1496 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1497 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1498 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1500 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1501 INDEX `uri-id` (`uri-id`),
1502 INDEX `parent-uri-id` (`parent-uri-id`),
1503 INDEX `thr-parent-id` (`thr-parent-id`),
1504 INDEX `external-id` (`external-id`),
1505 INDEX `owner-id` (`owner-id`),
1506 INDEX `author-id` (`author-id`),
1507 INDEX `causer-id` (`causer-id`),
1508 INDEX `vid` (`vid`),
1509 INDEX `contact-id` (`contact-id`),
1510 INDEX `event-id` (`event-id`),
1511 INDEX `psid` (`psid`),
1512 INDEX `author-id_uid` (`author-id`,`uid`),
1513 INDEX `author-id_received` (`author-id`,`received`),
1514 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1515 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1516 INDEX `uid_contactid` (`uid`,`contact-id`),
1517 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1518 INDEX `uid_unseen` (`uid`,`unseen`),
1519 INDEX `uid_hidden_uri-id` (`uid`,`hidden`,`uri-id`),
1520 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1521 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1522 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1523 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1524 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1525 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1526 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1527 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1528 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1529 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1530 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1531 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1532 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1535 -- TABLE post-thread-user
1537 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1538 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1539 `conversation-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the conversation uri',
1540 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1541 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1542 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1543 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1544 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1545 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1546 `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',
1547 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1548 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1549 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
1550 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1551 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1552 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1553 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1554 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1555 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Deprecated',
1556 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1557 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1558 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1559 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1560 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1561 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1562 PRIMARY KEY(`uid`,`uri-id`),
1563 INDEX `uri-id` (`uri-id`),
1564 INDEX `conversation-id` (`conversation-id`),
1565 INDEX `owner-id` (`owner-id`),
1566 INDEX `author-id` (`author-id`),
1567 INDEX `causer-id` (`causer-id`),
1568 INDEX `uid` (`uid`),
1569 INDEX `contact-id` (`contact-id`),
1570 INDEX `psid` (`psid`),
1571 INDEX `post-user-id` (`post-user-id`),
1572 INDEX `commented` (`commented`),
1573 INDEX `uid_received` (`uid`,`received`),
1574 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1575 INDEX `uid_commented` (`uid`,`commented`),
1576 INDEX `uid_starred` (`uid`,`starred`),
1577 INDEX `uid_mention` (`uid`,`mention`),
1578 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1579 FOREIGN KEY (`conversation-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1580 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1581 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1582 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1583 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1584 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1585 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1586 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1587 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1590 -- TABLE post-user-notification
1592 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1593 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1594 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1595 `notification-type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1596 PRIMARY KEY(`uid`,`uri-id`),
1597 INDEX `uri-id` (`uri-id`),
1598 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1599 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1600 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1605 CREATE TABLE IF NOT EXISTS `process` (
1606 `pid` int unsigned NOT NULL COMMENT 'The ID of the process',
1607 `hostname` varchar(255) NOT NULL COMMENT 'The name of the host the process is ran on',
1608 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1609 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1610 PRIMARY KEY(`pid`,`hostname`),
1611 INDEX `command` (`command`)
1612 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1617 CREATE TABLE IF NOT EXISTS `profile` (
1618 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1619 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1620 `profile-name` varchar(255) COMMENT 'Deprecated',
1621 `is-default` boolean COMMENT 'Deprecated',
1622 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1623 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Unused in favor of user.username',
1624 `pdesc` varchar(255) COMMENT 'Deprecated',
1625 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1626 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1627 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1628 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1629 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1630 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1631 `hometown` varchar(255) COMMENT 'Deprecated',
1632 `gender` varchar(32) COMMENT 'Deprecated',
1633 `marital` varchar(255) COMMENT 'Deprecated',
1634 `with` text COMMENT 'Deprecated',
1635 `howlong` datetime COMMENT 'Deprecated',
1636 `sexual` varchar(255) COMMENT 'Deprecated',
1637 `politic` varchar(255) COMMENT 'Deprecated',
1638 `religion` varchar(255) COMMENT 'Deprecated',
1639 `pub_keywords` text COMMENT '',
1640 `prv_keywords` text COMMENT '',
1641 `likes` text COMMENT 'Deprecated',
1642 `dislikes` text COMMENT 'Deprecated',
1643 `about` text COMMENT 'Profile description',
1644 `summary` varchar(255) COMMENT 'Deprecated',
1645 `music` text COMMENT 'Deprecated',
1646 `book` text COMMENT 'Deprecated',
1647 `tv` text COMMENT 'Deprecated',
1648 `film` text COMMENT 'Deprecated',
1649 `interest` text COMMENT 'Deprecated',
1650 `romance` text COMMENT 'Deprecated',
1651 `work` text COMMENT 'Deprecated',
1652 `education` text COMMENT 'Deprecated',
1653 `contact` text COMMENT 'Deprecated',
1654 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1655 `homepage_verified` boolean NOT NULL DEFAULT '0' COMMENT 'was the homepage verified by a rel-me link back to the profile',
1656 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
1657 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
1658 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1659 `thumb` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1660 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1661 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1663 INDEX `uid_is-default` (`uid`,`is-default`),
1664 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1665 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1666 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1669 -- TABLE profile_field
1671 CREATE TABLE IF NOT EXISTS `profile_field` (
1672 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1673 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1674 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1675 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1676 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1677 `value` text COMMENT 'Value of the field',
1678 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1679 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1681 INDEX `uid` (`uid`),
1682 INDEX `order` (`order`),
1683 INDEX `psid` (`psid`),
1684 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1685 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1686 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1689 -- TABLE push_subscriber
1691 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1692 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1693 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1694 `callback_url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1695 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1696 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1697 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1698 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1699 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1700 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1701 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1703 INDEX `next_try` (`next_try`),
1704 INDEX `uid` (`uid`),
1705 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1706 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1711 CREATE TABLE IF NOT EXISTS `register` (
1712 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1713 `hash` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1714 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1715 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1716 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1717 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1718 `note` text COMMENT '',
1720 INDEX `uid` (`uid`),
1721 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1722 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1727 CREATE TABLE IF NOT EXISTS `report` (
1728 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1729 `uid` mediumint unsigned COMMENT 'Reporting user',
1730 `reporter-id` int unsigned COMMENT 'Reporting contact',
1731 `cid` int unsigned NOT NULL COMMENT 'Reported contact',
1732 `gsid` int unsigned COMMENT 'Reported contact server',
1733 `comment` text COMMENT 'Report',
1734 `category-id` int unsigned NOT NULL DEFAULT 1 COMMENT 'Report category, one of Entity\Report::CATEGORY_*',
1735 `forward` boolean COMMENT 'Forward the report to the remote server',
1736 `public-remarks` text COMMENT 'Remarks shared with the reporter',
1737 `private-remarks` text COMMENT 'Remarks shared with the moderation team',
1738 `last-editor-uid` mediumint unsigned COMMENT 'Last editor user',
1739 `assigned-uid` mediumint unsigned COMMENT 'Assigned moderator user',
1740 `status` tinyint unsigned NOT NULL COMMENT 'Status of the report, one of Entity\Report::STATUS_*',
1741 `resolution` tinyint unsigned COMMENT 'Resolution of the report, one of Entity\Report::RESOLUTION_*',
1742 `created` datetime(6) NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1743 `edited` datetime(6) COMMENT 'Last time the report has been edited',
1745 INDEX `uid` (`uid`),
1746 INDEX `cid` (`cid`),
1747 INDEX `reporter-id` (`reporter-id`),
1748 INDEX `gsid` (`gsid`),
1749 INDEX `last-editor-uid` (`last-editor-uid`),
1750 INDEX `assigned-uid` (`assigned-uid`),
1751 INDEX `status-resolution` (`status`,`resolution`),
1752 INDEX `created` (`created`),
1753 INDEX `edited` (`edited`),
1754 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1755 FOREIGN KEY (`reporter-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1756 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1757 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1758 FOREIGN KEY (`last-editor-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1759 FOREIGN KEY (`assigned-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1760 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1763 -- TABLE report-post
1765 CREATE TABLE IF NOT EXISTS `report-post` (
1766 `rid` int unsigned NOT NULL COMMENT 'Report id',
1767 `uri-id` int unsigned NOT NULL COMMENT 'Uri-id of the reported post',
1768 `status` tinyint unsigned COMMENT 'Status of the reported post',
1769 PRIMARY KEY(`rid`,`uri-id`),
1770 INDEX `uri-id` (`uri-id`),
1771 FOREIGN KEY (`rid`) REFERENCES `report` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1772 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1773 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Individual posts attached to a moderation report';
1776 -- TABLE report-rule
1778 CREATE TABLE IF NOT EXISTS `report-rule` (
1779 `rid` int unsigned NOT NULL COMMENT 'Report id',
1780 `line-id` int unsigned NOT NULL COMMENT 'Terms of service rule line number, may become invalid after a TOS change.',
1781 `text` text NOT NULL COMMENT 'Terms of service rule text recorded at the time of the report',
1782 PRIMARY KEY(`rid`,`line-id`),
1783 FOREIGN KEY (`rid`) REFERENCES `report` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1784 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Terms of service rule lines relevant to a moderation report';
1789 CREATE TABLE IF NOT EXISTS `search` (
1790 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1791 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1792 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1794 INDEX `uid_term` (`uid`,`term`(64)),
1795 INDEX `term` (`term`(64)),
1796 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1797 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1802 CREATE TABLE IF NOT EXISTS `session` (
1803 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1804 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1805 `data` text COMMENT '',
1806 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1808 INDEX `sid` (`sid`(64)),
1809 INDEX `expire` (`expire`)
1810 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1815 CREATE TABLE IF NOT EXISTS `storage` (
1816 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1817 `data` longblob NOT NULL COMMENT 'file data',
1819 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1822 -- TABLE subscription
1824 CREATE TABLE IF NOT EXISTS `subscription` (
1825 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1826 `application-id` int unsigned NOT NULL COMMENT '',
1827 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
1828 `endpoint` varchar(511) COMMENT 'Endpoint URL',
1829 `pubkey` varchar(127) COMMENT 'User agent public key',
1830 `secret` varchar(32) COMMENT 'Auth secret',
1831 `follow` boolean COMMENT '',
1832 `favourite` boolean COMMENT '',
1833 `reblog` boolean COMMENT '',
1834 `mention` boolean COMMENT '',
1835 `poll` boolean COMMENT '',
1836 `follow_request` boolean COMMENT '',
1837 `status` boolean COMMENT '',
1839 UNIQUE INDEX `application-id_uid` (`application-id`,`uid`),
1840 INDEX `uid_application-id` (`uid`,`application-id`),
1841 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1842 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1843 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Push Subscription for the API';
1848 CREATE TABLE IF NOT EXISTS `userd` (
1849 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1850 `username` varchar(255) NOT NULL COMMENT '',
1852 INDEX `username` (`username`(32))
1853 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1856 -- TABLE user-contact
1858 CREATE TABLE IF NOT EXISTS `user-contact` (
1859 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1860 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1861 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
1862 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1863 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1864 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1865 `hidden` boolean COMMENT 'This contact is hidden from the others',
1866 `is-blocked` boolean COMMENT 'User is blocked by this contact',
1867 `pending` boolean COMMENT '',
1868 `rel` tinyint unsigned COMMENT 'The kind of the relation between the user and the contact',
1869 `info` mediumtext COMMENT '',
1870 `notify_new_posts` boolean COMMENT '',
1871 `remote_self` tinyint unsigned COMMENT '0 => No mirroring, 1-2 => Mirror as own post, 3 => Mirror as reshare',
1872 `fetch_further_information` tinyint unsigned COMMENT '0 => None, 1 => Fetch information, 3 => Fetch keywords, 2 => Fetch both',
1873 `ffi_keyword_denylist` text COMMENT '',
1874 `subhub` boolean COMMENT '',
1875 `hub-verify` varbinary(383) COMMENT '',
1876 `protocol` char(4) COMMENT 'Protocol of the contact',
1877 `rating` tinyint COMMENT 'Automatically detected feed poll frequency',
1878 `priority` tinyint unsigned COMMENT 'Feed poll priority',
1879 PRIMARY KEY(`uid`,`cid`),
1880 INDEX `cid` (`cid`),
1881 UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
1882 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1883 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1884 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1885 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1888 -- TABLE arrived-activity
1890 CREATE TABLE IF NOT EXISTS `arrived-activity` (
1891 `object-id` varbinary(383) NOT NULL COMMENT 'object id of the incoming activity',
1892 `received` datetime COMMENT 'Receiving date',
1893 PRIMARY KEY(`object-id`)
1894 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Id of arrived activities';
1897 -- TABLE fetched-activity
1899 CREATE TABLE IF NOT EXISTS `fetched-activity` (
1900 `object-id` varbinary(383) NOT NULL COMMENT 'object id of fetched activity',
1901 `received` datetime COMMENT 'Receiving date',
1902 PRIMARY KEY(`object-id`)
1903 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Id of fetched activities';
1908 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1909 `key` int NOT NULL COMMENT '',
1910 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1912 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1915 -- VIEW application-view
1917 DROP VIEW IF EXISTS `application-view`;
1918 CREATE VIEW `application-view` AS SELECT
1919 `application`.`id` AS `id`,
1920 `application-token`.`uid` AS `uid`,
1921 `application`.`name` AS `name`,
1922 `application`.`redirect_uri` AS `redirect_uri`,
1923 `application`.`website` AS `website`,
1924 `application`.`client_id` AS `client_id`,
1925 `application`.`client_secret` AS `client_secret`,
1926 `application-token`.`code` AS `code`,
1927 `application-token`.`access_token` AS `access_token`,
1928 `application-token`.`created_at` AS `created_at`,
1929 `application-token`.`scopes` AS `scopes`,
1930 `application-token`.`read` AS `read`,
1931 `application-token`.`write` AS `write`,
1932 `application-token`.`follow` AS `follow`,
1933 `application-token`.`push` AS `push`
1934 FROM `application-token`
1935 INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`;
1938 -- VIEW circle-member-view
1940 DROP VIEW IF EXISTS `circle-member-view`;
1941 CREATE VIEW `circle-member-view` AS SELECT
1942 `group_member`.`id` AS `id`,
1943 `group`.`uid` AS `uid`,
1944 `group_member`.`contact-id` AS `contact-id`,
1945 `contact`.`uri-id` AS `contact-uri-id`,
1946 `contact`.`url` AS `contact-link`,
1947 `contact`.`addr` AS `contact-addr`,
1948 `contact`.`name` AS `contact-name`,
1949 `contact`.`nick` AS `contact-nick`,
1950 `contact`.`thumb` AS `contact-avatar`,
1951 `contact`.`network` AS `contact-network`,
1952 `contact`.`blocked` AS `contact-blocked`,
1953 `contact`.`hidden` AS `contact-hidden`,
1954 `contact`.`readonly` AS `contact-readonly`,
1955 `contact`.`archive` AS `contact-archive`,
1956 `contact`.`pending` AS `contact-pending`,
1957 `contact`.`self` AS `contact-self`,
1958 `contact`.`rel` AS `contact-rel`,
1959 `contact`.`contact-type` AS `contact-contact-type`,
1960 `group_member`.`gid` AS `circle-id`,
1961 `group`.`visible` AS `circle-visible`,
1962 `group`.`deleted` AS `circle-deleted`,
1963 `group`.`name` AS `circle-name`
1965 INNER JOIN `contact` ON `group_member`.`contact-id` = `contact`.`id`
1966 INNER JOIN `group` ON `group_member`.`gid` = `group`.`id`;
1969 -- VIEW post-user-view
1971 DROP VIEW IF EXISTS `post-user-view`;
1972 CREATE VIEW `post-user-view` AS SELECT
1973 `post-user`.`id` AS `id`,
1974 `post-user`.`id` AS `post-user-id`,
1975 `post-user`.`uid` AS `uid`,
1976 `post-thread-user`.`post-user-id` AS `parent`,
1977 `item-uri`.`uri` AS `uri`,
1978 `post-user`.`uri-id` AS `uri-id`,
1979 `parent-item-uri`.`uri` AS `parent-uri`,
1980 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1981 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1982 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1983 `conversation-item-uri`.`uri` AS `conversation`,
1984 `post-thread-user`.`conversation-id` AS `conversation-id`,
1985 `quote-item-uri`.`uri` AS `quote-uri`,
1986 `post-content`.`quote-uri-id` AS `quote-uri-id`,
1987 `item-uri`.`guid` AS `guid`,
1988 `post-user`.`wall` AS `wall`,
1989 `post-user`.`gravity` AS `gravity`,
1990 `external-item-uri`.`uri` AS `extid`,
1991 `post-user`.`external-id` AS `external-id`,
1992 `post-user`.`created` AS `created`,
1993 `post-user`.`edited` AS `edited`,
1994 `post-thread-user`.`commented` AS `commented`,
1995 `post-user`.`received` AS `received`,
1996 `post-thread-user`.`changed` AS `changed`,
1997 `post-user`.`post-type` AS `post-type`,
1998 `post-user`.`post-reason` AS `post-reason`,
1999 `post-user`.`private` AS `private`,
2000 `post-thread-user`.`pubmail` AS `pubmail`,
2001 `post-user`.`visible` AS `visible`,
2002 `post-thread-user`.`starred` AS `starred`,
2003 `post-user`.`unseen` AS `unseen`,
2004 `post-user`.`deleted` AS `deleted`,
2005 `post-user`.`origin` AS `origin`,
2006 `post-thread-user`.`origin` AS `parent-origin`,
2007 `post-thread-user`.`mention` AS `mention`,
2008 `post-user`.`global` AS `global`,
2009 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-user`.`uri-id`) AS `featured`,
2010 `post-user`.`network` AS `network`,
2011 `post-user`.`protocol` AS `protocol`,
2012 `post-user`.`vid` AS `vid`,
2013 `post-user`.`psid` AS `psid`,
2014 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2015 `post-content`.`title` AS `title`,
2016 `post-content`.`content-warning` AS `content-warning`,
2017 `post-content`.`raw-body` AS `raw-body`,
2018 IFNULL (`post-content`.`body`, '') AS `body`,
2019 `post-content`.`rendered-hash` AS `rendered-hash`,
2020 `post-content`.`rendered-html` AS `rendered-html`,
2021 `post-content`.`language` AS `language`,
2022 `post-content`.`plink` AS `plink`,
2023 `post-content`.`location` AS `location`,
2024 `post-content`.`coord` AS `coord`,
2025 `post-content`.`app` AS `app`,
2026 `post-content`.`object-type` AS `object-type`,
2027 `post-content`.`object` AS `object`,
2028 `post-content`.`target-type` AS `target-type`,
2029 `post-content`.`target` AS `target`,
2030 `post-content`.`resource-id` AS `resource-id`,
2031 `post-user`.`contact-id` AS `contact-id`,
2032 `contact`.`uri-id` AS `contact-uri-id`,
2033 `contact`.`url` AS `contact-link`,
2034 `contact`.`addr` AS `contact-addr`,
2035 `contact`.`name` AS `contact-name`,
2036 `contact`.`nick` AS `contact-nick`,
2037 `contact`.`thumb` AS `contact-avatar`,
2038 `contact`.`network` AS `contact-network`,
2039 `contact`.`blocked` AS `contact-blocked`,
2040 `contact`.`hidden` AS `contact-hidden`,
2041 `contact`.`readonly` AS `contact-readonly`,
2042 `contact`.`archive` AS `contact-archive`,
2043 `contact`.`pending` AS `contact-pending`,
2044 `contact`.`rel` AS `contact-rel`,
2045 `contact`.`uid` AS `contact-uid`,
2046 `contact`.`contact-type` AS `contact-contact-type`,
2047 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
2048 `contact`.`self` AS `self`,
2049 `contact`.`id` AS `cid`,
2050 `contact`.`alias` AS `alias`,
2051 `contact`.`photo` AS `photo`,
2052 `contact`.`name-date` AS `name-date`,
2053 `contact`.`uri-date` AS `uri-date`,
2054 `contact`.`avatar-date` AS `avatar-date`,
2055 `contact`.`thumb` AS `thumb`,
2056 `post-user`.`author-id` AS `author-id`,
2057 `author`.`uri-id` AS `author-uri-id`,
2058 `author`.`url` AS `author-link`,
2059 `author`.`addr` AS `author-addr`,
2060 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
2061 `author`.`nick` AS `author-nick`,
2062 `author`.`alias` AS `author-alias`,
2063 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
2064 `author`.`network` AS `author-network`,
2065 `author`.`blocked` AS `author-blocked`,
2066 `author`.`hidden` AS `author-hidden`,
2067 `author`.`updated` AS `author-updated`,
2068 `author`.`gsid` AS `author-gsid`,
2069 `author`.`baseurl` AS `author-baseurl`,
2070 `post-user`.`owner-id` AS `owner-id`,
2071 `owner`.`uri-id` AS `owner-uri-id`,
2072 `owner`.`url` AS `owner-link`,
2073 `owner`.`addr` AS `owner-addr`,
2074 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
2075 `owner`.`nick` AS `owner-nick`,
2076 `owner`.`alias` AS `owner-alias`,
2077 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
2078 `owner`.`network` AS `owner-network`,
2079 `owner`.`blocked` AS `owner-blocked`,
2080 `owner`.`hidden` AS `owner-hidden`,
2081 `owner`.`updated` AS `owner-updated`,
2082 `owner`.`gsid` AS `owner-gsid`,
2083 `owner`.`contact-type` AS `owner-contact-type`,
2084 `post-user`.`causer-id` AS `causer-id`,
2085 `causer`.`uri-id` AS `causer-uri-id`,
2086 `causer`.`url` AS `causer-link`,
2087 `causer`.`addr` AS `causer-addr`,
2088 `causer`.`name` AS `causer-name`,
2089 `causer`.`nick` AS `causer-nick`,
2090 `causer`.`alias` AS `causer-alias`,
2091 `causer`.`thumb` AS `causer-avatar`,
2092 `causer`.`network` AS `causer-network`,
2093 `causer`.`blocked` AS `causer-blocked`,
2094 `causer`.`hidden` AS `causer-hidden`,
2095 `causer`.`gsid` AS `causer-gsid`,
2096 `causer`.`contact-type` AS `causer-contact-type`,
2097 `post-delivery-data`.`postopts` AS `postopts`,
2098 `post-delivery-data`.`inform` AS `inform`,
2099 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
2100 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
2101 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
2102 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
2103 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
2104 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
2105 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
2106 `post-user`.`event-id` AS `event-id`,
2107 `event`.`created` AS `event-created`,
2108 `event`.`edited` AS `event-edited`,
2109 `event`.`start` AS `event-start`,
2110 `event`.`finish` AS `event-finish`,
2111 `event`.`summary` AS `event-summary`,
2112 `event`.`desc` AS `event-desc`,
2113 `event`.`location` AS `event-location`,
2114 `event`.`type` AS `event-type`,
2115 `event`.`nofinish` AS `event-nofinish`,
2116 `event`.`ignore` AS `event-ignore`,
2117 `post-question`.`id` AS `question-id`,
2118 `post-question`.`multiple` AS `question-multiple`,
2119 `post-question`.`voters` AS `question-voters`,
2120 `post-question`.`end-time` AS `question-end-time`,
2121 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`,
2122 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-user`.`uri-id`) AS `has-media`,
2123 `diaspora-interaction`.`interaction` AS `signed_text`,
2124 `parent-item-uri`.`guid` AS `parent-guid`,
2125 `post-thread-user`.`network` AS `parent-network`,
2126 `post-thread-user`.`author-id` AS `parent-author-id`,
2127 `parent-post-author`.`url` AS `parent-author-link`,
2128 `parent-post-author`.`name` AS `parent-author-name`,
2129 `parent-post-author`.`nick` AS `parent-author-nick`,
2130 `parent-post-author`.`network` AS `parent-author-network`
2132 INNER JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2133 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
2134 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
2135 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
2136 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
2137 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
2138 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
2139 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
2140 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
2141 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
2142 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
2143 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
2144 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
2145 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
2146 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2147 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
2148 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-user`.`uri-id`
2149 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
2150 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `post-thread-user`.`author-id`;
2153 -- VIEW post-thread-user-view
2155 DROP VIEW IF EXISTS `post-thread-user-view`;
2156 CREATE VIEW `post-thread-user-view` AS SELECT
2157 `post-user`.`id` AS `id`,
2158 `post-user`.`id` AS `post-user-id`,
2159 `post-thread-user`.`uid` AS `uid`,
2160 `post-thread-user`.`post-user-id` AS `parent`,
2161 `item-uri`.`uri` AS `uri`,
2162 `post-thread-user`.`uri-id` AS `uri-id`,
2163 `parent-item-uri`.`uri` AS `parent-uri`,
2164 `post-user`.`parent-uri-id` AS `parent-uri-id`,
2165 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2166 `post-user`.`thr-parent-id` AS `thr-parent-id`,
2167 `conversation-item-uri`.`uri` AS `conversation`,
2168 `post-thread-user`.`conversation-id` AS `conversation-id`,
2169 `quote-item-uri`.`uri` AS `quote-uri`,
2170 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2171 `item-uri`.`guid` AS `guid`,
2172 `post-thread-user`.`wall` AS `wall`,
2173 `post-user`.`gravity` AS `gravity`,
2174 `external-item-uri`.`uri` AS `extid`,
2175 `post-user`.`external-id` AS `external-id`,
2176 `post-thread-user`.`created` AS `created`,
2177 `post-user`.`edited` AS `edited`,
2178 `post-thread-user`.`commented` AS `commented`,
2179 `post-thread-user`.`received` AS `received`,
2180 `post-thread-user`.`changed` AS `changed`,
2181 `post-user`.`post-type` AS `post-type`,
2182 `post-user`.`post-reason` AS `post-reason`,
2183 `post-user`.`private` AS `private`,
2184 `post-thread-user`.`pubmail` AS `pubmail`,
2185 `post-thread-user`.`ignored` AS `ignored`,
2186 `post-user`.`visible` AS `visible`,
2187 `post-thread-user`.`starred` AS `starred`,
2188 `post-thread-user`.`unseen` AS `unseen`,
2189 `post-user`.`deleted` AS `deleted`,
2190 `post-thread-user`.`origin` AS `origin`,
2191 `post-thread-user`.`mention` AS `mention`,
2192 `post-user`.`global` AS `global`,
2193 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread-user`.`uri-id`) AS `featured`,
2194 `post-thread-user`.`network` AS `network`,
2195 `post-user`.`vid` AS `vid`,
2196 `post-thread-user`.`psid` AS `psid`,
2197 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2198 `post-content`.`title` AS `title`,
2199 `post-content`.`content-warning` AS `content-warning`,
2200 `post-content`.`raw-body` AS `raw-body`,
2201 `post-content`.`body` AS `body`,
2202 `post-content`.`rendered-hash` AS `rendered-hash`,
2203 `post-content`.`rendered-html` AS `rendered-html`,
2204 `post-content`.`language` AS `language`,
2205 `post-content`.`plink` AS `plink`,
2206 `post-content`.`location` AS `location`,
2207 `post-content`.`coord` AS `coord`,
2208 `post-content`.`app` AS `app`,
2209 `post-content`.`object-type` AS `object-type`,
2210 `post-content`.`object` AS `object`,
2211 `post-content`.`target-type` AS `target-type`,
2212 `post-content`.`target` AS `target`,
2213 `post-content`.`resource-id` AS `resource-id`,
2214 `post-thread-user`.`contact-id` AS `contact-id`,
2215 `contact`.`uri-id` AS `contact-uri-id`,
2216 `contact`.`url` AS `contact-link`,
2217 `contact`.`addr` AS `contact-addr`,
2218 `contact`.`name` AS `contact-name`,
2219 `contact`.`nick` AS `contact-nick`,
2220 `contact`.`thumb` AS `contact-avatar`,
2221 `contact`.`network` AS `contact-network`,
2222 `contact`.`blocked` AS `contact-blocked`,
2223 `contact`.`hidden` AS `contact-hidden`,
2224 `contact`.`readonly` AS `contact-readonly`,
2225 `contact`.`archive` AS `contact-archive`,
2226 `contact`.`pending` AS `contact-pending`,
2227 `contact`.`rel` AS `contact-rel`,
2228 `contact`.`uid` AS `contact-uid`,
2229 `contact`.`gsid` AS `contact-gsid`,
2230 `contact`.`contact-type` AS `contact-contact-type`,
2231 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
2232 `contact`.`self` AS `self`,
2233 `contact`.`id` AS `cid`,
2234 `contact`.`alias` AS `alias`,
2235 `contact`.`photo` AS `photo`,
2236 `contact`.`name-date` AS `name-date`,
2237 `contact`.`uri-date` AS `uri-date`,
2238 `contact`.`avatar-date` AS `avatar-date`,
2239 `contact`.`thumb` AS `thumb`,
2240 `post-thread-user`.`author-id` AS `author-id`,
2241 `author`.`uri-id` AS `author-uri-id`,
2242 `author`.`url` AS `author-link`,
2243 `author`.`addr` AS `author-addr`,
2244 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
2245 `author`.`nick` AS `author-nick`,
2246 `author`.`alias` AS `author-alias`,
2247 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
2248 `author`.`network` AS `author-network`,
2249 `author`.`blocked` AS `author-blocked`,
2250 `author`.`hidden` AS `author-hidden`,
2251 `author`.`updated` AS `author-updated`,
2252 `author`.`gsid` AS `author-gsid`,
2253 `post-thread-user`.`owner-id` AS `owner-id`,
2254 `owner`.`uri-id` AS `owner-uri-id`,
2255 `owner`.`url` AS `owner-link`,
2256 `owner`.`addr` AS `owner-addr`,
2257 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
2258 `owner`.`nick` AS `owner-nick`,
2259 `owner`.`alias` AS `owner-alias`,
2260 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
2261 `owner`.`network` AS `owner-network`,
2262 `owner`.`blocked` AS `owner-blocked`,
2263 `owner`.`hidden` AS `owner-hidden`,
2264 `owner`.`updated` AS `owner-updated`,
2265 `owner`.`gsid` AS `owner-gsid`,
2266 `owner`.`contact-type` AS `owner-contact-type`,
2267 `post-thread-user`.`causer-id` AS `causer-id`,
2268 `causer`.`uri-id` AS `causer-uri-id`,
2269 `causer`.`url` AS `causer-link`,
2270 `causer`.`addr` AS `causer-addr`,
2271 `causer`.`name` AS `causer-name`,
2272 `causer`.`nick` AS `causer-nick`,
2273 `causer`.`alias` AS `causer-alias`,
2274 `causer`.`thumb` AS `causer-avatar`,
2275 `causer`.`network` AS `causer-network`,
2276 `causer`.`blocked` AS `causer-blocked`,
2277 `causer`.`hidden` AS `causer-hidden`,
2278 `causer`.`gsid` AS `causer-gsid`,
2279 `causer`.`contact-type` AS `causer-contact-type`,
2280 `post-delivery-data`.`postopts` AS `postopts`,
2281 `post-delivery-data`.`inform` AS `inform`,
2282 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
2283 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
2284 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
2285 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
2286 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
2287 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
2288 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
2289 `post-user`.`event-id` AS `event-id`,
2290 `event`.`created` AS `event-created`,
2291 `event`.`edited` AS `event-edited`,
2292 `event`.`start` AS `event-start`,
2293 `event`.`finish` AS `event-finish`,
2294 `event`.`summary` AS `event-summary`,
2295 `event`.`desc` AS `event-desc`,
2296 `event`.`location` AS `event-location`,
2297 `event`.`type` AS `event-type`,
2298 `event`.`nofinish` AS `event-nofinish`,
2299 `event`.`ignore` AS `event-ignore`,
2300 `post-question`.`id` AS `question-id`,
2301 `post-question`.`multiple` AS `question-multiple`,
2302 `post-question`.`voters` AS `question-voters`,
2303 `post-question`.`end-time` AS `question-end-time`,
2304 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`,
2305 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread-user`.`uri-id`) AS `has-media`,
2306 `diaspora-interaction`.`interaction` AS `signed_text`,
2307 `parent-item-uri`.`guid` AS `parent-guid`,
2308 `post-thread-user`.`network` AS `parent-network`,
2309 `post-thread-user`.`author-id` AS `parent-author-id`,
2310 `author`.`url` AS `parent-author-link`,
2311 `author`.`name` AS `parent-author-name`,
2312 `author`.`nick` AS `parent-author-nick`,
2313 `author`.`network` AS `parent-author-network`
2314 FROM `post-thread-user`
2315 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2316 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2317 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
2318 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
2319 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
2320 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
2321 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
2322 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
2323 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
2324 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
2325 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
2326 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
2327 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
2328 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
2329 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2330 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
2331 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread-user`.`uri-id`
2332 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`;
2337 DROP VIEW IF EXISTS `post-view`;
2338 CREATE VIEW `post-view` AS SELECT
2339 `item-uri`.`uri` AS `uri`,
2340 `post`.`uri-id` AS `uri-id`,
2341 `parent-item-uri`.`uri` AS `parent-uri`,
2342 `post`.`parent-uri-id` AS `parent-uri-id`,
2343 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2344 `post`.`thr-parent-id` AS `thr-parent-id`,
2345 `conversation-item-uri`.`uri` AS `conversation`,
2346 `post-thread`.`conversation-id` AS `conversation-id`,
2347 `quote-item-uri`.`uri` AS `quote-uri`,
2348 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2349 `item-uri`.`guid` AS `guid`,
2350 `post`.`gravity` AS `gravity`,
2351 `external-item-uri`.`uri` AS `extid`,
2352 `post`.`external-id` AS `external-id`,
2353 `post`.`created` AS `created`,
2354 `post`.`edited` AS `edited`,
2355 `post-thread`.`commented` AS `commented`,
2356 `post`.`received` AS `received`,
2357 `post-thread`.`changed` AS `changed`,
2358 `post`.`post-type` AS `post-type`,
2359 `post`.`private` AS `private`,
2360 `post`.`visible` AS `visible`,
2361 `post`.`deleted` AS `deleted`,
2362 `post`.`global` AS `global`,
2363 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post`.`uri-id`) AS `featured`,
2364 `post`.`network` AS `network`,
2365 `post`.`vid` AS `vid`,
2366 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2367 `post-content`.`title` AS `title`,
2368 `post-content`.`content-warning` AS `content-warning`,
2369 `post-content`.`raw-body` AS `raw-body`,
2370 `post-content`.`body` AS `body`,
2371 `post-content`.`rendered-hash` AS `rendered-hash`,
2372 `post-content`.`rendered-html` AS `rendered-html`,
2373 `post-content`.`language` AS `language`,
2374 `post-content`.`plink` AS `plink`,
2375 `post-content`.`location` AS `location`,
2376 `post-content`.`coord` AS `coord`,
2377 `post-content`.`app` AS `app`,
2378 `post-content`.`object-type` AS `object-type`,
2379 `post-content`.`object` AS `object`,
2380 `post-content`.`target-type` AS `target-type`,
2381 `post-content`.`target` AS `target`,
2382 `post-content`.`resource-id` AS `resource-id`,
2383 `post`.`author-id` AS `contact-id`,
2384 `author`.`uri-id` AS `contact-uri-id`,
2385 `author`.`url` AS `contact-link`,
2386 `author`.`addr` AS `contact-addr`,
2387 `author`.`name` AS `contact-name`,
2388 `author`.`nick` AS `contact-nick`,
2389 `author`.`thumb` AS `contact-avatar`,
2390 `author`.`network` AS `contact-network`,
2391 `author`.`blocked` AS `contact-blocked`,
2392 `author`.`hidden` AS `contact-hidden`,
2393 `author`.`readonly` AS `contact-readonly`,
2394 `author`.`archive` AS `contact-archive`,
2395 `author`.`pending` AS `contact-pending`,
2396 `author`.`rel` AS `contact-rel`,
2397 `author`.`uid` AS `contact-uid`,
2398 `author`.`contact-type` AS `contact-contact-type`,
2399 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2401 `author`.`id` AS `cid`,
2402 `author`.`alias` AS `alias`,
2403 `author`.`photo` AS `photo`,
2404 `author`.`name-date` AS `name-date`,
2405 `author`.`uri-date` AS `uri-date`,
2406 `author`.`avatar-date` AS `avatar-date`,
2407 `author`.`thumb` AS `thumb`,
2408 `post`.`author-id` AS `author-id`,
2409 `author`.`uri-id` AS `author-uri-id`,
2410 `author`.`url` AS `author-link`,
2411 `author`.`addr` AS `author-addr`,
2412 `author`.`name` AS `author-name`,
2413 `author`.`nick` AS `author-nick`,
2414 `author`.`alias` AS `author-alias`,
2415 `author`.`thumb` AS `author-avatar`,
2416 `author`.`network` AS `author-network`,
2417 `author`.`blocked` AS `author-blocked`,
2418 `author`.`hidden` AS `author-hidden`,
2419 `author`.`updated` AS `author-updated`,
2420 `author`.`gsid` AS `author-gsid`,
2421 `post`.`owner-id` AS `owner-id`,
2422 `owner`.`uri-id` AS `owner-uri-id`,
2423 `owner`.`url` AS `owner-link`,
2424 `owner`.`addr` AS `owner-addr`,
2425 `owner`.`name` AS `owner-name`,
2426 `owner`.`nick` AS `owner-nick`,
2427 `owner`.`alias` AS `owner-alias`,
2428 `owner`.`thumb` AS `owner-avatar`,
2429 `owner`.`network` AS `owner-network`,
2430 `owner`.`blocked` AS `owner-blocked`,
2431 `owner`.`hidden` AS `owner-hidden`,
2432 `owner`.`updated` AS `owner-updated`,
2433 `owner`.`contact-type` AS `owner-contact-type`,
2434 `owner`.`gsid` AS `owner-gsid`,
2435 `post`.`causer-id` AS `causer-id`,
2436 `causer`.`uri-id` AS `causer-uri-id`,
2437 `causer`.`url` AS `causer-link`,
2438 `causer`.`addr` AS `causer-addr`,
2439 `causer`.`name` AS `causer-name`,
2440 `causer`.`nick` AS `causer-nick`,
2441 `causer`.`alias` AS `causer-alias`,
2442 `causer`.`thumb` AS `causer-avatar`,
2443 `causer`.`network` AS `causer-network`,
2444 `causer`.`blocked` AS `causer-blocked`,
2445 `causer`.`hidden` AS `causer-hidden`,
2446 `causer`.`contact-type` AS `causer-contact-type`,
2447 `causer`.`gsid` AS `causer-gsid`,
2448 `post-question`.`id` AS `question-id`,
2449 `post-question`.`multiple` AS `question-multiple`,
2450 `post-question`.`voters` AS `question-voters`,
2451 `post-question`.`end-time` AS `question-end-time`,
2452 0 AS `has-categories`,
2453 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post`.`uri-id`) AS `has-media`,
2454 `diaspora-interaction`.`interaction` AS `signed_text`,
2455 `parent-item-uri`.`guid` AS `parent-guid`,
2456 `post-thread`.`network` AS `parent-network`,
2457 `post-thread`.`author-id` AS `parent-author-id`,
2458 `parent-post-author`.`url` AS `parent-author-link`,
2459 `parent-post-author`.`name` AS `parent-author-name`,
2460 `parent-post-author`.`nick` AS `parent-author-nick`,
2461 `parent-post-author`.`network` AS `parent-author-network`
2463 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
2464 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
2465 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
2466 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
2467 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
2468 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2469 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2470 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
2471 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2472 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2473 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
2474 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
2475 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2476 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post`.`uri-id`
2477 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `post-thread`.`author-id`;
2480 -- VIEW post-thread-view
2482 DROP VIEW IF EXISTS `post-thread-view`;
2483 CREATE VIEW `post-thread-view` AS SELECT
2484 `item-uri`.`uri` AS `uri`,
2485 `post-thread`.`uri-id` AS `uri-id`,
2486 `parent-item-uri`.`uri` AS `parent-uri`,
2487 `post`.`parent-uri-id` AS `parent-uri-id`,
2488 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2489 `post`.`thr-parent-id` AS `thr-parent-id`,
2490 `conversation-item-uri`.`uri` AS `conversation`,
2491 `post-thread`.`conversation-id` AS `conversation-id`,
2492 `quote-item-uri`.`uri` AS `quote-uri`,
2493 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2494 `item-uri`.`guid` AS `guid`,
2495 `post`.`gravity` AS `gravity`,
2496 `external-item-uri`.`uri` AS `extid`,
2497 `post`.`external-id` AS `external-id`,
2498 `post-thread`.`created` AS `created`,
2499 `post`.`edited` AS `edited`,
2500 `post-thread`.`commented` AS `commented`,
2501 `post-thread`.`received` AS `received`,
2502 `post-thread`.`changed` AS `changed`,
2503 `post`.`post-type` AS `post-type`,
2504 `post`.`private` AS `private`,
2505 `post`.`visible` AS `visible`,
2506 `post`.`deleted` AS `deleted`,
2507 `post`.`global` AS `global`,
2508 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread`.`uri-id`) AS `featured`,
2509 `post-thread`.`network` AS `network`,
2510 `post`.`vid` AS `vid`,
2511 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2512 `post-content`.`title` AS `title`,
2513 `post-content`.`content-warning` AS `content-warning`,
2514 `post-content`.`raw-body` AS `raw-body`,
2515 `post-content`.`body` AS `body`,
2516 `post-content`.`rendered-hash` AS `rendered-hash`,
2517 `post-content`.`rendered-html` AS `rendered-html`,
2518 `post-content`.`language` AS `language`,
2519 `post-content`.`plink` AS `plink`,
2520 `post-content`.`location` AS `location`,
2521 `post-content`.`coord` AS `coord`,
2522 `post-content`.`app` AS `app`,
2523 `post-content`.`object-type` AS `object-type`,
2524 `post-content`.`object` AS `object`,
2525 `post-content`.`target-type` AS `target-type`,
2526 `post-content`.`target` AS `target`,
2527 `post-content`.`resource-id` AS `resource-id`,
2528 `post-thread`.`author-id` AS `contact-id`,
2529 `author`.`uri-id` AS `contact-uri-id`,
2530 `author`.`url` AS `contact-link`,
2531 `author`.`addr` AS `contact-addr`,
2532 `author`.`name` AS `contact-name`,
2533 `author`.`nick` AS `contact-nick`,
2534 `author`.`thumb` AS `contact-avatar`,
2535 `author`.`network` AS `contact-network`,
2536 `author`.`blocked` AS `contact-blocked`,
2537 `author`.`hidden` AS `contact-hidden`,
2538 `author`.`readonly` AS `contact-readonly`,
2539 `author`.`archive` AS `contact-archive`,
2540 `author`.`pending` AS `contact-pending`,
2541 `author`.`rel` AS `contact-rel`,
2542 `author`.`uid` AS `contact-uid`,
2543 `author`.`contact-type` AS `contact-contact-type`,
2544 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2546 `author`.`id` AS `cid`,
2547 `author`.`alias` AS `alias`,
2548 `author`.`photo` AS `photo`,
2549 `author`.`name-date` AS `name-date`,
2550 `author`.`uri-date` AS `uri-date`,
2551 `author`.`avatar-date` AS `avatar-date`,
2552 `author`.`thumb` AS `thumb`,
2553 `post-thread`.`author-id` AS `author-id`,
2554 `author`.`uri-id` AS `author-uri-id`,
2555 `author`.`url` AS `author-link`,
2556 `author`.`addr` AS `author-addr`,
2557 `author`.`name` AS `author-name`,
2558 `author`.`nick` AS `author-nick`,
2559 `author`.`alias` AS `author-alias`,
2560 `author`.`thumb` AS `author-avatar`,
2561 `author`.`network` AS `author-network`,
2562 `author`.`blocked` AS `author-blocked`,
2563 `author`.`hidden` AS `author-hidden`,
2564 `author`.`updated` AS `author-updated`,
2565 `author`.`gsid` AS `author-gsid`,
2566 `post-thread`.`owner-id` AS `owner-id`,
2567 `owner`.`uri-id` AS `owner-uri-id`,
2568 `owner`.`url` AS `owner-link`,
2569 `owner`.`addr` AS `owner-addr`,
2570 `owner`.`name` AS `owner-name`,
2571 `owner`.`nick` AS `owner-nick`,
2572 `owner`.`alias` AS `owner-alias`,
2573 `owner`.`thumb` AS `owner-avatar`,
2574 `owner`.`network` AS `owner-network`,
2575 `owner`.`blocked` AS `owner-blocked`,
2576 `owner`.`hidden` AS `owner-hidden`,
2577 `owner`.`updated` AS `owner-updated`,
2578 `owner`.`gsid` AS `owner-gsid`,
2579 `owner`.`contact-type` AS `owner-contact-type`,
2580 `post-thread`.`causer-id` AS `causer-id`,
2581 `causer`.`uri-id` AS `causer-uri-id`,
2582 `causer`.`url` AS `causer-link`,
2583 `causer`.`addr` AS `causer-addr`,
2584 `causer`.`name` AS `causer-name`,
2585 `causer`.`nick` AS `causer-nick`,
2586 `causer`.`alias` AS `causer-alias`,
2587 `causer`.`thumb` AS `causer-avatar`,
2588 `causer`.`network` AS `causer-network`,
2589 `causer`.`blocked` AS `causer-blocked`,
2590 `causer`.`hidden` AS `causer-hidden`,
2591 `causer`.`gsid` AS `causer-gsid`,
2592 `causer`.`contact-type` AS `causer-contact-type`,
2593 `post-question`.`id` AS `question-id`,
2594 `post-question`.`multiple` AS `question-multiple`,
2595 `post-question`.`voters` AS `question-voters`,
2596 `post-question`.`end-time` AS `question-end-time`,
2597 0 AS `has-categories`,
2598 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread`.`uri-id`) AS `has-media`,
2599 (SELECT COUNT(*) FROM `post` WHERE `parent-uri-id` = `post-thread`.`uri-id` AND `gravity` = 6) AS `total-comments`,
2600 (SELECT COUNT(DISTINCT(`author-id`)) FROM `post` WHERE `parent-uri-id` = `post-thread`.`uri-id` AND `gravity` = 6) AS `total-actors`,
2601 `diaspora-interaction`.`interaction` AS `signed_text`,
2602 `parent-item-uri`.`guid` AS `parent-guid`,
2603 `post-thread`.`network` AS `parent-network`,
2604 `post-thread`.`author-id` AS `parent-author-id`,
2605 `author`.`url` AS `parent-author-link`,
2606 `author`.`name` AS `parent-author-name`,
2607 `author`.`nick` AS `parent-author-nick`,
2608 `author`.`network` AS `parent-author-network`
2610 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
2611 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
2612 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
2613 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
2614 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
2615 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2616 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2617 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
2618 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2619 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2620 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
2621 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
2622 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2623 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread`.`uri-id`;
2626 -- VIEW category-view
2628 DROP VIEW IF EXISTS `category-view`;
2629 CREATE VIEW `category-view` AS SELECT
2630 `post-category`.`uri-id` AS `uri-id`,
2631 `post-category`.`uid` AS `uid`,
2632 `post-category`.`type` AS `type`,
2633 `post-category`.`tid` AS `tid`,
2634 `tag`.`name` AS `name`,
2635 `tag`.`url` AS `url`
2636 FROM `post-category`
2637 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2640 -- VIEW collection-view
2642 DROP VIEW IF EXISTS `collection-view`;
2643 CREATE VIEW `collection-view` AS SELECT
2644 `post-collection`.`uri-id` AS `uri-id`,
2645 `post-collection`.`type` AS `type`,
2646 `post-collection`.`author-id` AS `cid`,
2647 `post`.`received` AS `received`,
2648 `post`.`created` AS `created`,
2649 `post-thread`.`commented` AS `commented`,
2650 `post`.`private` AS `private`,
2651 `post`.`visible` AS `visible`,
2652 `post`.`deleted` AS `deleted`,
2653 `post`.`thr-parent-id` AS `thr-parent-id`,
2654 `post-collection`.`author-id` AS `author-id`,
2655 `post`.`gravity` AS `gravity`
2656 FROM `post-collection`
2657 INNER JOIN `post` ON `post-collection`.`uri-id` = `post`.`uri-id`
2658 INNER JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`;
2663 DROP VIEW IF EXISTS `media-view`;
2664 CREATE VIEW `media-view` AS SELECT
2665 `post-media`.`uri-id` AS `uri-id`,
2666 `post-media`.`type` AS `type`,
2667 `post`.`received` AS `received`,
2668 `post`.`created` AS `created`,
2669 `post`.`private` AS `private`,
2670 `post`.`visible` AS `visible`,
2671 `post`.`deleted` AS `deleted`,
2672 `post`.`thr-parent-id` AS `thr-parent-id`,
2673 `post`.`author-id` AS `author-id`,
2674 `post`.`gravity` AS `gravity`
2676 INNER JOIN `post` ON `post-media`.`uri-id` = `post`.`uri-id`;
2681 DROP VIEW IF EXISTS `tag-view`;
2682 CREATE VIEW `tag-view` AS SELECT
2683 `post-tag`.`uri-id` AS `uri-id`,
2684 `post-tag`.`type` AS `type`,
2685 `post-tag`.`tid` AS `tid`,
2686 `post-tag`.`cid` AS `cid`,
2687 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2688 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`,
2689 CASE `cid` WHEN 0 THEN `tag`.`type` ELSE 1 END AS `tag-type`
2691 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2692 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2695 -- VIEW network-item-view
2697 DROP VIEW IF EXISTS `network-item-view`;
2698 CREATE VIEW `network-item-view` AS SELECT
2699 `post-user`.`uri-id` AS `uri-id`,
2700 `post-thread-user`.`post-user-id` AS `parent`,
2701 `post-user`.`received` AS `received`,
2702 `post-thread-user`.`commented` AS `commented`,
2703 `post-user`.`created` AS `created`,
2704 `post-user`.`uid` AS `uid`,
2705 `post-thread-user`.`starred` AS `starred`,
2706 `post-thread-user`.`mention` AS `mention`,
2707 `post-user`.`network` AS `network`,
2708 `post-user`.`unseen` AS `unseen`,
2709 `post-user`.`gravity` AS `gravity`,
2710 `post-user`.`contact-id` AS `contact-id`,
2711 `ownercontact`.`contact-type` AS `contact-type`
2713 INNER JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2714 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2715 STRAIGHT_JOIN `contact` AS `authorcontact` ON `authorcontact`.`id` = `post-thread-user`.`author-id`
2716 STRAIGHT_JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2717 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2718 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2719 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
2720 AND NOT `authorcontact`.`blocked` AND NOT `ownercontact`.`blocked`
2721 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`))
2722 AND NOT EXISTS(SELECT `gsid` FROM `user-gserver` WHERE `uid` = `post-thread-user`.`uid` AND `gsid` IN (`authorcontact`.`gsid`, `ownercontact`.`gsid`) AND `ignored`);
2725 -- VIEW network-thread-view
2727 DROP VIEW IF EXISTS `network-thread-view`;
2728 CREATE VIEW `network-thread-view` AS SELECT
2729 `post-thread-user`.`uri-id` AS `uri-id`,
2730 `post-thread-user`.`post-user-id` AS `parent`,
2731 `post-thread-user`.`received` AS `received`,
2732 `post-thread-user`.`commented` AS `commented`,
2733 `post-thread-user`.`created` AS `created`,
2734 `post-thread-user`.`uid` AS `uid`,
2735 `post-thread-user`.`starred` AS `starred`,
2736 `post-thread-user`.`mention` AS `mention`,
2737 `post-thread-user`.`network` AS `network`,
2738 `post-thread-user`.`contact-id` AS `contact-id`,
2739 `ownercontact`.`contact-type` AS `contact-type`
2740 FROM `post-thread-user`
2741 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2742 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2743 STRAIGHT_JOIN `contact` AS `authorcontact` ON `authorcontact`.`id` = `post-thread-user`.`author-id`
2744 STRAIGHT_JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2745 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2746 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2747 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2748 AND NOT `authorcontact`.`blocked` AND NOT `ownercontact`.`blocked`
2749 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`))
2750 AND NOT EXISTS(SELECT `gsid` FROM `user-gserver` WHERE `uid` = `post-thread-user`.`uid` AND `gsid` IN (`authorcontact`.`gsid`, `ownercontact`.`gsid`) AND `ignored`);
2755 DROP VIEW IF EXISTS `owner-view`;
2756 CREATE VIEW `owner-view` AS SELECT
2757 `contact`.`id` AS `id`,
2758 `contact`.`uid` AS `uid`,
2759 `contact`.`created` AS `created`,
2760 `contact`.`updated` AS `updated`,
2761 `contact`.`self` AS `self`,
2762 `contact`.`remote_self` AS `remote_self`,
2763 `contact`.`rel` AS `rel`,
2764 `contact`.`network` AS `network`,
2765 `contact`.`protocol` AS `protocol`,
2766 `contact`.`name` AS `name`,
2767 `contact`.`nick` AS `nick`,
2768 `contact`.`location` AS `location`,
2769 `contact`.`about` AS `about`,
2770 `contact`.`keywords` AS `keywords`,
2771 `contact`.`xmpp` AS `xmpp`,
2772 `contact`.`matrix` AS `matrix`,
2773 `contact`.`attag` AS `attag`,
2774 `contact`.`avatar` AS `avatar`,
2775 `contact`.`photo` AS `photo`,
2776 `contact`.`thumb` AS `thumb`,
2777 `contact`.`micro` AS `micro`,
2778 `contact`.`header` AS `header`,
2779 `contact`.`url` AS `url`,
2780 `contact`.`nurl` AS `nurl`,
2781 `contact`.`uri-id` AS `uri-id`,
2782 `contact`.`addr` AS `addr`,
2783 `contact`.`alias` AS `alias`,
2784 `contact`.`pubkey` AS `pubkey`,
2785 `contact`.`prvkey` AS `prvkey`,
2786 `contact`.`batch` AS `batch`,
2787 `contact`.`request` AS `request`,
2788 `contact`.`notify` AS `notify`,
2789 `contact`.`poll` AS `poll`,
2790 `contact`.`confirm` AS `confirm`,
2791 `contact`.`poco` AS `poco`,
2792 `contact`.`subhub` AS `subhub`,
2793 `contact`.`hub-verify` AS `hub-verify`,
2794 `contact`.`last-update` AS `last-update`,
2795 `contact`.`success_update` AS `success_update`,
2796 `contact`.`failure_update` AS `failure_update`,
2797 `contact`.`name-date` AS `name-date`,
2798 `contact`.`uri-date` AS `uri-date`,
2799 `contact`.`avatar-date` AS `avatar-date`,
2800 `contact`.`avatar-date` AS `picdate`,
2801 `contact`.`term-date` AS `term-date`,
2802 `contact`.`last-item` AS `last-item`,
2803 `contact`.`priority` AS `priority`,
2804 `user`.`blocked` AS `blocked`,
2805 `contact`.`block_reason` AS `block_reason`,
2806 `contact`.`readonly` AS `readonly`,
2807 `contact`.`writable` AS `writable`,
2808 `contact`.`forum` AS `forum`,
2809 `contact`.`prv` AS `prv`,
2810 `contact`.`contact-type` AS `contact-type`,
2811 `contact`.`manually-approve` AS `manually-approve`,
2812 `contact`.`hidden` AS `hidden`,
2813 `contact`.`archive` AS `archive`,
2814 `contact`.`pending` AS `pending`,
2815 `contact`.`deleted` AS `deleted`,
2816 `contact`.`unsearchable` AS `unsearchable`,
2817 `contact`.`sensitive` AS `sensitive`,
2818 `contact`.`baseurl` AS `baseurl`,
2819 `contact`.`reason` AS `reason`,
2820 `contact`.`info` AS `info`,
2821 `contact`.`bdyear` AS `bdyear`,
2822 `contact`.`bd` AS `bd`,
2823 `contact`.`notify_new_posts` AS `notify_new_posts`,
2824 `contact`.`fetch_further_information` AS `fetch_further_information`,
2825 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2826 `user`.`parent-uid` AS `parent-uid`,
2827 `user`.`guid` AS `guid`,
2828 `user`.`nickname` AS `nickname`,
2829 `user`.`email` AS `email`,
2830 `user`.`openid` AS `openid`,
2831 `user`.`timezone` AS `timezone`,
2832 `user`.`language` AS `language`,
2833 `user`.`register_date` AS `register_date`,
2834 `user`.`login_date` AS `login_date`,
2835 `user`.`last-activity` AS `last-activity`,
2836 `user`.`default-location` AS `default-location`,
2837 `user`.`allow_location` AS `allow_location`,
2838 `user`.`theme` AS `theme`,
2839 `user`.`pubkey` AS `upubkey`,
2840 `user`.`prvkey` AS `uprvkey`,
2841 `user`.`sprvkey` AS `sprvkey`,
2842 `user`.`spubkey` AS `spubkey`,
2843 `user`.`verified` AS `verified`,
2844 `user`.`blockwall` AS `blockwall`,
2845 `user`.`hidewall` AS `hidewall`,
2846 `user`.`blocktags` AS `blocktags`,
2847 `user`.`unkmail` AS `unkmail`,
2848 `user`.`cntunkmail` AS `cntunkmail`,
2849 `user`.`notify-flags` AS `notify-flags`,
2850 `user`.`page-flags` AS `page-flags`,
2851 `user`.`account-type` AS `account-type`,
2852 `user`.`prvnets` AS `prvnets`,
2853 `user`.`maxreq` AS `maxreq`,
2854 `user`.`expire` AS `expire`,
2855 `user`.`account_removed` AS `account_removed`,
2856 `user`.`account_expired` AS `account_expired`,
2857 `user`.`account_expires_on` AS `account_expires_on`,
2858 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2859 `user`.`def_gid` AS `def_gid`,
2860 `user`.`allow_cid` AS `allow_cid`,
2861 `user`.`allow_gid` AS `allow_gid`,
2862 `user`.`deny_cid` AS `deny_cid`,
2863 `user`.`deny_gid` AS `deny_gid`,
2864 `user`.`openidserver` AS `openidserver`,
2865 `profile`.`publish` AS `publish`,
2866 `profile`.`net-publish` AS `net-publish`,
2867 `profile`.`hide-friends` AS `hide-friends`,
2868 `profile`.`prv_keywords` AS `prv_keywords`,
2869 `profile`.`pub_keywords` AS `pub_keywords`,
2870 `profile`.`address` AS `address`,
2871 `profile`.`locality` AS `locality`,
2872 `profile`.`region` AS `region`,
2873 `profile`.`postal-code` AS `postal-code`,
2874 `profile`.`country-name` AS `country-name`,
2875 `profile`.`homepage` AS `homepage`,
2876 `profile`.`homepage_verified` AS `homepage_verified`,
2877 `profile`.`dob` AS `dob`
2879 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2880 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2883 -- VIEW account-view
2885 DROP VIEW IF EXISTS `account-view`;
2886 CREATE VIEW `account-view` AS SELECT
2887 `contact`.`id` AS `id`,
2888 `contact`.`url` AS `url`,
2889 `contact`.`nurl` AS `nurl`,
2890 `contact`.`uri-id` AS `uri-id`,
2891 `item-uri`.`guid` AS `guid`,
2892 `contact`.`addr` AS `addr`,
2893 `contact`.`alias` AS `alias`,
2894 `contact`.`name` AS `name`,
2895 `contact`.`nick` AS `nick`,
2896 `contact`.`about` AS `about`,
2897 `contact`.`keywords` AS `keywords`,
2898 `contact`.`xmpp` AS `xmpp`,
2899 `contact`.`matrix` AS `matrix`,
2900 `contact`.`avatar` AS `avatar`,
2901 `contact`.`photo` AS `photo`,
2902 `contact`.`thumb` AS `thumb`,
2903 `contact`.`micro` AS `micro`,
2904 `contact`.`header` AS `header`,
2905 `contact`.`created` AS `created`,
2906 `contact`.`updated` AS `updated`,
2907 `contact`.`network` AS `network`,
2908 `contact`.`protocol` AS `protocol`,
2909 `contact`.`location` AS `location`,
2910 `contact`.`attag` AS `attag`,
2911 `contact`.`pubkey` AS `pubkey`,
2912 `contact`.`prvkey` AS `prvkey`,
2913 `contact`.`subscribe` AS `subscribe`,
2914 `contact`.`last-update` AS `last-update`,
2915 `contact`.`success_update` AS `success_update`,
2916 `contact`.`failure_update` AS `failure_update`,
2917 `contact`.`failed` AS `failed`,
2918 `contact`.`last-item` AS `last-item`,
2919 `contact`.`last-discovery` AS `last-discovery`,
2920 `contact`.`contact-type` AS `contact-type`,
2921 `contact`.`manually-approve` AS `manually-approve`,
2922 `contact`.`unsearchable` AS `unsearchable`,
2923 `contact`.`sensitive` AS `sensitive`,
2924 `contact`.`baseurl` AS `baseurl`,
2925 `contact`.`gsid` AS `gsid`,
2926 `contact`.`info` AS `info`,
2927 `contact`.`bdyear` AS `bdyear`,
2928 `contact`.`bd` AS `bd`,
2929 `contact`.`poco` AS `poco`,
2930 `contact`.`name-date` AS `name-date`,
2931 `contact`.`uri-date` AS `uri-date`,
2932 `contact`.`avatar-date` AS `avatar-date`,
2933 `contact`.`term-date` AS `term-date`,
2934 `contact`.`hidden` AS `global-ignored`,
2935 `contact`.`blocked` AS `global-blocked`,
2936 `contact`.`hidden` AS `hidden`,
2937 `contact`.`archive` AS `archive`,
2938 `contact`.`deleted` AS `deleted`,
2939 `contact`.`blocked` AS `blocked`,
2940 `contact`.`notify` AS `dfrn-notify`,
2941 `contact`.`poll` AS `dfrn-poll`,
2942 `item-uri`.`guid` AS `diaspora-guid`,
2943 `diaspora-contact`.`batch` AS `diaspora-batch`,
2944 `diaspora-contact`.`notify` AS `diaspora-notify`,
2945 `diaspora-contact`.`poll` AS `diaspora-poll`,
2946 `diaspora-contact`.`alias` AS `diaspora-alias`,
2947 `apcontact`.`uuid` AS `ap-uuid`,
2948 `apcontact`.`type` AS `ap-type`,
2949 `apcontact`.`following` AS `ap-following`,
2950 `apcontact`.`followers` AS `ap-followers`,
2951 `apcontact`.`inbox` AS `ap-inbox`,
2952 `apcontact`.`outbox` AS `ap-outbox`,
2953 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2954 `apcontact`.`generator` AS `ap-generator`,
2955 `apcontact`.`following_count` AS `ap-following_count`,
2956 `apcontact`.`followers_count` AS `ap-followers_count`,
2957 `apcontact`.`statuses_count` AS `ap-statuses_count`,
2958 `gserver`.`site_name` AS `site_name`,
2959 `gserver`.`platform` AS `platform`,
2960 `gserver`.`version` AS `version`,
2961 `gserver`.`blocked` AS `server-blocked`,
2962 `gserver`.`failed` AS `server-failed`
2964 LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id`
2965 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
2966 LEFT JOIN `diaspora-contact` ON `diaspora-contact`.`uri-id` = contact.`uri-id`
2967 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`
2968 WHERE `contact`.`uid` = 0;
2971 -- VIEW account-user-view
2973 DROP VIEW IF EXISTS `account-user-view`;
2974 CREATE VIEW `account-user-view` AS SELECT
2975 `ucontact`.`id` AS `id`,
2976 `contact`.`id` AS `pid`,
2977 `ucontact`.`uid` AS `uid`,
2978 `contact`.`url` AS `url`,
2979 `contact`.`nurl` AS `nurl`,
2980 `contact`.`uri-id` AS `uri-id`,
2981 `item-uri`.`guid` AS `guid`,
2982 `contact`.`addr` AS `addr`,
2983 `contact`.`alias` AS `alias`,
2984 `contact`.`name` AS `name`,
2985 `contact`.`nick` AS `nick`,
2986 `contact`.`about` AS `about`,
2987 `contact`.`keywords` AS `keywords`,
2988 `contact`.`xmpp` AS `xmpp`,
2989 `contact`.`matrix` AS `matrix`,
2990 `contact`.`avatar` AS `avatar`,
2991 `contact`.`photo` AS `photo`,
2992 `contact`.`thumb` AS `thumb`,
2993 `contact`.`micro` AS `micro`,
2994 `contact`.`header` AS `header`,
2995 `contact`.`created` AS `created`,
2996 `contact`.`updated` AS `updated`,
2997 `ucontact`.`self` AS `self`,
2998 `ucontact`.`remote_self` AS `remote_self`,
2999 `ucontact`.`rel` AS `rel`,
3000 `contact`.`network` AS `network`,
3001 `ucontact`.`protocol` AS `protocol`,
3002 `contact`.`location` AS `location`,
3003 `ucontact`.`attag` AS `attag`,
3004 `contact`.`pubkey` AS `pubkey`,
3005 `contact`.`prvkey` AS `prvkey`,
3006 `contact`.`subscribe` AS `subscribe`,
3007 `contact`.`last-update` AS `last-update`,
3008 `contact`.`success_update` AS `success_update`,
3009 `contact`.`failure_update` AS `failure_update`,
3010 `contact`.`failed` AS `failed`,
3011 `contact`.`last-item` AS `last-item`,
3012 `contact`.`last-discovery` AS `last-discovery`,
3013 `contact`.`contact-type` AS `contact-type`,
3014 `contact`.`manually-approve` AS `manually-approve`,
3015 `contact`.`unsearchable` AS `unsearchable`,
3016 `contact`.`sensitive` AS `sensitive`,
3017 `contact`.`baseurl` AS `baseurl`,
3018 `contact`.`gsid` AS `gsid`,
3019 `ucontact`.`info` AS `info`,
3020 `contact`.`bdyear` AS `bdyear`,
3021 `contact`.`bd` AS `bd`,
3022 `contact`.`poco` AS `poco`,
3023 `contact`.`name-date` AS `name-date`,
3024 `contact`.`uri-date` AS `uri-date`,
3025 `contact`.`avatar-date` AS `avatar-date`,
3026 `contact`.`term-date` AS `term-date`,
3027 `contact`.`hidden` AS `global-ignored`,
3028 `contact`.`blocked` AS `global-blocked`,
3029 `ucontact`.`hidden` AS `hidden`,
3030 `ucontact`.`archive` AS `archive`,
3031 `ucontact`.`pending` AS `pending`,
3032 `ucontact`.`deleted` AS `deleted`,
3033 `ucontact`.`notify_new_posts` AS `notify_new_posts`,
3034 `ucontact`.`fetch_further_information` AS `fetch_further_information`,
3035 `ucontact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
3036 `ucontact`.`rating` AS `rating`,
3037 `ucontact`.`readonly` AS `readonly`,
3038 `ucontact`.`blocked` AS `blocked`,
3039 `ucontact`.`block_reason` AS `block_reason`,
3040 `ucontact`.`subhub` AS `subhub`,
3041 `ucontact`.`hub-verify` AS `hub-verify`,
3042 `ucontact`.`reason` AS `reason`,
3043 `contact`.`notify` AS `dfrn-notify`,
3044 `contact`.`poll` AS `dfrn-poll`,
3045 `item-uri`.`guid` AS `diaspora-guid`,
3046 `diaspora-contact`.`batch` AS `diaspora-batch`,
3047 `diaspora-contact`.`notify` AS `diaspora-notify`,
3048 `diaspora-contact`.`poll` AS `diaspora-poll`,
3049 `diaspora-contact`.`alias` AS `diaspora-alias`,
3050 `diaspora-contact`.`interacting_count` AS `diaspora-interacting_count`,
3051 `diaspora-contact`.`interacted_count` AS `diaspora-interacted_count`,
3052 `diaspora-contact`.`post_count` AS `diaspora-post_count`,
3053 `apcontact`.`uuid` AS `ap-uuid`,
3054 `apcontact`.`type` AS `ap-type`,
3055 `apcontact`.`following` AS `ap-following`,
3056 `apcontact`.`followers` AS `ap-followers`,
3057 `apcontact`.`inbox` AS `ap-inbox`,
3058 `apcontact`.`outbox` AS `ap-outbox`,
3059 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
3060 `apcontact`.`generator` AS `ap-generator`,
3061 `apcontact`.`following_count` AS `ap-following_count`,
3062 `apcontact`.`followers_count` AS `ap-followers_count`,
3063 `apcontact`.`statuses_count` AS `ap-statuses_count`,
3064 `gserver`.`site_name` AS `site_name`,
3065 `gserver`.`platform` AS `platform`,
3066 `gserver`.`version` AS `version`,
3067 `gserver`.`blocked` AS `server-blocked`,
3068 `gserver`.`failed` AS `server-failed`
3069 FROM `contact` AS `ucontact`
3070 INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
3071 LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id`
3072 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
3073 LEFT JOIN `diaspora-contact` ON `diaspora-contact`.`uri-id` = `ucontact`.`uri-id`
3074 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`;
3077 -- VIEW pending-view
3079 DROP VIEW IF EXISTS `pending-view`;
3080 CREATE VIEW `pending-view` AS SELECT
3081 `register`.`id` AS `id`,
3082 `register`.`hash` AS `hash`,
3083 `register`.`created` AS `created`,
3084 `register`.`uid` AS `uid`,
3085 `register`.`password` AS `password`,
3086 `register`.`language` AS `language`,
3087 `register`.`note` AS `note`,
3088 `contact`.`self` AS `self`,
3089 `contact`.`name` AS `name`,
3090 `contact`.`url` AS `url`,
3091 `contact`.`micro` AS `micro`,
3092 `user`.`email` AS `email`,
3093 `contact`.`nick` AS `nick`
3095 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
3096 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
3099 -- VIEW tag-search-view
3101 DROP VIEW IF EXISTS `tag-search-view`;
3102 CREATE VIEW `tag-search-view` AS SELECT
3103 `post-tag`.`uri-id` AS `uri-id`,
3104 `post-user`.`uid` AS `uid`,
3105 `post-user`.`id` AS `iid`,
3106 `post-user`.`private` AS `private`,
3107 `post-user`.`wall` AS `wall`,
3108 `post-user`.`origin` AS `origin`,
3109 `post-user`.`global` AS `global`,
3110 `post-user`.`gravity` AS `gravity`,
3111 `post-user`.`received` AS `received`,
3112 `post-user`.`network` AS `network`,
3113 `post-user`.`author-id` AS `author-id`,
3114 `tag`.`name` AS `name`
3116 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
3117 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
3118 WHERE `post-tag`.`type` = 1;
3121 -- VIEW workerqueue-view
3123 DROP VIEW IF EXISTS `workerqueue-view`;
3124 CREATE VIEW `workerqueue-view` AS SELECT
3125 `process`.`pid` AS `pid`,
3126 `workerqueue`.`priority` AS `priority`
3128 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
3129 WHERE NOT `workerqueue`.`done`;
3132 -- VIEW profile_field-view
3134 DROP VIEW IF EXISTS `profile_field-view`;
3135 CREATE VIEW `profile_field-view` AS SELECT
3136 `profile_field`.`id` AS `id`,
3137 `profile_field`.`uid` AS `uid`,
3138 `profile_field`.`label` AS `label`,
3139 `profile_field`.`value` AS `value`,
3140 `profile_field`.`order` AS `order`,
3141 `profile_field`.`psid` AS `psid`,
3142 `permissionset`.`allow_cid` AS `allow_cid`,
3143 `permissionset`.`allow_gid` AS `allow_gid`,
3144 `permissionset`.`deny_cid` AS `deny_cid`,
3145 `permissionset`.`deny_gid` AS `deny_gid`,
3146 `profile_field`.`created` AS `created`,
3147 `profile_field`.`edited` AS `edited`
3148 FROM `profile_field`
3149 INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`;
3152 -- VIEW diaspora-contact-view
3154 DROP VIEW IF EXISTS `diaspora-contact-view`;
3155 CREATE VIEW `diaspora-contact-view` AS SELECT
3156 `diaspora-contact`.`uri-id` AS `uri-id`,
3157 `item-uri`.`uri` AS `url`,
3158 `item-uri`.`guid` AS `guid`,
3159 `diaspora-contact`.`addr` AS `addr`,
3160 `diaspora-contact`.`alias` AS `alias`,
3161 `diaspora-contact`.`nick` AS `nick`,
3162 `diaspora-contact`.`name` AS `name`,
3163 `diaspora-contact`.`given-name` AS `given-name`,
3164 `diaspora-contact`.`family-name` AS `family-name`,
3165 `diaspora-contact`.`photo` AS `photo`,
3166 `diaspora-contact`.`photo-medium` AS `photo-medium`,
3167 `diaspora-contact`.`photo-small` AS `photo-small`,
3168 `diaspora-contact`.`batch` AS `batch`,
3169 `diaspora-contact`.`notify` AS `notify`,
3170 `diaspora-contact`.`poll` AS `poll`,
3171 `diaspora-contact`.`subscribe` AS `subscribe`,
3172 `diaspora-contact`.`searchable` AS `searchable`,
3173 `diaspora-contact`.`pubkey` AS `pubkey`,
3174 `gserver`.`url` AS `baseurl`,
3175 `diaspora-contact`.`gsid` AS `gsid`,
3176 `diaspora-contact`.`created` AS `created`,
3177 `diaspora-contact`.`updated` AS `updated`,
3178 `diaspora-contact`.`interacting_count` AS `interacting_count`,
3179 `diaspora-contact`.`interacted_count` AS `interacted_count`,
3180 `diaspora-contact`.`post_count` AS `post_count`
3181 FROM `diaspora-contact`
3182 INNER JOIN `item-uri` ON `item-uri`.`id` = `diaspora-contact`.`uri-id`
3183 LEFT JOIN `gserver` ON `gserver`.`id` = `diaspora-contact`.`gsid`;