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