1 -- ------------------------------------------
2 -- Friendica 2024.03-dev (Yellow Archangel)
3 -- DB_UPDATE_VERSION 1544
4 -- ------------------------------------------
10 CREATE TABLE IF NOT EXISTS `gserver` (
11 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
12 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
13 `nurl` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
14 `version` varchar(255) NOT NULL DEFAULT '' COMMENT '',
15 `site_name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
16 `info` text COMMENT '',
17 `register_policy` tinyint NOT NULL DEFAULT 0 COMMENT '',
18 `registered-users` int unsigned NOT NULL DEFAULT 0 COMMENT 'Number of registered users',
19 `active-week-users` int unsigned COMMENT 'Number of active users in the last week',
20 `active-month-users` int unsigned COMMENT 'Number of active users in the last month',
21 `active-halfyear-users` int unsigned COMMENT 'Number of active users in the last six month',
22 `local-posts` int unsigned COMMENT 'Number of local posts',
23 `local-comments` int unsigned COMMENT 'Number of local comments',
24 `directory-type` tinyint DEFAULT 0 COMMENT 'Type of directory service (Poco, Mastodon)',
25 `poco` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
26 `noscrape` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
27 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
28 `protocol` tinyint unsigned COMMENT 'The protocol of the server',
29 `platform` varchar(255) NOT NULL DEFAULT '' COMMENT '',
30 `relay-subscribe` boolean NOT NULL DEFAULT '0' COMMENT 'Has the server subscribed to the relay system',
31 `relay-scope` varchar(10) NOT NULL DEFAULT '' COMMENT 'The scope of messages that the server wants to get',
32 `detection-method` tinyint unsigned COMMENT 'Method that had been used to detect that server',
33 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
34 `last_poco_query` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
35 `last_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Last successful connection request',
36 `last_failure` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Last failed connection request',
37 `blocked` boolean COMMENT 'Server is blocked',
38 `failed` boolean COMMENT 'Connection failed',
39 `next_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Next connection request',
41 UNIQUE INDEX `nurl` (`nurl`(190)),
42 INDEX `next_contact` (`next_contact`),
43 INDEX `network` (`network`)
44 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Global servers';
49 CREATE TABLE IF NOT EXISTS `user` (
50 `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
51 `parent-uid` mediumint unsigned COMMENT 'The parent user that has full control about this user',
52 `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
53 `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
54 `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
55 `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
56 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
57 `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
58 `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
59 `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
60 `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
61 `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
62 `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
63 `last-activity` date COMMENT 'Day of the last activity',
64 `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
65 `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
66 `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
67 `pubkey` text COMMENT 'RSA public key 4096 bit',
68 `prvkey` text COMMENT 'RSA private key 4096 bit',
69 `spubkey` text COMMENT '',
70 `sprvkey` text COMMENT '',
71 `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
72 `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
73 `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
74 `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unknown viewers',
75 `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
76 `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
77 `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
78 `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
79 `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
80 `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
81 `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
82 `pwdreset` varchar(255) COMMENT 'Password reset request token',
83 `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
84 `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
85 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT 'Delay in days before deleting user-related posts. Scope is controlled by pConfig.',
86 `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
87 `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
88 `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
89 `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
90 `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
91 `allow_cid` mediumtext COMMENT 'default permission for this user',
92 `allow_gid` mediumtext COMMENT 'default permission for this user',
93 `deny_cid` mediumtext COMMENT 'default permission for this user',
94 `deny_gid` mediumtext COMMENT 'default permission for this user',
95 `openidserver` text COMMENT '',
97 INDEX `nickname` (`nickname`(32)),
98 INDEX `parent-uid` (`parent-uid`),
99 INDEX `guid` (`guid`),
100 INDEX `email` (`email`(64)),
101 FOREIGN KEY (`parent-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
102 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
105 -- TABLE user-gserver
107 CREATE TABLE IF NOT EXISTS `user-gserver` (
108 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
109 `gsid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Gserver id',
110 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'server accounts are ignored for the user',
111 PRIMARY KEY(`uid`,`gsid`),
112 INDEX `gsid` (`gsid`),
113 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
114 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
115 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User settings about remote servers';
120 CREATE TABLE IF NOT EXISTS `item-uri` (
121 `id` int unsigned NOT NULL auto_increment,
122 `uri` varbinary(383) NOT NULL COMMENT 'URI of an item',
123 `guid` varbinary(255) COMMENT 'A unique identifier for an item',
125 UNIQUE INDEX `uri` (`uri`),
126 INDEX `guid` (`guid`)
127 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
132 CREATE TABLE IF NOT EXISTS `contact` (
133 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
134 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
135 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
136 `updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last contact update',
137 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network of the contact',
138 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
139 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
140 `location` varchar(255) DEFAULT '' COMMENT '',
141 `about` text COMMENT '',
142 `keywords` text COMMENT 'public keywords (interests) of the contact',
143 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
144 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
145 `avatar` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
146 `blurhash` varbinary(255) COMMENT 'BlurHash representation of the avatar',
147 `header` varbinary(383) COMMENT 'Header picture',
148 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
149 `nurl` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
150 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
151 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
152 `alias` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
153 `pubkey` text COMMENT 'RSA public key 4096 bit',
154 `prvkey` text COMMENT 'RSA private key 4096 bit',
155 `batch` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
156 `notify` varbinary(383) COMMENT '',
157 `poll` varbinary(383) COMMENT '',
158 `subscribe` varbinary(383) COMMENT '',
159 `last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
160 `next-update` datetime COMMENT 'Next connection request',
161 `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
162 `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
163 `failed` boolean COMMENT 'Connection failed',
164 `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
165 `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
166 `last-discovery` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last follower discovery',
167 `local-data` boolean COMMENT 'Is true when there are posts with this contact on the system',
168 `blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
169 `block_reason` text COMMENT 'Node-wide block reason',
170 `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
171 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Person, organisation, news, community, relay',
172 `manually-approve` boolean COMMENT 'Contact requests have to be approved manually',
173 `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
174 `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
175 `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
176 `baseurl` varbinary(383) DEFAULT '' COMMENT 'baseurl of the contact from the gserver record, can be missing',
177 `gsid` int unsigned COMMENT 'Global Server ID, can be missing',
178 `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
179 `reason` text COMMENT '',
180 `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
181 `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
182 `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
183 `protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
184 `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
185 `hub-verify` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
186 `rating` tinyint NOT NULL DEFAULT 0 COMMENT 'Automatically detected feed poll frequency',
187 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Feed poll priority',
188 `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
189 `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
190 `pending` boolean NOT NULL DEFAULT '1' COMMENT 'Contact request is pending',
191 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
192 `info` mediumtext COMMENT '',
193 `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
194 `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
195 `ffi_keyword_denylist` text COMMENT '',
196 `photo` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
197 `thumb` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
198 `micro` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
199 `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
200 `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
201 `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
202 `request` varbinary(383) COMMENT '',
203 `confirm` varbinary(383) COMMENT '',
204 `poco` varbinary(383) COMMENT '',
205 `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
206 `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a group. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = false instead',
207 `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = true instead',
208 `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
209 `site-pubkey` text COMMENT 'Deprecated',
210 `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
211 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
212 `issued-id` varbinary(383) NOT NULL DEFAULT '' COMMENT 'Deprecated',
213 `dfrn-id` varbinary(383) NOT NULL DEFAULT '' COMMENT 'Deprecated',
214 `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
215 `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
216 `usehub` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
217 `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT 'Deprecated',
218 `profile-id` int unsigned COMMENT 'Deprecated',
220 INDEX `uid_name` (`uid`,`name`(190)),
221 INDEX `self_uid` (`self`,`uid`),
222 INDEX `alias_uid` (`alias`(128),`uid`),
223 INDEX `pending_uid` (`pending`,`uid`),
224 INDEX `blocked_uid` (`blocked`,`uid`),
225 INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
226 INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
227 INDEX `batch_contact-type` (`batch`(64),`contact-type`),
228 INDEX `addr_uid` (`addr`(128),`uid`),
229 INDEX `nurl_uid` (`nurl`(128),`uid`),
230 INDEX `nick_uid` (`nick`(128),`uid`),
231 INDEX `attag_uid` (`attag`(96),`uid`),
232 INDEX `network_uid_lastupdate` (`network`,`uid`,`last-update`),
233 INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`),
234 INDEX `next-update` (`next-update`),
235 INDEX `local-data-next-update` (`local-data`,`next-update`),
236 INDEX `uid_lastitem` (`uid`,`last-item`),
237 INDEX `baseurl` (`baseurl`(64)),
238 INDEX `uid_contact-type` (`uid`,`contact-type`),
239 INDEX `uid_self_contact-type` (`uid`,`self`,`contact-type`),
240 INDEX `self_network_uid` (`self`,`network`,`uid`),
241 INDEX `gsid_uid_failed` (`gsid`,`uid`,`failed`),
242 INDEX `uri-id` (`uri-id`),
243 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
244 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
245 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
246 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
251 CREATE TABLE IF NOT EXISTS `tag` (
252 `id` int unsigned NOT NULL auto_increment COMMENT '',
253 `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
254 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
255 `type` tinyint unsigned COMMENT 'Type of the tag (Unknown, General Collection, Follower Collection or Account)',
257 UNIQUE INDEX `type_name_url` (`name`,`url`),
259 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
262 -- TABLE permissionset
264 CREATE TABLE IF NOT EXISTS `permissionset` (
265 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
266 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
267 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
268 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed circles',
269 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
270 `deny_gid` mediumtext COMMENT 'Access Control - list of denied circles',
272 INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`uid`,`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30)),
273 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
274 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
279 CREATE TABLE IF NOT EXISTS `verb` (
280 `id` smallint unsigned NOT NULL auto_increment,
281 `name` varchar(100) NOT NULL DEFAULT '' COMMENT '',
283 INDEX `name` (`name`)
284 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activity Verbs';
287 -- TABLE 2fa_app_specific_password
289 CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
290 `id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
291 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
292 `description` varchar(255) COMMENT 'Description of the usage of the password',
293 `hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
294 `generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
295 `last_used` datetime COMMENT 'Datetime the password was last used',
297 INDEX `uid_description` (`uid`,`description`(190)),
298 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
299 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
302 -- TABLE 2fa_recovery_codes
304 CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
305 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
306 `code` varchar(50) NOT NULL COMMENT 'Recovery code string',
307 `generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
308 `used` datetime COMMENT 'Datetime the code was used',
309 PRIMARY KEY(`uid`,`code`),
310 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
311 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
314 -- TABLE 2fa_trusted_browser
316 CREATE TABLE IF NOT EXISTS `2fa_trusted_browser` (
317 `cookie_hash` varchar(80) NOT NULL COMMENT 'Trusted cookie hash',
318 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
319 `user_agent` text COMMENT 'User agent string',
320 `trusted` boolean NOT NULL DEFAULT '1' COMMENT 'Whenever this browser should be trusted or not',
321 `created` datetime NOT NULL COMMENT 'Datetime the trusted browser was recorded',
322 `last_used` datetime COMMENT 'Datetime the trusted browser was last used',
323 PRIMARY KEY(`cookie_hash`),
325 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
326 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication trusted browsers';
329 -- TABLE account-suggestion
331 CREATE TABLE IF NOT EXISTS `account-suggestion` (
332 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the account url',
333 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
334 `level` smallint unsigned COMMENT 'level of closeness',
335 `ignore` boolean NOT NULL DEFAULT '0' COMMENT 'If set, this account will not be suggested again',
336 PRIMARY KEY(`uid`,`uri-id`),
337 INDEX `uri-id_uid` (`uri-id`,`uid`),
338 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
339 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
340 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Account suggestion';
343 -- TABLE account-user
345 CREATE TABLE IF NOT EXISTS `account-user` (
346 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
347 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the account url',
348 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
350 UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
351 INDEX `uid_uri-id` (`uid`,`uri-id`),
352 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
353 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
354 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Remote and local accounts';
359 CREATE TABLE IF NOT EXISTS `apcontact` (
360 `url` varbinary(383) NOT NULL COMMENT 'URL of the contact',
361 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
362 `uuid` varbinary(255) COMMENT '',
363 `type` varchar(20) NOT NULL COMMENT '',
364 `following` varbinary(383) COMMENT '',
365 `followers` varbinary(383) COMMENT '',
366 `inbox` varbinary(383) NOT NULL COMMENT '',
367 `outbox` varbinary(383) COMMENT '',
368 `sharedinbox` varbinary(383) COMMENT '',
369 `featured` varbinary(383) COMMENT 'Address for the collection of featured posts',
370 `featured-tags` varbinary(383) COMMENT 'Address for the collection of featured tags',
371 `manually-approve` boolean COMMENT '',
372 `discoverable` boolean COMMENT 'Mastodon extension: true if profile is published in their directory',
373 `suspended` boolean COMMENT 'Mastodon extension: true if profile is suspended',
374 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
375 `name` varchar(255) COMMENT '',
376 `about` text COMMENT '',
377 `xmpp` varchar(255) COMMENT 'XMPP address',
378 `matrix` varchar(255) COMMENT 'Matrix address',
379 `photo` varbinary(383) COMMENT '',
380 `header` varbinary(383) COMMENT 'Header picture',
381 `addr` varchar(255) COMMENT '',
382 `alias` varbinary(383) COMMENT '',
383 `pubkey` text COMMENT '',
384 `subscribe` varbinary(383) COMMENT '',
385 `baseurl` varbinary(383) COMMENT 'baseurl of the ap contact',
386 `gsid` int unsigned COMMENT 'Global Server ID',
387 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
388 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
389 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
390 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
391 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
393 INDEX `addr` (`addr`(32)),
394 INDEX `alias` (`alias`(190)),
395 INDEX `followers` (`followers`(190)),
396 INDEX `baseurl` (`baseurl`(190)),
397 INDEX `sharedinbox` (`sharedinbox`(190)),
398 INDEX `gsid` (`gsid`),
399 UNIQUE INDEX `uri-id` (`uri-id`),
400 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
401 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
402 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
407 CREATE TABLE IF NOT EXISTS `application` (
408 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
409 `client_id` varchar(64) NOT NULL COMMENT '',
410 `client_secret` varchar(64) NOT NULL COMMENT '',
411 `name` varchar(255) NOT NULL COMMENT '',
412 `redirect_uri` varbinary(383) NOT NULL COMMENT '',
413 `website` varbinary(383) COMMENT '',
414 `scopes` varchar(255) COMMENT '',
415 `read` boolean COMMENT 'Read scope',
416 `write` boolean COMMENT 'Write scope',
417 `follow` boolean COMMENT 'Follow scope',
418 `push` boolean COMMENT 'Push scope',
420 UNIQUE INDEX `client_id` (`client_id`)
421 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth application';
424 -- TABLE application-marker
426 CREATE TABLE IF NOT EXISTS `application-marker` (
427 `application-id` int unsigned NOT NULL COMMENT '',
428 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
429 `timeline` varchar(64) NOT NULL COMMENT 'Marker (home, notifications)',
430 `last_read_id` varbinary(383) COMMENT 'Marker id for the timeline',
431 `version` smallint unsigned COMMENT 'Version number',
432 `updated_at` datetime COMMENT 'creation time',
433 PRIMARY KEY(`application-id`,`uid`,`timeline`),
434 INDEX `uid_id` (`uid`),
435 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
436 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
437 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Timeline marker';
440 -- TABLE application-token
442 CREATE TABLE IF NOT EXISTS `application-token` (
443 `application-id` int unsigned NOT NULL COMMENT '',
444 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
445 `code` varchar(64) NOT NULL COMMENT '',
446 `access_token` varchar(64) NOT NULL COMMENT '',
447 `created_at` datetime NOT NULL COMMENT 'creation time',
448 `scopes` varchar(255) COMMENT '',
449 `read` boolean COMMENT 'Read scope',
450 `write` boolean COMMENT 'Write scope',
451 `follow` boolean COMMENT 'Follow scope',
452 `push` boolean COMMENT 'Push scope',
453 PRIMARY KEY(`application-id`,`uid`),
454 INDEX `uid_id` (`uid`,`application-id`),
455 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
456 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
457 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth user token';
462 CREATE TABLE IF NOT EXISTS `attach` (
463 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
464 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
465 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
466 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
467 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
468 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
469 `data` longblob NOT NULL COMMENT 'file data',
470 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
471 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
472 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
473 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed circles',
474 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
475 `deny_gid` mediumtext COMMENT 'Access Control - list of denied circles',
476 `backend-class` tinytext COMMENT 'Storage backend class',
477 `backend-ref` text COMMENT 'Storage backend data reference',
480 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
481 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
486 CREATE TABLE IF NOT EXISTS `cache` (
487 `k` varbinary(255) NOT NULL COMMENT 'cache key',
488 `v` mediumtext COMMENT 'cached serialized value',
489 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
490 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
492 INDEX `k_expires` (`k`,`expires`)
493 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
498 CREATE TABLE IF NOT EXISTS `channel` (
499 `id` int unsigned NOT NULL auto_increment COMMENT '',
500 `uid` mediumint unsigned NOT NULL COMMENT 'User id',
501 `label` varchar(64) NOT NULL COMMENT 'Channel label',
502 `description` varchar(64) COMMENT 'Channel description',
503 `circle` int COMMENT 'Circle or channel that this channel is based on',
504 `access-key` varchar(1) COMMENT 'Access key',
505 `include-tags` varchar(1023) COMMENT 'Comma separated list of tags that will be included in the channel',
506 `exclude-tags` varchar(1023) COMMENT 'Comma separated list of tags that aren\'t allowed in the channel',
507 `full-text-search` varchar(1023) COMMENT 'Full text search pattern, see https://mariadb.com/kb/en/full-text-index-overview/#in-boolean-mode',
508 `media-type` smallint unsigned COMMENT 'Filtered media types',
511 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
512 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User defined Channels';
517 CREATE TABLE IF NOT EXISTS `config` (
518 `id` int unsigned NOT NULL auto_increment COMMENT '',
519 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT 'The category of the entry',
520 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT 'The key of the entry',
521 `v` mediumtext COMMENT '',
523 UNIQUE INDEX `cat_k` (`cat`,`k`)
524 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
527 -- TABLE contact-relation
529 CREATE TABLE IF NOT EXISTS `contact-relation` (
530 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
531 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
532 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction by relation-cid on cid',
533 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
534 `follows` boolean NOT NULL DEFAULT '0' COMMENT 'if true, relation-cid follows cid',
535 `score` smallint unsigned COMMENT 'score for interactions of cid on relation-cid',
536 `relation-score` smallint unsigned COMMENT 'score for interactions of relation-cid on cid',
537 `thread-score` smallint unsigned COMMENT 'score for interactions of cid on threads of relation-cid',
538 `relation-thread-score` smallint unsigned COMMENT 'score for interactions of relation-cid on threads of cid',
539 PRIMARY KEY(`cid`,`relation-cid`),
540 INDEX `relation-cid` (`relation-cid`),
541 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
542 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
543 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
548 CREATE TABLE IF NOT EXISTS `conv` (
549 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
550 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
551 `recips` text COMMENT 'sender_handle;recipient_handle',
552 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
553 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
554 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
555 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
556 `subject` text COMMENT 'subject of initial message',
559 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
560 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
565 CREATE TABLE IF NOT EXISTS `workerqueue` (
566 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
567 `command` varchar(100) COMMENT 'Task command',
568 `parameter` mediumtext COMMENT 'Task parameter',
569 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
570 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
571 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
572 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
573 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
574 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
575 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
577 INDEX `command` (`command`),
578 INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
579 INDEX `done_executed` (`done`,`executed`),
580 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
581 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
582 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
583 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
584 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
585 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
588 -- TABLE delayed-post
590 CREATE TABLE IF NOT EXISTS `delayed-post` (
591 `id` int unsigned NOT NULL auto_increment,
592 `uri` varbinary(383) COMMENT 'URI of the post that will be distributed later',
593 `uid` mediumint unsigned COMMENT 'Owner User id',
594 `delayed` datetime COMMENT 'delay time',
595 `wid` int unsigned COMMENT 'Workerqueue id',
597 UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
599 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
600 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
601 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
604 -- TABLE delivery-queue
606 CREATE TABLE IF NOT EXISTS `delivery-queue` (
607 `gsid` int unsigned NOT NULL COMMENT 'Target server',
608 `uri-id` int unsigned NOT NULL COMMENT 'Delivered post',
609 `created` datetime COMMENT '',
610 `command` varbinary(32) COMMENT '',
611 `cid` int unsigned COMMENT 'Target contact',
612 `uid` mediumint unsigned COMMENT 'Delivering user',
613 `failed` tinyint DEFAULT 0 COMMENT 'Number of times the delivery has failed',
614 PRIMARY KEY(`uri-id`,`gsid`),
615 INDEX `gsid_created` (`gsid`,`created`),
618 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
619 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
620 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
621 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
622 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for posts for the batch processing';
625 -- TABLE diaspora-contact
627 CREATE TABLE IF NOT EXISTS `diaspora-contact` (
628 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the contact URL',
629 `addr` varchar(255) COMMENT '',
630 `alias` varchar(255) COMMENT '',
631 `nick` varchar(255) COMMENT '',
632 `name` varchar(255) COMMENT '',
633 `given-name` varchar(255) COMMENT '',
634 `family-name` varchar(255) COMMENT '',
635 `photo` varchar(255) COMMENT '',
636 `photo-medium` varchar(255) COMMENT '',
637 `photo-small` varchar(255) COMMENT '',
638 `batch` varchar(255) COMMENT '',
639 `notify` varchar(255) COMMENT '',
640 `poll` varchar(255) COMMENT '',
641 `subscribe` varchar(255) COMMENT '',
642 `searchable` boolean COMMENT '',
643 `pubkey` text COMMENT '',
644 `gsid` int unsigned COMMENT 'Global Server ID',
645 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
646 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
647 `interacting_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts this contact interacts with',
648 `interacted_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts that interacted with this contact',
649 `post_count` int unsigned DEFAULT 0 COMMENT 'Number of posts and comments',
650 PRIMARY KEY(`uri-id`),
651 UNIQUE INDEX `addr` (`addr`),
652 INDEX `alias` (`alias`),
653 INDEX `gsid` (`gsid`),
654 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
655 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
656 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
659 -- TABLE diaspora-interaction
661 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
662 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
663 `interaction` mediumtext COMMENT 'The Diaspora interaction',
664 PRIMARY KEY(`uri-id`),
665 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
666 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
671 CREATE TABLE IF NOT EXISTS `endpoint` (
672 `url` varbinary(383) NOT NULL COMMENT 'URL of the contact',
673 `type` varchar(20) NOT NULL COMMENT '',
674 `owner-uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
676 UNIQUE INDEX `owner-uri-id_type` (`owner-uri-id`,`type`),
677 FOREIGN KEY (`owner-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
678 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub endpoints - used in the ActivityPub implementation';
683 CREATE TABLE IF NOT EXISTS `event` (
684 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
685 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
686 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
687 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
688 `uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
689 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the event uri',
690 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
691 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
692 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
693 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
694 `summary` text COMMENT 'short description or title of the event',
695 `desc` text COMMENT 'event description',
696 `location` text COMMENT 'event location',
697 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
698 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
699 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
700 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
701 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed circles',
702 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
703 `deny_gid` mediumtext COMMENT 'Access Control - list of denied circles',
705 INDEX `uid_start` (`uid`,`start`),
707 INDEX `uri-id` (`uri-id`),
708 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
709 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
710 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
711 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
716 CREATE TABLE IF NOT EXISTS `fetch-entry` (
717 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
718 `url` varbinary(383) COMMENT 'url that awaiting to be fetched',
719 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of the fetch request',
720 `wid` int unsigned COMMENT 'Workerqueue id',
722 UNIQUE INDEX `url` (`url`),
723 INDEX `created` (`created`),
725 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
726 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
731 CREATE TABLE IF NOT EXISTS `fsuggest` (
732 `id` int unsigned NOT NULL auto_increment COMMENT '',
733 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
734 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
735 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
736 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
737 `request` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
738 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
739 `note` text COMMENT '',
740 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
744 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
745 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
746 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
751 CREATE TABLE IF NOT EXISTS `group` (
752 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
753 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
754 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
755 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the circle has been deleted',
756 `cid` int unsigned COMMENT 'Contact id of group. When this field is filled then the members are synced automatically.',
757 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of circle',
761 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
762 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
763 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy circles, circle info';
766 -- TABLE group_member
768 CREATE TABLE IF NOT EXISTS `group_member` (
769 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
770 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'group.id of the associated circle',
771 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated circle',
773 INDEX `contactid` (`contact-id`),
774 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
775 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
776 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
777 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy circles, member info';
782 CREATE TABLE IF NOT EXISTS `gserver-tag` (
783 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
784 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
785 PRIMARY KEY(`gserver-id`,`tag`),
787 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
788 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
793 CREATE TABLE IF NOT EXISTS `hook` (
794 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
795 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
796 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
797 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
798 `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',
800 INDEX `priority` (`priority`),
801 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
802 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
807 CREATE TABLE IF NOT EXISTS `inbox-entry` (
808 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
809 `activity-id` varbinary(383) COMMENT 'id of the incoming activity',
810 `object-id` varbinary(383) COMMENT '',
811 `in-reply-to-id` varbinary(383) COMMENT '',
812 `conversation` varbinary(383) COMMENT '',
813 `type` varchar(64) COMMENT 'Type of the activity',
814 `object-type` varchar(64) COMMENT 'Type of the object activity',
815 `object-object-type` varchar(64) COMMENT 'Type of the object\'s object activity',
816 `received` datetime COMMENT 'Receiving date',
817 `activity` mediumtext COMMENT 'The JSON activity',
818 `signer` varchar(255) COMMENT '',
819 `push` boolean COMMENT 'Is the entry pushed or have pulled it?',
820 `trust` boolean COMMENT 'Do we trust this entry?',
821 `wid` int unsigned COMMENT 'Workerqueue id',
823 UNIQUE INDEX `activity-id` (`activity-id`),
824 INDEX `object-id` (`object-id`),
825 INDEX `received` (`received`),
827 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
828 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Incoming activity';
831 -- TABLE inbox-entry-receiver
833 CREATE TABLE IF NOT EXISTS `inbox-entry-receiver` (
834 `queue-id` int unsigned NOT NULL COMMENT '',
835 `uid` mediumint unsigned NOT NULL COMMENT 'User id',
836 PRIMARY KEY(`queue-id`,`uid`),
838 FOREIGN KEY (`queue-id`) REFERENCES `inbox-entry` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
839 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
840 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Receiver for the incoming activity';
843 -- TABLE inbox-status
845 CREATE TABLE IF NOT EXISTS `inbox-status` (
846 `url` varbinary(383) NOT NULL COMMENT 'URL of the inbox',
847 `uri-id` int unsigned COMMENT 'Item-uri id of inbox url',
848 `gsid` int unsigned COMMENT 'ID of the related server',
849 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
850 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
851 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
852 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
853 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
854 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
856 INDEX `uri-id` (`uri-id`),
857 INDEX `gsid` (`gsid`),
858 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
859 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
860 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
865 CREATE TABLE IF NOT EXISTS `intro` (
866 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
867 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
868 `fid` int unsigned COMMENT 'deprecated',
869 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
870 `suggest-cid` int unsigned COMMENT 'Suggested contact',
871 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
872 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
873 `note` text COMMENT '',
874 `hash` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
875 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
876 `blocked` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
877 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
879 INDEX `contact-id` (`contact-id`),
880 INDEX `suggest-cid` (`suggest-cid`),
882 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
883 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
884 FOREIGN KEY (`suggest-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
885 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
890 CREATE TABLE IF NOT EXISTS `key-value` (
891 `k` varbinary(50) NOT NULL COMMENT '',
892 `v` mediumtext COMMENT '',
893 `updated_at` int unsigned NOT NULL COMMENT 'timestamp of the last update',
895 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='A key value storage';
900 CREATE TABLE IF NOT EXISTS `locks` (
901 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
902 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
903 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
904 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
905 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
907 INDEX `name_expires` (`name`,`expires`)
908 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
913 CREATE TABLE IF NOT EXISTS `mail` (
914 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
915 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
916 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
917 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
918 `from-photo` varbinary(383) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
919 `from-url` varbinary(383) NOT NULL DEFAULT '' COMMENT 'profile link of the sender',
920 `contact-id` varbinary(255) COMMENT 'contact.id',
921 `author-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the author of the mail',
922 `convid` int unsigned COMMENT 'conv.id',
923 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
924 `body` mediumtext COMMENT '',
925 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
926 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
927 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
928 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
929 `uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
930 `uri-id` int unsigned COMMENT 'Item-uri id of the related mail',
931 `parent-uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
932 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related mail',
933 `thr-parent` varbinary(383) COMMENT '',
934 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
935 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
937 INDEX `uid_seen` (`uid`,`seen`),
938 INDEX `convid` (`convid`),
939 INDEX `uri` (`uri`(64)),
940 INDEX `parent-uri` (`parent-uri`(64)),
941 INDEX `contactid` (`contact-id`(32)),
942 INDEX `author-id` (`author-id`),
943 INDEX `uri-id` (`uri-id`),
944 INDEX `parent-uri-id` (`parent-uri-id`),
945 INDEX `thr-parent-id` (`thr-parent-id`),
946 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
947 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
948 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
949 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
950 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
951 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
956 CREATE TABLE IF NOT EXISTS `mailacct` (
957 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
958 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
959 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
960 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
961 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
962 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
963 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
964 `pass` text COMMENT '',
965 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
966 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
967 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
968 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
969 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
972 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
973 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
978 CREATE TABLE IF NOT EXISTS `manage` (
979 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
980 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
981 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
983 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
985 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
986 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
987 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
990 -- TABLE notification
992 CREATE TABLE IF NOT EXISTS `notification` (
993 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
994 `uid` mediumint unsigned COMMENT 'Owner User id',
995 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
996 `type` smallint unsigned COMMENT '',
997 `actor-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the actor that caused the notification',
998 `target-uri-id` int unsigned COMMENT 'Item-uri id of the related post',
999 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
1000 `created` datetime COMMENT '',
1001 `seen` boolean DEFAULT '0' COMMENT 'Seen on the desktop',
1002 `dismissed` boolean DEFAULT '0' COMMENT 'Dismissed via the API',
1004 UNIQUE INDEX `uid_vid_type_actor-id_target-uri-id` (`uid`,`vid`,`type`,`actor-id`,`target-uri-id`),
1005 INDEX `vid` (`vid`),
1006 INDEX `actor-id` (`actor-id`),
1007 INDEX `target-uri-id` (`target-uri-id`),
1008 INDEX `parent-uri-id` (`parent-uri-id`),
1009 INDEX `seen_uid` (`seen`,`uid`),
1010 INDEX `uid_type_parent-uri-id_actor-id` (`uid`,`type`,`parent-uri-id`,`actor-id`),
1011 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1012 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1013 FOREIGN KEY (`actor-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1014 FOREIGN KEY (`target-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1015 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1016 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
1021 CREATE TABLE IF NOT EXISTS `notify` (
1022 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1023 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1024 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1025 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1026 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1027 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1028 `msg` mediumtext COMMENT '',
1029 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1030 `link` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1031 `iid` int unsigned COMMENT '',
1032 `parent` int unsigned COMMENT '',
1033 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
1034 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
1035 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
1036 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
1037 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
1038 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
1039 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
1041 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
1042 INDEX `uid_date` (`uid`,`date`),
1043 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
1044 INDEX `uri-id` (`uri-id`),
1045 INDEX `parent-uri-id` (`parent-uri-id`),
1046 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1047 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1048 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1049 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='[Deprecated] User notifications';
1052 -- TABLE notify-threads
1054 CREATE TABLE IF NOT EXISTS `notify-threads` (
1055 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1056 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1057 `master-parent-item` int unsigned COMMENT 'Deprecated',
1058 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
1059 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1060 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1062 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
1063 INDEX `receiver-uid` (`receiver-uid`),
1064 INDEX `notify-id` (`notify-id`),
1065 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1066 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1067 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1068 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1073 CREATE TABLE IF NOT EXISTS `oembed` (
1074 `url` varbinary(383) NOT NULL COMMENT 'page url',
1075 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
1076 `content` mediumtext COMMENT 'OEmbed data of the page',
1077 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1078 PRIMARY KEY(`url`,`maxwidth`),
1079 INDEX `created` (`created`)
1080 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
1083 -- TABLE openwebauth-token
1085 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
1086 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1087 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
1088 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
1089 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
1090 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1091 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1093 INDEX `uid` (`uid`),
1094 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1095 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
1100 CREATE TABLE IF NOT EXISTS `parsed_url` (
1101 `url_hash` binary(64) NOT NULL COMMENT 'page url hash',
1102 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
1103 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
1104 `url` text NOT NULL COMMENT 'page url',
1105 `content` mediumtext COMMENT 'page data',
1106 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1107 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration',
1108 PRIMARY KEY(`url_hash`,`guessing`,`oembed`),
1109 INDEX `created` (`created`),
1110 INDEX `expires` (`expires`)
1111 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
1116 CREATE TABLE IF NOT EXISTS `pconfig` (
1117 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
1118 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1119 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
1120 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
1121 `v` mediumtext COMMENT 'Value',
1123 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
1124 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1125 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
1130 CREATE TABLE IF NOT EXISTS `photo` (
1131 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1132 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1133 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1134 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
1135 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
1136 `hash` char(32) COMMENT 'hash value of the photo',
1137 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
1138 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
1139 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1140 `desc` text COMMENT '',
1141 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
1142 `photo-type` tinyint unsigned COMMENT 'User avatar, user banner, contact avatar, contact banner or default',
1143 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1144 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
1145 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1146 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1147 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1148 `blurhash` varbinary(255) COMMENT 'BlurHash representation of the photo',
1149 `data` mediumblob NOT NULL COMMENT '',
1150 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1151 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
1152 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
1153 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed circles',
1154 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
1155 `deny_gid` mediumtext COMMENT 'Access Control - list of denied circles',
1156 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
1157 `backend-class` tinytext COMMENT 'Storage backend class',
1158 `backend-ref` text COMMENT 'Storage backend data reference',
1159 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1161 INDEX `contactid` (`contact-id`),
1162 INDEX `uid_contactid` (`uid`,`contact-id`),
1163 INDEX `uid_profile` (`uid`,`profile`),
1164 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
1165 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
1166 INDEX `resource-id` (`resource-id`),
1167 INDEX `uid_photo-type` (`uid`,`photo-type`),
1168 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1169 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1170 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1175 CREATE TABLE IF NOT EXISTS `post` (
1176 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1177 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1178 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1179 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1180 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1181 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1182 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1183 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1184 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1185 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1186 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1187 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1188 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1189 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1190 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1191 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1192 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1193 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1194 PRIMARY KEY(`uri-id`),
1195 INDEX `parent-uri-id` (`parent-uri-id`),
1196 INDEX `thr-parent-id` (`thr-parent-id`),
1197 INDEX `external-id` (`external-id`),
1198 INDEX `owner-id` (`owner-id`),
1199 INDEX `author-id` (`author-id`),
1200 INDEX `causer-id` (`causer-id`),
1201 INDEX `vid` (`vid`),
1202 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1203 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1204 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1205 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1206 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1207 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1208 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1209 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1210 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
1213 -- TABLE post-activity
1215 CREATE TABLE IF NOT EXISTS `post-activity` (
1216 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1217 `activity` mediumtext COMMENT 'Original activity',
1218 `received` datetime COMMENT '',
1219 PRIMARY KEY(`uri-id`),
1220 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1221 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Original remote activity';
1224 -- TABLE post-category
1226 CREATE TABLE IF NOT EXISTS `post-category` (
1227 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1228 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1229 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1230 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1231 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1232 INDEX `tid` (`tid`),
1233 INDEX `uid_uri-id` (`uid`,`uri-id`),
1234 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1235 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1236 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1237 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1240 -- TABLE post-counts
1242 CREATE TABLE IF NOT EXISTS `post-counts` (
1243 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1244 `vid` smallint unsigned NOT NULL COMMENT 'Id of the verb table entry that contains the activity verbs',
1245 `reaction` varchar(1) NOT NULL COMMENT 'Emoji Reaction',
1246 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1247 `count` int unsigned DEFAULT 0 COMMENT 'Number of activities',
1248 PRIMARY KEY(`uri-id`,`vid`,`reaction`),
1249 INDEX `vid` (`vid`),
1250 INDEX `parent-uri-id` (`parent-uri-id`),
1251 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1252 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1253 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1254 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Original remote activity';
1257 -- TABLE post-collection
1259 CREATE TABLE IF NOT EXISTS `post-collection` (
1260 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1261 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0 - Featured',
1262 `author-id` int unsigned COMMENT 'Author of the featured post',
1263 PRIMARY KEY(`uri-id`,`type`),
1264 INDEX `type` (`type`),
1265 INDEX `author-id` (`author-id`),
1266 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1267 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1268 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Collection of posts';
1271 -- TABLE post-content
1273 CREATE TABLE IF NOT EXISTS `post-content` (
1274 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1275 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1276 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1277 `body` mediumtext COMMENT 'item body content',
1278 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1279 `quote-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the quoted uri',
1280 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1281 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1282 `language` text COMMENT 'Language information about this post',
1283 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1284 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1285 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1286 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1287 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1288 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1289 `target` text COMMENT 'JSON encoded target structure if used',
1290 `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',
1291 `plink` varbinary(383) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1292 PRIMARY KEY(`uri-id`),
1293 INDEX `plink` (`plink`(191)),
1294 INDEX `resource-id` (`resource-id`),
1295 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
1296 INDEX `quote-uri-id` (`quote-uri-id`),
1297 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1298 FOREIGN KEY (`quote-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1299 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1302 -- TABLE post-delivery
1304 CREATE TABLE IF NOT EXISTS `post-delivery` (
1305 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1306 `inbox-id` int unsigned NOT NULL COMMENT 'Item-uri id of inbox url',
1307 `uid` mediumint unsigned COMMENT 'Delivering user',
1308 `created` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
1309 `command` varbinary(32) COMMENT '',
1310 `failed` tinyint DEFAULT 0 COMMENT 'Number of times the delivery has failed',
1311 `receivers` mediumtext COMMENT 'JSON encoded array with the receiving contacts',
1312 PRIMARY KEY(`uri-id`,`inbox-id`),
1313 INDEX `inbox-id_created` (`inbox-id`,`created`),
1314 INDEX `uid` (`uid`),
1315 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1316 FOREIGN KEY (`inbox-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1317 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1318 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for posts for the batch processing';
1321 -- TABLE post-delivery-data
1323 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1324 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1325 `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',
1326 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1327 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1328 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1329 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1330 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1331 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1332 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1333 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1334 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1335 PRIMARY KEY(`uri-id`),
1336 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1337 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1340 -- TABLE post-engagement
1342 CREATE TABLE IF NOT EXISTS `post-engagement` (
1343 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1344 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1345 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Person, organisation, news, community, relay',
1346 `media-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Type of media in a bit array (1 = image, 2 = video, 4 = audio',
1347 `language` varbinary(128) COMMENT 'Language information about this post',
1348 `searchtext` mediumtext COMMENT 'Simplified text for the full text search',
1349 `created` datetime COMMENT '',
1350 `restricted` boolean NOT NULL DEFAULT '0' COMMENT 'If true, this post is either unlisted or not from a federated network',
1351 `comments` mediumint unsigned COMMENT 'Number of comments',
1352 `activities` mediumint unsigned COMMENT 'Number of activities (like, dislike, ...)',
1353 PRIMARY KEY(`uri-id`),
1354 INDEX `owner-id` (`owner-id`),
1355 INDEX `created` (`created`),
1356 FULLTEXT INDEX `searchtext` (`searchtext`),
1357 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1358 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1359 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Engagement data per post';
1362 -- TABLE post-history
1364 CREATE TABLE IF NOT EXISTS `post-history` (
1365 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1366 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of edit',
1367 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1368 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1369 `body` mediumtext COMMENT 'item body content',
1370 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1371 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1372 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1373 `language` text COMMENT 'Language information about this post',
1374 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1375 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1376 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1377 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1378 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1379 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1380 `target` text COMMENT 'JSON encoded target structure if used',
1381 `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',
1382 `plink` varbinary(383) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1383 PRIMARY KEY(`uri-id`,`edited`),
1384 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1385 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post history';
1390 CREATE TABLE IF NOT EXISTS `post-link` (
1391 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1392 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1393 `url` varbinary(511) NOT NULL COMMENT 'External URL',
1394 `mimetype` varchar(60) COMMENT '',
1395 `height` smallint unsigned COMMENT 'Height of the media',
1396 `width` smallint unsigned COMMENT 'Width of the media',
1397 `blurhash` varbinary(255) COMMENT 'BlurHash representation of the link',
1399 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1400 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1401 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post related external links';
1406 CREATE TABLE IF NOT EXISTS `post-media` (
1407 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1408 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1409 `url` varbinary(1024) NOT NULL COMMENT 'Media URL',
1410 `media-uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the activities uri-id',
1411 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1412 `mimetype` varchar(60) COMMENT '',
1413 `height` smallint unsigned COMMENT 'Height of the media',
1414 `width` smallint unsigned COMMENT 'Width of the media',
1415 `size` bigint unsigned COMMENT 'Media size',
1416 `blurhash` varbinary(255) COMMENT 'BlurHash representation of the image',
1417 `preview` varbinary(512) COMMENT 'Preview URL',
1418 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1419 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1420 `description` text COMMENT '',
1421 `name` varchar(255) COMMENT 'Name of the media',
1422 `author-url` varbinary(383) COMMENT 'URL of the author of the media',
1423 `author-name` varchar(255) COMMENT 'Name of the author of the media',
1424 `author-image` varbinary(383) COMMENT 'Image of the author of the media',
1425 `publisher-url` varbinary(383) COMMENT 'URL of the publisher of the media',
1426 `publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
1427 `publisher-image` varbinary(383) COMMENT 'Image of the publisher of the media',
1429 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`(512)),
1430 INDEX `uri-id-id` (`uri-id`,`id`),
1431 INDEX `media-uri-id` (`media-uri-id`),
1432 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1433 FOREIGN KEY (`media-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1434 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1437 -- TABLE post-question
1439 CREATE TABLE IF NOT EXISTS `post-question` (
1440 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1441 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1442 `multiple` boolean NOT NULL DEFAULT '0' COMMENT 'Multiple choice',
1443 `voters` int unsigned COMMENT 'Number of voters for this question',
1444 `end-time` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Question end time',
1446 UNIQUE INDEX `uri-id` (`uri-id`),
1447 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1448 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question';
1451 -- TABLE post-question-option
1453 CREATE TABLE IF NOT EXISTS `post-question-option` (
1454 `id` int unsigned NOT NULL COMMENT 'Id of the question',
1455 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1456 `name` varchar(255) COMMENT 'Name of the option',
1457 `replies` int unsigned COMMENT 'Number of replies for this question option',
1458 PRIMARY KEY(`uri-id`,`id`),
1459 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1460 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question option';
1465 CREATE TABLE IF NOT EXISTS `post-tag` (
1466 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1467 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1468 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1469 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1470 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1471 INDEX `tid` (`tid`),
1472 INDEX `cid` (`cid`),
1473 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1474 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1475 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1476 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1479 -- TABLE post-thread
1481 CREATE TABLE IF NOT EXISTS `post-thread` (
1482 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1483 `conversation-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the conversation uri',
1484 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1485 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1486 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1487 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1488 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1489 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1490 `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',
1491 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1492 PRIMARY KEY(`uri-id`),
1493 INDEX `conversation-id` (`conversation-id`),
1494 INDEX `owner-id` (`owner-id`),
1495 INDEX `author-id` (`author-id`),
1496 INDEX `causer-id` (`causer-id`),
1497 INDEX `received` (`received`),
1498 INDEX `commented` (`commented`),
1499 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1500 FOREIGN KEY (`conversation-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1501 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1502 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1503 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1504 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1509 CREATE TABLE IF NOT EXISTS `post-user` (
1510 `id` int unsigned NOT NULL auto_increment,
1511 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1512 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1513 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1514 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1515 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1516 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1517 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1518 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1519 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1520 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1521 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1522 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1523 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1524 `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
1525 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1526 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1527 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1528 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1529 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1530 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1531 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1532 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1533 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1534 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1535 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1536 `notification-type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1537 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1538 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1539 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1541 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1542 INDEX `uri-id` (`uri-id`),
1543 INDEX `parent-uri-id` (`parent-uri-id`),
1544 INDEX `thr-parent-id` (`thr-parent-id`),
1545 INDEX `external-id` (`external-id`),
1546 INDEX `owner-id` (`owner-id`),
1547 INDEX `author-id` (`author-id`),
1548 INDEX `causer-id` (`causer-id`),
1549 INDEX `vid` (`vid`),
1550 INDEX `contact-id` (`contact-id`),
1551 INDEX `event-id` (`event-id`),
1552 INDEX `psid` (`psid`),
1553 INDEX `author-id_uid` (`author-id`,`uid`),
1554 INDEX `author-id_created` (`author-id`,`created`),
1555 INDEX `owner-id_created` (`owner-id`,`created`),
1556 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1557 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1558 INDEX `uid_contactid` (`uid`,`contact-id`),
1559 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1560 INDEX `uid_unseen` (`uid`,`unseen`),
1561 INDEX `uid_hidden_uri-id` (`uid`,`hidden`,`uri-id`),
1562 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1563 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1564 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1565 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1566 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1567 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1568 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1569 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1570 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1571 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1572 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1573 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1574 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1577 -- TABLE post-thread-user
1579 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1580 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1581 `conversation-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the conversation uri',
1582 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1583 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1584 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1585 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1586 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1587 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1588 `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',
1589 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1590 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1591 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
1592 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1593 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1594 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1595 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1596 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1597 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Deprecated',
1598 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1599 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1600 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1601 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1602 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1603 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1604 PRIMARY KEY(`uid`,`uri-id`),
1605 INDEX `uri-id` (`uri-id`),
1606 INDEX `conversation-id` (`conversation-id`),
1607 INDEX `owner-id` (`owner-id`),
1608 INDEX `author-id` (`author-id`),
1609 INDEX `causer-id` (`causer-id`),
1610 INDEX `uid` (`uid`),
1611 INDEX `contact-id` (`contact-id`),
1612 INDEX `psid` (`psid`),
1613 INDEX `post-user-id` (`post-user-id`),
1614 INDEX `commented` (`commented`),
1615 INDEX `received` (`received`),
1616 INDEX `author-id_created` (`author-id`,`created`),
1617 INDEX `owner-id_created` (`owner-id`,`created`),
1618 INDEX `uid_received` (`uid`,`received`),
1619 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1620 INDEX `uid_commented` (`uid`,`commented`),
1621 INDEX `uid_created` (`uid`,`created`),
1622 INDEX `uid_starred` (`uid`,`starred`),
1623 INDEX `uid_mention` (`uid`,`mention`),
1624 INDEX `contact-id_commented` (`contact-id`,`commented`),
1625 INDEX `contact-id_received` (`contact-id`,`received`),
1626 INDEX `contact-id_created` (`contact-id`,`created`),
1627 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1628 FOREIGN KEY (`conversation-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1629 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1630 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1631 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1632 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1633 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1634 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1635 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1636 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1639 -- TABLE post-user-notification
1641 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1642 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1643 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1644 `notification-type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1645 PRIMARY KEY(`uid`,`uri-id`),
1646 INDEX `uri-id` (`uri-id`),
1647 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1648 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1649 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1654 CREATE TABLE IF NOT EXISTS `process` (
1655 `pid` int unsigned NOT NULL COMMENT 'The ID of the process',
1656 `hostname` varchar(255) NOT NULL COMMENT 'The name of the host the process is ran on',
1657 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1658 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1659 PRIMARY KEY(`pid`,`hostname`),
1660 INDEX `command` (`command`)
1661 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1666 CREATE TABLE IF NOT EXISTS `profile` (
1667 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1668 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1669 `profile-name` varchar(255) COMMENT 'Deprecated',
1670 `is-default` boolean COMMENT 'Deprecated',
1671 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1672 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Unused in favor of user.username',
1673 `pdesc` varchar(255) COMMENT 'Deprecated',
1674 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1675 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1676 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1677 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1678 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1679 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1680 `hometown` varchar(255) COMMENT 'Deprecated',
1681 `gender` varchar(32) COMMENT 'Deprecated',
1682 `marital` varchar(255) COMMENT 'Deprecated',
1683 `with` text COMMENT 'Deprecated',
1684 `howlong` datetime COMMENT 'Deprecated',
1685 `sexual` varchar(255) COMMENT 'Deprecated',
1686 `politic` varchar(255) COMMENT 'Deprecated',
1687 `religion` varchar(255) COMMENT 'Deprecated',
1688 `pub_keywords` text COMMENT '',
1689 `prv_keywords` text COMMENT '',
1690 `likes` text COMMENT 'Deprecated',
1691 `dislikes` text COMMENT 'Deprecated',
1692 `about` text COMMENT 'Profile description',
1693 `summary` varchar(255) COMMENT 'Deprecated',
1694 `music` text COMMENT 'Deprecated',
1695 `book` text COMMENT 'Deprecated',
1696 `tv` text COMMENT 'Deprecated',
1697 `film` text COMMENT 'Deprecated',
1698 `interest` text COMMENT 'Deprecated',
1699 `romance` text COMMENT 'Deprecated',
1700 `work` text COMMENT 'Deprecated',
1701 `education` text COMMENT 'Deprecated',
1702 `contact` text COMMENT 'Deprecated',
1703 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1704 `homepage_verified` boolean NOT NULL DEFAULT '0' COMMENT 'was the homepage verified by a rel-me link back to the profile',
1705 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
1706 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
1707 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1708 `thumb` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1709 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1710 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1712 INDEX `uid_is-default` (`uid`,`is-default`),
1713 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1714 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1715 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1718 -- TABLE profile_field
1720 CREATE TABLE IF NOT EXISTS `profile_field` (
1721 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1722 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1723 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1724 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1725 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1726 `value` text COMMENT 'Value of the field',
1727 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1728 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1730 INDEX `uid` (`uid`),
1731 INDEX `order` (`order`),
1732 INDEX `psid` (`psid`),
1733 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1734 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1735 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1738 -- TABLE push_subscriber
1740 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1741 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1742 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1743 `callback_url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1744 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1745 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1746 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1747 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1748 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1749 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1750 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1752 INDEX `next_try` (`next_try`),
1753 INDEX `uid` (`uid`),
1754 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1755 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1760 CREATE TABLE IF NOT EXISTS `register` (
1761 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1762 `hash` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1763 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1764 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1765 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1766 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1767 `note` text COMMENT '',
1769 INDEX `uid` (`uid`),
1770 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1771 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1776 CREATE TABLE IF NOT EXISTS `report` (
1777 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1778 `uid` mediumint unsigned COMMENT 'Reporting user',
1779 `reporter-id` int unsigned COMMENT 'Reporting contact',
1780 `cid` int unsigned NOT NULL COMMENT 'Reported contact',
1781 `gsid` int unsigned COMMENT 'Reported contact server',
1782 `comment` text COMMENT 'Report',
1783 `category-id` int unsigned NOT NULL DEFAULT 1 COMMENT 'Report category, one of Entity Report::CATEGORY_*',
1784 `forward` boolean COMMENT 'Forward the report to the remote server',
1785 `public-remarks` text COMMENT 'Remarks shared with the reporter',
1786 `private-remarks` text COMMENT 'Remarks shared with the moderation team',
1787 `last-editor-uid` mediumint unsigned COMMENT 'Last editor user',
1788 `assigned-uid` mediumint unsigned COMMENT 'Assigned moderator user',
1789 `status` tinyint unsigned NOT NULL COMMENT 'Status of the report, one of Entity Report::STATUS_*',
1790 `resolution` tinyint unsigned COMMENT 'Resolution of the report, one of Entity Report::RESOLUTION_*',
1791 `created` datetime(6) NOT NULL DEFAULT '0001-01-01 00:00:00.000000' COMMENT '',
1792 `edited` datetime(6) COMMENT 'Last time the report has been edited',
1794 INDEX `uid` (`uid`),
1795 INDEX `cid` (`cid`),
1796 INDEX `reporter-id` (`reporter-id`),
1797 INDEX `gsid` (`gsid`),
1798 INDEX `last-editor-uid` (`last-editor-uid`),
1799 INDEX `assigned-uid` (`assigned-uid`),
1800 INDEX `status-resolution` (`status`,`resolution`),
1801 INDEX `created` (`created`),
1802 INDEX `edited` (`edited`),
1803 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1804 FOREIGN KEY (`reporter-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1805 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1806 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1807 FOREIGN KEY (`last-editor-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1808 FOREIGN KEY (`assigned-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1809 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1812 -- TABLE report-post
1814 CREATE TABLE IF NOT EXISTS `report-post` (
1815 `rid` int unsigned NOT NULL COMMENT 'Report id',
1816 `uri-id` int unsigned NOT NULL COMMENT 'Uri-id of the reported post',
1817 `status` tinyint unsigned COMMENT 'Status of the reported post',
1818 PRIMARY KEY(`rid`,`uri-id`),
1819 INDEX `uri-id` (`uri-id`),
1820 FOREIGN KEY (`rid`) REFERENCES `report` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1821 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1822 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Individual posts attached to a moderation report';
1825 -- TABLE report-rule
1827 CREATE TABLE IF NOT EXISTS `report-rule` (
1828 `rid` int unsigned NOT NULL COMMENT 'Report id',
1829 `line-id` int unsigned NOT NULL COMMENT 'Terms of service rule line number, may become invalid after a TOS change.',
1830 `text` text NOT NULL COMMENT 'Terms of service rule text recorded at the time of the report',
1831 PRIMARY KEY(`rid`,`line-id`),
1832 FOREIGN KEY (`rid`) REFERENCES `report` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1833 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Terms of service rule lines relevant to a moderation report';
1838 CREATE TABLE IF NOT EXISTS `search` (
1839 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1840 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1841 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1843 INDEX `uid_term` (`uid`,`term`(64)),
1844 INDEX `term` (`term`(64)),
1845 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1846 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1851 CREATE TABLE IF NOT EXISTS `session` (
1852 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1853 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1854 `data` text COMMENT '',
1855 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1857 INDEX `sid` (`sid`(64)),
1858 INDEX `expire` (`expire`)
1859 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1864 CREATE TABLE IF NOT EXISTS `storage` (
1865 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1866 `data` longblob NOT NULL COMMENT 'file data',
1868 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1871 -- TABLE subscription
1873 CREATE TABLE IF NOT EXISTS `subscription` (
1874 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1875 `application-id` int unsigned NOT NULL COMMENT '',
1876 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
1877 `endpoint` varchar(511) COMMENT 'Endpoint URL',
1878 `pubkey` varchar(127) COMMENT 'User agent public key',
1879 `secret` varchar(32) COMMENT 'Auth secret',
1880 `follow` boolean COMMENT '',
1881 `favourite` boolean COMMENT '',
1882 `reblog` boolean COMMENT '',
1883 `mention` boolean COMMENT '',
1884 `poll` boolean COMMENT '',
1885 `follow_request` boolean COMMENT '',
1886 `status` boolean COMMENT '',
1888 UNIQUE INDEX `application-id_uid` (`application-id`,`uid`),
1889 INDEX `uid_application-id` (`uid`,`application-id`),
1890 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1891 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1892 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Push Subscription for the API';
1895 -- TABLE check-full-text-search
1897 CREATE TABLE IF NOT EXISTS `check-full-text-search` (
1898 `pid` int unsigned NOT NULL COMMENT 'The ID of the process',
1899 `searchtext` mediumtext COMMENT 'Simplified text for the full text search',
1901 FULLTEXT INDEX `searchtext` (`searchtext`)
1902 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Check for a full text search match in user defined channels before storing the message in the system';
1907 CREATE TABLE IF NOT EXISTS `userd` (
1908 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1909 `username` varchar(255) NOT NULL COMMENT '',
1911 INDEX `username` (`username`(32))
1912 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1915 -- TABLE user-contact
1917 CREATE TABLE IF NOT EXISTS `user-contact` (
1918 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1919 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1920 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
1921 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1922 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1923 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1924 `hidden` boolean COMMENT 'This contact is hidden from the others',
1925 `is-blocked` boolean COMMENT 'User is blocked by this contact',
1926 `channel-frequency` tinyint unsigned COMMENT 'Controls the frequency of the appearance of this contact in channels',
1927 `pending` boolean COMMENT '',
1928 `rel` tinyint unsigned COMMENT 'The kind of the relation between the user and the contact',
1929 `info` mediumtext COMMENT '',
1930 `notify_new_posts` boolean COMMENT '',
1931 `remote_self` tinyint unsigned COMMENT '0 => No mirroring, 1-2 => Mirror as own post, 3 => Mirror as reshare',
1932 `fetch_further_information` tinyint unsigned COMMENT '0 => None, 1 => Fetch information, 3 => Fetch keywords, 2 => Fetch both',
1933 `ffi_keyword_denylist` text COMMENT '',
1934 `subhub` boolean COMMENT '',
1935 `hub-verify` varbinary(383) COMMENT '',
1936 `protocol` char(4) COMMENT 'Protocol of the contact',
1937 `rating` tinyint COMMENT 'Automatically detected feed poll frequency',
1938 `priority` tinyint unsigned COMMENT 'Feed poll priority',
1939 PRIMARY KEY(`uid`,`cid`),
1940 INDEX `cid` (`cid`),
1941 UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
1942 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1943 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1944 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1945 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1948 -- TABLE arrived-activity
1950 CREATE TABLE IF NOT EXISTS `arrived-activity` (
1951 `object-id` varbinary(383) NOT NULL COMMENT 'object id of the incoming activity',
1952 `received` datetime COMMENT 'Receiving date',
1953 PRIMARY KEY(`object-id`)
1954 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Id of arrived activities';
1957 -- TABLE fetched-activity
1959 CREATE TABLE IF NOT EXISTS `fetched-activity` (
1960 `object-id` varbinary(383) NOT NULL COMMENT 'object id of fetched activity',
1961 `received` datetime COMMENT 'Receiving date',
1962 PRIMARY KEY(`object-id`)
1963 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Id of fetched activities';
1968 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1969 `key` int NOT NULL COMMENT '',
1970 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1972 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1975 -- VIEW application-view
1977 DROP VIEW IF EXISTS `application-view`;
1978 CREATE VIEW `application-view` AS SELECT
1979 `application`.`id` AS `id`,
1980 `application-token`.`uid` AS `uid`,
1981 `application`.`name` AS `name`,
1982 `application`.`redirect_uri` AS `redirect_uri`,
1983 `application`.`website` AS `website`,
1984 `application`.`client_id` AS `client_id`,
1985 `application`.`client_secret` AS `client_secret`,
1986 `application-token`.`code` AS `code`,
1987 `application-token`.`access_token` AS `access_token`,
1988 `application-token`.`created_at` AS `created_at`,
1989 `application-token`.`scopes` AS `scopes`,
1990 `application-token`.`read` AS `read`,
1991 `application-token`.`write` AS `write`,
1992 `application-token`.`follow` AS `follow`,
1993 `application-token`.`push` AS `push`
1994 FROM `application-token`
1995 INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`;
1998 -- VIEW circle-member-view
2000 DROP VIEW IF EXISTS `circle-member-view`;
2001 CREATE VIEW `circle-member-view` AS SELECT
2002 `group_member`.`id` AS `id`,
2003 `group`.`uid` AS `uid`,
2004 `group_member`.`contact-id` AS `contact-id`,
2005 `contact`.`uri-id` AS `contact-uri-id`,
2006 `contact`.`url` AS `contact-link`,
2007 `contact`.`addr` AS `contact-addr`,
2008 `contact`.`name` AS `contact-name`,
2009 `contact`.`nick` AS `contact-nick`,
2010 `contact`.`thumb` AS `contact-avatar`,
2011 `contact`.`network` AS `contact-network`,
2012 `contact`.`blocked` AS `contact-blocked`,
2013 `contact`.`hidden` AS `contact-hidden`,
2014 `contact`.`readonly` AS `contact-readonly`,
2015 `contact`.`archive` AS `contact-archive`,
2016 `contact`.`pending` AS `contact-pending`,
2017 `contact`.`self` AS `contact-self`,
2018 `contact`.`rel` AS `contact-rel`,
2019 `contact`.`contact-type` AS `contact-contact-type`,
2020 `group_member`.`gid` AS `circle-id`,
2021 `group`.`visible` AS `circle-visible`,
2022 `group`.`deleted` AS `circle-deleted`,
2023 `group`.`name` AS `circle-name`
2025 INNER JOIN `contact` ON `group_member`.`contact-id` = `contact`.`id`
2026 INNER JOIN `group` ON `group_member`.`gid` = `group`.`id`;
2029 -- VIEW post-counts-view
2031 DROP VIEW IF EXISTS `post-counts-view`;
2032 CREATE VIEW `post-counts-view` AS SELECT
2033 `post-counts`.`uri-id` AS `uri-id`,
2034 `post-counts`.`vid` AS `vid`,
2035 `verb`.`name` AS `verb`,
2036 `post-counts`.`reaction` AS `reaction`,
2037 `post-counts`.`parent-uri-id` AS `parent-uri-id`,
2038 `post-counts`.`count` AS `count`
2040 INNER JOIN `verb` ON `verb`.`id` = `post-counts`.`vid`;
2043 -- VIEW post-timeline-view
2045 DROP VIEW IF EXISTS `post-timeline-view`;
2046 CREATE VIEW `post-timeline-view` AS SELECT
2047 `post-user`.`uid` AS `uid`,
2048 `post-user`.`uri-id` AS `uri-id`,
2049 `post-user`.`gravity` AS `gravity`,
2050 `post-user`.`created` AS `created`,
2051 `post-user`.`edited` AS `edited`,
2052 `post-thread-user`.`commented` AS `commented`,
2053 `post-user`.`received` AS `received`,
2054 `post-thread-user`.`changed` AS `changed`,
2055 `post-user`.`private` AS `private`,
2056 `post-user`.`visible` AS `visible`,
2057 `post-user`.`deleted` AS `deleted`,
2058 `post-user`.`origin` AS `origin`,
2059 `post-user`.`global` AS `global`,
2060 `post-user`.`network` AS `network`,
2061 `post-user`.`protocol` AS `protocol`,
2062 `post-user`.`vid` AS `vid`,
2063 `post-user`.`contact-id` AS `contact-id`,
2064 `contact`.`blocked` AS `contact-blocked`,
2065 `contact`.`readonly` AS `contact-readonly`,
2066 `contact`.`pending` AS `contact-pending`,
2067 `contact`.`rel` AS `contact-rel`,
2068 `contact`.`uid` AS `contact-uid`,
2069 `contact`.`self` AS `self`,
2070 `post-user`.`author-id` AS `author-id`,
2071 `author`.`blocked` AS `author-blocked`,
2072 `author`.`hidden` AS `author-hidden`,
2073 `author`.`gsid` AS `author-gsid`,
2074 `post-user`.`owner-id` AS `owner-id`,
2075 `owner`.`blocked` AS `owner-blocked`,
2076 `owner`.`gsid` AS `owner-gsid`,
2077 `post-user`.`causer-id` AS `causer-id`,
2078 `causer`.`blocked` AS `causer-blocked`,
2079 `causer`.`gsid` AS `causer-gsid`
2081 LEFT JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2082 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
2083 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
2084 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
2085 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`;
2088 -- VIEW post-user-view
2090 DROP VIEW IF EXISTS `post-user-view`;
2091 CREATE VIEW `post-user-view` AS SELECT
2092 `post-user`.`id` AS `id`,
2093 `post-user`.`id` AS `post-user-id`,
2094 `post-user`.`uid` AS `uid`,
2095 `post-thread-user`.`post-user-id` AS `parent`,
2096 `item-uri`.`uri` AS `uri`,
2097 `post-user`.`uri-id` AS `uri-id`,
2098 `parent-item-uri`.`uri` AS `parent-uri`,
2099 `post-user`.`parent-uri-id` AS `parent-uri-id`,
2100 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2101 `post-user`.`thr-parent-id` AS `thr-parent-id`,
2102 `conversation-item-uri`.`uri` AS `conversation`,
2103 `post-thread-user`.`conversation-id` AS `conversation-id`,
2104 `quote-item-uri`.`uri` AS `quote-uri`,
2105 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2106 `item-uri`.`guid` AS `guid`,
2107 `post-user`.`wall` AS `wall`,
2108 `post-user`.`gravity` AS `gravity`,
2109 `external-item-uri`.`uri` AS `extid`,
2110 `post-user`.`external-id` AS `external-id`,
2111 `post-user`.`created` AS `created`,
2112 `post-user`.`edited` AS `edited`,
2113 `post-thread-user`.`commented` AS `commented`,
2114 `post-user`.`received` AS `received`,
2115 `post-thread-user`.`changed` AS `changed`,
2116 `post-user`.`post-type` AS `post-type`,
2117 `post-user`.`post-reason` AS `post-reason`,
2118 `post-user`.`private` AS `private`,
2119 `post-thread-user`.`pubmail` AS `pubmail`,
2120 `post-user`.`visible` AS `visible`,
2121 `post-thread-user`.`starred` AS `starred`,
2122 `post-user`.`unseen` AS `unseen`,
2123 `post-user`.`deleted` AS `deleted`,
2124 `post-user`.`origin` AS `origin`,
2125 `post-thread-user`.`origin` AS `parent-origin`,
2126 `post-thread-user`.`mention` AS `mention`,
2127 `post-user`.`global` AS `global`,
2128 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-user`.`uri-id`) AS `featured`,
2129 `post-user`.`network` AS `network`,
2130 `post-user`.`protocol` AS `protocol`,
2131 `post-user`.`vid` AS `vid`,
2132 `post-user`.`psid` AS `psid`,
2133 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2134 `post-content`.`title` AS `title`,
2135 `post-content`.`content-warning` AS `content-warning`,
2136 `post-content`.`raw-body` AS `raw-body`,
2137 IFNULL (`post-content`.`body`, '') AS `body`,
2138 `post-content`.`rendered-hash` AS `rendered-hash`,
2139 `post-content`.`rendered-html` AS `rendered-html`,
2140 `post-content`.`language` AS `language`,
2141 `post-content`.`plink` AS `plink`,
2142 `post-content`.`location` AS `location`,
2143 `post-content`.`coord` AS `coord`,
2144 `post-content`.`app` AS `app`,
2145 `post-content`.`object-type` AS `object-type`,
2146 `post-content`.`object` AS `object`,
2147 `post-content`.`target-type` AS `target-type`,
2148 `post-content`.`target` AS `target`,
2149 `post-content`.`resource-id` AS `resource-id`,
2150 `post-user`.`contact-id` AS `contact-id`,
2151 `contact`.`uri-id` AS `contact-uri-id`,
2152 `contact`.`url` AS `contact-link`,
2153 `contact`.`addr` AS `contact-addr`,
2154 `contact`.`name` AS `contact-name`,
2155 `contact`.`nick` AS `contact-nick`,
2156 `contact`.`thumb` AS `contact-avatar`,
2157 `contact`.`network` AS `contact-network`,
2158 `contact`.`blocked` AS `contact-blocked`,
2159 `contact`.`hidden` AS `contact-hidden`,
2160 `contact`.`readonly` AS `contact-readonly`,
2161 `contact`.`archive` AS `contact-archive`,
2162 `contact`.`pending` AS `contact-pending`,
2163 `contact`.`rel` AS `contact-rel`,
2164 `contact`.`uid` AS `contact-uid`,
2165 `contact`.`contact-type` AS `contact-contact-type`,
2166 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
2167 `contact`.`self` AS `self`,
2168 `contact`.`id` AS `cid`,
2169 `contact`.`alias` AS `alias`,
2170 `contact`.`photo` AS `photo`,
2171 `contact`.`name-date` AS `name-date`,
2172 `contact`.`uri-date` AS `uri-date`,
2173 `contact`.`avatar-date` AS `avatar-date`,
2174 `contact`.`thumb` AS `thumb`,
2175 `post-user`.`author-id` AS `author-id`,
2176 `author`.`uri-id` AS `author-uri-id`,
2177 `author`.`url` AS `author-link`,
2178 `author`.`addr` AS `author-addr`,
2179 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
2180 `author`.`nick` AS `author-nick`,
2181 `author`.`alias` AS `author-alias`,
2182 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
2183 `author`.`network` AS `author-network`,
2184 `author`.`blocked` AS `author-blocked`,
2185 `author`.`hidden` AS `author-hidden`,
2186 `author`.`updated` AS `author-updated`,
2187 `author`.`contact-type` AS `author-contact-type`,
2188 `author`.`gsid` AS `author-gsid`,
2189 `author`.`baseurl` AS `author-baseurl`,
2190 `post-user`.`owner-id` AS `owner-id`,
2191 `owner`.`uri-id` AS `owner-uri-id`,
2192 `owner`.`url` AS `owner-link`,
2193 `owner`.`addr` AS `owner-addr`,
2194 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
2195 `owner`.`nick` AS `owner-nick`,
2196 `owner`.`alias` AS `owner-alias`,
2197 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
2198 `owner`.`network` AS `owner-network`,
2199 `owner`.`blocked` AS `owner-blocked`,
2200 `owner`.`hidden` AS `owner-hidden`,
2201 `owner`.`updated` AS `owner-updated`,
2202 `owner`.`gsid` AS `owner-gsid`,
2203 `owner`.`contact-type` AS `owner-contact-type`,
2204 `post-user`.`causer-id` AS `causer-id`,
2205 `causer`.`uri-id` AS `causer-uri-id`,
2206 `causer`.`url` AS `causer-link`,
2207 `causer`.`addr` AS `causer-addr`,
2208 `causer`.`name` AS `causer-name`,
2209 `causer`.`nick` AS `causer-nick`,
2210 `causer`.`alias` AS `causer-alias`,
2211 `causer`.`thumb` AS `causer-avatar`,
2212 `causer`.`network` AS `causer-network`,
2213 `causer`.`blocked` AS `causer-blocked`,
2214 `causer`.`hidden` AS `causer-hidden`,
2215 `causer`.`gsid` AS `causer-gsid`,
2216 `causer`.`contact-type` AS `causer-contact-type`,
2217 `post-delivery-data`.`postopts` AS `postopts`,
2218 `post-delivery-data`.`inform` AS `inform`,
2219 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
2220 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
2221 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
2222 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
2223 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
2224 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
2225 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
2226 `post-user`.`event-id` AS `event-id`,
2227 `event`.`created` AS `event-created`,
2228 `event`.`edited` AS `event-edited`,
2229 `event`.`start` AS `event-start`,
2230 `event`.`finish` AS `event-finish`,
2231 `event`.`summary` AS `event-summary`,
2232 `event`.`desc` AS `event-desc`,
2233 `event`.`location` AS `event-location`,
2234 `event`.`type` AS `event-type`,
2235 `event`.`nofinish` AS `event-nofinish`,
2236 `event`.`ignore` AS `event-ignore`,
2237 `post-question`.`id` AS `question-id`,
2238 `post-question`.`multiple` AS `question-multiple`,
2239 `post-question`.`voters` AS `question-voters`,
2240 `post-question`.`end-time` AS `question-end-time`,
2241 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`,
2242 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-user`.`uri-id`) AS `has-media`,
2243 `diaspora-interaction`.`interaction` AS `signed_text`,
2244 `parent-item-uri`.`guid` AS `parent-guid`,
2245 `post-thread-user`.`network` AS `parent-network`,
2246 `post-thread-user`.`author-id` AS `parent-author-id`,
2247 `parent-post-author`.`url` AS `parent-author-link`,
2248 `parent-post-author`.`name` AS `parent-author-name`,
2249 `parent-post-author`.`nick` AS `parent-author-nick`,
2250 `parent-post-author`.`network` AS `parent-author-network`
2252 INNER JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2253 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
2254 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
2255 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
2256 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
2257 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
2258 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
2259 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
2260 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
2261 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
2262 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
2263 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
2264 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
2265 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
2266 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2267 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
2268 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-user`.`uri-id`
2269 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
2270 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `post-thread-user`.`author-id`;
2273 -- VIEW post-thread-user-view
2275 DROP VIEW IF EXISTS `post-thread-user-view`;
2276 CREATE VIEW `post-thread-user-view` AS SELECT
2277 `post-user`.`id` AS `id`,
2278 `post-user`.`id` AS `post-user-id`,
2279 `post-thread-user`.`uid` AS `uid`,
2280 `post-thread-user`.`post-user-id` AS `parent`,
2281 `item-uri`.`uri` AS `uri`,
2282 `post-thread-user`.`uri-id` AS `uri-id`,
2283 `parent-item-uri`.`uri` AS `parent-uri`,
2284 `post-user`.`parent-uri-id` AS `parent-uri-id`,
2285 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2286 `post-user`.`thr-parent-id` AS `thr-parent-id`,
2287 `conversation-item-uri`.`uri` AS `conversation`,
2288 `post-thread-user`.`conversation-id` AS `conversation-id`,
2289 `quote-item-uri`.`uri` AS `quote-uri`,
2290 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2291 `item-uri`.`guid` AS `guid`,
2292 `post-thread-user`.`wall` AS `wall`,
2293 `post-user`.`gravity` AS `gravity`,
2294 `external-item-uri`.`uri` AS `extid`,
2295 `post-user`.`external-id` AS `external-id`,
2296 `post-thread-user`.`created` AS `created`,
2297 `post-user`.`edited` AS `edited`,
2298 `post-thread-user`.`commented` AS `commented`,
2299 `post-thread-user`.`received` AS `received`,
2300 `post-thread-user`.`changed` AS `changed`,
2301 `post-user`.`post-type` AS `post-type`,
2302 `post-user`.`post-reason` AS `post-reason`,
2303 `post-user`.`private` AS `private`,
2304 `post-thread-user`.`pubmail` AS `pubmail`,
2305 `post-thread-user`.`ignored` AS `ignored`,
2306 `post-user`.`visible` AS `visible`,
2307 `post-thread-user`.`starred` AS `starred`,
2308 `post-thread-user`.`unseen` AS `unseen`,
2309 `post-user`.`deleted` AS `deleted`,
2310 `post-thread-user`.`origin` AS `origin`,
2311 `post-thread-user`.`mention` AS `mention`,
2312 `post-user`.`global` AS `global`,
2313 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread-user`.`uri-id`) AS `featured`,
2314 `post-thread-user`.`network` AS `network`,
2315 `post-user`.`vid` AS `vid`,
2316 `post-thread-user`.`psid` AS `psid`,
2317 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2318 `post-content`.`title` AS `title`,
2319 `post-content`.`content-warning` AS `content-warning`,
2320 `post-content`.`raw-body` AS `raw-body`,
2321 `post-content`.`body` AS `body`,
2322 `post-content`.`rendered-hash` AS `rendered-hash`,
2323 `post-content`.`rendered-html` AS `rendered-html`,
2324 `post-content`.`language` AS `language`,
2325 `post-content`.`plink` AS `plink`,
2326 `post-content`.`location` AS `location`,
2327 `post-content`.`coord` AS `coord`,
2328 `post-content`.`app` AS `app`,
2329 `post-content`.`object-type` AS `object-type`,
2330 `post-content`.`object` AS `object`,
2331 `post-content`.`target-type` AS `target-type`,
2332 `post-content`.`target` AS `target`,
2333 `post-content`.`resource-id` AS `resource-id`,
2334 `post-thread-user`.`contact-id` AS `contact-id`,
2335 `contact`.`uri-id` AS `contact-uri-id`,
2336 `contact`.`url` AS `contact-link`,
2337 `contact`.`addr` AS `contact-addr`,
2338 `contact`.`name` AS `contact-name`,
2339 `contact`.`nick` AS `contact-nick`,
2340 `contact`.`thumb` AS `contact-avatar`,
2341 `contact`.`network` AS `contact-network`,
2342 `contact`.`blocked` AS `contact-blocked`,
2343 `contact`.`hidden` AS `contact-hidden`,
2344 `contact`.`readonly` AS `contact-readonly`,
2345 `contact`.`archive` AS `contact-archive`,
2346 `contact`.`pending` AS `contact-pending`,
2347 `contact`.`rel` AS `contact-rel`,
2348 `contact`.`uid` AS `contact-uid`,
2349 `contact`.`gsid` AS `contact-gsid`,
2350 `contact`.`contact-type` AS `contact-contact-type`,
2351 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
2352 `contact`.`self` AS `self`,
2353 `contact`.`id` AS `cid`,
2354 `contact`.`alias` AS `alias`,
2355 `contact`.`photo` AS `photo`,
2356 `contact`.`name-date` AS `name-date`,
2357 `contact`.`uri-date` AS `uri-date`,
2358 `contact`.`avatar-date` AS `avatar-date`,
2359 `contact`.`thumb` AS `thumb`,
2360 `post-thread-user`.`author-id` AS `author-id`,
2361 `author`.`uri-id` AS `author-uri-id`,
2362 `author`.`url` AS `author-link`,
2363 `author`.`addr` AS `author-addr`,
2364 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
2365 `author`.`nick` AS `author-nick`,
2366 `author`.`alias` AS `author-alias`,
2367 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
2368 `author`.`network` AS `author-network`,
2369 `author`.`blocked` AS `author-blocked`,
2370 `author`.`hidden` AS `author-hidden`,
2371 `author`.`updated` AS `author-updated`,
2372 `author`.`contact-type` AS `author-contact-type`,
2373 `author`.`gsid` AS `author-gsid`,
2374 `post-thread-user`.`owner-id` AS `owner-id`,
2375 `owner`.`uri-id` AS `owner-uri-id`,
2376 `owner`.`url` AS `owner-link`,
2377 `owner`.`addr` AS `owner-addr`,
2378 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
2379 `owner`.`nick` AS `owner-nick`,
2380 `owner`.`alias` AS `owner-alias`,
2381 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
2382 `owner`.`network` AS `owner-network`,
2383 `owner`.`blocked` AS `owner-blocked`,
2384 `owner`.`hidden` AS `owner-hidden`,
2385 `owner`.`updated` AS `owner-updated`,
2386 `owner`.`gsid` AS `owner-gsid`,
2387 `owner`.`contact-type` AS `owner-contact-type`,
2388 `post-thread-user`.`causer-id` AS `causer-id`,
2389 `causer`.`uri-id` AS `causer-uri-id`,
2390 `causer`.`url` AS `causer-link`,
2391 `causer`.`addr` AS `causer-addr`,
2392 `causer`.`name` AS `causer-name`,
2393 `causer`.`nick` AS `causer-nick`,
2394 `causer`.`alias` AS `causer-alias`,
2395 `causer`.`thumb` AS `causer-avatar`,
2396 `causer`.`network` AS `causer-network`,
2397 `causer`.`blocked` AS `causer-blocked`,
2398 `causer`.`hidden` AS `causer-hidden`,
2399 `causer`.`gsid` AS `causer-gsid`,
2400 `causer`.`contact-type` AS `causer-contact-type`,
2401 `post-delivery-data`.`postopts` AS `postopts`,
2402 `post-delivery-data`.`inform` AS `inform`,
2403 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
2404 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
2405 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
2406 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
2407 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
2408 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
2409 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
2410 `post-user`.`event-id` AS `event-id`,
2411 `event`.`created` AS `event-created`,
2412 `event`.`edited` AS `event-edited`,
2413 `event`.`start` AS `event-start`,
2414 `event`.`finish` AS `event-finish`,
2415 `event`.`summary` AS `event-summary`,
2416 `event`.`desc` AS `event-desc`,
2417 `event`.`location` AS `event-location`,
2418 `event`.`type` AS `event-type`,
2419 `event`.`nofinish` AS `event-nofinish`,
2420 `event`.`ignore` AS `event-ignore`,
2421 `post-question`.`id` AS `question-id`,
2422 `post-question`.`multiple` AS `question-multiple`,
2423 `post-question`.`voters` AS `question-voters`,
2424 `post-question`.`end-time` AS `question-end-time`,
2425 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`,
2426 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread-user`.`uri-id`) AS `has-media`,
2427 `diaspora-interaction`.`interaction` AS `signed_text`,
2428 `parent-item-uri`.`guid` AS `parent-guid`,
2429 `post-thread-user`.`network` AS `parent-network`,
2430 `post-thread-user`.`author-id` AS `parent-author-id`,
2431 `author`.`url` AS `parent-author-link`,
2432 `author`.`name` AS `parent-author-name`,
2433 `author`.`nick` AS `parent-author-nick`,
2434 `author`.`network` AS `parent-author-network`
2435 FROM `post-thread-user`
2436 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2437 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2438 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
2439 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
2440 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
2441 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
2442 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
2443 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
2444 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
2445 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
2446 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
2447 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
2448 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
2449 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
2450 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2451 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
2452 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread-user`.`uri-id`
2453 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`;
2458 DROP VIEW IF EXISTS `post-view`;
2459 CREATE VIEW `post-view` AS SELECT
2460 `item-uri`.`uri` AS `uri`,
2461 `post`.`uri-id` AS `uri-id`,
2462 `parent-item-uri`.`uri` AS `parent-uri`,
2463 `post`.`parent-uri-id` AS `parent-uri-id`,
2464 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2465 `post`.`thr-parent-id` AS `thr-parent-id`,
2466 `conversation-item-uri`.`uri` AS `conversation`,
2467 `post-thread`.`conversation-id` AS `conversation-id`,
2468 `quote-item-uri`.`uri` AS `quote-uri`,
2469 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2470 `item-uri`.`guid` AS `guid`,
2471 `post`.`gravity` AS `gravity`,
2472 `external-item-uri`.`uri` AS `extid`,
2473 `post`.`external-id` AS `external-id`,
2474 `post`.`created` AS `created`,
2475 `post`.`edited` AS `edited`,
2476 `post-thread`.`commented` AS `commented`,
2477 `post`.`received` AS `received`,
2478 `post-thread`.`changed` AS `changed`,
2479 `post`.`post-type` AS `post-type`,
2480 `post`.`private` AS `private`,
2481 `post`.`visible` AS `visible`,
2482 `post`.`deleted` AS `deleted`,
2483 `post`.`global` AS `global`,
2484 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post`.`uri-id`) AS `featured`,
2485 `post`.`network` AS `network`,
2486 `post`.`vid` AS `vid`,
2487 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2488 `post-content`.`title` AS `title`,
2489 `post-content`.`content-warning` AS `content-warning`,
2490 `post-content`.`raw-body` AS `raw-body`,
2491 `post-content`.`body` AS `body`,
2492 `post-content`.`rendered-hash` AS `rendered-hash`,
2493 `post-content`.`rendered-html` AS `rendered-html`,
2494 `post-content`.`language` AS `language`,
2495 `post-content`.`plink` AS `plink`,
2496 `post-content`.`location` AS `location`,
2497 `post-content`.`coord` AS `coord`,
2498 `post-content`.`app` AS `app`,
2499 `post-content`.`object-type` AS `object-type`,
2500 `post-content`.`object` AS `object`,
2501 `post-content`.`target-type` AS `target-type`,
2502 `post-content`.`target` AS `target`,
2503 `post-content`.`resource-id` AS `resource-id`,
2504 `post`.`author-id` AS `contact-id`,
2505 `author`.`uri-id` AS `contact-uri-id`,
2506 `author`.`url` AS `contact-link`,
2507 `author`.`addr` AS `contact-addr`,
2508 `author`.`name` AS `contact-name`,
2509 `author`.`nick` AS `contact-nick`,
2510 `author`.`thumb` AS `contact-avatar`,
2511 `author`.`network` AS `contact-network`,
2512 `author`.`blocked` AS `contact-blocked`,
2513 `author`.`hidden` AS `contact-hidden`,
2514 `author`.`readonly` AS `contact-readonly`,
2515 `author`.`archive` AS `contact-archive`,
2516 `author`.`pending` AS `contact-pending`,
2517 `author`.`rel` AS `contact-rel`,
2518 `author`.`uid` AS `contact-uid`,
2519 `author`.`contact-type` AS `contact-contact-type`,
2520 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2522 `author`.`id` AS `cid`,
2523 `author`.`alias` AS `alias`,
2524 `author`.`photo` AS `photo`,
2525 `author`.`name-date` AS `name-date`,
2526 `author`.`uri-date` AS `uri-date`,
2527 `author`.`avatar-date` AS `avatar-date`,
2528 `author`.`thumb` AS `thumb`,
2529 `post`.`author-id` AS `author-id`,
2530 `author`.`uri-id` AS `author-uri-id`,
2531 `author`.`url` AS `author-link`,
2532 `author`.`addr` AS `author-addr`,
2533 `author`.`name` AS `author-name`,
2534 `author`.`nick` AS `author-nick`,
2535 `author`.`alias` AS `author-alias`,
2536 `author`.`thumb` AS `author-avatar`,
2537 `author`.`network` AS `author-network`,
2538 `author`.`blocked` AS `author-blocked`,
2539 `author`.`hidden` AS `author-hidden`,
2540 `author`.`updated` AS `author-updated`,
2541 `author`.`contact-type` AS `author-contact-type`,
2542 `author`.`gsid` AS `author-gsid`,
2543 `post`.`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`.`contact-type` AS `owner-contact-type`,
2556 `owner`.`gsid` AS `owner-gsid`,
2557 `post`.`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`.`contact-type` AS `causer-contact-type`,
2569 `causer`.`gsid` AS `causer-gsid`,
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`.`uri-id`) AS `has-media`,
2576 `diaspora-interaction`.`interaction` AS `signed_text`,
2577 `parent-item-uri`.`guid` AS `parent-guid`,
2578 `post-thread`.`network` AS `parent-network`,
2579 `post-thread`.`author-id` AS `parent-author-id`,
2580 `parent-post-author`.`url` AS `parent-author-link`,
2581 `parent-post-author`.`name` AS `parent-author-name`,
2582 `parent-post-author`.`nick` AS `parent-author-nick`,
2583 `parent-post-author`.`network` AS `parent-author-network`
2585 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
2586 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
2587 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
2588 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
2589 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
2590 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2591 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2592 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
2593 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2594 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2595 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
2596 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
2597 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2598 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post`.`uri-id`
2599 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `post-thread`.`author-id`;
2602 -- VIEW post-thread-view
2604 DROP VIEW IF EXISTS `post-thread-view`;
2605 CREATE VIEW `post-thread-view` AS SELECT
2606 `item-uri`.`uri` AS `uri`,
2607 `post-thread`.`uri-id` AS `uri-id`,
2608 `parent-item-uri`.`uri` AS `parent-uri`,
2609 `post`.`parent-uri-id` AS `parent-uri-id`,
2610 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2611 `post`.`thr-parent-id` AS `thr-parent-id`,
2612 `conversation-item-uri`.`uri` AS `conversation`,
2613 `post-thread`.`conversation-id` AS `conversation-id`,
2614 `quote-item-uri`.`uri` AS `quote-uri`,
2615 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2616 `item-uri`.`guid` AS `guid`,
2617 `post`.`gravity` AS `gravity`,
2618 `external-item-uri`.`uri` AS `extid`,
2619 `post`.`external-id` AS `external-id`,
2620 `post-thread`.`created` AS `created`,
2621 `post`.`edited` AS `edited`,
2622 `post-thread`.`commented` AS `commented`,
2623 `post-thread`.`received` AS `received`,
2624 `post-thread`.`changed` AS `changed`,
2625 `post`.`post-type` AS `post-type`,
2626 `post`.`private` AS `private`,
2627 `post`.`visible` AS `visible`,
2628 `post`.`deleted` AS `deleted`,
2629 `post`.`global` AS `global`,
2630 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread`.`uri-id`) AS `featured`,
2631 `post-thread`.`network` AS `network`,
2632 `post`.`vid` AS `vid`,
2633 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2634 `post-content`.`title` AS `title`,
2635 `post-content`.`content-warning` AS `content-warning`,
2636 `post-content`.`raw-body` AS `raw-body`,
2637 `post-content`.`body` AS `body`,
2638 `post-content`.`rendered-hash` AS `rendered-hash`,
2639 `post-content`.`rendered-html` AS `rendered-html`,
2640 `post-content`.`language` AS `language`,
2641 `post-content`.`plink` AS `plink`,
2642 `post-content`.`location` AS `location`,
2643 `post-content`.`coord` AS `coord`,
2644 `post-content`.`app` AS `app`,
2645 `post-content`.`object-type` AS `object-type`,
2646 `post-content`.`object` AS `object`,
2647 `post-content`.`target-type` AS `target-type`,
2648 `post-content`.`target` AS `target`,
2649 `post-content`.`resource-id` AS `resource-id`,
2650 `post-thread`.`author-id` AS `contact-id`,
2651 `author`.`uri-id` AS `contact-uri-id`,
2652 `author`.`url` AS `contact-link`,
2653 `author`.`addr` AS `contact-addr`,
2654 `author`.`name` AS `contact-name`,
2655 `author`.`nick` AS `contact-nick`,
2656 `author`.`thumb` AS `contact-avatar`,
2657 `author`.`network` AS `contact-network`,
2658 `author`.`blocked` AS `contact-blocked`,
2659 `author`.`hidden` AS `contact-hidden`,
2660 `author`.`readonly` AS `contact-readonly`,
2661 `author`.`archive` AS `contact-archive`,
2662 `author`.`pending` AS `contact-pending`,
2663 `author`.`rel` AS `contact-rel`,
2664 `author`.`uid` AS `contact-uid`,
2665 `author`.`contact-type` AS `contact-contact-type`,
2666 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2668 `author`.`id` AS `cid`,
2669 `author`.`alias` AS `alias`,
2670 `author`.`photo` AS `photo`,
2671 `author`.`name-date` AS `name-date`,
2672 `author`.`uri-date` AS `uri-date`,
2673 `author`.`avatar-date` AS `avatar-date`,
2674 `author`.`thumb` AS `thumb`,
2675 `post-thread`.`author-id` AS `author-id`,
2676 `author`.`uri-id` AS `author-uri-id`,
2677 `author`.`url` AS `author-link`,
2678 `author`.`addr` AS `author-addr`,
2679 `author`.`name` AS `author-name`,
2680 `author`.`nick` AS `author-nick`,
2681 `author`.`alias` AS `author-alias`,
2682 `author`.`thumb` AS `author-avatar`,
2683 `author`.`network` AS `author-network`,
2684 `author`.`blocked` AS `author-blocked`,
2685 `author`.`hidden` AS `author-hidden`,
2686 `author`.`updated` AS `author-updated`,
2687 `author`.`contact-type` AS `author-contact-type`,
2688 `author`.`gsid` AS `author-gsid`,
2689 `post-thread`.`owner-id` AS `owner-id`,
2690 `owner`.`uri-id` AS `owner-uri-id`,
2691 `owner`.`url` AS `owner-link`,
2692 `owner`.`addr` AS `owner-addr`,
2693 `owner`.`name` AS `owner-name`,
2694 `owner`.`nick` AS `owner-nick`,
2695 `owner`.`alias` AS `owner-alias`,
2696 `owner`.`thumb` AS `owner-avatar`,
2697 `owner`.`network` AS `owner-network`,
2698 `owner`.`blocked` AS `owner-blocked`,
2699 `owner`.`hidden` AS `owner-hidden`,
2700 `owner`.`updated` AS `owner-updated`,
2701 `owner`.`gsid` AS `owner-gsid`,
2702 `owner`.`contact-type` AS `owner-contact-type`,
2703 `post-thread`.`causer-id` AS `causer-id`,
2704 `causer`.`uri-id` AS `causer-uri-id`,
2705 `causer`.`url` AS `causer-link`,
2706 `causer`.`addr` AS `causer-addr`,
2707 `causer`.`name` AS `causer-name`,
2708 `causer`.`nick` AS `causer-nick`,
2709 `causer`.`alias` AS `causer-alias`,
2710 `causer`.`thumb` AS `causer-avatar`,
2711 `causer`.`network` AS `causer-network`,
2712 `causer`.`blocked` AS `causer-blocked`,
2713 `causer`.`hidden` AS `causer-hidden`,
2714 `causer`.`gsid` AS `causer-gsid`,
2715 `causer`.`contact-type` AS `causer-contact-type`,
2716 `post-question`.`id` AS `question-id`,
2717 `post-question`.`multiple` AS `question-multiple`,
2718 `post-question`.`voters` AS `question-voters`,
2719 `post-question`.`end-time` AS `question-end-time`,
2720 0 AS `has-categories`,
2721 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread`.`uri-id`) AS `has-media`,
2722 (SELECT COUNT(*) FROM `post` WHERE `parent-uri-id` = `post-thread`.`uri-id` AND `gravity` = 6) AS `total-comments`,
2723 (SELECT COUNT(DISTINCT(`author-id`)) FROM `post` WHERE `parent-uri-id` = `post-thread`.`uri-id` AND `gravity` = 6) AS `total-actors`,
2724 `diaspora-interaction`.`interaction` AS `signed_text`,
2725 `parent-item-uri`.`guid` AS `parent-guid`,
2726 `post-thread`.`network` AS `parent-network`,
2727 `post-thread`.`author-id` AS `parent-author-id`,
2728 `author`.`url` AS `parent-author-link`,
2729 `author`.`name` AS `parent-author-name`,
2730 `author`.`nick` AS `parent-author-nick`,
2731 `author`.`network` AS `parent-author-network`
2733 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
2734 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
2735 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
2736 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
2737 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
2738 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2739 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2740 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
2741 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2742 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2743 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
2744 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
2745 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2746 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread`.`uri-id`;
2749 -- VIEW category-view
2751 DROP VIEW IF EXISTS `category-view`;
2752 CREATE VIEW `category-view` AS SELECT
2753 `post-category`.`uri-id` AS `uri-id`,
2754 `post-category`.`uid` AS `uid`,
2755 `post-category`.`type` AS `type`,
2756 `post-category`.`tid` AS `tid`,
2757 `tag`.`name` AS `name`,
2758 `tag`.`url` AS `url`
2759 FROM `post-category`
2760 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2763 -- VIEW collection-view
2765 DROP VIEW IF EXISTS `collection-view`;
2766 CREATE VIEW `collection-view` AS SELECT
2767 `post-collection`.`uri-id` AS `uri-id`,
2768 `post-collection`.`type` AS `type`,
2769 `post-collection`.`author-id` AS `cid`,
2770 `post`.`received` AS `received`,
2771 `post`.`created` AS `created`,
2772 `post-thread`.`commented` AS `commented`,
2773 `post`.`private` AS `private`,
2774 `post`.`visible` AS `visible`,
2775 `post`.`deleted` AS `deleted`,
2776 `post`.`thr-parent-id` AS `thr-parent-id`,
2777 `post-collection`.`author-id` AS `author-id`,
2778 `post`.`gravity` AS `gravity`
2779 FROM `post-collection`
2780 INNER JOIN `post` ON `post-collection`.`uri-id` = `post`.`uri-id`
2781 INNER JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`;
2786 DROP VIEW IF EXISTS `media-view`;
2787 CREATE VIEW `media-view` AS SELECT
2788 `post-media`.`uri-id` AS `uri-id`,
2789 `post-media`.`type` AS `type`,
2790 `post`.`received` AS `received`,
2791 `post`.`created` AS `created`,
2792 `post`.`private` AS `private`,
2793 `post`.`visible` AS `visible`,
2794 `post`.`deleted` AS `deleted`,
2795 `post`.`thr-parent-id` AS `thr-parent-id`,
2796 `post`.`author-id` AS `author-id`,
2797 `post`.`gravity` AS `gravity`
2799 INNER JOIN `post` ON `post-media`.`uri-id` = `post`.`uri-id`;
2804 DROP VIEW IF EXISTS `tag-view`;
2805 CREATE VIEW `tag-view` AS SELECT
2806 `post-tag`.`uri-id` AS `uri-id`,
2807 `post-tag`.`type` AS `type`,
2808 `post-tag`.`tid` AS `tid`,
2809 `post-tag`.`cid` AS `cid`,
2810 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2811 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`,
2812 CASE `cid` WHEN 0 THEN `tag`.`type` ELSE 1 END AS `tag-type`
2814 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2815 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2818 -- VIEW network-item-view
2820 DROP VIEW IF EXISTS `network-item-view`;
2821 CREATE VIEW `network-item-view` AS SELECT
2822 `post-user`.`uri-id` AS `uri-id`,
2823 `post-thread-user`.`post-user-id` AS `parent`,
2824 `post-user`.`received` AS `received`,
2825 `post-thread-user`.`commented` AS `commented`,
2826 `post-user`.`created` AS `created`,
2827 `post-user`.`uid` AS `uid`,
2828 `post-thread-user`.`starred` AS `starred`,
2829 `post-thread-user`.`mention` AS `mention`,
2830 `post-user`.`network` AS `network`,
2831 `post-user`.`unseen` AS `unseen`,
2832 `post-user`.`gravity` AS `gravity`,
2833 `post-user`.`contact-id` AS `contact-id`,
2834 `ownercontact`.`contact-type` AS `contact-type`
2836 INNER JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2837 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2838 STRAIGHT_JOIN `contact` AS `authorcontact` ON `authorcontact`.`id` = `post-thread-user`.`author-id`
2839 STRAIGHT_JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2840 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2841 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2842 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
2843 AND NOT `authorcontact`.`blocked` AND NOT `ownercontact`.`blocked`
2844 AND NOT EXISTS(SELECT `cid` FROM `user-contact` WHERE `uid` = `post-thread-user`.`uid` AND `cid` IN (`authorcontact`.`id`, `ownercontact`.`id`) AND (`blocked` OR `ignored`))
2845 AND NOT EXISTS(SELECT `gsid` FROM `user-gserver` WHERE `uid` = `post-thread-user`.`uid` AND `gsid` IN (`authorcontact`.`gsid`, `ownercontact`.`gsid`) AND `ignored`);
2848 -- VIEW network-thread-view
2850 DROP VIEW IF EXISTS `network-thread-view`;
2851 CREATE VIEW `network-thread-view` AS SELECT
2852 `post-thread-user`.`uri-id` AS `uri-id`,
2853 `post-thread-user`.`post-user-id` AS `parent`,
2854 `post-thread-user`.`received` AS `received`,
2855 `post-thread-user`.`commented` AS `commented`,
2856 `post-thread-user`.`created` AS `created`,
2857 `post-thread-user`.`uid` AS `uid`,
2858 `post-thread-user`.`starred` AS `starred`,
2859 `post-thread-user`.`mention` AS `mention`,
2860 `post-thread-user`.`network` AS `network`,
2861 `post-thread-user`.`contact-id` AS `contact-id`,
2862 `ownercontact`.`contact-type` AS `contact-type`
2863 FROM `post-thread-user`
2864 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2865 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2866 STRAIGHT_JOIN `contact` AS `authorcontact` ON `authorcontact`.`id` = `post-thread-user`.`author-id`
2867 STRAIGHT_JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2868 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2869 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2870 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2871 AND NOT `authorcontact`.`blocked` AND NOT `ownercontact`.`blocked`
2872 AND NOT EXISTS(SELECT `cid` FROM `user-contact` WHERE `uid` = `post-thread-user`.`uid` AND `cid` IN (`authorcontact`.`id`, `ownercontact`.`id`) AND (`blocked` OR `ignored`))
2873 AND NOT EXISTS(SELECT `gsid` FROM `user-gserver` WHERE `uid` = `post-thread-user`.`uid` AND `gsid` IN (`authorcontact`.`gsid`, `ownercontact`.`gsid`) AND `ignored`);
2878 DROP VIEW IF EXISTS `owner-view`;
2879 CREATE VIEW `owner-view` AS SELECT
2880 `contact`.`id` AS `id`,
2881 `contact`.`uid` AS `uid`,
2882 `contact`.`created` AS `created`,
2883 `contact`.`updated` AS `updated`,
2884 `contact`.`self` AS `self`,
2885 `contact`.`remote_self` AS `remote_self`,
2886 `contact`.`rel` AS `rel`,
2887 `contact`.`network` AS `network`,
2888 `contact`.`protocol` AS `protocol`,
2889 `contact`.`name` AS `name`,
2890 `contact`.`nick` AS `nick`,
2891 `contact`.`location` AS `location`,
2892 `contact`.`about` AS `about`,
2893 `contact`.`keywords` AS `keywords`,
2894 `contact`.`xmpp` AS `xmpp`,
2895 `contact`.`matrix` AS `matrix`,
2896 `contact`.`attag` AS `attag`,
2897 `contact`.`avatar` AS `avatar`,
2898 `contact`.`photo` AS `photo`,
2899 `contact`.`thumb` AS `thumb`,
2900 `contact`.`micro` AS `micro`,
2901 `contact`.`header` AS `header`,
2902 `contact`.`url` AS `url`,
2903 `contact`.`nurl` AS `nurl`,
2904 `contact`.`uri-id` AS `uri-id`,
2905 `contact`.`addr` AS `addr`,
2906 `contact`.`alias` AS `alias`,
2907 `contact`.`pubkey` AS `pubkey`,
2908 `contact`.`prvkey` AS `prvkey`,
2909 `contact`.`batch` AS `batch`,
2910 `contact`.`request` AS `request`,
2911 `contact`.`notify` AS `notify`,
2912 `contact`.`poll` AS `poll`,
2913 `contact`.`confirm` AS `confirm`,
2914 `contact`.`poco` AS `poco`,
2915 `contact`.`subhub` AS `subhub`,
2916 `contact`.`hub-verify` AS `hub-verify`,
2917 `contact`.`last-update` AS `last-update`,
2918 `contact`.`success_update` AS `success_update`,
2919 `contact`.`failure_update` AS `failure_update`,
2920 `contact`.`name-date` AS `name-date`,
2921 `contact`.`uri-date` AS `uri-date`,
2922 `contact`.`avatar-date` AS `avatar-date`,
2923 `contact`.`avatar-date` AS `picdate`,
2924 `contact`.`term-date` AS `term-date`,
2925 `contact`.`last-item` AS `last-item`,
2926 `contact`.`priority` AS `priority`,
2927 `user`.`blocked` AS `blocked`,
2928 `contact`.`block_reason` AS `block_reason`,
2929 `contact`.`readonly` AS `readonly`,
2930 `contact`.`writable` AS `writable`,
2931 `contact`.`forum` AS `forum`,
2932 `contact`.`prv` AS `prv`,
2933 `contact`.`contact-type` AS `contact-type`,
2934 `contact`.`manually-approve` AS `manually-approve`,
2935 `contact`.`hidden` AS `hidden`,
2936 `contact`.`archive` AS `archive`,
2937 `contact`.`pending` AS `pending`,
2938 `contact`.`deleted` AS `deleted`,
2939 `contact`.`unsearchable` AS `unsearchable`,
2940 `contact`.`sensitive` AS `sensitive`,
2941 `contact`.`baseurl` AS `baseurl`,
2942 `contact`.`reason` AS `reason`,
2943 `contact`.`info` AS `info`,
2944 `contact`.`bdyear` AS `bdyear`,
2945 `contact`.`bd` AS `bd`,
2946 `contact`.`notify_new_posts` AS `notify_new_posts`,
2947 `contact`.`fetch_further_information` AS `fetch_further_information`,
2948 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2949 `user`.`parent-uid` AS `parent-uid`,
2950 `user`.`guid` AS `guid`,
2951 `user`.`nickname` AS `nickname`,
2952 `user`.`email` AS `email`,
2953 `user`.`openid` AS `openid`,
2954 `user`.`timezone` AS `timezone`,
2955 `user`.`language` AS `language`,
2956 `user`.`register_date` AS `register_date`,
2957 `user`.`login_date` AS `login_date`,
2958 `user`.`last-activity` AS `last-activity`,
2959 `user`.`default-location` AS `default-location`,
2960 `user`.`allow_location` AS `allow_location`,
2961 `user`.`theme` AS `theme`,
2962 `user`.`pubkey` AS `upubkey`,
2963 `user`.`prvkey` AS `uprvkey`,
2964 `user`.`sprvkey` AS `sprvkey`,
2965 `user`.`spubkey` AS `spubkey`,
2966 `user`.`verified` AS `verified`,
2967 `user`.`blockwall` AS `blockwall`,
2968 `user`.`hidewall` AS `hidewall`,
2969 `user`.`blocktags` AS `blocktags`,
2970 `user`.`unkmail` AS `unkmail`,
2971 `user`.`cntunkmail` AS `cntunkmail`,
2972 `user`.`notify-flags` AS `notify-flags`,
2973 `user`.`page-flags` AS `page-flags`,
2974 `user`.`account-type` AS `account-type`,
2975 `user`.`prvnets` AS `prvnets`,
2976 `user`.`maxreq` AS `maxreq`,
2977 `user`.`expire` AS `expire`,
2978 `user`.`account_removed` AS `account_removed`,
2979 `user`.`account_expired` AS `account_expired`,
2980 `user`.`account_expires_on` AS `account_expires_on`,
2981 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2982 `user`.`def_gid` AS `def_gid`,
2983 `user`.`allow_cid` AS `allow_cid`,
2984 `user`.`allow_gid` AS `allow_gid`,
2985 `user`.`deny_cid` AS `deny_cid`,
2986 `user`.`deny_gid` AS `deny_gid`,
2987 `user`.`openidserver` AS `openidserver`,
2988 `profile`.`publish` AS `publish`,
2989 `profile`.`net-publish` AS `net-publish`,
2990 `profile`.`hide-friends` AS `hide-friends`,
2991 `profile`.`prv_keywords` AS `prv_keywords`,
2992 `profile`.`pub_keywords` AS `pub_keywords`,
2993 `profile`.`address` AS `address`,
2994 `profile`.`locality` AS `locality`,
2995 `profile`.`region` AS `region`,
2996 `profile`.`postal-code` AS `postal-code`,
2997 `profile`.`country-name` AS `country-name`,
2998 `profile`.`homepage` AS `homepage`,
2999 `profile`.`homepage_verified` AS `homepage_verified`,
3000 `profile`.`dob` AS `dob`
3002 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
3003 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
3006 -- VIEW account-view
3008 DROP VIEW IF EXISTS `account-view`;
3009 CREATE VIEW `account-view` AS SELECT
3010 `contact`.`id` AS `id`,
3011 `contact`.`url` AS `url`,
3012 `contact`.`nurl` AS `nurl`,
3013 `contact`.`uri-id` AS `uri-id`,
3014 `item-uri`.`guid` AS `guid`,
3015 `contact`.`addr` AS `addr`,
3016 `contact`.`alias` AS `alias`,
3017 `contact`.`name` AS `name`,
3018 `contact`.`nick` AS `nick`,
3019 `contact`.`about` AS `about`,
3020 `contact`.`keywords` AS `keywords`,
3021 `contact`.`xmpp` AS `xmpp`,
3022 `contact`.`matrix` AS `matrix`,
3023 `contact`.`avatar` AS `avatar`,
3024 `contact`.`photo` AS `photo`,
3025 `contact`.`thumb` AS `thumb`,
3026 `contact`.`micro` AS `micro`,
3027 `contact`.`header` AS `header`,
3028 `contact`.`created` AS `created`,
3029 `contact`.`updated` AS `updated`,
3030 `contact`.`network` AS `network`,
3031 `contact`.`protocol` AS `protocol`,
3032 `contact`.`location` AS `location`,
3033 `contact`.`attag` AS `attag`,
3034 `contact`.`pubkey` AS `pubkey`,
3035 `contact`.`prvkey` AS `prvkey`,
3036 `contact`.`subscribe` AS `subscribe`,
3037 `contact`.`last-update` AS `last-update`,
3038 `contact`.`success_update` AS `success_update`,
3039 `contact`.`failure_update` AS `failure_update`,
3040 `contact`.`failed` AS `failed`,
3041 `contact`.`last-item` AS `last-item`,
3042 `contact`.`last-discovery` AS `last-discovery`,
3043 `contact`.`contact-type` AS `contact-type`,
3044 `contact`.`manually-approve` AS `manually-approve`,
3045 `contact`.`unsearchable` AS `unsearchable`,
3046 `contact`.`sensitive` AS `sensitive`,
3047 `contact`.`baseurl` AS `baseurl`,
3048 `contact`.`gsid` AS `gsid`,
3049 `contact`.`info` AS `info`,
3050 `contact`.`bdyear` AS `bdyear`,
3051 `contact`.`bd` AS `bd`,
3052 `contact`.`poco` AS `poco`,
3053 `contact`.`name-date` AS `name-date`,
3054 `contact`.`uri-date` AS `uri-date`,
3055 `contact`.`avatar-date` AS `avatar-date`,
3056 `contact`.`term-date` AS `term-date`,
3057 `contact`.`hidden` AS `global-ignored`,
3058 `contact`.`blocked` AS `global-blocked`,
3059 `contact`.`hidden` AS `hidden`,
3060 `contact`.`archive` AS `archive`,
3061 `contact`.`deleted` AS `deleted`,
3062 `contact`.`blocked` AS `blocked`,
3063 `contact`.`notify` AS `dfrn-notify`,
3064 `contact`.`poll` AS `dfrn-poll`,
3065 `item-uri`.`guid` AS `diaspora-guid`,
3066 `diaspora-contact`.`batch` AS `diaspora-batch`,
3067 `diaspora-contact`.`notify` AS `diaspora-notify`,
3068 `diaspora-contact`.`poll` AS `diaspora-poll`,
3069 `diaspora-contact`.`alias` AS `diaspora-alias`,
3070 `apcontact`.`uuid` AS `ap-uuid`,
3071 `apcontact`.`type` AS `ap-type`,
3072 `apcontact`.`following` AS `ap-following`,
3073 `apcontact`.`followers` AS `ap-followers`,
3074 `apcontact`.`inbox` AS `ap-inbox`,
3075 `apcontact`.`outbox` AS `ap-outbox`,
3076 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
3077 `apcontact`.`generator` AS `ap-generator`,
3078 `apcontact`.`following_count` AS `ap-following_count`,
3079 `apcontact`.`followers_count` AS `ap-followers_count`,
3080 `apcontact`.`statuses_count` AS `ap-statuses_count`,
3081 `gserver`.`site_name` AS `site_name`,
3082 `gserver`.`platform` AS `platform`,
3083 `gserver`.`version` AS `version`,
3084 `gserver`.`blocked` AS `server-blocked`,
3085 `gserver`.`failed` AS `server-failed`
3087 LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id`
3088 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
3089 LEFT JOIN `diaspora-contact` ON `diaspora-contact`.`uri-id` = contact.`uri-id`
3090 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`
3091 WHERE `contact`.`uid` = 0;
3094 -- VIEW account-user-view
3096 DROP VIEW IF EXISTS `account-user-view`;
3097 CREATE VIEW `account-user-view` AS SELECT
3098 `ucontact`.`id` AS `id`,
3099 `contact`.`id` AS `pid`,
3100 `ucontact`.`uid` AS `uid`,
3101 `contact`.`url` AS `url`,
3102 `contact`.`nurl` AS `nurl`,
3103 `contact`.`uri-id` AS `uri-id`,
3104 `item-uri`.`guid` AS `guid`,
3105 `contact`.`addr` AS `addr`,
3106 `contact`.`alias` AS `alias`,
3107 `contact`.`name` AS `name`,
3108 `contact`.`nick` AS `nick`,
3109 `contact`.`about` AS `about`,
3110 `contact`.`keywords` AS `keywords`,
3111 `contact`.`xmpp` AS `xmpp`,
3112 `contact`.`matrix` AS `matrix`,
3113 `contact`.`avatar` AS `avatar`,
3114 `contact`.`photo` AS `photo`,
3115 `contact`.`thumb` AS `thumb`,
3116 `contact`.`micro` AS `micro`,
3117 `contact`.`header` AS `header`,
3118 `contact`.`created` AS `created`,
3119 `contact`.`updated` AS `updated`,
3120 `ucontact`.`self` AS `self`,
3121 `ucontact`.`remote_self` AS `remote_self`,
3122 `ucontact`.`rel` AS `rel`,
3123 `contact`.`network` AS `network`,
3124 `ucontact`.`protocol` AS `protocol`,
3125 `contact`.`location` AS `location`,
3126 `ucontact`.`attag` AS `attag`,
3127 `contact`.`pubkey` AS `pubkey`,
3128 `contact`.`prvkey` AS `prvkey`,
3129 `contact`.`subscribe` AS `subscribe`,
3130 `contact`.`last-update` AS `last-update`,
3131 `contact`.`success_update` AS `success_update`,
3132 `contact`.`failure_update` AS `failure_update`,
3133 `contact`.`failed` AS `failed`,
3134 `contact`.`last-item` AS `last-item`,
3135 `contact`.`last-discovery` AS `last-discovery`,
3136 `contact`.`contact-type` AS `contact-type`,
3137 `contact`.`manually-approve` AS `manually-approve`,
3138 `contact`.`unsearchable` AS `unsearchable`,
3139 `contact`.`sensitive` AS `sensitive`,
3140 `contact`.`baseurl` AS `baseurl`,
3141 `contact`.`gsid` AS `gsid`,
3142 `ucontact`.`info` AS `info`,
3143 `contact`.`bdyear` AS `bdyear`,
3144 `contact`.`bd` AS `bd`,
3145 `contact`.`poco` AS `poco`,
3146 `contact`.`name-date` AS `name-date`,
3147 `contact`.`uri-date` AS `uri-date`,
3148 `contact`.`avatar-date` AS `avatar-date`,
3149 `contact`.`term-date` AS `term-date`,
3150 `contact`.`hidden` AS `global-ignored`,
3151 `contact`.`blocked` AS `global-blocked`,
3152 `ucontact`.`hidden` AS `hidden`,
3153 `ucontact`.`archive` AS `archive`,
3154 `ucontact`.`pending` AS `pending`,
3155 `ucontact`.`deleted` AS `deleted`,
3156 `ucontact`.`notify_new_posts` AS `notify_new_posts`,
3157 `ucontact`.`fetch_further_information` AS `fetch_further_information`,
3158 `ucontact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
3159 `ucontact`.`rating` AS `rating`,
3160 `ucontact`.`readonly` AS `readonly`,
3161 `ucontact`.`blocked` AS `blocked`,
3162 `ucontact`.`block_reason` AS `block_reason`,
3163 `ucontact`.`subhub` AS `subhub`,
3164 `ucontact`.`hub-verify` AS `hub-verify`,
3165 `ucontact`.`reason` AS `reason`,
3166 `contact`.`notify` AS `dfrn-notify`,
3167 `contact`.`poll` AS `dfrn-poll`,
3168 `item-uri`.`guid` AS `diaspora-guid`,
3169 `diaspora-contact`.`batch` AS `diaspora-batch`,
3170 `diaspora-contact`.`notify` AS `diaspora-notify`,
3171 `diaspora-contact`.`poll` AS `diaspora-poll`,
3172 `diaspora-contact`.`alias` AS `diaspora-alias`,
3173 `diaspora-contact`.`interacting_count` AS `diaspora-interacting_count`,
3174 `diaspora-contact`.`interacted_count` AS `diaspora-interacted_count`,
3175 `diaspora-contact`.`post_count` AS `diaspora-post_count`,
3176 `apcontact`.`uuid` AS `ap-uuid`,
3177 `apcontact`.`type` AS `ap-type`,
3178 `apcontact`.`following` AS `ap-following`,
3179 `apcontact`.`followers` AS `ap-followers`,
3180 `apcontact`.`inbox` AS `ap-inbox`,
3181 `apcontact`.`outbox` AS `ap-outbox`,
3182 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
3183 `apcontact`.`generator` AS `ap-generator`,
3184 `apcontact`.`following_count` AS `ap-following_count`,
3185 `apcontact`.`followers_count` AS `ap-followers_count`,
3186 `apcontact`.`statuses_count` AS `ap-statuses_count`,
3187 `gserver`.`site_name` AS `site_name`,
3188 `gserver`.`platform` AS `platform`,
3189 `gserver`.`version` AS `version`,
3190 `gserver`.`blocked` AS `server-blocked`,
3191 `gserver`.`failed` AS `server-failed`
3192 FROM `contact` AS `ucontact`
3193 INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
3194 LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id`
3195 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
3196 LEFT JOIN `diaspora-contact` ON `diaspora-contact`.`uri-id` = `ucontact`.`uri-id`
3197 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`;
3200 -- VIEW pending-view
3202 DROP VIEW IF EXISTS `pending-view`;
3203 CREATE VIEW `pending-view` AS SELECT
3204 `register`.`id` AS `id`,
3205 `register`.`hash` AS `hash`,
3206 `register`.`created` AS `created`,
3207 `register`.`uid` AS `uid`,
3208 `register`.`password` AS `password`,
3209 `register`.`language` AS `language`,
3210 `register`.`note` AS `note`,
3211 `contact`.`self` AS `self`,
3212 `contact`.`name` AS `name`,
3213 `contact`.`url` AS `url`,
3214 `contact`.`micro` AS `micro`,
3215 `user`.`email` AS `email`,
3216 `contact`.`nick` AS `nick`
3218 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
3219 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
3222 -- VIEW tag-search-view
3224 DROP VIEW IF EXISTS `tag-search-view`;
3225 CREATE VIEW `tag-search-view` AS SELECT
3226 `post-tag`.`uri-id` AS `uri-id`,
3227 `post-user`.`uid` AS `uid`,
3228 `post-user`.`id` AS `iid`,
3229 `post-user`.`private` AS `private`,
3230 `post-user`.`wall` AS `wall`,
3231 `post-user`.`origin` AS `origin`,
3232 `post-user`.`global` AS `global`,
3233 `post-user`.`gravity` AS `gravity`,
3234 `post-user`.`received` AS `received`,
3235 `post-user`.`network` AS `network`,
3236 `post-user`.`author-id` AS `author-id`,
3237 `tag`.`name` AS `name`
3239 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
3240 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
3241 WHERE `post-tag`.`type` = 1;
3244 -- VIEW workerqueue-view
3246 DROP VIEW IF EXISTS `workerqueue-view`;
3247 CREATE VIEW `workerqueue-view` AS SELECT
3248 `process`.`pid` AS `pid`,
3249 `workerqueue`.`priority` AS `priority`
3251 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
3252 WHERE NOT `workerqueue`.`done`;
3255 -- VIEW profile_field-view
3257 DROP VIEW IF EXISTS `profile_field-view`;
3258 CREATE VIEW `profile_field-view` AS SELECT
3259 `profile_field`.`id` AS `id`,
3260 `profile_field`.`uid` AS `uid`,
3261 `profile_field`.`label` AS `label`,
3262 `profile_field`.`value` AS `value`,
3263 `profile_field`.`order` AS `order`,
3264 `profile_field`.`psid` AS `psid`,
3265 `permissionset`.`allow_cid` AS `allow_cid`,
3266 `permissionset`.`allow_gid` AS `allow_gid`,
3267 `permissionset`.`deny_cid` AS `deny_cid`,
3268 `permissionset`.`deny_gid` AS `deny_gid`,
3269 `profile_field`.`created` AS `created`,
3270 `profile_field`.`edited` AS `edited`
3271 FROM `profile_field`
3272 INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`;
3275 -- VIEW diaspora-contact-view
3277 DROP VIEW IF EXISTS `diaspora-contact-view`;
3278 CREATE VIEW `diaspora-contact-view` AS SELECT
3279 `diaspora-contact`.`uri-id` AS `uri-id`,
3280 `item-uri`.`uri` AS `url`,
3281 `item-uri`.`guid` AS `guid`,
3282 `diaspora-contact`.`addr` AS `addr`,
3283 `diaspora-contact`.`alias` AS `alias`,
3284 `diaspora-contact`.`nick` AS `nick`,
3285 `diaspora-contact`.`name` AS `name`,
3286 `diaspora-contact`.`given-name` AS `given-name`,
3287 `diaspora-contact`.`family-name` AS `family-name`,
3288 `diaspora-contact`.`photo` AS `photo`,
3289 `diaspora-contact`.`photo-medium` AS `photo-medium`,
3290 `diaspora-contact`.`photo-small` AS `photo-small`,
3291 `diaspora-contact`.`batch` AS `batch`,
3292 `diaspora-contact`.`notify` AS `notify`,
3293 `diaspora-contact`.`poll` AS `poll`,
3294 `diaspora-contact`.`subscribe` AS `subscribe`,
3295 `diaspora-contact`.`searchable` AS `searchable`,
3296 `diaspora-contact`.`pubkey` AS `pubkey`,
3297 `gserver`.`url` AS `baseurl`,
3298 `diaspora-contact`.`gsid` AS `gsid`,
3299 `diaspora-contact`.`created` AS `created`,
3300 `diaspora-contact`.`updated` AS `updated`,
3301 `diaspora-contact`.`interacting_count` AS `interacting_count`,
3302 `diaspora-contact`.`interacted_count` AS `interacted_count`,
3303 `diaspora-contact`.`post_count` AS `post_count`
3304 FROM `diaspora-contact`
3305 INNER JOIN `item-uri` ON `item-uri`.`id` = `diaspora-contact`.`uri-id`
3306 LEFT JOIN `gserver` ON `gserver`.`id` = `diaspora-contact`.`gsid`;