1 -- ------------------------------------------
2 -- Friendica 2023.09-dev (Giant Rhubarb)
3 -- DB_UPDATE_VERSION 1528
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',
177 `gsid` int unsigned COMMENT 'Global Server ID',
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 PRIMARY KEY(`cid`,`relation-cid`),
517 INDEX `relation-cid` (`relation-cid`),
518 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
519 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
520 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
525 CREATE TABLE IF NOT EXISTS `conv` (
526 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
527 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
528 `recips` text COMMENT 'sender_handle;recipient_handle',
529 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
530 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
531 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
532 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
533 `subject` text COMMENT 'subject of initial message',
536 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
537 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
542 CREATE TABLE IF NOT EXISTS `workerqueue` (
543 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
544 `command` varchar(100) COMMENT 'Task command',
545 `parameter` mediumtext COMMENT 'Task parameter',
546 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
547 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
548 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
549 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
550 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
551 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
552 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
554 INDEX `command` (`command`),
555 INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
556 INDEX `done_executed` (`done`,`executed`),
557 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
558 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
559 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
560 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
561 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
562 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
565 -- TABLE delayed-post
567 CREATE TABLE IF NOT EXISTS `delayed-post` (
568 `id` int unsigned NOT NULL auto_increment,
569 `uri` varbinary(383) COMMENT 'URI of the post that will be distributed later',
570 `uid` mediumint unsigned COMMENT 'Owner User id',
571 `delayed` datetime COMMENT 'delay time',
572 `wid` int unsigned COMMENT 'Workerqueue id',
574 UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
576 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
577 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
578 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
581 -- TABLE delivery-queue
583 CREATE TABLE IF NOT EXISTS `delivery-queue` (
584 `gsid` int unsigned NOT NULL COMMENT 'Target server',
585 `uri-id` int unsigned NOT NULL COMMENT 'Delivered post',
586 `created` datetime COMMENT '',
587 `command` varbinary(32) COMMENT '',
588 `cid` int unsigned COMMENT 'Target contact',
589 `uid` mediumint unsigned COMMENT 'Delivering user',
590 `failed` tinyint DEFAULT 0 COMMENT 'Number of times the delivery has failed',
591 PRIMARY KEY(`uri-id`,`gsid`),
592 INDEX `gsid_created` (`gsid`,`created`),
595 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
596 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
597 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
598 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
599 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for posts for the batch processing';
602 -- TABLE diaspora-contact
604 CREATE TABLE IF NOT EXISTS `diaspora-contact` (
605 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the contact URL',
606 `addr` varchar(255) COMMENT '',
607 `alias` varchar(255) COMMENT '',
608 `nick` varchar(255) COMMENT '',
609 `name` varchar(255) COMMENT '',
610 `given-name` varchar(255) COMMENT '',
611 `family-name` varchar(255) COMMENT '',
612 `photo` varchar(255) COMMENT '',
613 `photo-medium` varchar(255) COMMENT '',
614 `photo-small` varchar(255) COMMENT '',
615 `batch` varchar(255) COMMENT '',
616 `notify` varchar(255) COMMENT '',
617 `poll` varchar(255) COMMENT '',
618 `subscribe` varchar(255) COMMENT '',
619 `searchable` boolean COMMENT '',
620 `pubkey` text COMMENT '',
621 `gsid` int unsigned COMMENT 'Global Server ID',
622 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
623 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
624 `interacting_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts this contact interacts with',
625 `interacted_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts that interacted with this contact',
626 `post_count` int unsigned DEFAULT 0 COMMENT 'Number of posts and comments',
627 PRIMARY KEY(`uri-id`),
628 UNIQUE INDEX `addr` (`addr`),
629 INDEX `alias` (`alias`),
630 INDEX `gsid` (`gsid`),
631 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
632 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
633 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
636 -- TABLE diaspora-interaction
638 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
639 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
640 `interaction` mediumtext COMMENT 'The Diaspora interaction',
641 PRIMARY KEY(`uri-id`),
642 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
643 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
648 CREATE TABLE IF NOT EXISTS `endpoint` (
649 `url` varbinary(383) NOT NULL COMMENT 'URL of the contact',
650 `type` varchar(20) NOT NULL COMMENT '',
651 `owner-uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
653 UNIQUE INDEX `owner-uri-id_type` (`owner-uri-id`,`type`),
654 FOREIGN KEY (`owner-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
655 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub endpoints - used in the ActivityPub implementation';
660 CREATE TABLE IF NOT EXISTS `event` (
661 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
662 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
663 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
664 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
665 `uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
666 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the event uri',
667 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
668 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
669 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
670 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
671 `summary` text COMMENT 'short description or title of the event',
672 `desc` text COMMENT 'event description',
673 `location` text COMMENT 'event location',
674 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
675 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
676 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
677 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
678 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed circles',
679 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
680 `deny_gid` mediumtext COMMENT 'Access Control - list of denied circles',
682 INDEX `uid_start` (`uid`,`start`),
684 INDEX `uri-id` (`uri-id`),
685 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
686 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
687 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
688 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
693 CREATE TABLE IF NOT EXISTS `fetch-entry` (
694 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
695 `url` varbinary(383) COMMENT 'url that awaiting to be fetched',
696 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of the fetch request',
697 `wid` int unsigned COMMENT 'Workerqueue id',
699 UNIQUE INDEX `url` (`url`),
700 INDEX `created` (`created`),
702 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
703 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
708 CREATE TABLE IF NOT EXISTS `fsuggest` (
709 `id` int unsigned NOT NULL auto_increment COMMENT '',
710 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
711 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
712 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
713 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
714 `request` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
715 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
716 `note` text COMMENT '',
717 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
721 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
722 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
723 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
728 CREATE TABLE IF NOT EXISTS `group` (
729 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
730 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
731 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
732 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the circle has been deleted',
733 `cid` int unsigned COMMENT 'Contact id of group. When this field is filled then the members are synced automatically.',
734 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of circle',
738 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
739 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
740 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy circles, circle info';
743 -- TABLE group_member
745 CREATE TABLE IF NOT EXISTS `group_member` (
746 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
747 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'group.id of the associated circle',
748 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated circle',
750 INDEX `contactid` (`contact-id`),
751 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
752 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
753 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
754 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy circles, member info';
759 CREATE TABLE IF NOT EXISTS `gserver-tag` (
760 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
761 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
762 PRIMARY KEY(`gserver-id`,`tag`),
764 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
765 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
770 CREATE TABLE IF NOT EXISTS `hook` (
771 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
772 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
773 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
774 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
775 `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',
777 INDEX `priority` (`priority`),
778 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
779 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
784 CREATE TABLE IF NOT EXISTS `inbox-entry` (
785 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
786 `activity-id` varbinary(383) COMMENT 'id of the incoming activity',
787 `object-id` varbinary(383) COMMENT '',
788 `in-reply-to-id` varbinary(383) COMMENT '',
789 `conversation` varbinary(383) COMMENT '',
790 `type` varchar(64) COMMENT 'Type of the activity',
791 `object-type` varchar(64) COMMENT 'Type of the object activity',
792 `object-object-type` varchar(64) COMMENT 'Type of the object\'s object activity',
793 `received` datetime COMMENT 'Receiving date',
794 `activity` mediumtext COMMENT 'The JSON activity',
795 `signer` varchar(255) COMMENT '',
796 `push` boolean COMMENT 'Is the entry pushed or have pulled it?',
797 `trust` boolean COMMENT 'Do we trust this entry?',
798 `wid` int unsigned COMMENT 'Workerqueue id',
800 UNIQUE INDEX `activity-id` (`activity-id`),
801 INDEX `object-id` (`object-id`),
802 INDEX `received` (`received`),
804 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
805 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Incoming activity';
808 -- TABLE inbox-entry-receiver
810 CREATE TABLE IF NOT EXISTS `inbox-entry-receiver` (
811 `queue-id` int unsigned NOT NULL COMMENT '',
812 `uid` mediumint unsigned NOT NULL COMMENT 'User id',
813 PRIMARY KEY(`queue-id`,`uid`),
815 FOREIGN KEY (`queue-id`) REFERENCES `inbox-entry` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
816 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
817 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Receiver for the incoming activity';
820 -- TABLE inbox-status
822 CREATE TABLE IF NOT EXISTS `inbox-status` (
823 `url` varbinary(383) NOT NULL COMMENT 'URL of the inbox',
824 `uri-id` int unsigned COMMENT 'Item-uri id of inbox url',
825 `gsid` int unsigned COMMENT 'ID of the related server',
826 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
827 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
828 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
829 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
830 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
831 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
833 INDEX `uri-id` (`uri-id`),
834 INDEX `gsid` (`gsid`),
835 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
836 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
837 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
842 CREATE TABLE IF NOT EXISTS `intro` (
843 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
844 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
845 `fid` int unsigned COMMENT 'deprecated',
846 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
847 `suggest-cid` int unsigned COMMENT 'Suggested contact',
848 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
849 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
850 `note` text COMMENT '',
851 `hash` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
852 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
853 `blocked` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
854 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
856 INDEX `contact-id` (`contact-id`),
857 INDEX `suggest-cid` (`suggest-cid`),
859 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
860 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
861 FOREIGN KEY (`suggest-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
862 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
867 CREATE TABLE IF NOT EXISTS `key-value` (
868 `k` varbinary(50) NOT NULL COMMENT '',
869 `v` mediumtext COMMENT '',
870 `updated_at` int unsigned NOT NULL COMMENT 'timestamp of the last update',
872 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='A key value storage';
877 CREATE TABLE IF NOT EXISTS `locks` (
878 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
879 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
880 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
881 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
882 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
884 INDEX `name_expires` (`name`,`expires`)
885 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
890 CREATE TABLE IF NOT EXISTS `mail` (
891 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
892 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
893 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
894 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
895 `from-photo` varbinary(383) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
896 `from-url` varbinary(383) NOT NULL DEFAULT '' COMMENT 'profile link of the sender',
897 `contact-id` varbinary(255) COMMENT 'contact.id',
898 `author-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the author of the mail',
899 `convid` int unsigned COMMENT 'conv.id',
900 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
901 `body` mediumtext COMMENT '',
902 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
903 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
904 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
905 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
906 `uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
907 `uri-id` int unsigned COMMENT 'Item-uri id of the related mail',
908 `parent-uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
909 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related mail',
910 `thr-parent` varbinary(383) COMMENT '',
911 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
912 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
914 INDEX `uid_seen` (`uid`,`seen`),
915 INDEX `convid` (`convid`),
916 INDEX `uri` (`uri`(64)),
917 INDEX `parent-uri` (`parent-uri`(64)),
918 INDEX `contactid` (`contact-id`(32)),
919 INDEX `author-id` (`author-id`),
920 INDEX `uri-id` (`uri-id`),
921 INDEX `parent-uri-id` (`parent-uri-id`),
922 INDEX `thr-parent-id` (`thr-parent-id`),
923 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
924 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
925 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
926 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
927 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
928 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
933 CREATE TABLE IF NOT EXISTS `mailacct` (
934 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
935 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
936 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
937 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
938 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
939 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
940 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
941 `pass` text COMMENT '',
942 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
943 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
944 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
945 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
946 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
949 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
950 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
955 CREATE TABLE IF NOT EXISTS `manage` (
956 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
957 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
958 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
960 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
962 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
963 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
964 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
967 -- TABLE notification
969 CREATE TABLE IF NOT EXISTS `notification` (
970 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
971 `uid` mediumint unsigned COMMENT 'Owner User id',
972 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
973 `type` smallint unsigned COMMENT '',
974 `actor-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the actor that caused the notification',
975 `target-uri-id` int unsigned COMMENT 'Item-uri id of the related post',
976 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
977 `created` datetime COMMENT '',
978 `seen` boolean DEFAULT '0' COMMENT 'Seen on the desktop',
979 `dismissed` boolean DEFAULT '0' COMMENT 'Dismissed via the API',
981 UNIQUE INDEX `uid_vid_type_actor-id_target-uri-id` (`uid`,`vid`,`type`,`actor-id`,`target-uri-id`),
983 INDEX `actor-id` (`actor-id`),
984 INDEX `target-uri-id` (`target-uri-id`),
985 INDEX `parent-uri-id` (`parent-uri-id`),
986 INDEX `seen_uid` (`seen`,`uid`),
987 INDEX `uid_type_parent-uri-id_actor-id` (`uid`,`type`,`parent-uri-id`,`actor-id`),
988 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
989 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
990 FOREIGN KEY (`actor-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
991 FOREIGN KEY (`target-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
992 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
993 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
998 CREATE TABLE IF NOT EXISTS `notify` (
999 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1000 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1001 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1002 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1003 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1004 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1005 `msg` mediumtext COMMENT '',
1006 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1007 `link` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1008 `iid` int unsigned COMMENT '',
1009 `parent` int unsigned COMMENT '',
1010 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
1011 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
1012 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
1013 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
1014 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
1015 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
1016 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
1018 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
1019 INDEX `uid_date` (`uid`,`date`),
1020 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
1021 INDEX `uri-id` (`uri-id`),
1022 INDEX `parent-uri-id` (`parent-uri-id`),
1023 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1024 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1025 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1026 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='[Deprecated] User notifications';
1029 -- TABLE notify-threads
1031 CREATE TABLE IF NOT EXISTS `notify-threads` (
1032 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1033 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1034 `master-parent-item` int unsigned COMMENT 'Deprecated',
1035 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
1036 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1037 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1039 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
1040 INDEX `receiver-uid` (`receiver-uid`),
1041 INDEX `notify-id` (`notify-id`),
1042 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1043 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1044 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1045 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1050 CREATE TABLE IF NOT EXISTS `oembed` (
1051 `url` varbinary(383) NOT NULL COMMENT 'page url',
1052 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
1053 `content` mediumtext COMMENT 'OEmbed data of the page',
1054 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1055 PRIMARY KEY(`url`,`maxwidth`),
1056 INDEX `created` (`created`)
1057 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
1060 -- TABLE openwebauth-token
1062 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
1063 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1064 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
1065 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
1066 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
1067 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1068 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1070 INDEX `uid` (`uid`),
1071 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1072 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
1077 CREATE TABLE IF NOT EXISTS `parsed_url` (
1078 `url_hash` binary(64) NOT NULL COMMENT 'page url hash',
1079 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
1080 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
1081 `url` text NOT NULL COMMENT 'page url',
1082 `content` mediumtext COMMENT 'page data',
1083 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1084 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration',
1085 PRIMARY KEY(`url_hash`,`guessing`,`oembed`),
1086 INDEX `created` (`created`),
1087 INDEX `expires` (`expires`)
1088 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
1093 CREATE TABLE IF NOT EXISTS `pconfig` (
1094 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
1095 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1096 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
1097 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
1098 `v` mediumtext COMMENT 'Value',
1100 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
1101 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1102 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
1107 CREATE TABLE IF NOT EXISTS `photo` (
1108 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1109 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1110 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1111 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
1112 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
1113 `hash` char(32) COMMENT 'hash value of the photo',
1114 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
1115 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
1116 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1117 `desc` text COMMENT '',
1118 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
1119 `photo-type` tinyint unsigned COMMENT 'User avatar, user banner, contact avatar, contact banner or default',
1120 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1121 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
1122 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1123 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1124 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1125 `blurhash` varbinary(255) COMMENT 'BlurHash representation of the photo',
1126 `data` mediumblob NOT NULL COMMENT '',
1127 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1128 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
1129 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
1130 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed circles',
1131 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
1132 `deny_gid` mediumtext COMMENT 'Access Control - list of denied circles',
1133 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
1134 `backend-class` tinytext COMMENT 'Storage backend class',
1135 `backend-ref` text COMMENT 'Storage backend data reference',
1136 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1138 INDEX `contactid` (`contact-id`),
1139 INDEX `uid_contactid` (`uid`,`contact-id`),
1140 INDEX `uid_profile` (`uid`,`profile`),
1141 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
1142 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
1143 INDEX `resource-id` (`resource-id`),
1144 INDEX `uid_photo-type` (`uid`,`photo-type`),
1145 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1146 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1147 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1152 CREATE TABLE IF NOT EXISTS `post` (
1153 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1154 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1155 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1156 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1157 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1158 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1159 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1160 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1161 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1162 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1163 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1164 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1165 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1166 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1167 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1168 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1169 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1170 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1171 PRIMARY KEY(`uri-id`),
1172 INDEX `parent-uri-id` (`parent-uri-id`),
1173 INDEX `thr-parent-id` (`thr-parent-id`),
1174 INDEX `external-id` (`external-id`),
1175 INDEX `owner-id` (`owner-id`),
1176 INDEX `author-id` (`author-id`),
1177 INDEX `causer-id` (`causer-id`),
1178 INDEX `vid` (`vid`),
1179 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1180 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1181 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1182 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1183 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1184 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1185 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1186 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1187 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
1190 -- TABLE post-activity
1192 CREATE TABLE IF NOT EXISTS `post-activity` (
1193 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1194 `activity` mediumtext COMMENT 'Original activity',
1195 `received` datetime COMMENT '',
1196 PRIMARY KEY(`uri-id`),
1197 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1198 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Original remote activity';
1201 -- TABLE post-category
1203 CREATE TABLE IF NOT EXISTS `post-category` (
1204 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1205 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1206 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1207 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1208 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1209 INDEX `tid` (`tid`),
1210 INDEX `uid_uri-id` (`uid`,`uri-id`),
1211 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1212 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1213 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1214 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1217 -- TABLE post-collection
1219 CREATE TABLE IF NOT EXISTS `post-collection` (
1220 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1221 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0 - Featured',
1222 `author-id` int unsigned COMMENT 'Author of the featured post',
1223 PRIMARY KEY(`uri-id`,`type`),
1224 INDEX `type` (`type`),
1225 INDEX `author-id` (`author-id`),
1226 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1227 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1228 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Collection of posts';
1231 -- TABLE post-content
1233 CREATE TABLE IF NOT EXISTS `post-content` (
1234 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1235 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1236 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1237 `body` mediumtext COMMENT 'item body content',
1238 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1239 `quote-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the quoted uri',
1240 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1241 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1242 `language` text COMMENT 'Language information about this post',
1243 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1244 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1245 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1246 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1247 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1248 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1249 `target` text COMMENT 'JSON encoded target structure if used',
1250 `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',
1251 `plink` varbinary(383) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1252 PRIMARY KEY(`uri-id`),
1253 INDEX `plink` (`plink`(191)),
1254 INDEX `resource-id` (`resource-id`),
1255 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
1256 INDEX `quote-uri-id` (`quote-uri-id`),
1257 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1258 FOREIGN KEY (`quote-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1259 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1262 -- TABLE post-delivery
1264 CREATE TABLE IF NOT EXISTS `post-delivery` (
1265 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1266 `inbox-id` int unsigned NOT NULL COMMENT 'Item-uri id of inbox url',
1267 `uid` mediumint unsigned COMMENT 'Delivering user',
1268 `created` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
1269 `command` varbinary(32) COMMENT '',
1270 `failed` tinyint DEFAULT 0 COMMENT 'Number of times the delivery has failed',
1271 `receivers` mediumtext COMMENT 'JSON encoded array with the receiving contacts',
1272 PRIMARY KEY(`uri-id`,`inbox-id`),
1273 INDEX `inbox-id_created` (`inbox-id`,`created`),
1274 INDEX `uid` (`uid`),
1275 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1276 FOREIGN KEY (`inbox-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1277 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1278 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for posts for the batch processing';
1281 -- TABLE post-delivery-data
1283 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1284 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1285 `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',
1286 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1287 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1288 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1289 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1290 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1291 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1292 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1293 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1294 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1295 PRIMARY KEY(`uri-id`),
1296 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1297 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1300 -- TABLE post-history
1302 CREATE TABLE IF NOT EXISTS `post-history` (
1303 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1304 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of edit',
1305 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1306 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1307 `body` mediumtext COMMENT 'item body content',
1308 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1309 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1310 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1311 `language` text COMMENT 'Language information about this post',
1312 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1313 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1314 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1315 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1316 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1317 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1318 `target` text COMMENT 'JSON encoded target structure if used',
1319 `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',
1320 `plink` varbinary(383) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1321 PRIMARY KEY(`uri-id`,`edited`),
1322 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1323 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post history';
1328 CREATE TABLE IF NOT EXISTS `post-link` (
1329 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1330 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1331 `url` varbinary(511) NOT NULL COMMENT 'External URL',
1332 `mimetype` varchar(60) COMMENT '',
1333 `height` smallint unsigned COMMENT 'Height of the media',
1334 `width` smallint unsigned COMMENT 'Width of the media',
1335 `blurhash` varbinary(255) COMMENT 'BlurHash representation of the link',
1337 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1338 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1339 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post related external links';
1344 CREATE TABLE IF NOT EXISTS `post-media` (
1345 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1346 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1347 `url` varbinary(1024) NOT NULL COMMENT 'Media URL',
1348 `media-uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the activities uri-id',
1349 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1350 `mimetype` varchar(60) COMMENT '',
1351 `height` smallint unsigned COMMENT 'Height of the media',
1352 `width` smallint unsigned COMMENT 'Width of the media',
1353 `size` bigint unsigned COMMENT 'Media size',
1354 `blurhash` varbinary(255) COMMENT 'BlurHash representation of the image',
1355 `preview` varbinary(512) COMMENT 'Preview URL',
1356 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1357 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1358 `description` text COMMENT '',
1359 `name` varchar(255) COMMENT 'Name of the media',
1360 `author-url` varbinary(383) COMMENT 'URL of the author of the media',
1361 `author-name` varchar(255) COMMENT 'Name of the author of the media',
1362 `author-image` varbinary(383) COMMENT 'Image of the author of the media',
1363 `publisher-url` varbinary(383) COMMENT 'URL of the publisher of the media',
1364 `publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
1365 `publisher-image` varbinary(383) COMMENT 'Image of the publisher of the media',
1367 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`(512)),
1368 INDEX `uri-id-id` (`uri-id`,`id`),
1369 INDEX `media-uri-id` (`media-uri-id`),
1370 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1371 FOREIGN KEY (`media-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1372 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1375 -- TABLE post-question
1377 CREATE TABLE IF NOT EXISTS `post-question` (
1378 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1379 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1380 `multiple` boolean NOT NULL DEFAULT '0' COMMENT 'Multiple choice',
1381 `voters` int unsigned COMMENT 'Number of voters for this question',
1382 `end-time` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Question end time',
1384 UNIQUE INDEX `uri-id` (`uri-id`),
1385 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1386 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question';
1389 -- TABLE post-question-option
1391 CREATE TABLE IF NOT EXISTS `post-question-option` (
1392 `id` int unsigned NOT NULL COMMENT 'Id of the question',
1393 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1394 `name` varchar(255) COMMENT 'Name of the option',
1395 `replies` int unsigned COMMENT 'Number of replies for this question option',
1396 PRIMARY KEY(`uri-id`,`id`),
1397 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1398 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question option';
1403 CREATE TABLE IF NOT EXISTS `post-tag` (
1404 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1405 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1406 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1407 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1408 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1409 INDEX `tid` (`tid`),
1410 INDEX `cid` (`cid`),
1411 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1412 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1413 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1414 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1417 -- TABLE post-thread
1419 CREATE TABLE IF NOT EXISTS `post-thread` (
1420 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1421 `conversation-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the conversation uri',
1422 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1423 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1424 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1425 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1426 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1427 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1428 `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',
1429 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1430 PRIMARY KEY(`uri-id`),
1431 INDEX `conversation-id` (`conversation-id`),
1432 INDEX `owner-id` (`owner-id`),
1433 INDEX `author-id` (`author-id`),
1434 INDEX `causer-id` (`causer-id`),
1435 INDEX `received` (`received`),
1436 INDEX `commented` (`commented`),
1437 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1438 FOREIGN KEY (`conversation-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1439 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1440 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1441 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1442 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1447 CREATE TABLE IF NOT EXISTS `post-user` (
1448 `id` int unsigned NOT NULL auto_increment,
1449 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1450 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1451 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1452 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1453 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1454 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1455 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1456 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1457 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1458 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1459 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1460 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1461 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1462 `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
1463 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1464 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1465 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1466 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1467 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1468 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1469 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1470 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1471 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1472 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1473 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1474 `notification-type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1475 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1476 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1477 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1479 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1480 INDEX `uri-id` (`uri-id`),
1481 INDEX `parent-uri-id` (`parent-uri-id`),
1482 INDEX `thr-parent-id` (`thr-parent-id`),
1483 INDEX `external-id` (`external-id`),
1484 INDEX `owner-id` (`owner-id`),
1485 INDEX `author-id` (`author-id`),
1486 INDEX `causer-id` (`causer-id`),
1487 INDEX `vid` (`vid`),
1488 INDEX `contact-id` (`contact-id`),
1489 INDEX `event-id` (`event-id`),
1490 INDEX `psid` (`psid`),
1491 INDEX `author-id_uid` (`author-id`,`uid`),
1492 INDEX `author-id_received` (`author-id`,`received`),
1493 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1494 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1495 INDEX `uid_contactid` (`uid`,`contact-id`),
1496 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1497 INDEX `uid_unseen` (`uid`,`unseen`),
1498 INDEX `uid_hidden_uri-id` (`uid`,`hidden`,`uri-id`),
1499 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1500 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1501 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1502 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1503 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1504 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1505 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1506 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1507 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1508 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1509 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1510 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1511 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1514 -- TABLE post-thread-user
1516 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1517 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1518 `conversation-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the conversation uri',
1519 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1520 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1521 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1522 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1523 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1524 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1525 `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',
1526 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1527 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1528 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
1529 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1530 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1531 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1532 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1533 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1534 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Deprecated',
1535 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1536 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1537 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1538 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1539 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1540 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1541 PRIMARY KEY(`uid`,`uri-id`),
1542 INDEX `uri-id` (`uri-id`),
1543 INDEX `conversation-id` (`conversation-id`),
1544 INDEX `owner-id` (`owner-id`),
1545 INDEX `author-id` (`author-id`),
1546 INDEX `causer-id` (`causer-id`),
1547 INDEX `uid` (`uid`),
1548 INDEX `contact-id` (`contact-id`),
1549 INDEX `psid` (`psid`),
1550 INDEX `post-user-id` (`post-user-id`),
1551 INDEX `commented` (`commented`),
1552 INDEX `uid_received` (`uid`,`received`),
1553 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1554 INDEX `uid_commented` (`uid`,`commented`),
1555 INDEX `uid_starred` (`uid`,`starred`),
1556 INDEX `uid_mention` (`uid`,`mention`),
1557 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1558 FOREIGN KEY (`conversation-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1559 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1560 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1561 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1562 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1563 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1564 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1565 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1566 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1569 -- TABLE post-user-notification
1571 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1572 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1573 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1574 `notification-type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1575 PRIMARY KEY(`uid`,`uri-id`),
1576 INDEX `uri-id` (`uri-id`),
1577 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1578 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1579 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1584 CREATE TABLE IF NOT EXISTS `process` (
1585 `pid` int unsigned NOT NULL COMMENT 'The ID of the process',
1586 `hostname` varchar(255) NOT NULL COMMENT 'The name of the host the process is ran on',
1587 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1588 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1589 PRIMARY KEY(`pid`,`hostname`),
1590 INDEX `command` (`command`)
1591 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1596 CREATE TABLE IF NOT EXISTS `profile` (
1597 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1598 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1599 `profile-name` varchar(255) COMMENT 'Deprecated',
1600 `is-default` boolean COMMENT 'Deprecated',
1601 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1602 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Unused in favor of user.username',
1603 `pdesc` varchar(255) COMMENT 'Deprecated',
1604 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1605 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1606 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1607 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1608 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1609 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1610 `hometown` varchar(255) COMMENT 'Deprecated',
1611 `gender` varchar(32) COMMENT 'Deprecated',
1612 `marital` varchar(255) COMMENT 'Deprecated',
1613 `with` text COMMENT 'Deprecated',
1614 `howlong` datetime COMMENT 'Deprecated',
1615 `sexual` varchar(255) COMMENT 'Deprecated',
1616 `politic` varchar(255) COMMENT 'Deprecated',
1617 `religion` varchar(255) COMMENT 'Deprecated',
1618 `pub_keywords` text COMMENT '',
1619 `prv_keywords` text COMMENT '',
1620 `likes` text COMMENT 'Deprecated',
1621 `dislikes` text COMMENT 'Deprecated',
1622 `about` text COMMENT 'Profile description',
1623 `summary` varchar(255) COMMENT 'Deprecated',
1624 `music` text COMMENT 'Deprecated',
1625 `book` text COMMENT 'Deprecated',
1626 `tv` text COMMENT 'Deprecated',
1627 `film` text COMMENT 'Deprecated',
1628 `interest` text COMMENT 'Deprecated',
1629 `romance` text COMMENT 'Deprecated',
1630 `work` text COMMENT 'Deprecated',
1631 `education` text COMMENT 'Deprecated',
1632 `contact` text COMMENT 'Deprecated',
1633 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1634 `homepage_verified` boolean NOT NULL DEFAULT '0' COMMENT 'was the homepage verified by a rel-me link back to the profile',
1635 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
1636 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
1637 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1638 `thumb` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1639 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1640 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1642 INDEX `uid_is-default` (`uid`,`is-default`),
1643 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1644 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1645 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1648 -- TABLE profile_field
1650 CREATE TABLE IF NOT EXISTS `profile_field` (
1651 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1652 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1653 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1654 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1655 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1656 `value` text COMMENT 'Value of the field',
1657 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1658 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1660 INDEX `uid` (`uid`),
1661 INDEX `order` (`order`),
1662 INDEX `psid` (`psid`),
1663 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1664 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1665 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1668 -- TABLE push_subscriber
1670 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1671 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1672 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1673 `callback_url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1674 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1675 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1676 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1677 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1678 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1679 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1680 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1682 INDEX `next_try` (`next_try`),
1683 INDEX `uid` (`uid`),
1684 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1685 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1690 CREATE TABLE IF NOT EXISTS `register` (
1691 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1692 `hash` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1693 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1694 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1695 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1696 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1697 `note` text COMMENT '',
1699 INDEX `uid` (`uid`),
1700 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1701 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1706 CREATE TABLE IF NOT EXISTS `report` (
1707 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1708 `uid` mediumint unsigned COMMENT 'Reporting user',
1709 `reporter-id` int unsigned COMMENT 'Reporting contact',
1710 `cid` int unsigned NOT NULL COMMENT 'Reported contact',
1711 `gsid` int unsigned COMMENT 'Reported contact server',
1712 `comment` text COMMENT 'Report',
1713 `category-id` int unsigned NOT NULL DEFAULT 1 COMMENT 'Report category, one of Entity\Report::CATEGORY_*',
1714 `forward` boolean COMMENT 'Forward the report to the remote server',
1715 `public-remarks` text COMMENT 'Remarks shared with the reporter',
1716 `private-remarks` text COMMENT 'Remarks shared with the moderation team',
1717 `last-editor-uid` mediumint unsigned COMMENT 'Last editor user',
1718 `assigned-uid` mediumint unsigned COMMENT 'Assigned moderator user',
1719 `status` tinyint unsigned NOT NULL COMMENT 'Status of the report, one of Entity\Report::STATUS_*',
1720 `resolution` tinyint unsigned COMMENT 'Resolution of the report, one of Entity\Report::RESOLUTION_*',
1721 `created` datetime(6) NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1722 `edited` datetime(6) COMMENT 'Last time the report has been edited',
1724 INDEX `uid` (`uid`),
1725 INDEX `cid` (`cid`),
1726 INDEX `reporter-id` (`reporter-id`),
1727 INDEX `gsid` (`gsid`),
1728 INDEX `last-editor-uid` (`last-editor-uid`),
1729 INDEX `assigned-uid` (`assigned-uid`),
1730 INDEX `status-resolution` (`status`,`resolution`),
1731 INDEX `created` (`created`),
1732 INDEX `edited` (`edited`),
1733 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1734 FOREIGN KEY (`reporter-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1735 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1736 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1737 FOREIGN KEY (`last-editor-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1738 FOREIGN KEY (`assigned-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1739 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1742 -- TABLE report-post
1744 CREATE TABLE IF NOT EXISTS `report-post` (
1745 `rid` int unsigned NOT NULL COMMENT 'Report id',
1746 `uri-id` int unsigned NOT NULL COMMENT 'Uri-id of the reported post',
1747 `status` tinyint unsigned COMMENT 'Status of the reported post',
1748 PRIMARY KEY(`rid`,`uri-id`),
1749 INDEX `uri-id` (`uri-id`),
1750 FOREIGN KEY (`rid`) REFERENCES `report` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1751 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1752 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Individual posts attached to a moderation report';
1755 -- TABLE report-rule
1757 CREATE TABLE IF NOT EXISTS `report-rule` (
1758 `rid` int unsigned NOT NULL COMMENT 'Report id',
1759 `line-id` int unsigned NOT NULL COMMENT 'Terms of service rule line number, may become invalid after a TOS change.',
1760 `text` text NOT NULL COMMENT 'Terms of service rule text recorded at the time of the report',
1761 PRIMARY KEY(`rid`,`line-id`),
1762 FOREIGN KEY (`rid`) REFERENCES `report` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1763 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Terms of service rule lines relevant to a moderation report';
1768 CREATE TABLE IF NOT EXISTS `search` (
1769 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1770 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1771 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1773 INDEX `uid_term` (`uid`,`term`(64)),
1774 INDEX `term` (`term`(64)),
1775 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1776 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1781 CREATE TABLE IF NOT EXISTS `session` (
1782 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1783 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1784 `data` text COMMENT '',
1785 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1787 INDEX `sid` (`sid`(64)),
1788 INDEX `expire` (`expire`)
1789 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1794 CREATE TABLE IF NOT EXISTS `storage` (
1795 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1796 `data` longblob NOT NULL COMMENT 'file data',
1798 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1801 -- TABLE subscription
1803 CREATE TABLE IF NOT EXISTS `subscription` (
1804 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1805 `application-id` int unsigned NOT NULL COMMENT '',
1806 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
1807 `endpoint` varchar(511) COMMENT 'Endpoint URL',
1808 `pubkey` varchar(127) COMMENT 'User agent public key',
1809 `secret` varchar(32) COMMENT 'Auth secret',
1810 `follow` boolean COMMENT '',
1811 `favourite` boolean COMMENT '',
1812 `reblog` boolean COMMENT '',
1813 `mention` boolean COMMENT '',
1814 `poll` boolean COMMENT '',
1815 `follow_request` boolean COMMENT '',
1816 `status` boolean COMMENT '',
1818 UNIQUE INDEX `application-id_uid` (`application-id`,`uid`),
1819 INDEX `uid_application-id` (`uid`,`application-id`),
1820 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1821 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1822 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Push Subscription for the API';
1827 CREATE TABLE IF NOT EXISTS `userd` (
1828 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1829 `username` varchar(255) NOT NULL COMMENT '',
1831 INDEX `username` (`username`(32))
1832 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1835 -- TABLE user-contact
1837 CREATE TABLE IF NOT EXISTS `user-contact` (
1838 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1839 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1840 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
1841 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1842 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1843 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1844 `hidden` boolean COMMENT 'This contact is hidden from the others',
1845 `is-blocked` boolean COMMENT 'User is blocked by this contact',
1846 `pending` boolean COMMENT '',
1847 `rel` tinyint unsigned COMMENT 'The kind of the relation between the user and the contact',
1848 `info` mediumtext COMMENT '',
1849 `notify_new_posts` boolean COMMENT '',
1850 `remote_self` tinyint unsigned COMMENT '0 => No mirroring, 1-2 => Mirror as own post, 3 => Mirror as reshare',
1851 `fetch_further_information` tinyint unsigned COMMENT '0 => None, 1 => Fetch information, 3 => Fetch keywords, 2 => Fetch both',
1852 `ffi_keyword_denylist` text COMMENT '',
1853 `subhub` boolean COMMENT '',
1854 `hub-verify` varbinary(383) COMMENT '',
1855 `protocol` char(4) COMMENT 'Protocol of the contact',
1856 `rating` tinyint COMMENT 'Automatically detected feed poll frequency',
1857 `priority` tinyint unsigned COMMENT 'Feed poll priority',
1858 PRIMARY KEY(`uid`,`cid`),
1859 INDEX `cid` (`cid`),
1860 UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
1861 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1862 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1863 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1864 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1867 -- TABLE arrived-activity
1869 CREATE TABLE IF NOT EXISTS `arrived-activity` (
1870 `object-id` varbinary(383) NOT NULL COMMENT 'object id of the incoming activity',
1871 `received` datetime COMMENT 'Receiving date',
1872 PRIMARY KEY(`object-id`)
1873 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Id of arrived activities';
1876 -- TABLE fetched-activity
1878 CREATE TABLE IF NOT EXISTS `fetched-activity` (
1879 `object-id` varbinary(383) NOT NULL COMMENT 'object id of fetched activity',
1880 `received` datetime COMMENT 'Receiving date',
1881 PRIMARY KEY(`object-id`)
1882 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Id of fetched activities';
1887 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1888 `key` int NOT NULL COMMENT '',
1889 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1891 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1894 -- VIEW application-view
1896 DROP VIEW IF EXISTS `application-view`;
1897 CREATE VIEW `application-view` AS SELECT
1898 `application`.`id` AS `id`,
1899 `application-token`.`uid` AS `uid`,
1900 `application`.`name` AS `name`,
1901 `application`.`redirect_uri` AS `redirect_uri`,
1902 `application`.`website` AS `website`,
1903 `application`.`client_id` AS `client_id`,
1904 `application`.`client_secret` AS `client_secret`,
1905 `application-token`.`code` AS `code`,
1906 `application-token`.`access_token` AS `access_token`,
1907 `application-token`.`created_at` AS `created_at`,
1908 `application-token`.`scopes` AS `scopes`,
1909 `application-token`.`read` AS `read`,
1910 `application-token`.`write` AS `write`,
1911 `application-token`.`follow` AS `follow`,
1912 `application-token`.`push` AS `push`
1913 FROM `application-token`
1914 INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`;
1917 -- VIEW circle-member-view
1919 DROP VIEW IF EXISTS `circle-member-view`;
1920 CREATE VIEW `circle-member-view` AS SELECT
1921 `group_member`.`id` AS `id`,
1922 `group`.`uid` AS `uid`,
1923 `group_member`.`contact-id` AS `contact-id`,
1924 `contact`.`uri-id` AS `contact-uri-id`,
1925 `contact`.`url` AS `contact-link`,
1926 `contact`.`addr` AS `contact-addr`,
1927 `contact`.`name` AS `contact-name`,
1928 `contact`.`nick` AS `contact-nick`,
1929 `contact`.`thumb` AS `contact-avatar`,
1930 `contact`.`network` AS `contact-network`,
1931 `contact`.`blocked` AS `contact-blocked`,
1932 `contact`.`hidden` AS `contact-hidden`,
1933 `contact`.`readonly` AS `contact-readonly`,
1934 `contact`.`archive` AS `contact-archive`,
1935 `contact`.`pending` AS `contact-pending`,
1936 `contact`.`self` AS `contact-self`,
1937 `contact`.`rel` AS `contact-rel`,
1938 `contact`.`contact-type` AS `contact-contact-type`,
1939 `group_member`.`gid` AS `circle-id`,
1940 `group`.`visible` AS `circle-visible`,
1941 `group`.`deleted` AS `circle-deleted`,
1942 `group`.`name` AS `circle-name`
1944 INNER JOIN `contact` ON `group_member`.`contact-id` = `contact`.`id`
1945 INNER JOIN `group` ON `group_member`.`gid` = `group`.`id`;
1948 -- VIEW post-user-view
1950 DROP VIEW IF EXISTS `post-user-view`;
1951 CREATE VIEW `post-user-view` AS SELECT
1952 `post-user`.`id` AS `id`,
1953 `post-user`.`id` AS `post-user-id`,
1954 `post-user`.`uid` AS `uid`,
1955 `post-thread-user`.`post-user-id` AS `parent`,
1956 `item-uri`.`uri` AS `uri`,
1957 `post-user`.`uri-id` AS `uri-id`,
1958 `parent-item-uri`.`uri` AS `parent-uri`,
1959 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1960 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1961 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1962 `conversation-item-uri`.`uri` AS `conversation`,
1963 `post-thread-user`.`conversation-id` AS `conversation-id`,
1964 `quote-item-uri`.`uri` AS `quote-uri`,
1965 `post-content`.`quote-uri-id` AS `quote-uri-id`,
1966 `item-uri`.`guid` AS `guid`,
1967 `post-user`.`wall` AS `wall`,
1968 `post-user`.`gravity` AS `gravity`,
1969 `external-item-uri`.`uri` AS `extid`,
1970 `post-user`.`external-id` AS `external-id`,
1971 `post-user`.`created` AS `created`,
1972 `post-user`.`edited` AS `edited`,
1973 `post-thread-user`.`commented` AS `commented`,
1974 `post-user`.`received` AS `received`,
1975 `post-thread-user`.`changed` AS `changed`,
1976 `post-user`.`post-type` AS `post-type`,
1977 `post-user`.`post-reason` AS `post-reason`,
1978 `post-user`.`private` AS `private`,
1979 `post-thread-user`.`pubmail` AS `pubmail`,
1980 `post-user`.`visible` AS `visible`,
1981 `post-thread-user`.`starred` AS `starred`,
1982 `post-user`.`unseen` AS `unseen`,
1983 `post-user`.`deleted` AS `deleted`,
1984 `post-user`.`origin` AS `origin`,
1985 `post-thread-user`.`origin` AS `parent-origin`,
1986 `post-thread-user`.`mention` AS `mention`,
1987 `post-user`.`global` AS `global`,
1988 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-user`.`uri-id`) AS `featured`,
1989 `post-user`.`network` AS `network`,
1990 `post-user`.`protocol` AS `protocol`,
1991 `post-user`.`vid` AS `vid`,
1992 `post-user`.`psid` AS `psid`,
1993 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1994 `post-content`.`title` AS `title`,
1995 `post-content`.`content-warning` AS `content-warning`,
1996 `post-content`.`raw-body` AS `raw-body`,
1997 IFNULL (`post-content`.`body`, '') AS `body`,
1998 `post-content`.`rendered-hash` AS `rendered-hash`,
1999 `post-content`.`rendered-html` AS `rendered-html`,
2000 `post-content`.`language` AS `language`,
2001 `post-content`.`plink` AS `plink`,
2002 `post-content`.`location` AS `location`,
2003 `post-content`.`coord` AS `coord`,
2004 `post-content`.`app` AS `app`,
2005 `post-content`.`object-type` AS `object-type`,
2006 `post-content`.`object` AS `object`,
2007 `post-content`.`target-type` AS `target-type`,
2008 `post-content`.`target` AS `target`,
2009 `post-content`.`resource-id` AS `resource-id`,
2010 `post-user`.`contact-id` AS `contact-id`,
2011 `contact`.`uri-id` AS `contact-uri-id`,
2012 `contact`.`url` AS `contact-link`,
2013 `contact`.`addr` AS `contact-addr`,
2014 `contact`.`name` AS `contact-name`,
2015 `contact`.`nick` AS `contact-nick`,
2016 `contact`.`thumb` AS `contact-avatar`,
2017 `contact`.`network` AS `contact-network`,
2018 `contact`.`blocked` AS `contact-blocked`,
2019 `contact`.`hidden` AS `contact-hidden`,
2020 `contact`.`readonly` AS `contact-readonly`,
2021 `contact`.`archive` AS `contact-archive`,
2022 `contact`.`pending` AS `contact-pending`,
2023 `contact`.`rel` AS `contact-rel`,
2024 `contact`.`uid` AS `contact-uid`,
2025 `contact`.`contact-type` AS `contact-contact-type`,
2026 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
2027 `contact`.`self` AS `self`,
2028 `contact`.`id` AS `cid`,
2029 `contact`.`alias` AS `alias`,
2030 `contact`.`photo` AS `photo`,
2031 `contact`.`name-date` AS `name-date`,
2032 `contact`.`uri-date` AS `uri-date`,
2033 `contact`.`avatar-date` AS `avatar-date`,
2034 `contact`.`thumb` AS `thumb`,
2035 `post-user`.`author-id` AS `author-id`,
2036 `author`.`uri-id` AS `author-uri-id`,
2037 `author`.`url` AS `author-link`,
2038 `author`.`addr` AS `author-addr`,
2039 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
2040 `author`.`nick` AS `author-nick`,
2041 `author`.`alias` AS `author-alias`,
2042 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
2043 `author`.`network` AS `author-network`,
2044 `author`.`blocked` AS `author-blocked`,
2045 `author`.`hidden` AS `author-hidden`,
2046 `author`.`updated` AS `author-updated`,
2047 `author`.`gsid` AS `author-gsid`,
2048 `post-user`.`owner-id` AS `owner-id`,
2049 `owner`.`uri-id` AS `owner-uri-id`,
2050 `owner`.`url` AS `owner-link`,
2051 `owner`.`addr` AS `owner-addr`,
2052 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
2053 `owner`.`nick` AS `owner-nick`,
2054 `owner`.`alias` AS `owner-alias`,
2055 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
2056 `owner`.`network` AS `owner-network`,
2057 `owner`.`blocked` AS `owner-blocked`,
2058 `owner`.`hidden` AS `owner-hidden`,
2059 `owner`.`updated` AS `owner-updated`,
2060 `owner`.`gsid` AS `owner-gsid`,
2061 `owner`.`contact-type` AS `owner-contact-type`,
2062 `post-user`.`causer-id` AS `causer-id`,
2063 `causer`.`uri-id` AS `causer-uri-id`,
2064 `causer`.`url` AS `causer-link`,
2065 `causer`.`addr` AS `causer-addr`,
2066 `causer`.`name` AS `causer-name`,
2067 `causer`.`nick` AS `causer-nick`,
2068 `causer`.`alias` AS `causer-alias`,
2069 `causer`.`thumb` AS `causer-avatar`,
2070 `causer`.`network` AS `causer-network`,
2071 `causer`.`blocked` AS `causer-blocked`,
2072 `causer`.`hidden` AS `causer-hidden`,
2073 `causer`.`gsid` AS `causer-gsid`,
2074 `causer`.`contact-type` AS `causer-contact-type`,
2075 `post-delivery-data`.`postopts` AS `postopts`,
2076 `post-delivery-data`.`inform` AS `inform`,
2077 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
2078 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
2079 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
2080 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
2081 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
2082 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
2083 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
2084 `post-user`.`event-id` AS `event-id`,
2085 `event`.`created` AS `event-created`,
2086 `event`.`edited` AS `event-edited`,
2087 `event`.`start` AS `event-start`,
2088 `event`.`finish` AS `event-finish`,
2089 `event`.`summary` AS `event-summary`,
2090 `event`.`desc` AS `event-desc`,
2091 `event`.`location` AS `event-location`,
2092 `event`.`type` AS `event-type`,
2093 `event`.`nofinish` AS `event-nofinish`,
2094 `event`.`ignore` AS `event-ignore`,
2095 `post-question`.`id` AS `question-id`,
2096 `post-question`.`multiple` AS `question-multiple`,
2097 `post-question`.`voters` AS `question-voters`,
2098 `post-question`.`end-time` AS `question-end-time`,
2099 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`,
2100 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-user`.`uri-id`) AS `has-media`,
2101 `diaspora-interaction`.`interaction` AS `signed_text`,
2102 `parent-item-uri`.`guid` AS `parent-guid`,
2103 `post-thread-user`.`network` AS `parent-network`,
2104 `post-thread-user`.`author-id` AS `parent-author-id`,
2105 `parent-post-author`.`url` AS `parent-author-link`,
2106 `parent-post-author`.`name` AS `parent-author-name`,
2107 `parent-post-author`.`nick` AS `parent-author-nick`,
2108 `parent-post-author`.`network` AS `parent-author-network`
2110 INNER JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2111 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
2112 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
2113 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
2114 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
2115 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
2116 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
2117 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
2118 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
2119 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
2120 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
2121 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
2122 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
2123 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
2124 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2125 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
2126 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-user`.`uri-id`
2127 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
2128 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `post-thread-user`.`author-id`;
2131 -- VIEW post-thread-user-view
2133 DROP VIEW IF EXISTS `post-thread-user-view`;
2134 CREATE VIEW `post-thread-user-view` AS SELECT
2135 `post-user`.`id` AS `id`,
2136 `post-user`.`id` AS `post-user-id`,
2137 `post-thread-user`.`uid` AS `uid`,
2138 `post-thread-user`.`post-user-id` AS `parent`,
2139 `item-uri`.`uri` AS `uri`,
2140 `post-thread-user`.`uri-id` AS `uri-id`,
2141 `parent-item-uri`.`uri` AS `parent-uri`,
2142 `post-user`.`parent-uri-id` AS `parent-uri-id`,
2143 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2144 `post-user`.`thr-parent-id` AS `thr-parent-id`,
2145 `conversation-item-uri`.`uri` AS `conversation`,
2146 `post-thread-user`.`conversation-id` AS `conversation-id`,
2147 `quote-item-uri`.`uri` AS `quote-uri`,
2148 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2149 `item-uri`.`guid` AS `guid`,
2150 `post-thread-user`.`wall` AS `wall`,
2151 `post-user`.`gravity` AS `gravity`,
2152 `external-item-uri`.`uri` AS `extid`,
2153 `post-user`.`external-id` AS `external-id`,
2154 `post-thread-user`.`created` AS `created`,
2155 `post-user`.`edited` AS `edited`,
2156 `post-thread-user`.`commented` AS `commented`,
2157 `post-thread-user`.`received` AS `received`,
2158 `post-thread-user`.`changed` AS `changed`,
2159 `post-user`.`post-type` AS `post-type`,
2160 `post-user`.`post-reason` AS `post-reason`,
2161 `post-user`.`private` AS `private`,
2162 `post-thread-user`.`pubmail` AS `pubmail`,
2163 `post-thread-user`.`ignored` AS `ignored`,
2164 `post-user`.`visible` AS `visible`,
2165 `post-thread-user`.`starred` AS `starred`,
2166 `post-thread-user`.`unseen` AS `unseen`,
2167 `post-user`.`deleted` AS `deleted`,
2168 `post-thread-user`.`origin` AS `origin`,
2169 `post-thread-user`.`mention` AS `mention`,
2170 `post-user`.`global` AS `global`,
2171 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread-user`.`uri-id`) AS `featured`,
2172 `post-thread-user`.`network` AS `network`,
2173 `post-user`.`vid` AS `vid`,
2174 `post-thread-user`.`psid` AS `psid`,
2175 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2176 `post-content`.`title` AS `title`,
2177 `post-content`.`content-warning` AS `content-warning`,
2178 `post-content`.`raw-body` AS `raw-body`,
2179 `post-content`.`body` AS `body`,
2180 `post-content`.`rendered-hash` AS `rendered-hash`,
2181 `post-content`.`rendered-html` AS `rendered-html`,
2182 `post-content`.`language` AS `language`,
2183 `post-content`.`plink` AS `plink`,
2184 `post-content`.`location` AS `location`,
2185 `post-content`.`coord` AS `coord`,
2186 `post-content`.`app` AS `app`,
2187 `post-content`.`object-type` AS `object-type`,
2188 `post-content`.`object` AS `object`,
2189 `post-content`.`target-type` AS `target-type`,
2190 `post-content`.`target` AS `target`,
2191 `post-content`.`resource-id` AS `resource-id`,
2192 `post-thread-user`.`contact-id` AS `contact-id`,
2193 `contact`.`uri-id` AS `contact-uri-id`,
2194 `contact`.`url` AS `contact-link`,
2195 `contact`.`addr` AS `contact-addr`,
2196 `contact`.`name` AS `contact-name`,
2197 `contact`.`nick` AS `contact-nick`,
2198 `contact`.`thumb` AS `contact-avatar`,
2199 `contact`.`network` AS `contact-network`,
2200 `contact`.`blocked` AS `contact-blocked`,
2201 `contact`.`hidden` AS `contact-hidden`,
2202 `contact`.`readonly` AS `contact-readonly`,
2203 `contact`.`archive` AS `contact-archive`,
2204 `contact`.`pending` AS `contact-pending`,
2205 `contact`.`rel` AS `contact-rel`,
2206 `contact`.`uid` AS `contact-uid`,
2207 `contact`.`gsid` AS `contact-gsid`,
2208 `contact`.`contact-type` AS `contact-contact-type`,
2209 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
2210 `contact`.`self` AS `self`,
2211 `contact`.`id` AS `cid`,
2212 `contact`.`alias` AS `alias`,
2213 `contact`.`photo` AS `photo`,
2214 `contact`.`name-date` AS `name-date`,
2215 `contact`.`uri-date` AS `uri-date`,
2216 `contact`.`avatar-date` AS `avatar-date`,
2217 `contact`.`thumb` AS `thumb`,
2218 `post-thread-user`.`author-id` AS `author-id`,
2219 `author`.`uri-id` AS `author-uri-id`,
2220 `author`.`url` AS `author-link`,
2221 `author`.`addr` AS `author-addr`,
2222 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
2223 `author`.`nick` AS `author-nick`,
2224 `author`.`alias` AS `author-alias`,
2225 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
2226 `author`.`network` AS `author-network`,
2227 `author`.`blocked` AS `author-blocked`,
2228 `author`.`hidden` AS `author-hidden`,
2229 `author`.`updated` AS `author-updated`,
2230 `author`.`gsid` AS `author-gsid`,
2231 `post-thread-user`.`owner-id` AS `owner-id`,
2232 `owner`.`uri-id` AS `owner-uri-id`,
2233 `owner`.`url` AS `owner-link`,
2234 `owner`.`addr` AS `owner-addr`,
2235 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
2236 `owner`.`nick` AS `owner-nick`,
2237 `owner`.`alias` AS `owner-alias`,
2238 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
2239 `owner`.`network` AS `owner-network`,
2240 `owner`.`blocked` AS `owner-blocked`,
2241 `owner`.`hidden` AS `owner-hidden`,
2242 `owner`.`updated` AS `owner-updated`,
2243 `owner`.`gsid` AS `owner-gsid`,
2244 `owner`.`contact-type` AS `owner-contact-type`,
2245 `post-thread-user`.`causer-id` AS `causer-id`,
2246 `causer`.`uri-id` AS `causer-uri-id`,
2247 `causer`.`url` AS `causer-link`,
2248 `causer`.`addr` AS `causer-addr`,
2249 `causer`.`name` AS `causer-name`,
2250 `causer`.`nick` AS `causer-nick`,
2251 `causer`.`alias` AS `causer-alias`,
2252 `causer`.`thumb` AS `causer-avatar`,
2253 `causer`.`network` AS `causer-network`,
2254 `causer`.`blocked` AS `causer-blocked`,
2255 `causer`.`hidden` AS `causer-hidden`,
2256 `causer`.`gsid` AS `causer-gsid`,
2257 `causer`.`contact-type` AS `causer-contact-type`,
2258 `post-delivery-data`.`postopts` AS `postopts`,
2259 `post-delivery-data`.`inform` AS `inform`,
2260 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
2261 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
2262 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
2263 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
2264 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
2265 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
2266 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
2267 `post-user`.`event-id` AS `event-id`,
2268 `event`.`created` AS `event-created`,
2269 `event`.`edited` AS `event-edited`,
2270 `event`.`start` AS `event-start`,
2271 `event`.`finish` AS `event-finish`,
2272 `event`.`summary` AS `event-summary`,
2273 `event`.`desc` AS `event-desc`,
2274 `event`.`location` AS `event-location`,
2275 `event`.`type` AS `event-type`,
2276 `event`.`nofinish` AS `event-nofinish`,
2277 `event`.`ignore` AS `event-ignore`,
2278 `post-question`.`id` AS `question-id`,
2279 `post-question`.`multiple` AS `question-multiple`,
2280 `post-question`.`voters` AS `question-voters`,
2281 `post-question`.`end-time` AS `question-end-time`,
2282 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`,
2283 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread-user`.`uri-id`) AS `has-media`,
2284 `diaspora-interaction`.`interaction` AS `signed_text`,
2285 `parent-item-uri`.`guid` AS `parent-guid`,
2286 `post-thread-user`.`network` AS `parent-network`,
2287 `post-thread-user`.`author-id` AS `parent-author-id`,
2288 `author`.`url` AS `parent-author-link`,
2289 `author`.`name` AS `parent-author-name`,
2290 `author`.`nick` AS `parent-author-nick`,
2291 `author`.`network` AS `parent-author-network`
2292 FROM `post-thread-user`
2293 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2294 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2295 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
2296 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
2297 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
2298 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
2299 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
2300 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
2301 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
2302 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
2303 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
2304 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
2305 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
2306 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
2307 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2308 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
2309 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread-user`.`uri-id`
2310 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`;
2315 DROP VIEW IF EXISTS `post-view`;
2316 CREATE VIEW `post-view` AS SELECT
2317 `item-uri`.`uri` AS `uri`,
2318 `post`.`uri-id` AS `uri-id`,
2319 `parent-item-uri`.`uri` AS `parent-uri`,
2320 `post`.`parent-uri-id` AS `parent-uri-id`,
2321 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2322 `post`.`thr-parent-id` AS `thr-parent-id`,
2323 `conversation-item-uri`.`uri` AS `conversation`,
2324 `post-thread`.`conversation-id` AS `conversation-id`,
2325 `quote-item-uri`.`uri` AS `quote-uri`,
2326 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2327 `item-uri`.`guid` AS `guid`,
2328 `post`.`gravity` AS `gravity`,
2329 `external-item-uri`.`uri` AS `extid`,
2330 `post`.`external-id` AS `external-id`,
2331 `post`.`created` AS `created`,
2332 `post`.`edited` AS `edited`,
2333 `post-thread`.`commented` AS `commented`,
2334 `post`.`received` AS `received`,
2335 `post-thread`.`changed` AS `changed`,
2336 `post`.`post-type` AS `post-type`,
2337 `post`.`private` AS `private`,
2338 `post`.`visible` AS `visible`,
2339 `post`.`deleted` AS `deleted`,
2340 `post`.`global` AS `global`,
2341 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post`.`uri-id`) AS `featured`,
2342 `post`.`network` AS `network`,
2343 `post`.`vid` AS `vid`,
2344 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2345 `post-content`.`title` AS `title`,
2346 `post-content`.`content-warning` AS `content-warning`,
2347 `post-content`.`raw-body` AS `raw-body`,
2348 `post-content`.`body` AS `body`,
2349 `post-content`.`rendered-hash` AS `rendered-hash`,
2350 `post-content`.`rendered-html` AS `rendered-html`,
2351 `post-content`.`language` AS `language`,
2352 `post-content`.`plink` AS `plink`,
2353 `post-content`.`location` AS `location`,
2354 `post-content`.`coord` AS `coord`,
2355 `post-content`.`app` AS `app`,
2356 `post-content`.`object-type` AS `object-type`,
2357 `post-content`.`object` AS `object`,
2358 `post-content`.`target-type` AS `target-type`,
2359 `post-content`.`target` AS `target`,
2360 `post-content`.`resource-id` AS `resource-id`,
2361 `post`.`author-id` AS `contact-id`,
2362 `author`.`uri-id` AS `contact-uri-id`,
2363 `author`.`url` AS `contact-link`,
2364 `author`.`addr` AS `contact-addr`,
2365 `author`.`name` AS `contact-name`,
2366 `author`.`nick` AS `contact-nick`,
2367 `author`.`thumb` AS `contact-avatar`,
2368 `author`.`network` AS `contact-network`,
2369 `author`.`blocked` AS `contact-blocked`,
2370 `author`.`hidden` AS `contact-hidden`,
2371 `author`.`readonly` AS `contact-readonly`,
2372 `author`.`archive` AS `contact-archive`,
2373 `author`.`pending` AS `contact-pending`,
2374 `author`.`rel` AS `contact-rel`,
2375 `author`.`uid` AS `contact-uid`,
2376 `author`.`contact-type` AS `contact-contact-type`,
2377 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2379 `author`.`id` AS `cid`,
2380 `author`.`alias` AS `alias`,
2381 `author`.`photo` AS `photo`,
2382 `author`.`name-date` AS `name-date`,
2383 `author`.`uri-date` AS `uri-date`,
2384 `author`.`avatar-date` AS `avatar-date`,
2385 `author`.`thumb` AS `thumb`,
2386 `post`.`author-id` AS `author-id`,
2387 `author`.`uri-id` AS `author-uri-id`,
2388 `author`.`url` AS `author-link`,
2389 `author`.`addr` AS `author-addr`,
2390 `author`.`name` AS `author-name`,
2391 `author`.`nick` AS `author-nick`,
2392 `author`.`alias` AS `author-alias`,
2393 `author`.`thumb` AS `author-avatar`,
2394 `author`.`network` AS `author-network`,
2395 `author`.`blocked` AS `author-blocked`,
2396 `author`.`hidden` AS `author-hidden`,
2397 `author`.`updated` AS `author-updated`,
2398 `author`.`gsid` AS `author-gsid`,
2399 `post`.`owner-id` AS `owner-id`,
2400 `owner`.`uri-id` AS `owner-uri-id`,
2401 `owner`.`url` AS `owner-link`,
2402 `owner`.`addr` AS `owner-addr`,
2403 `owner`.`name` AS `owner-name`,
2404 `owner`.`nick` AS `owner-nick`,
2405 `owner`.`alias` AS `owner-alias`,
2406 `owner`.`thumb` AS `owner-avatar`,
2407 `owner`.`network` AS `owner-network`,
2408 `owner`.`blocked` AS `owner-blocked`,
2409 `owner`.`hidden` AS `owner-hidden`,
2410 `owner`.`updated` AS `owner-updated`,
2411 `owner`.`contact-type` AS `owner-contact-type`,
2412 `owner`.`gsid` AS `owner-gsid`,
2413 `post`.`causer-id` AS `causer-id`,
2414 `causer`.`uri-id` AS `causer-uri-id`,
2415 `causer`.`url` AS `causer-link`,
2416 `causer`.`addr` AS `causer-addr`,
2417 `causer`.`name` AS `causer-name`,
2418 `causer`.`nick` AS `causer-nick`,
2419 `causer`.`alias` AS `causer-alias`,
2420 `causer`.`thumb` AS `causer-avatar`,
2421 `causer`.`network` AS `causer-network`,
2422 `causer`.`blocked` AS `causer-blocked`,
2423 `causer`.`hidden` AS `causer-hidden`,
2424 `causer`.`contact-type` AS `causer-contact-type`,
2425 `causer`.`gsid` AS `causer-gsid`,
2426 `post-question`.`id` AS `question-id`,
2427 `post-question`.`multiple` AS `question-multiple`,
2428 `post-question`.`voters` AS `question-voters`,
2429 `post-question`.`end-time` AS `question-end-time`,
2430 0 AS `has-categories`,
2431 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post`.`uri-id`) AS `has-media`,
2432 `diaspora-interaction`.`interaction` AS `signed_text`,
2433 `parent-item-uri`.`guid` AS `parent-guid`,
2434 `post-thread`.`network` AS `parent-network`,
2435 `post-thread`.`author-id` AS `parent-author-id`,
2436 `parent-post-author`.`url` AS `parent-author-link`,
2437 `parent-post-author`.`name` AS `parent-author-name`,
2438 `parent-post-author`.`nick` AS `parent-author-nick`,
2439 `parent-post-author`.`network` AS `parent-author-network`
2441 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
2442 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
2443 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
2444 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
2445 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
2446 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2447 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2448 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
2449 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2450 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2451 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
2452 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
2453 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2454 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post`.`uri-id`
2455 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `post-thread`.`author-id`;
2458 -- VIEW post-thread-view
2460 DROP VIEW IF EXISTS `post-thread-view`;
2461 CREATE VIEW `post-thread-view` AS SELECT
2462 `item-uri`.`uri` AS `uri`,
2463 `post-thread`.`uri-id` AS `uri-id`,
2464 `parent-item-uri`.`uri` AS `parent-uri`,
2465 `post`.`parent-uri-id` AS `parent-uri-id`,
2466 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2467 `post`.`thr-parent-id` AS `thr-parent-id`,
2468 `conversation-item-uri`.`uri` AS `conversation`,
2469 `post-thread`.`conversation-id` AS `conversation-id`,
2470 `quote-item-uri`.`uri` AS `quote-uri`,
2471 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2472 `item-uri`.`guid` AS `guid`,
2473 `post`.`gravity` AS `gravity`,
2474 `external-item-uri`.`uri` AS `extid`,
2475 `post`.`external-id` AS `external-id`,
2476 `post-thread`.`created` AS `created`,
2477 `post`.`edited` AS `edited`,
2478 `post-thread`.`commented` AS `commented`,
2479 `post-thread`.`received` AS `received`,
2480 `post-thread`.`changed` AS `changed`,
2481 `post`.`post-type` AS `post-type`,
2482 `post`.`private` AS `private`,
2483 `post`.`visible` AS `visible`,
2484 `post`.`deleted` AS `deleted`,
2485 `post`.`global` AS `global`,
2486 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread`.`uri-id`) AS `featured`,
2487 `post-thread`.`network` AS `network`,
2488 `post`.`vid` AS `vid`,
2489 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2490 `post-content`.`title` AS `title`,
2491 `post-content`.`content-warning` AS `content-warning`,
2492 `post-content`.`raw-body` AS `raw-body`,
2493 `post-content`.`body` AS `body`,
2494 `post-content`.`rendered-hash` AS `rendered-hash`,
2495 `post-content`.`rendered-html` AS `rendered-html`,
2496 `post-content`.`language` AS `language`,
2497 `post-content`.`plink` AS `plink`,
2498 `post-content`.`location` AS `location`,
2499 `post-content`.`coord` AS `coord`,
2500 `post-content`.`app` AS `app`,
2501 `post-content`.`object-type` AS `object-type`,
2502 `post-content`.`object` AS `object`,
2503 `post-content`.`target-type` AS `target-type`,
2504 `post-content`.`target` AS `target`,
2505 `post-content`.`resource-id` AS `resource-id`,
2506 `post-thread`.`author-id` AS `contact-id`,
2507 `author`.`uri-id` AS `contact-uri-id`,
2508 `author`.`url` AS `contact-link`,
2509 `author`.`addr` AS `contact-addr`,
2510 `author`.`name` AS `contact-name`,
2511 `author`.`nick` AS `contact-nick`,
2512 `author`.`thumb` AS `contact-avatar`,
2513 `author`.`network` AS `contact-network`,
2514 `author`.`blocked` AS `contact-blocked`,
2515 `author`.`hidden` AS `contact-hidden`,
2516 `author`.`readonly` AS `contact-readonly`,
2517 `author`.`archive` AS `contact-archive`,
2518 `author`.`pending` AS `contact-pending`,
2519 `author`.`rel` AS `contact-rel`,
2520 `author`.`uid` AS `contact-uid`,
2521 `author`.`contact-type` AS `contact-contact-type`,
2522 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2524 `author`.`id` AS `cid`,
2525 `author`.`alias` AS `alias`,
2526 `author`.`photo` AS `photo`,
2527 `author`.`name-date` AS `name-date`,
2528 `author`.`uri-date` AS `uri-date`,
2529 `author`.`avatar-date` AS `avatar-date`,
2530 `author`.`thumb` AS `thumb`,
2531 `post-thread`.`author-id` AS `author-id`,
2532 `author`.`uri-id` AS `author-uri-id`,
2533 `author`.`url` AS `author-link`,
2534 `author`.`addr` AS `author-addr`,
2535 `author`.`name` AS `author-name`,
2536 `author`.`nick` AS `author-nick`,
2537 `author`.`alias` AS `author-alias`,
2538 `author`.`thumb` AS `author-avatar`,
2539 `author`.`network` AS `author-network`,
2540 `author`.`blocked` AS `author-blocked`,
2541 `author`.`hidden` AS `author-hidden`,
2542 `author`.`updated` AS `author-updated`,
2543 `author`.`gsid` AS `author-gsid`,
2544 `post-thread`.`owner-id` AS `owner-id`,
2545 `owner`.`uri-id` AS `owner-uri-id`,
2546 `owner`.`url` AS `owner-link`,
2547 `owner`.`addr` AS `owner-addr`,
2548 `owner`.`name` AS `owner-name`,
2549 `owner`.`nick` AS `owner-nick`,
2550 `owner`.`alias` AS `owner-alias`,
2551 `owner`.`thumb` AS `owner-avatar`,
2552 `owner`.`network` AS `owner-network`,
2553 `owner`.`blocked` AS `owner-blocked`,
2554 `owner`.`hidden` AS `owner-hidden`,
2555 `owner`.`updated` AS `owner-updated`,
2556 `owner`.`gsid` AS `owner-gsid`,
2557 `owner`.`contact-type` AS `owner-contact-type`,
2558 `post-thread`.`causer-id` AS `causer-id`,
2559 `causer`.`uri-id` AS `causer-uri-id`,
2560 `causer`.`url` AS `causer-link`,
2561 `causer`.`addr` AS `causer-addr`,
2562 `causer`.`name` AS `causer-name`,
2563 `causer`.`nick` AS `causer-nick`,
2564 `causer`.`alias` AS `causer-alias`,
2565 `causer`.`thumb` AS `causer-avatar`,
2566 `causer`.`network` AS `causer-network`,
2567 `causer`.`blocked` AS `causer-blocked`,
2568 `causer`.`hidden` AS `causer-hidden`,
2569 `causer`.`gsid` AS `causer-gsid`,
2570 `causer`.`contact-type` AS `causer-contact-type`,
2571 `post-question`.`id` AS `question-id`,
2572 `post-question`.`multiple` AS `question-multiple`,
2573 `post-question`.`voters` AS `question-voters`,
2574 `post-question`.`end-time` AS `question-end-time`,
2575 0 AS `has-categories`,
2576 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread`.`uri-id`) AS `has-media`,
2577 (SELECT COUNT(*) FROM `post` WHERE `parent-uri-id` = `post-thread`.`uri-id` AND `gravity` = 6) AS `total-comments`,
2578 (SELECT COUNT(DISTINCT(`author-id`)) FROM `post` WHERE `parent-uri-id` = `post-thread`.`uri-id` AND `gravity` = 6) AS `total-actors`,
2579 `diaspora-interaction`.`interaction` AS `signed_text`,
2580 `parent-item-uri`.`guid` AS `parent-guid`,
2581 `post-thread`.`network` AS `parent-network`,
2582 `post-thread`.`author-id` AS `parent-author-id`,
2583 `author`.`url` AS `parent-author-link`,
2584 `author`.`name` AS `parent-author-name`,
2585 `author`.`nick` AS `parent-author-nick`,
2586 `author`.`network` AS `parent-author-network`
2588 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
2589 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
2590 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
2591 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
2592 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
2593 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2594 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2595 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
2596 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2597 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2598 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
2599 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
2600 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2601 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread`.`uri-id`;
2604 -- VIEW category-view
2606 DROP VIEW IF EXISTS `category-view`;
2607 CREATE VIEW `category-view` AS SELECT
2608 `post-category`.`uri-id` AS `uri-id`,
2609 `post-category`.`uid` AS `uid`,
2610 `post-category`.`type` AS `type`,
2611 `post-category`.`tid` AS `tid`,
2612 `tag`.`name` AS `name`,
2613 `tag`.`url` AS `url`
2614 FROM `post-category`
2615 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2618 -- VIEW collection-view
2620 DROP VIEW IF EXISTS `collection-view`;
2621 CREATE VIEW `collection-view` AS SELECT
2622 `post-collection`.`uri-id` AS `uri-id`,
2623 `post-collection`.`type` AS `type`,
2624 `post-collection`.`author-id` AS `cid`,
2625 `post`.`received` AS `received`,
2626 `post`.`created` AS `created`,
2627 `post-thread`.`commented` AS `commented`,
2628 `post`.`private` AS `private`,
2629 `post`.`visible` AS `visible`,
2630 `post`.`deleted` AS `deleted`,
2631 `post`.`thr-parent-id` AS `thr-parent-id`,
2632 `post-collection`.`author-id` AS `author-id`,
2633 `post`.`gravity` AS `gravity`
2634 FROM `post-collection`
2635 INNER JOIN `post` ON `post-collection`.`uri-id` = `post`.`uri-id`
2636 INNER JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`;
2641 DROP VIEW IF EXISTS `media-view`;
2642 CREATE VIEW `media-view` AS SELECT
2643 `post-media`.`uri-id` AS `uri-id`,
2644 `post-media`.`type` AS `type`,
2645 `post`.`received` AS `received`,
2646 `post`.`created` AS `created`,
2647 `post`.`private` AS `private`,
2648 `post`.`visible` AS `visible`,
2649 `post`.`deleted` AS `deleted`,
2650 `post`.`thr-parent-id` AS `thr-parent-id`,
2651 `post`.`author-id` AS `author-id`,
2652 `post`.`gravity` AS `gravity`
2654 INNER JOIN `post` ON `post-media`.`uri-id` = `post`.`uri-id`;
2659 DROP VIEW IF EXISTS `tag-view`;
2660 CREATE VIEW `tag-view` AS SELECT
2661 `post-tag`.`uri-id` AS `uri-id`,
2662 `post-tag`.`type` AS `type`,
2663 `post-tag`.`tid` AS `tid`,
2664 `post-tag`.`cid` AS `cid`,
2665 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2666 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`,
2667 CASE `cid` WHEN 0 THEN `tag`.`type` ELSE 1 END AS `tag-type`
2669 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2670 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2673 -- VIEW network-item-view
2675 DROP VIEW IF EXISTS `network-item-view`;
2676 CREATE VIEW `network-item-view` AS SELECT
2677 `post-user`.`uri-id` AS `uri-id`,
2678 `post-thread-user`.`post-user-id` AS `parent`,
2679 `post-user`.`received` AS `received`,
2680 `post-thread-user`.`commented` AS `commented`,
2681 `post-user`.`created` AS `created`,
2682 `post-user`.`uid` AS `uid`,
2683 `post-thread-user`.`starred` AS `starred`,
2684 `post-thread-user`.`mention` AS `mention`,
2685 `post-user`.`network` AS `network`,
2686 `post-user`.`unseen` AS `unseen`,
2687 `post-user`.`gravity` AS `gravity`,
2688 `post-user`.`contact-id` AS `contact-id`,
2689 `ownercontact`.`contact-type` AS `contact-type`
2691 INNER JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2692 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2693 STRAIGHT_JOIN `contact` AS `authorcontact` ON `authorcontact`.`id` = `post-thread-user`.`author-id`
2694 STRAIGHT_JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2695 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2696 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2697 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
2698 AND NOT `authorcontact`.`blocked` AND NOT `ownercontact`.`blocked`
2699 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`))
2700 AND NOT EXISTS(SELECT `gsid` FROM `user-gserver` WHERE `uid` = `post-thread-user`.`uid` AND `gsid` IN (`authorcontact`.`gsid`, `ownercontact`.`gsid`) AND `ignored`);
2703 -- VIEW network-thread-view
2705 DROP VIEW IF EXISTS `network-thread-view`;
2706 CREATE VIEW `network-thread-view` AS SELECT
2707 `post-thread-user`.`uri-id` AS `uri-id`,
2708 `post-thread-user`.`post-user-id` AS `parent`,
2709 `post-thread-user`.`received` AS `received`,
2710 `post-thread-user`.`commented` AS `commented`,
2711 `post-thread-user`.`created` AS `created`,
2712 `post-thread-user`.`uid` AS `uid`,
2713 `post-thread-user`.`starred` AS `starred`,
2714 `post-thread-user`.`mention` AS `mention`,
2715 `post-thread-user`.`network` AS `network`,
2716 `post-thread-user`.`contact-id` AS `contact-id`,
2717 `ownercontact`.`contact-type` AS `contact-type`
2718 FROM `post-thread-user`
2719 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2720 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2721 STRAIGHT_JOIN `contact` AS `authorcontact` ON `authorcontact`.`id` = `post-thread-user`.`author-id`
2722 STRAIGHT_JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2723 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2724 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2725 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2726 AND NOT `authorcontact`.`blocked` AND NOT `ownercontact`.`blocked`
2727 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`))
2728 AND NOT EXISTS(SELECT `gsid` FROM `user-gserver` WHERE `uid` = `post-thread-user`.`uid` AND `gsid` IN (`authorcontact`.`gsid`, `ownercontact`.`gsid`) AND `ignored`);
2733 DROP VIEW IF EXISTS `owner-view`;
2734 CREATE VIEW `owner-view` AS SELECT
2735 `contact`.`id` AS `id`,
2736 `contact`.`uid` AS `uid`,
2737 `contact`.`created` AS `created`,
2738 `contact`.`updated` AS `updated`,
2739 `contact`.`self` AS `self`,
2740 `contact`.`remote_self` AS `remote_self`,
2741 `contact`.`rel` AS `rel`,
2742 `contact`.`network` AS `network`,
2743 `contact`.`protocol` AS `protocol`,
2744 `contact`.`name` AS `name`,
2745 `contact`.`nick` AS `nick`,
2746 `contact`.`location` AS `location`,
2747 `contact`.`about` AS `about`,
2748 `contact`.`keywords` AS `keywords`,
2749 `contact`.`xmpp` AS `xmpp`,
2750 `contact`.`matrix` AS `matrix`,
2751 `contact`.`attag` AS `attag`,
2752 `contact`.`avatar` AS `avatar`,
2753 `contact`.`photo` AS `photo`,
2754 `contact`.`thumb` AS `thumb`,
2755 `contact`.`micro` AS `micro`,
2756 `contact`.`header` AS `header`,
2757 `contact`.`url` AS `url`,
2758 `contact`.`nurl` AS `nurl`,
2759 `contact`.`uri-id` AS `uri-id`,
2760 `contact`.`addr` AS `addr`,
2761 `contact`.`alias` AS `alias`,
2762 `contact`.`pubkey` AS `pubkey`,
2763 `contact`.`prvkey` AS `prvkey`,
2764 `contact`.`batch` AS `batch`,
2765 `contact`.`request` AS `request`,
2766 `contact`.`notify` AS `notify`,
2767 `contact`.`poll` AS `poll`,
2768 `contact`.`confirm` AS `confirm`,
2769 `contact`.`poco` AS `poco`,
2770 `contact`.`subhub` AS `subhub`,
2771 `contact`.`hub-verify` AS `hub-verify`,
2772 `contact`.`last-update` AS `last-update`,
2773 `contact`.`success_update` AS `success_update`,
2774 `contact`.`failure_update` AS `failure_update`,
2775 `contact`.`name-date` AS `name-date`,
2776 `contact`.`uri-date` AS `uri-date`,
2777 `contact`.`avatar-date` AS `avatar-date`,
2778 `contact`.`avatar-date` AS `picdate`,
2779 `contact`.`term-date` AS `term-date`,
2780 `contact`.`last-item` AS `last-item`,
2781 `contact`.`priority` AS `priority`,
2782 `user`.`blocked` AS `blocked`,
2783 `contact`.`block_reason` AS `block_reason`,
2784 `contact`.`readonly` AS `readonly`,
2785 `contact`.`writable` AS `writable`,
2786 `contact`.`forum` AS `forum`,
2787 `contact`.`prv` AS `prv`,
2788 `contact`.`contact-type` AS `contact-type`,
2789 `contact`.`manually-approve` AS `manually-approve`,
2790 `contact`.`hidden` AS `hidden`,
2791 `contact`.`archive` AS `archive`,
2792 `contact`.`pending` AS `pending`,
2793 `contact`.`deleted` AS `deleted`,
2794 `contact`.`unsearchable` AS `unsearchable`,
2795 `contact`.`sensitive` AS `sensitive`,
2796 `contact`.`baseurl` AS `baseurl`,
2797 `contact`.`reason` AS `reason`,
2798 `contact`.`info` AS `info`,
2799 `contact`.`bdyear` AS `bdyear`,
2800 `contact`.`bd` AS `bd`,
2801 `contact`.`notify_new_posts` AS `notify_new_posts`,
2802 `contact`.`fetch_further_information` AS `fetch_further_information`,
2803 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2804 `user`.`parent-uid` AS `parent-uid`,
2805 `user`.`guid` AS `guid`,
2806 `user`.`nickname` AS `nickname`,
2807 `user`.`email` AS `email`,
2808 `user`.`openid` AS `openid`,
2809 `user`.`timezone` AS `timezone`,
2810 `user`.`language` AS `language`,
2811 `user`.`register_date` AS `register_date`,
2812 `user`.`login_date` AS `login_date`,
2813 `user`.`last-activity` AS `last-activity`,
2814 `user`.`default-location` AS `default-location`,
2815 `user`.`allow_location` AS `allow_location`,
2816 `user`.`theme` AS `theme`,
2817 `user`.`pubkey` AS `upubkey`,
2818 `user`.`prvkey` AS `uprvkey`,
2819 `user`.`sprvkey` AS `sprvkey`,
2820 `user`.`spubkey` AS `spubkey`,
2821 `user`.`verified` AS `verified`,
2822 `user`.`blockwall` AS `blockwall`,
2823 `user`.`hidewall` AS `hidewall`,
2824 `user`.`blocktags` AS `blocktags`,
2825 `user`.`unkmail` AS `unkmail`,
2826 `user`.`cntunkmail` AS `cntunkmail`,
2827 `user`.`notify-flags` AS `notify-flags`,
2828 `user`.`page-flags` AS `page-flags`,
2829 `user`.`account-type` AS `account-type`,
2830 `user`.`prvnets` AS `prvnets`,
2831 `user`.`maxreq` AS `maxreq`,
2832 `user`.`expire` AS `expire`,
2833 `user`.`account_removed` AS `account_removed`,
2834 `user`.`account_expired` AS `account_expired`,
2835 `user`.`account_expires_on` AS `account_expires_on`,
2836 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2837 `user`.`def_gid` AS `def_gid`,
2838 `user`.`allow_cid` AS `allow_cid`,
2839 `user`.`allow_gid` AS `allow_gid`,
2840 `user`.`deny_cid` AS `deny_cid`,
2841 `user`.`deny_gid` AS `deny_gid`,
2842 `user`.`openidserver` AS `openidserver`,
2843 `profile`.`publish` AS `publish`,
2844 `profile`.`net-publish` AS `net-publish`,
2845 `profile`.`hide-friends` AS `hide-friends`,
2846 `profile`.`prv_keywords` AS `prv_keywords`,
2847 `profile`.`pub_keywords` AS `pub_keywords`,
2848 `profile`.`address` AS `address`,
2849 `profile`.`locality` AS `locality`,
2850 `profile`.`region` AS `region`,
2851 `profile`.`postal-code` AS `postal-code`,
2852 `profile`.`country-name` AS `country-name`,
2853 `profile`.`homepage` AS `homepage`,
2854 `profile`.`homepage_verified` AS `homepage_verified`,
2855 `profile`.`dob` AS `dob`
2857 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2858 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2861 -- VIEW account-view
2863 DROP VIEW IF EXISTS `account-view`;
2864 CREATE VIEW `account-view` AS SELECT
2865 `contact`.`id` AS `id`,
2866 `contact`.`url` AS `url`,
2867 `contact`.`nurl` AS `nurl`,
2868 `contact`.`uri-id` AS `uri-id`,
2869 `item-uri`.`guid` AS `guid`,
2870 `contact`.`addr` AS `addr`,
2871 `contact`.`alias` AS `alias`,
2872 `contact`.`name` AS `name`,
2873 `contact`.`nick` AS `nick`,
2874 `contact`.`about` AS `about`,
2875 `contact`.`keywords` AS `keywords`,
2876 `contact`.`xmpp` AS `xmpp`,
2877 `contact`.`matrix` AS `matrix`,
2878 `contact`.`avatar` AS `avatar`,
2879 `contact`.`photo` AS `photo`,
2880 `contact`.`thumb` AS `thumb`,
2881 `contact`.`micro` AS `micro`,
2882 `contact`.`header` AS `header`,
2883 `contact`.`created` AS `created`,
2884 `contact`.`updated` AS `updated`,
2885 `contact`.`network` AS `network`,
2886 `contact`.`protocol` AS `protocol`,
2887 `contact`.`location` AS `location`,
2888 `contact`.`attag` AS `attag`,
2889 `contact`.`pubkey` AS `pubkey`,
2890 `contact`.`prvkey` AS `prvkey`,
2891 `contact`.`subscribe` AS `subscribe`,
2892 `contact`.`last-update` AS `last-update`,
2893 `contact`.`success_update` AS `success_update`,
2894 `contact`.`failure_update` AS `failure_update`,
2895 `contact`.`failed` AS `failed`,
2896 `contact`.`last-item` AS `last-item`,
2897 `contact`.`last-discovery` AS `last-discovery`,
2898 `contact`.`contact-type` AS `contact-type`,
2899 `contact`.`manually-approve` AS `manually-approve`,
2900 `contact`.`unsearchable` AS `unsearchable`,
2901 `contact`.`sensitive` AS `sensitive`,
2902 `contact`.`baseurl` AS `baseurl`,
2903 `contact`.`gsid` AS `gsid`,
2904 `contact`.`info` AS `info`,
2905 `contact`.`bdyear` AS `bdyear`,
2906 `contact`.`bd` AS `bd`,
2907 `contact`.`poco` AS `poco`,
2908 `contact`.`name-date` AS `name-date`,
2909 `contact`.`uri-date` AS `uri-date`,
2910 `contact`.`avatar-date` AS `avatar-date`,
2911 `contact`.`term-date` AS `term-date`,
2912 `contact`.`hidden` AS `global-ignored`,
2913 `contact`.`blocked` AS `global-blocked`,
2914 `contact`.`hidden` AS `hidden`,
2915 `contact`.`archive` AS `archive`,
2916 `contact`.`deleted` AS `deleted`,
2917 `contact`.`blocked` AS `blocked`,
2918 `contact`.`notify` AS `dfrn-notify`,
2919 `contact`.`poll` AS `dfrn-poll`,
2920 `item-uri`.`guid` AS `diaspora-guid`,
2921 `diaspora-contact`.`batch` AS `diaspora-batch`,
2922 `diaspora-contact`.`notify` AS `diaspora-notify`,
2923 `diaspora-contact`.`poll` AS `diaspora-poll`,
2924 `diaspora-contact`.`alias` AS `diaspora-alias`,
2925 `apcontact`.`uuid` AS `ap-uuid`,
2926 `apcontact`.`type` AS `ap-type`,
2927 `apcontact`.`following` AS `ap-following`,
2928 `apcontact`.`followers` AS `ap-followers`,
2929 `apcontact`.`inbox` AS `ap-inbox`,
2930 `apcontact`.`outbox` AS `ap-outbox`,
2931 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2932 `apcontact`.`generator` AS `ap-generator`,
2933 `apcontact`.`following_count` AS `ap-following_count`,
2934 `apcontact`.`followers_count` AS `ap-followers_count`,
2935 `apcontact`.`statuses_count` AS `ap-statuses_count`,
2936 `gserver`.`site_name` AS `site_name`,
2937 `gserver`.`platform` AS `platform`,
2938 `gserver`.`version` AS `version`,
2939 `gserver`.`blocked` AS `server-blocked`,
2940 `gserver`.`failed` AS `server-failed`
2942 LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id`
2943 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
2944 LEFT JOIN `diaspora-contact` ON `diaspora-contact`.`uri-id` = contact.`uri-id`
2945 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`
2946 WHERE `contact`.`uid` = 0;
2949 -- VIEW account-user-view
2951 DROP VIEW IF EXISTS `account-user-view`;
2952 CREATE VIEW `account-user-view` AS SELECT
2953 `ucontact`.`id` AS `id`,
2954 `contact`.`id` AS `pid`,
2955 `ucontact`.`uid` AS `uid`,
2956 `contact`.`url` AS `url`,
2957 `contact`.`nurl` AS `nurl`,
2958 `contact`.`uri-id` AS `uri-id`,
2959 `item-uri`.`guid` AS `guid`,
2960 `contact`.`addr` AS `addr`,
2961 `contact`.`alias` AS `alias`,
2962 `contact`.`name` AS `name`,
2963 `contact`.`nick` AS `nick`,
2964 `contact`.`about` AS `about`,
2965 `contact`.`keywords` AS `keywords`,
2966 `contact`.`xmpp` AS `xmpp`,
2967 `contact`.`matrix` AS `matrix`,
2968 `contact`.`avatar` AS `avatar`,
2969 `contact`.`photo` AS `photo`,
2970 `contact`.`thumb` AS `thumb`,
2971 `contact`.`micro` AS `micro`,
2972 `contact`.`header` AS `header`,
2973 `contact`.`created` AS `created`,
2974 `contact`.`updated` AS `updated`,
2975 `ucontact`.`self` AS `self`,
2976 `ucontact`.`remote_self` AS `remote_self`,
2977 `ucontact`.`rel` AS `rel`,
2978 `contact`.`network` AS `network`,
2979 `ucontact`.`protocol` AS `protocol`,
2980 `contact`.`location` AS `location`,
2981 `ucontact`.`attag` AS `attag`,
2982 `contact`.`pubkey` AS `pubkey`,
2983 `contact`.`prvkey` AS `prvkey`,
2984 `contact`.`subscribe` AS `subscribe`,
2985 `contact`.`last-update` AS `last-update`,
2986 `contact`.`success_update` AS `success_update`,
2987 `contact`.`failure_update` AS `failure_update`,
2988 `contact`.`failed` AS `failed`,
2989 `contact`.`last-item` AS `last-item`,
2990 `contact`.`last-discovery` AS `last-discovery`,
2991 `contact`.`contact-type` AS `contact-type`,
2992 `contact`.`manually-approve` AS `manually-approve`,
2993 `contact`.`unsearchable` AS `unsearchable`,
2994 `contact`.`sensitive` AS `sensitive`,
2995 `contact`.`baseurl` AS `baseurl`,
2996 `contact`.`gsid` AS `gsid`,
2997 `ucontact`.`info` AS `info`,
2998 `contact`.`bdyear` AS `bdyear`,
2999 `contact`.`bd` AS `bd`,
3000 `contact`.`poco` AS `poco`,
3001 `contact`.`name-date` AS `name-date`,
3002 `contact`.`uri-date` AS `uri-date`,
3003 `contact`.`avatar-date` AS `avatar-date`,
3004 `contact`.`term-date` AS `term-date`,
3005 `contact`.`hidden` AS `global-ignored`,
3006 `contact`.`blocked` AS `global-blocked`,
3007 `ucontact`.`hidden` AS `hidden`,
3008 `ucontact`.`archive` AS `archive`,
3009 `ucontact`.`pending` AS `pending`,
3010 `ucontact`.`deleted` AS `deleted`,
3011 `ucontact`.`notify_new_posts` AS `notify_new_posts`,
3012 `ucontact`.`fetch_further_information` AS `fetch_further_information`,
3013 `ucontact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
3014 `ucontact`.`rating` AS `rating`,
3015 `ucontact`.`readonly` AS `readonly`,
3016 `ucontact`.`blocked` AS `blocked`,
3017 `ucontact`.`block_reason` AS `block_reason`,
3018 `ucontact`.`subhub` AS `subhub`,
3019 `ucontact`.`hub-verify` AS `hub-verify`,
3020 `ucontact`.`reason` AS `reason`,
3021 `contact`.`notify` AS `dfrn-notify`,
3022 `contact`.`poll` AS `dfrn-poll`,
3023 `item-uri`.`guid` AS `diaspora-guid`,
3024 `diaspora-contact`.`batch` AS `diaspora-batch`,
3025 `diaspora-contact`.`notify` AS `diaspora-notify`,
3026 `diaspora-contact`.`poll` AS `diaspora-poll`,
3027 `diaspora-contact`.`alias` AS `diaspora-alias`,
3028 `diaspora-contact`.`interacting_count` AS `diaspora-interacting_count`,
3029 `diaspora-contact`.`interacted_count` AS `diaspora-interacted_count`,
3030 `diaspora-contact`.`post_count` AS `diaspora-post_count`,
3031 `apcontact`.`uuid` AS `ap-uuid`,
3032 `apcontact`.`type` AS `ap-type`,
3033 `apcontact`.`following` AS `ap-following`,
3034 `apcontact`.`followers` AS `ap-followers`,
3035 `apcontact`.`inbox` AS `ap-inbox`,
3036 `apcontact`.`outbox` AS `ap-outbox`,
3037 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
3038 `apcontact`.`generator` AS `ap-generator`,
3039 `apcontact`.`following_count` AS `ap-following_count`,
3040 `apcontact`.`followers_count` AS `ap-followers_count`,
3041 `apcontact`.`statuses_count` AS `ap-statuses_count`,
3042 `gserver`.`site_name` AS `site_name`,
3043 `gserver`.`platform` AS `platform`,
3044 `gserver`.`version` AS `version`,
3045 `gserver`.`blocked` AS `server-blocked`,
3046 `gserver`.`failed` AS `server-failed`
3047 FROM `contact` AS `ucontact`
3048 INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
3049 LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id`
3050 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
3051 LEFT JOIN `diaspora-contact` ON `diaspora-contact`.`uri-id` = `ucontact`.`uri-id`
3052 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`;
3055 -- VIEW pending-view
3057 DROP VIEW IF EXISTS `pending-view`;
3058 CREATE VIEW `pending-view` AS SELECT
3059 `register`.`id` AS `id`,
3060 `register`.`hash` AS `hash`,
3061 `register`.`created` AS `created`,
3062 `register`.`uid` AS `uid`,
3063 `register`.`password` AS `password`,
3064 `register`.`language` AS `language`,
3065 `register`.`note` AS `note`,
3066 `contact`.`self` AS `self`,
3067 `contact`.`name` AS `name`,
3068 `contact`.`url` AS `url`,
3069 `contact`.`micro` AS `micro`,
3070 `user`.`email` AS `email`,
3071 `contact`.`nick` AS `nick`
3073 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
3074 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
3077 -- VIEW tag-search-view
3079 DROP VIEW IF EXISTS `tag-search-view`;
3080 CREATE VIEW `tag-search-view` AS SELECT
3081 `post-tag`.`uri-id` AS `uri-id`,
3082 `post-user`.`uid` AS `uid`,
3083 `post-user`.`id` AS `iid`,
3084 `post-user`.`private` AS `private`,
3085 `post-user`.`wall` AS `wall`,
3086 `post-user`.`origin` AS `origin`,
3087 `post-user`.`global` AS `global`,
3088 `post-user`.`gravity` AS `gravity`,
3089 `post-user`.`received` AS `received`,
3090 `post-user`.`network` AS `network`,
3091 `post-user`.`author-id` AS `author-id`,
3092 `tag`.`name` AS `name`
3094 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
3095 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
3096 WHERE `post-tag`.`type` = 1;
3099 -- VIEW workerqueue-view
3101 DROP VIEW IF EXISTS `workerqueue-view`;
3102 CREATE VIEW `workerqueue-view` AS SELECT
3103 `process`.`pid` AS `pid`,
3104 `workerqueue`.`priority` AS `priority`
3106 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
3107 WHERE NOT `workerqueue`.`done`;
3110 -- VIEW profile_field-view
3112 DROP VIEW IF EXISTS `profile_field-view`;
3113 CREATE VIEW `profile_field-view` AS SELECT
3114 `profile_field`.`id` AS `id`,
3115 `profile_field`.`uid` AS `uid`,
3116 `profile_field`.`label` AS `label`,
3117 `profile_field`.`value` AS `value`,
3118 `profile_field`.`order` AS `order`,
3119 `profile_field`.`psid` AS `psid`,
3120 `permissionset`.`allow_cid` AS `allow_cid`,
3121 `permissionset`.`allow_gid` AS `allow_gid`,
3122 `permissionset`.`deny_cid` AS `deny_cid`,
3123 `permissionset`.`deny_gid` AS `deny_gid`,
3124 `profile_field`.`created` AS `created`,
3125 `profile_field`.`edited` AS `edited`
3126 FROM `profile_field`
3127 INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`;
3130 -- VIEW diaspora-contact-view
3132 DROP VIEW IF EXISTS `diaspora-contact-view`;
3133 CREATE VIEW `diaspora-contact-view` AS SELECT
3134 `diaspora-contact`.`uri-id` AS `uri-id`,
3135 `item-uri`.`uri` AS `url`,
3136 `item-uri`.`guid` AS `guid`,
3137 `diaspora-contact`.`addr` AS `addr`,
3138 `diaspora-contact`.`alias` AS `alias`,
3139 `diaspora-contact`.`nick` AS `nick`,
3140 `diaspora-contact`.`name` AS `name`,
3141 `diaspora-contact`.`given-name` AS `given-name`,
3142 `diaspora-contact`.`family-name` AS `family-name`,
3143 `diaspora-contact`.`photo` AS `photo`,
3144 `diaspora-contact`.`photo-medium` AS `photo-medium`,
3145 `diaspora-contact`.`photo-small` AS `photo-small`,
3146 `diaspora-contact`.`batch` AS `batch`,
3147 `diaspora-contact`.`notify` AS `notify`,
3148 `diaspora-contact`.`poll` AS `poll`,
3149 `diaspora-contact`.`subscribe` AS `subscribe`,
3150 `diaspora-contact`.`searchable` AS `searchable`,
3151 `diaspora-contact`.`pubkey` AS `pubkey`,
3152 `gserver`.`url` AS `baseurl`,
3153 `diaspora-contact`.`gsid` AS `gsid`,
3154 `diaspora-contact`.`created` AS `created`,
3155 `diaspora-contact`.`updated` AS `updated`,
3156 `diaspora-contact`.`interacting_count` AS `interacting_count`,
3157 `diaspora-contact`.`interacted_count` AS `interacted_count`,
3158 `diaspora-contact`.`post_count` AS `post_count`
3159 FROM `diaspora-contact`
3160 INNER JOIN `item-uri` ON `item-uri`.`id` = `diaspora-contact`.`uri-id`
3161 LEFT JOIN `gserver` ON `gserver`.`id` = `diaspora-contact`.`gsid`;