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