1 -- ------------------------------------------
2 -- Friendica 2023.09-dev (Giant Rhubarb)
3 -- DB_UPDATE_VERSION 1535
4 -- ------------------------------------------
10 CREATE TABLE IF NOT EXISTS `gserver` (
11 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
12 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
13 `nurl` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
14 `version` varchar(255) NOT NULL DEFAULT '' COMMENT '',
15 `site_name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
16 `info` text COMMENT '',
17 `register_policy` tinyint NOT NULL DEFAULT 0 COMMENT '',
18 `registered-users` int unsigned NOT NULL DEFAULT 0 COMMENT 'Number of registered users',
19 `active-week-users` int unsigned COMMENT 'Number of active users in the last week',
20 `active-month-users` int unsigned COMMENT 'Number of active users in the last month',
21 `active-halfyear-users` int unsigned COMMENT 'Number of active users in the last six month',
22 `local-posts` int unsigned COMMENT 'Number of local posts',
23 `local-comments` int unsigned COMMENT 'Number of local comments',
24 `directory-type` tinyint DEFAULT 0 COMMENT 'Type of directory service (Poco, Mastodon)',
25 `poco` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
26 `noscrape` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
27 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
28 `protocol` tinyint unsigned COMMENT 'The protocol of the server',
29 `platform` varchar(255) NOT NULL DEFAULT '' COMMENT '',
30 `relay-subscribe` boolean NOT NULL DEFAULT '0' COMMENT 'Has the server subscribed to the relay system',
31 `relay-scope` varchar(10) NOT NULL DEFAULT '' COMMENT 'The scope of messages that the server wants to get',
32 `detection-method` tinyint unsigned COMMENT 'Method that had been used to detect that server',
33 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
34 `last_poco_query` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
35 `last_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Last successful connection request',
36 `last_failure` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Last failed connection request',
37 `blocked` boolean COMMENT 'Server is blocked',
38 `failed` boolean COMMENT 'Connection failed',
39 `next_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Next connection request',
41 UNIQUE INDEX `nurl` (`nurl`(190)),
42 INDEX `next_contact` (`next_contact`),
43 INDEX `network` (`network`)
44 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Global servers';
49 CREATE TABLE IF NOT EXISTS `user` (
50 `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
51 `parent-uid` mediumint unsigned COMMENT 'The parent user that has full control about this user',
52 `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
53 `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
54 `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
55 `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
56 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
57 `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
58 `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
59 `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
60 `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
61 `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
62 `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
63 `last-activity` date COMMENT 'Day of the last activity',
64 `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
65 `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
66 `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
67 `pubkey` text COMMENT 'RSA public key 4096 bit',
68 `prvkey` text COMMENT 'RSA private key 4096 bit',
69 `spubkey` text COMMENT '',
70 `sprvkey` text COMMENT '',
71 `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
72 `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
73 `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
74 `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unknown viewers',
75 `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
76 `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
77 `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
78 `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
79 `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
80 `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
81 `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
82 `pwdreset` varchar(255) COMMENT 'Password reset request token',
83 `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
84 `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
85 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT 'Delay in days before deleting user-related posts. Scope is controlled by pConfig.',
86 `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
87 `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
88 `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
89 `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
90 `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
91 `allow_cid` mediumtext COMMENT 'default permission for this user',
92 `allow_gid` mediumtext COMMENT 'default permission for this user',
93 `deny_cid` mediumtext COMMENT 'default permission for this user',
94 `deny_gid` mediumtext COMMENT 'default permission for this user',
95 `openidserver` text COMMENT '',
97 INDEX `nickname` (`nickname`(32)),
98 INDEX `parent-uid` (`parent-uid`),
99 INDEX `guid` (`guid`),
100 INDEX `email` (`email`(64)),
101 FOREIGN KEY (`parent-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
102 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
105 -- TABLE user-gserver
107 CREATE TABLE IF NOT EXISTS `user-gserver` (
108 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
109 `gsid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Gserver id',
110 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'server accounts are ignored for the user',
111 PRIMARY KEY(`uid`,`gsid`),
112 INDEX `gsid` (`gsid`),
113 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
114 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
115 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User settings about remote servers';
120 CREATE TABLE IF NOT EXISTS `item-uri` (
121 `id` int unsigned NOT NULL auto_increment,
122 `uri` varbinary(383) NOT NULL COMMENT 'URI of an item',
123 `guid` varbinary(255) COMMENT 'A unique identifier for an item',
125 UNIQUE INDEX `uri` (`uri`),
126 INDEX `guid` (`guid`)
127 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
132 CREATE TABLE IF NOT EXISTS `contact` (
133 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
134 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
135 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
136 `updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last contact update',
137 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network of the contact',
138 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
139 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
140 `location` varchar(255) DEFAULT '' COMMENT '',
141 `about` text COMMENT '',
142 `keywords` text COMMENT 'public keywords (interests) of the contact',
143 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
144 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
145 `avatar` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
146 `blurhash` varbinary(255) COMMENT 'BlurHash representation of the avatar',
147 `header` varbinary(383) COMMENT 'Header picture',
148 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
149 `nurl` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
150 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
151 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
152 `alias` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
153 `pubkey` text COMMENT 'RSA public key 4096 bit',
154 `prvkey` text COMMENT 'RSA private key 4096 bit',
155 `batch` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
156 `notify` varbinary(383) COMMENT '',
157 `poll` varbinary(383) COMMENT '',
158 `subscribe` varbinary(383) COMMENT '',
159 `last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
160 `next-update` datetime COMMENT 'Next connection request',
161 `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
162 `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
163 `failed` boolean COMMENT 'Connection failed',
164 `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
165 `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
166 `last-discovery` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last follower discovery',
167 `local-data` boolean COMMENT 'Is true when there are posts with this contact on the system',
168 `blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
169 `block_reason` text COMMENT 'Node-wide block reason',
170 `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
171 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Person, organisation, news, community, relay',
172 `manually-approve` boolean COMMENT 'Contact requests have to be approved manually',
173 `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
174 `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
175 `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
176 `baseurl` varbinary(383) DEFAULT '' COMMENT 'baseurl of the contact from the gserver record, can be missing',
177 `gsid` int unsigned COMMENT 'Global Server ID, can be missing',
178 `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
179 `reason` text COMMENT '',
180 `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
181 `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
182 `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
183 `protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
184 `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
185 `hub-verify` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
186 `rating` tinyint NOT NULL DEFAULT 0 COMMENT 'Automatically detected feed poll frequency',
187 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Feed poll priority',
188 `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
189 `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
190 `pending` boolean NOT NULL DEFAULT '1' COMMENT 'Contact request is pending',
191 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
192 `info` mediumtext COMMENT '',
193 `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
194 `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
195 `ffi_keyword_denylist` text COMMENT '',
196 `photo` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
197 `thumb` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
198 `micro` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
199 `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
200 `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
201 `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
202 `request` varbinary(383) COMMENT '',
203 `confirm` varbinary(383) COMMENT '',
204 `poco` varbinary(383) COMMENT '',
205 `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
206 `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a group. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = false instead',
207 `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = true instead',
208 `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
209 `site-pubkey` text COMMENT 'Deprecated',
210 `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
211 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
212 `issued-id` varbinary(383) NOT NULL DEFAULT '' COMMENT 'Deprecated',
213 `dfrn-id` varbinary(383) NOT NULL DEFAULT '' COMMENT 'Deprecated',
214 `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
215 `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
216 `usehub` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
217 `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT 'Deprecated',
218 `profile-id` int unsigned COMMENT 'Deprecated',
220 INDEX `uid_name` (`uid`,`name`(190)),
221 INDEX `self_uid` (`self`,`uid`),
222 INDEX `alias_uid` (`alias`(128),`uid`),
223 INDEX `pending_uid` (`pending`,`uid`),
224 INDEX `blocked_uid` (`blocked`,`uid`),
225 INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
226 INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
227 INDEX `batch_contact-type` (`batch`(64),`contact-type`),
228 INDEX `addr_uid` (`addr`(128),`uid`),
229 INDEX `nurl_uid` (`nurl`(128),`uid`),
230 INDEX `nick_uid` (`nick`(128),`uid`),
231 INDEX `attag_uid` (`attag`(96),`uid`),
232 INDEX `network_uid_lastupdate` (`network`,`uid`,`last-update`),
233 INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`),
234 INDEX `next-update` (`next-update`),
235 INDEX `local-data-next-update` (`local-data`,`next-update`),
236 INDEX `uid_lastitem` (`uid`,`last-item`),
237 INDEX `baseurl` (`baseurl`(64)),
238 INDEX `uid_contact-type` (`uid`,`contact-type`),
239 INDEX `uid_self_contact-type` (`uid`,`self`,`contact-type`),
240 INDEX `self_network_uid` (`self`,`network`,`uid`),
241 INDEX `gsid_uid_failed` (`gsid`,`uid`,`failed`),
242 INDEX `uri-id` (`uri-id`),
243 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
244 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
245 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
246 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
251 CREATE TABLE IF NOT EXISTS `tag` (
252 `id` int unsigned NOT NULL auto_increment COMMENT '',
253 `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
254 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
255 `type` tinyint unsigned COMMENT 'Type of the tag (Unknown, General Collection, Follower Collection or Account)',
257 UNIQUE INDEX `type_name_url` (`name`,`url`),
259 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
262 -- TABLE permissionset
264 CREATE TABLE IF NOT EXISTS `permissionset` (
265 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
266 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
267 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
268 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed circles',
269 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
270 `deny_gid` mediumtext COMMENT 'Access Control - list of denied circles',
272 INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`uid`,`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30)),
273 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
274 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
279 CREATE TABLE IF NOT EXISTS `verb` (
280 `id` smallint unsigned NOT NULL auto_increment,
281 `name` varchar(100) NOT NULL DEFAULT '' COMMENT '',
283 INDEX `name` (`name`)
284 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activity Verbs';
287 -- TABLE 2fa_app_specific_password
289 CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
290 `id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
291 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
292 `description` varchar(255) COMMENT 'Description of the usage of the password',
293 `hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
294 `generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
295 `last_used` datetime COMMENT 'Datetime the password was last used',
297 INDEX `uid_description` (`uid`,`description`(190)),
298 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
299 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
302 -- TABLE 2fa_recovery_codes
304 CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
305 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
306 `code` varchar(50) NOT NULL COMMENT 'Recovery code string',
307 `generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
308 `used` datetime COMMENT 'Datetime the code was used',
309 PRIMARY KEY(`uid`,`code`),
310 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
311 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
314 -- TABLE 2fa_trusted_browser
316 CREATE TABLE IF NOT EXISTS `2fa_trusted_browser` (
317 `cookie_hash` varchar(80) NOT NULL COMMENT 'Trusted cookie hash',
318 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
319 `user_agent` text COMMENT 'User agent string',
320 `trusted` boolean NOT NULL DEFAULT '1' COMMENT 'Whenever this browser should be trusted or not',
321 `created` datetime NOT NULL COMMENT 'Datetime the trusted browser was recorded',
322 `last_used` datetime COMMENT 'Datetime the trusted browser was last used',
323 PRIMARY KEY(`cookie_hash`),
325 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
326 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication trusted browsers';
329 -- TABLE account-suggestion
331 CREATE TABLE IF NOT EXISTS `account-suggestion` (
332 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the account url',
333 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
334 `level` smallint unsigned COMMENT 'level of closeness',
335 `ignore` boolean NOT NULL DEFAULT '0' COMMENT 'If set, this account will not be suggested again',
336 PRIMARY KEY(`uid`,`uri-id`),
337 INDEX `uri-id_uid` (`uri-id`,`uid`),
338 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
339 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
340 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Account suggestion';
343 -- TABLE account-user
345 CREATE TABLE IF NOT EXISTS `account-user` (
346 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
347 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the account url',
348 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
350 UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
351 INDEX `uid_uri-id` (`uid`,`uri-id`),
352 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
353 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
354 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Remote and local accounts';
359 CREATE TABLE IF NOT EXISTS `apcontact` (
360 `url` varbinary(383) NOT NULL COMMENT 'URL of the contact',
361 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
362 `uuid` varbinary(255) COMMENT '',
363 `type` varchar(20) NOT NULL COMMENT '',
364 `following` varbinary(383) COMMENT '',
365 `followers` varbinary(383) COMMENT '',
366 `inbox` varbinary(383) NOT NULL COMMENT '',
367 `outbox` varbinary(383) COMMENT '',
368 `sharedinbox` varbinary(383) COMMENT '',
369 `featured` varbinary(383) COMMENT 'Address for the collection of featured posts',
370 `featured-tags` varbinary(383) COMMENT 'Address for the collection of featured tags',
371 `manually-approve` boolean COMMENT '',
372 `discoverable` boolean COMMENT 'Mastodon extension: true if profile is published in their directory',
373 `suspended` boolean COMMENT 'Mastodon extension: true if profile is suspended',
374 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
375 `name` varchar(255) COMMENT '',
376 `about` text COMMENT '',
377 `xmpp` varchar(255) COMMENT 'XMPP address',
378 `matrix` varchar(255) COMMENT 'Matrix address',
379 `photo` varbinary(383) COMMENT '',
380 `header` varbinary(383) COMMENT 'Header picture',
381 `addr` varchar(255) COMMENT '',
382 `alias` varbinary(383) COMMENT '',
383 `pubkey` text COMMENT '',
384 `subscribe` varbinary(383) COMMENT '',
385 `baseurl` varbinary(383) COMMENT 'baseurl of the ap contact',
386 `gsid` int unsigned COMMENT 'Global Server ID',
387 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
388 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
389 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
390 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
391 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
393 INDEX `addr` (`addr`(32)),
394 INDEX `alias` (`alias`(190)),
395 INDEX `followers` (`followers`(190)),
396 INDEX `baseurl` (`baseurl`(190)),
397 INDEX `sharedinbox` (`sharedinbox`(190)),
398 INDEX `gsid` (`gsid`),
399 UNIQUE INDEX `uri-id` (`uri-id`),
400 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
401 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
402 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
407 CREATE TABLE IF NOT EXISTS `application` (
408 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
409 `client_id` varchar(64) NOT NULL COMMENT '',
410 `client_secret` varchar(64) NOT NULL COMMENT '',
411 `name` varchar(255) NOT NULL COMMENT '',
412 `redirect_uri` varbinary(383) NOT NULL COMMENT '',
413 `website` varbinary(383) COMMENT '',
414 `scopes` varchar(255) COMMENT '',
415 `read` boolean COMMENT 'Read scope',
416 `write` boolean COMMENT 'Write scope',
417 `follow` boolean COMMENT 'Follow scope',
418 `push` boolean COMMENT 'Push scope',
420 UNIQUE INDEX `client_id` (`client_id`)
421 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth application';
424 -- TABLE application-marker
426 CREATE TABLE IF NOT EXISTS `application-marker` (
427 `application-id` int unsigned NOT NULL COMMENT '',
428 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
429 `timeline` varchar(64) NOT NULL COMMENT 'Marker (home, notifications)',
430 `last_read_id` varbinary(383) COMMENT 'Marker id for the timeline',
431 `version` smallint unsigned COMMENT 'Version number',
432 `updated_at` datetime COMMENT 'creation time',
433 PRIMARY KEY(`application-id`,`uid`,`timeline`),
434 INDEX `uid_id` (`uid`),
435 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
436 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
437 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Timeline marker';
440 -- TABLE application-token
442 CREATE TABLE IF NOT EXISTS `application-token` (
443 `application-id` int unsigned NOT NULL COMMENT '',
444 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
445 `code` varchar(64) NOT NULL COMMENT '',
446 `access_token` varchar(64) NOT NULL COMMENT '',
447 `created_at` datetime NOT NULL COMMENT 'creation time',
448 `scopes` varchar(255) COMMENT '',
449 `read` boolean COMMENT 'Read scope',
450 `write` boolean COMMENT 'Write scope',
451 `follow` boolean COMMENT 'Follow scope',
452 `push` boolean COMMENT 'Push scope',
453 PRIMARY KEY(`application-id`,`uid`),
454 INDEX `uid_id` (`uid`,`application-id`),
455 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
456 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
457 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth user token';
462 CREATE TABLE IF NOT EXISTS `attach` (
463 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
464 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
465 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
466 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
467 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
468 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
469 `data` longblob NOT NULL COMMENT 'file data',
470 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
471 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
472 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
473 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed circles',
474 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
475 `deny_gid` mediumtext COMMENT 'Access Control - list of denied circles',
476 `backend-class` tinytext COMMENT 'Storage backend class',
477 `backend-ref` text COMMENT 'Storage backend data reference',
480 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
481 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
486 CREATE TABLE IF NOT EXISTS `cache` (
487 `k` varbinary(255) NOT NULL COMMENT 'cache key',
488 `v` mediumtext COMMENT 'cached serialized value',
489 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
490 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
492 INDEX `k_expires` (`k`,`expires`)
493 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
498 CREATE TABLE IF NOT EXISTS `channel` (
499 `id` int unsigned NOT NULL auto_increment COMMENT '',
500 `uid` mediumint unsigned NOT NULL COMMENT 'User id',
501 `label` varchar(64) NOT NULL COMMENT 'Channel label',
502 `description` varchar(64) COMMENT 'Channel description',
503 `access-key` varchar(1) COMMENT 'Access key',
504 `include-tags` varchar(255) COMMENT 'Comma separated list of tags that will be included in the channel',
505 `exclude-tags` varchar(255) COMMENT 'Comma separated list of tags that aren\'t allowed in the channel',
506 `full-text-search` varchar(255) COMMENT 'Full text search pattern, see https://mariadb.com/kb/en/full-text-index-overview/#in-boolean-mode',
507 `media-type` smallint unsigned COMMENT 'Filtered media types',
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-collection
1241 CREATE TABLE IF NOT EXISTS `post-collection` (
1242 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1243 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0 - Featured',
1244 `author-id` int unsigned COMMENT 'Author of the featured post',
1245 PRIMARY KEY(`uri-id`,`type`),
1246 INDEX `type` (`type`),
1247 INDEX `author-id` (`author-id`),
1248 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1249 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1250 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Collection of posts';
1253 -- TABLE post-content
1255 CREATE TABLE IF NOT EXISTS `post-content` (
1256 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1257 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1258 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1259 `body` mediumtext COMMENT 'item body content',
1260 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1261 `quote-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the quoted uri',
1262 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1263 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1264 `language` text COMMENT 'Language information about this post',
1265 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1266 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1267 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1268 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1269 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1270 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1271 `target` text COMMENT 'JSON encoded target structure if used',
1272 `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',
1273 `plink` varbinary(383) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1274 PRIMARY KEY(`uri-id`),
1275 INDEX `plink` (`plink`(191)),
1276 INDEX `resource-id` (`resource-id`),
1277 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
1278 INDEX `quote-uri-id` (`quote-uri-id`),
1279 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1280 FOREIGN KEY (`quote-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1281 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1284 -- TABLE post-delivery
1286 CREATE TABLE IF NOT EXISTS `post-delivery` (
1287 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1288 `inbox-id` int unsigned NOT NULL COMMENT 'Item-uri id of inbox url',
1289 `uid` mediumint unsigned COMMENT 'Delivering user',
1290 `created` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
1291 `command` varbinary(32) COMMENT '',
1292 `failed` tinyint DEFAULT 0 COMMENT 'Number of times the delivery has failed',
1293 `receivers` mediumtext COMMENT 'JSON encoded array with the receiving contacts',
1294 PRIMARY KEY(`uri-id`,`inbox-id`),
1295 INDEX `inbox-id_created` (`inbox-id`,`created`),
1296 INDEX `uid` (`uid`),
1297 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1298 FOREIGN KEY (`inbox-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1299 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1300 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for posts for the batch processing';
1303 -- TABLE post-delivery-data
1305 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1306 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1307 `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',
1308 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1309 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1310 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1311 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1312 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1313 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1314 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1315 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1316 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1317 PRIMARY KEY(`uri-id`),
1318 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1319 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1322 -- TABLE post-engagement
1324 CREATE TABLE IF NOT EXISTS `post-engagement` (
1325 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1326 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1327 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Person, organisation, news, community, relay',
1328 `media-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Type of media in a bit array (1 = image, 2 = video, 4 = audio',
1329 `language` varbinary(128) COMMENT 'Language information about this post',
1330 `searchtext` mediumtext COMMENT 'Simplified text for the full text search',
1331 `created` datetime COMMENT '',
1332 `restricted` boolean NOT NULL DEFAULT '0' COMMENT 'If true, this post is either unlisted or not from a federated network',
1333 `comments` mediumint unsigned COMMENT 'Number of comments',
1334 `activities` mediumint unsigned COMMENT 'Number of activities (like, dislike, ...)',
1335 PRIMARY KEY(`uri-id`),
1336 INDEX `owner-id` (`owner-id`),
1337 INDEX `created` (`created`),
1338 FULLTEXT INDEX `searchtext` (`searchtext`),
1339 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1340 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1341 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Engagement data per post';
1344 -- TABLE post-history
1346 CREATE TABLE IF NOT EXISTS `post-history` (
1347 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1348 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of edit',
1349 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1350 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1351 `body` mediumtext COMMENT 'item body content',
1352 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1353 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1354 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1355 `language` text COMMENT 'Language information about this post',
1356 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1357 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1358 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1359 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1360 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1361 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1362 `target` text COMMENT 'JSON encoded target structure if used',
1363 `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',
1364 `plink` varbinary(383) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1365 PRIMARY KEY(`uri-id`,`edited`),
1366 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1367 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post history';
1372 CREATE TABLE IF NOT EXISTS `post-link` (
1373 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1374 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1375 `url` varbinary(511) NOT NULL COMMENT 'External URL',
1376 `mimetype` varchar(60) COMMENT '',
1377 `height` smallint unsigned COMMENT 'Height of the media',
1378 `width` smallint unsigned COMMENT 'Width of the media',
1379 `blurhash` varbinary(255) COMMENT 'BlurHash representation of the link',
1381 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1382 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1383 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post related external links';
1388 CREATE TABLE IF NOT EXISTS `post-media` (
1389 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1390 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1391 `url` varbinary(1024) NOT NULL COMMENT 'Media URL',
1392 `media-uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the activities uri-id',
1393 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1394 `mimetype` varchar(60) COMMENT '',
1395 `height` smallint unsigned COMMENT 'Height of the media',
1396 `width` smallint unsigned COMMENT 'Width of the media',
1397 `size` bigint unsigned COMMENT 'Media size',
1398 `blurhash` varbinary(255) COMMENT 'BlurHash representation of the image',
1399 `preview` varbinary(512) COMMENT 'Preview URL',
1400 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1401 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1402 `description` text COMMENT '',
1403 `name` varchar(255) COMMENT 'Name of the media',
1404 `author-url` varbinary(383) COMMENT 'URL of the author of the media',
1405 `author-name` varchar(255) COMMENT 'Name of the author of the media',
1406 `author-image` varbinary(383) COMMENT 'Image of the author of the media',
1407 `publisher-url` varbinary(383) COMMENT 'URL of the publisher of the media',
1408 `publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
1409 `publisher-image` varbinary(383) COMMENT 'Image of the publisher of the media',
1411 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`(512)),
1412 INDEX `uri-id-id` (`uri-id`,`id`),
1413 INDEX `media-uri-id` (`media-uri-id`),
1414 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1415 FOREIGN KEY (`media-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1416 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1419 -- TABLE post-question
1421 CREATE TABLE IF NOT EXISTS `post-question` (
1422 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1423 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1424 `multiple` boolean NOT NULL DEFAULT '0' COMMENT 'Multiple choice',
1425 `voters` int unsigned COMMENT 'Number of voters for this question',
1426 `end-time` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Question end time',
1428 UNIQUE INDEX `uri-id` (`uri-id`),
1429 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1430 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question';
1433 -- TABLE post-question-option
1435 CREATE TABLE IF NOT EXISTS `post-question-option` (
1436 `id` int unsigned NOT NULL COMMENT 'Id of the question',
1437 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1438 `name` varchar(255) COMMENT 'Name of the option',
1439 `replies` int unsigned COMMENT 'Number of replies for this question option',
1440 PRIMARY KEY(`uri-id`,`id`),
1441 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1442 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question option';
1447 CREATE TABLE IF NOT EXISTS `post-tag` (
1448 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1449 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1450 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1451 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1452 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1453 INDEX `tid` (`tid`),
1454 INDEX `cid` (`cid`),
1455 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1456 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1457 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1458 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1461 -- TABLE post-thread
1463 CREATE TABLE IF NOT EXISTS `post-thread` (
1464 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1465 `conversation-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the conversation uri',
1466 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1467 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1468 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1469 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1470 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1471 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1472 `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',
1473 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1474 PRIMARY KEY(`uri-id`),
1475 INDEX `conversation-id` (`conversation-id`),
1476 INDEX `owner-id` (`owner-id`),
1477 INDEX `author-id` (`author-id`),
1478 INDEX `causer-id` (`causer-id`),
1479 INDEX `received` (`received`),
1480 INDEX `commented` (`commented`),
1481 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1482 FOREIGN KEY (`conversation-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1483 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1484 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1485 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1486 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1491 CREATE TABLE IF NOT EXISTS `post-user` (
1492 `id` int unsigned NOT NULL auto_increment,
1493 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1494 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1495 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1496 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1497 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1498 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1499 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1500 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1501 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1502 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1503 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1504 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1505 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1506 `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
1507 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1508 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1509 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1510 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1511 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1512 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1513 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1514 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1515 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1516 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1517 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1518 `notification-type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1519 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1520 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1521 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1523 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1524 INDEX `uri-id` (`uri-id`),
1525 INDEX `parent-uri-id` (`parent-uri-id`),
1526 INDEX `thr-parent-id` (`thr-parent-id`),
1527 INDEX `external-id` (`external-id`),
1528 INDEX `owner-id` (`owner-id`),
1529 INDEX `author-id` (`author-id`),
1530 INDEX `causer-id` (`causer-id`),
1531 INDEX `vid` (`vid`),
1532 INDEX `contact-id` (`contact-id`),
1533 INDEX `event-id` (`event-id`),
1534 INDEX `psid` (`psid`),
1535 INDEX `author-id_uid` (`author-id`,`uid`),
1536 INDEX `author-id_received` (`author-id`,`received`),
1537 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1538 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1539 INDEX `uid_contactid` (`uid`,`contact-id`),
1540 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1541 INDEX `uid_unseen` (`uid`,`unseen`),
1542 INDEX `uid_hidden_uri-id` (`uid`,`hidden`,`uri-id`),
1543 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1544 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1545 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1546 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1547 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1548 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1549 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1550 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1551 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1552 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1553 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1554 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1555 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1558 -- TABLE post-thread-user
1560 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1561 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1562 `conversation-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the conversation uri',
1563 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1564 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1565 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1566 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1567 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1568 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1569 `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',
1570 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1571 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1572 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
1573 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1574 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1575 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1576 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1577 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1578 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Deprecated',
1579 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1580 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1581 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1582 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1583 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1584 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1585 PRIMARY KEY(`uid`,`uri-id`),
1586 INDEX `uri-id` (`uri-id`),
1587 INDEX `conversation-id` (`conversation-id`),
1588 INDEX `owner-id` (`owner-id`),
1589 INDEX `author-id` (`author-id`),
1590 INDEX `causer-id` (`causer-id`),
1591 INDEX `uid` (`uid`),
1592 INDEX `contact-id` (`contact-id`),
1593 INDEX `psid` (`psid`),
1594 INDEX `post-user-id` (`post-user-id`),
1595 INDEX `commented` (`commented`),
1596 INDEX `received` (`received`),
1597 INDEX `uid_received` (`uid`,`received`),
1598 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1599 INDEX `uid_commented` (`uid`,`commented`),
1600 INDEX `uid_starred` (`uid`,`starred`),
1601 INDEX `uid_mention` (`uid`,`mention`),
1602 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1603 FOREIGN KEY (`conversation-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1604 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1605 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1606 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1607 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1608 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1609 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1610 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1611 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1614 -- TABLE post-user-notification
1616 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1617 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1618 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1619 `notification-type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1620 PRIMARY KEY(`uid`,`uri-id`),
1621 INDEX `uri-id` (`uri-id`),
1622 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1623 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1624 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1629 CREATE TABLE IF NOT EXISTS `process` (
1630 `pid` int unsigned NOT NULL COMMENT 'The ID of the process',
1631 `hostname` varchar(255) NOT NULL COMMENT 'The name of the host the process is ran on',
1632 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1633 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1634 PRIMARY KEY(`pid`,`hostname`),
1635 INDEX `command` (`command`)
1636 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1641 CREATE TABLE IF NOT EXISTS `profile` (
1642 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1643 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1644 `profile-name` varchar(255) COMMENT 'Deprecated',
1645 `is-default` boolean COMMENT 'Deprecated',
1646 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1647 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Unused in favor of user.username',
1648 `pdesc` varchar(255) COMMENT 'Deprecated',
1649 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1650 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1651 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1652 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1653 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1654 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1655 `hometown` varchar(255) COMMENT 'Deprecated',
1656 `gender` varchar(32) COMMENT 'Deprecated',
1657 `marital` varchar(255) COMMENT 'Deprecated',
1658 `with` text COMMENT 'Deprecated',
1659 `howlong` datetime COMMENT 'Deprecated',
1660 `sexual` varchar(255) COMMENT 'Deprecated',
1661 `politic` varchar(255) COMMENT 'Deprecated',
1662 `religion` varchar(255) COMMENT 'Deprecated',
1663 `pub_keywords` text COMMENT '',
1664 `prv_keywords` text COMMENT '',
1665 `likes` text COMMENT 'Deprecated',
1666 `dislikes` text COMMENT 'Deprecated',
1667 `about` text COMMENT 'Profile description',
1668 `summary` varchar(255) COMMENT 'Deprecated',
1669 `music` text COMMENT 'Deprecated',
1670 `book` text COMMENT 'Deprecated',
1671 `tv` text COMMENT 'Deprecated',
1672 `film` text COMMENT 'Deprecated',
1673 `interest` text COMMENT 'Deprecated',
1674 `romance` text COMMENT 'Deprecated',
1675 `work` text COMMENT 'Deprecated',
1676 `education` text COMMENT 'Deprecated',
1677 `contact` text COMMENT 'Deprecated',
1678 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1679 `homepage_verified` boolean NOT NULL DEFAULT '0' COMMENT 'was the homepage verified by a rel-me link back to the profile',
1680 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
1681 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
1682 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1683 `thumb` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1684 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1685 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1687 INDEX `uid_is-default` (`uid`,`is-default`),
1688 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1689 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1690 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1693 -- TABLE profile_field
1695 CREATE TABLE IF NOT EXISTS `profile_field` (
1696 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1697 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1698 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1699 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1700 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1701 `value` text COMMENT 'Value of the field',
1702 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1703 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1705 INDEX `uid` (`uid`),
1706 INDEX `order` (`order`),
1707 INDEX `psid` (`psid`),
1708 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1709 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1710 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1713 -- TABLE push_subscriber
1715 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1716 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1717 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1718 `callback_url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1719 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1720 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1721 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1722 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1723 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1724 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1725 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1727 INDEX `next_try` (`next_try`),
1728 INDEX `uid` (`uid`),
1729 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1730 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1735 CREATE TABLE IF NOT EXISTS `register` (
1736 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1737 `hash` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1738 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1739 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1740 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1741 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1742 `note` text COMMENT '',
1744 INDEX `uid` (`uid`),
1745 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1746 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1751 CREATE TABLE IF NOT EXISTS `report` (
1752 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1753 `uid` mediumint unsigned COMMENT 'Reporting user',
1754 `reporter-id` int unsigned COMMENT 'Reporting contact',
1755 `cid` int unsigned NOT NULL COMMENT 'Reported contact',
1756 `gsid` int unsigned COMMENT 'Reported contact server',
1757 `comment` text COMMENT 'Report',
1758 `category-id` int unsigned NOT NULL DEFAULT 1 COMMENT 'Report category, one of Entity Report::CATEGORY_*',
1759 `forward` boolean COMMENT 'Forward the report to the remote server',
1760 `public-remarks` text COMMENT 'Remarks shared with the reporter',
1761 `private-remarks` text COMMENT 'Remarks shared with the moderation team',
1762 `last-editor-uid` mediumint unsigned COMMENT 'Last editor user',
1763 `assigned-uid` mediumint unsigned COMMENT 'Assigned moderator user',
1764 `status` tinyint unsigned NOT NULL COMMENT 'Status of the report, one of Entity Report::STATUS_*',
1765 `resolution` tinyint unsigned COMMENT 'Resolution of the report, one of Entity Report::RESOLUTION_*',
1766 `created` datetime(6) NOT NULL DEFAULT '0001-01-01 00:00:00.000000' COMMENT '',
1767 `edited` datetime(6) COMMENT 'Last time the report has been edited',
1769 INDEX `uid` (`uid`),
1770 INDEX `cid` (`cid`),
1771 INDEX `reporter-id` (`reporter-id`),
1772 INDEX `gsid` (`gsid`),
1773 INDEX `last-editor-uid` (`last-editor-uid`),
1774 INDEX `assigned-uid` (`assigned-uid`),
1775 INDEX `status-resolution` (`status`,`resolution`),
1776 INDEX `created` (`created`),
1777 INDEX `edited` (`edited`),
1778 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1779 FOREIGN KEY (`reporter-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1780 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1781 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1782 FOREIGN KEY (`last-editor-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1783 FOREIGN KEY (`assigned-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1784 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1787 -- TABLE report-post
1789 CREATE TABLE IF NOT EXISTS `report-post` (
1790 `rid` int unsigned NOT NULL COMMENT 'Report id',
1791 `uri-id` int unsigned NOT NULL COMMENT 'Uri-id of the reported post',
1792 `status` tinyint unsigned COMMENT 'Status of the reported post',
1793 PRIMARY KEY(`rid`,`uri-id`),
1794 INDEX `uri-id` (`uri-id`),
1795 FOREIGN KEY (`rid`) REFERENCES `report` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1796 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1797 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Individual posts attached to a moderation report';
1800 -- TABLE report-rule
1802 CREATE TABLE IF NOT EXISTS `report-rule` (
1803 `rid` int unsigned NOT NULL COMMENT 'Report id',
1804 `line-id` int unsigned NOT NULL COMMENT 'Terms of service rule line number, may become invalid after a TOS change.',
1805 `text` text NOT NULL COMMENT 'Terms of service rule text recorded at the time of the report',
1806 PRIMARY KEY(`rid`,`line-id`),
1807 FOREIGN KEY (`rid`) REFERENCES `report` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1808 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Terms of service rule lines relevant to a moderation report';
1813 CREATE TABLE IF NOT EXISTS `search` (
1814 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1815 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1816 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1818 INDEX `uid_term` (`uid`,`term`(64)),
1819 INDEX `term` (`term`(64)),
1820 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1821 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1826 CREATE TABLE IF NOT EXISTS `session` (
1827 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1828 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1829 `data` text COMMENT '',
1830 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1832 INDEX `sid` (`sid`(64)),
1833 INDEX `expire` (`expire`)
1834 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1839 CREATE TABLE IF NOT EXISTS `storage` (
1840 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1841 `data` longblob NOT NULL COMMENT 'file data',
1843 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1846 -- TABLE subscription
1848 CREATE TABLE IF NOT EXISTS `subscription` (
1849 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1850 `application-id` int unsigned NOT NULL COMMENT '',
1851 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
1852 `endpoint` varchar(511) COMMENT 'Endpoint URL',
1853 `pubkey` varchar(127) COMMENT 'User agent public key',
1854 `secret` varchar(32) COMMENT 'Auth secret',
1855 `follow` boolean COMMENT '',
1856 `favourite` boolean COMMENT '',
1857 `reblog` boolean COMMENT '',
1858 `mention` boolean COMMENT '',
1859 `poll` boolean COMMENT '',
1860 `follow_request` boolean COMMENT '',
1861 `status` boolean COMMENT '',
1863 UNIQUE INDEX `application-id_uid` (`application-id`,`uid`),
1864 INDEX `uid_application-id` (`uid`,`application-id`),
1865 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1866 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1867 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Push Subscription for the API';
1872 CREATE TABLE IF NOT EXISTS `userd` (
1873 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1874 `username` varchar(255) NOT NULL COMMENT '',
1876 INDEX `username` (`username`(32))
1877 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1880 -- TABLE user-contact
1882 CREATE TABLE IF NOT EXISTS `user-contact` (
1883 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1884 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1885 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
1886 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1887 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1888 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1889 `hidden` boolean COMMENT 'This contact is hidden from the others',
1890 `is-blocked` boolean COMMENT 'User is blocked by this contact',
1891 `channel-frequency` tinyint unsigned COMMENT 'Controls the frequency of the appearance of this contact in channels',
1892 `pending` boolean COMMENT '',
1893 `rel` tinyint unsigned COMMENT 'The kind of the relation between the user and the contact',
1894 `info` mediumtext COMMENT '',
1895 `notify_new_posts` boolean COMMENT '',
1896 `remote_self` tinyint unsigned COMMENT '0 => No mirroring, 1-2 => Mirror as own post, 3 => Mirror as reshare',
1897 `fetch_further_information` tinyint unsigned COMMENT '0 => None, 1 => Fetch information, 3 => Fetch keywords, 2 => Fetch both',
1898 `ffi_keyword_denylist` text COMMENT '',
1899 `subhub` boolean COMMENT '',
1900 `hub-verify` varbinary(383) COMMENT '',
1901 `protocol` char(4) COMMENT 'Protocol of the contact',
1902 `rating` tinyint COMMENT 'Automatically detected feed poll frequency',
1903 `priority` tinyint unsigned COMMENT 'Feed poll priority',
1904 PRIMARY KEY(`uid`,`cid`),
1905 INDEX `cid` (`cid`),
1906 UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
1907 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1908 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1909 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1910 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1913 -- TABLE arrived-activity
1915 CREATE TABLE IF NOT EXISTS `arrived-activity` (
1916 `object-id` varbinary(383) NOT NULL COMMENT 'object id of the incoming activity',
1917 `received` datetime COMMENT 'Receiving date',
1918 PRIMARY KEY(`object-id`)
1919 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Id of arrived activities';
1922 -- TABLE fetched-activity
1924 CREATE TABLE IF NOT EXISTS `fetched-activity` (
1925 `object-id` varbinary(383) NOT NULL COMMENT 'object id of fetched activity',
1926 `received` datetime COMMENT 'Receiving date',
1927 PRIMARY KEY(`object-id`)
1928 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Id of fetched activities';
1933 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1934 `key` int NOT NULL COMMENT '',
1935 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1937 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1940 -- VIEW application-view
1942 DROP VIEW IF EXISTS `application-view`;
1943 CREATE VIEW `application-view` AS SELECT
1944 `application`.`id` AS `id`,
1945 `application-token`.`uid` AS `uid`,
1946 `application`.`name` AS `name`,
1947 `application`.`redirect_uri` AS `redirect_uri`,
1948 `application`.`website` AS `website`,
1949 `application`.`client_id` AS `client_id`,
1950 `application`.`client_secret` AS `client_secret`,
1951 `application-token`.`code` AS `code`,
1952 `application-token`.`access_token` AS `access_token`,
1953 `application-token`.`created_at` AS `created_at`,
1954 `application-token`.`scopes` AS `scopes`,
1955 `application-token`.`read` AS `read`,
1956 `application-token`.`write` AS `write`,
1957 `application-token`.`follow` AS `follow`,
1958 `application-token`.`push` AS `push`
1959 FROM `application-token`
1960 INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`;
1963 -- VIEW circle-member-view
1965 DROP VIEW IF EXISTS `circle-member-view`;
1966 CREATE VIEW `circle-member-view` AS SELECT
1967 `group_member`.`id` AS `id`,
1968 `group`.`uid` AS `uid`,
1969 `group_member`.`contact-id` AS `contact-id`,
1970 `contact`.`uri-id` AS `contact-uri-id`,
1971 `contact`.`url` AS `contact-link`,
1972 `contact`.`addr` AS `contact-addr`,
1973 `contact`.`name` AS `contact-name`,
1974 `contact`.`nick` AS `contact-nick`,
1975 `contact`.`thumb` AS `contact-avatar`,
1976 `contact`.`network` AS `contact-network`,
1977 `contact`.`blocked` AS `contact-blocked`,
1978 `contact`.`hidden` AS `contact-hidden`,
1979 `contact`.`readonly` AS `contact-readonly`,
1980 `contact`.`archive` AS `contact-archive`,
1981 `contact`.`pending` AS `contact-pending`,
1982 `contact`.`self` AS `contact-self`,
1983 `contact`.`rel` AS `contact-rel`,
1984 `contact`.`contact-type` AS `contact-contact-type`,
1985 `group_member`.`gid` AS `circle-id`,
1986 `group`.`visible` AS `circle-visible`,
1987 `group`.`deleted` AS `circle-deleted`,
1988 `group`.`name` AS `circle-name`
1990 INNER JOIN `contact` ON `group_member`.`contact-id` = `contact`.`id`
1991 INNER JOIN `group` ON `group_member`.`gid` = `group`.`id`;
1994 -- VIEW post-user-view
1996 DROP VIEW IF EXISTS `post-user-view`;
1997 CREATE VIEW `post-user-view` AS SELECT
1998 `post-user`.`id` AS `id`,
1999 `post-user`.`id` AS `post-user-id`,
2000 `post-user`.`uid` AS `uid`,
2001 `post-thread-user`.`post-user-id` AS `parent`,
2002 `item-uri`.`uri` AS `uri`,
2003 `post-user`.`uri-id` AS `uri-id`,
2004 `parent-item-uri`.`uri` AS `parent-uri`,
2005 `post-user`.`parent-uri-id` AS `parent-uri-id`,
2006 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2007 `post-user`.`thr-parent-id` AS `thr-parent-id`,
2008 `conversation-item-uri`.`uri` AS `conversation`,
2009 `post-thread-user`.`conversation-id` AS `conversation-id`,
2010 `quote-item-uri`.`uri` AS `quote-uri`,
2011 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2012 `item-uri`.`guid` AS `guid`,
2013 `post-user`.`wall` AS `wall`,
2014 `post-user`.`gravity` AS `gravity`,
2015 `external-item-uri`.`uri` AS `extid`,
2016 `post-user`.`external-id` AS `external-id`,
2017 `post-user`.`created` AS `created`,
2018 `post-user`.`edited` AS `edited`,
2019 `post-thread-user`.`commented` AS `commented`,
2020 `post-user`.`received` AS `received`,
2021 `post-thread-user`.`changed` AS `changed`,
2022 `post-user`.`post-type` AS `post-type`,
2023 `post-user`.`post-reason` AS `post-reason`,
2024 `post-user`.`private` AS `private`,
2025 `post-thread-user`.`pubmail` AS `pubmail`,
2026 `post-user`.`visible` AS `visible`,
2027 `post-thread-user`.`starred` AS `starred`,
2028 `post-user`.`unseen` AS `unseen`,
2029 `post-user`.`deleted` AS `deleted`,
2030 `post-user`.`origin` AS `origin`,
2031 `post-thread-user`.`origin` AS `parent-origin`,
2032 `post-thread-user`.`mention` AS `mention`,
2033 `post-user`.`global` AS `global`,
2034 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-user`.`uri-id`) AS `featured`,
2035 `post-user`.`network` AS `network`,
2036 `post-user`.`protocol` AS `protocol`,
2037 `post-user`.`vid` AS `vid`,
2038 `post-user`.`psid` AS `psid`,
2039 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2040 `post-content`.`title` AS `title`,
2041 `post-content`.`content-warning` AS `content-warning`,
2042 `post-content`.`raw-body` AS `raw-body`,
2043 IFNULL (`post-content`.`body`, '') AS `body`,
2044 `post-content`.`rendered-hash` AS `rendered-hash`,
2045 `post-content`.`rendered-html` AS `rendered-html`,
2046 `post-content`.`language` AS `language`,
2047 `post-content`.`plink` AS `plink`,
2048 `post-content`.`location` AS `location`,
2049 `post-content`.`coord` AS `coord`,
2050 `post-content`.`app` AS `app`,
2051 `post-content`.`object-type` AS `object-type`,
2052 `post-content`.`object` AS `object`,
2053 `post-content`.`target-type` AS `target-type`,
2054 `post-content`.`target` AS `target`,
2055 `post-content`.`resource-id` AS `resource-id`,
2056 `post-user`.`contact-id` AS `contact-id`,
2057 `contact`.`uri-id` AS `contact-uri-id`,
2058 `contact`.`url` AS `contact-link`,
2059 `contact`.`addr` AS `contact-addr`,
2060 `contact`.`name` AS `contact-name`,
2061 `contact`.`nick` AS `contact-nick`,
2062 `contact`.`thumb` AS `contact-avatar`,
2063 `contact`.`network` AS `contact-network`,
2064 `contact`.`blocked` AS `contact-blocked`,
2065 `contact`.`hidden` AS `contact-hidden`,
2066 `contact`.`readonly` AS `contact-readonly`,
2067 `contact`.`archive` AS `contact-archive`,
2068 `contact`.`pending` AS `contact-pending`,
2069 `contact`.`rel` AS `contact-rel`,
2070 `contact`.`uid` AS `contact-uid`,
2071 `contact`.`contact-type` AS `contact-contact-type`,
2072 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
2073 `contact`.`self` AS `self`,
2074 `contact`.`id` AS `cid`,
2075 `contact`.`alias` AS `alias`,
2076 `contact`.`photo` AS `photo`,
2077 `contact`.`name-date` AS `name-date`,
2078 `contact`.`uri-date` AS `uri-date`,
2079 `contact`.`avatar-date` AS `avatar-date`,
2080 `contact`.`thumb` AS `thumb`,
2081 `post-user`.`author-id` AS `author-id`,
2082 `author`.`uri-id` AS `author-uri-id`,
2083 `author`.`url` AS `author-link`,
2084 `author`.`addr` AS `author-addr`,
2085 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
2086 `author`.`nick` AS `author-nick`,
2087 `author`.`alias` AS `author-alias`,
2088 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
2089 `author`.`network` AS `author-network`,
2090 `author`.`blocked` AS `author-blocked`,
2091 `author`.`hidden` AS `author-hidden`,
2092 `author`.`updated` AS `author-updated`,
2093 `author`.`gsid` AS `author-gsid`,
2094 `author`.`baseurl` AS `author-baseurl`,
2095 `post-user`.`owner-id` AS `owner-id`,
2096 `owner`.`uri-id` AS `owner-uri-id`,
2097 `owner`.`url` AS `owner-link`,
2098 `owner`.`addr` AS `owner-addr`,
2099 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
2100 `owner`.`nick` AS `owner-nick`,
2101 `owner`.`alias` AS `owner-alias`,
2102 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
2103 `owner`.`network` AS `owner-network`,
2104 `owner`.`blocked` AS `owner-blocked`,
2105 `owner`.`hidden` AS `owner-hidden`,
2106 `owner`.`updated` AS `owner-updated`,
2107 `owner`.`gsid` AS `owner-gsid`,
2108 `owner`.`contact-type` AS `owner-contact-type`,
2109 `post-user`.`causer-id` AS `causer-id`,
2110 `causer`.`uri-id` AS `causer-uri-id`,
2111 `causer`.`url` AS `causer-link`,
2112 `causer`.`addr` AS `causer-addr`,
2113 `causer`.`name` AS `causer-name`,
2114 `causer`.`nick` AS `causer-nick`,
2115 `causer`.`alias` AS `causer-alias`,
2116 `causer`.`thumb` AS `causer-avatar`,
2117 `causer`.`network` AS `causer-network`,
2118 `causer`.`blocked` AS `causer-blocked`,
2119 `causer`.`hidden` AS `causer-hidden`,
2120 `causer`.`gsid` AS `causer-gsid`,
2121 `causer`.`contact-type` AS `causer-contact-type`,
2122 `post-delivery-data`.`postopts` AS `postopts`,
2123 `post-delivery-data`.`inform` AS `inform`,
2124 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
2125 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
2126 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
2127 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
2128 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
2129 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
2130 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
2131 `post-user`.`event-id` AS `event-id`,
2132 `event`.`created` AS `event-created`,
2133 `event`.`edited` AS `event-edited`,
2134 `event`.`start` AS `event-start`,
2135 `event`.`finish` AS `event-finish`,
2136 `event`.`summary` AS `event-summary`,
2137 `event`.`desc` AS `event-desc`,
2138 `event`.`location` AS `event-location`,
2139 `event`.`type` AS `event-type`,
2140 `event`.`nofinish` AS `event-nofinish`,
2141 `event`.`ignore` AS `event-ignore`,
2142 `post-question`.`id` AS `question-id`,
2143 `post-question`.`multiple` AS `question-multiple`,
2144 `post-question`.`voters` AS `question-voters`,
2145 `post-question`.`end-time` AS `question-end-time`,
2146 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`,
2147 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-user`.`uri-id`) AS `has-media`,
2148 `diaspora-interaction`.`interaction` AS `signed_text`,
2149 `parent-item-uri`.`guid` AS `parent-guid`,
2150 `post-thread-user`.`network` AS `parent-network`,
2151 `post-thread-user`.`author-id` AS `parent-author-id`,
2152 `parent-post-author`.`url` AS `parent-author-link`,
2153 `parent-post-author`.`name` AS `parent-author-name`,
2154 `parent-post-author`.`nick` AS `parent-author-nick`,
2155 `parent-post-author`.`network` AS `parent-author-network`
2157 INNER JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2158 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
2159 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
2160 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
2161 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
2162 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
2163 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
2164 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
2165 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
2166 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
2167 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
2168 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
2169 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
2170 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
2171 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2172 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
2173 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-user`.`uri-id`
2174 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
2175 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `post-thread-user`.`author-id`;
2178 -- VIEW post-thread-user-view
2180 DROP VIEW IF EXISTS `post-thread-user-view`;
2181 CREATE VIEW `post-thread-user-view` AS SELECT
2182 `post-user`.`id` AS `id`,
2183 `post-user`.`id` AS `post-user-id`,
2184 `post-thread-user`.`uid` AS `uid`,
2185 `post-thread-user`.`post-user-id` AS `parent`,
2186 `item-uri`.`uri` AS `uri`,
2187 `post-thread-user`.`uri-id` AS `uri-id`,
2188 `parent-item-uri`.`uri` AS `parent-uri`,
2189 `post-user`.`parent-uri-id` AS `parent-uri-id`,
2190 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2191 `post-user`.`thr-parent-id` AS `thr-parent-id`,
2192 `conversation-item-uri`.`uri` AS `conversation`,
2193 `post-thread-user`.`conversation-id` AS `conversation-id`,
2194 `quote-item-uri`.`uri` AS `quote-uri`,
2195 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2196 `item-uri`.`guid` AS `guid`,
2197 `post-thread-user`.`wall` AS `wall`,
2198 `post-user`.`gravity` AS `gravity`,
2199 `external-item-uri`.`uri` AS `extid`,
2200 `post-user`.`external-id` AS `external-id`,
2201 `post-thread-user`.`created` AS `created`,
2202 `post-user`.`edited` AS `edited`,
2203 `post-thread-user`.`commented` AS `commented`,
2204 `post-thread-user`.`received` AS `received`,
2205 `post-thread-user`.`changed` AS `changed`,
2206 `post-user`.`post-type` AS `post-type`,
2207 `post-user`.`post-reason` AS `post-reason`,
2208 `post-user`.`private` AS `private`,
2209 `post-thread-user`.`pubmail` AS `pubmail`,
2210 `post-thread-user`.`ignored` AS `ignored`,
2211 `post-user`.`visible` AS `visible`,
2212 `post-thread-user`.`starred` AS `starred`,
2213 `post-thread-user`.`unseen` AS `unseen`,
2214 `post-user`.`deleted` AS `deleted`,
2215 `post-thread-user`.`origin` AS `origin`,
2216 `post-thread-user`.`mention` AS `mention`,
2217 `post-user`.`global` AS `global`,
2218 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread-user`.`uri-id`) AS `featured`,
2219 `post-thread-user`.`network` AS `network`,
2220 `post-user`.`vid` AS `vid`,
2221 `post-thread-user`.`psid` AS `psid`,
2222 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2223 `post-content`.`title` AS `title`,
2224 `post-content`.`content-warning` AS `content-warning`,
2225 `post-content`.`raw-body` AS `raw-body`,
2226 `post-content`.`body` AS `body`,
2227 `post-content`.`rendered-hash` AS `rendered-hash`,
2228 `post-content`.`rendered-html` AS `rendered-html`,
2229 `post-content`.`language` AS `language`,
2230 `post-content`.`plink` AS `plink`,
2231 `post-content`.`location` AS `location`,
2232 `post-content`.`coord` AS `coord`,
2233 `post-content`.`app` AS `app`,
2234 `post-content`.`object-type` AS `object-type`,
2235 `post-content`.`object` AS `object`,
2236 `post-content`.`target-type` AS `target-type`,
2237 `post-content`.`target` AS `target`,
2238 `post-content`.`resource-id` AS `resource-id`,
2239 `post-thread-user`.`contact-id` AS `contact-id`,
2240 `contact`.`uri-id` AS `contact-uri-id`,
2241 `contact`.`url` AS `contact-link`,
2242 `contact`.`addr` AS `contact-addr`,
2243 `contact`.`name` AS `contact-name`,
2244 `contact`.`nick` AS `contact-nick`,
2245 `contact`.`thumb` AS `contact-avatar`,
2246 `contact`.`network` AS `contact-network`,
2247 `contact`.`blocked` AS `contact-blocked`,
2248 `contact`.`hidden` AS `contact-hidden`,
2249 `contact`.`readonly` AS `contact-readonly`,
2250 `contact`.`archive` AS `contact-archive`,
2251 `contact`.`pending` AS `contact-pending`,
2252 `contact`.`rel` AS `contact-rel`,
2253 `contact`.`uid` AS `contact-uid`,
2254 `contact`.`gsid` AS `contact-gsid`,
2255 `contact`.`contact-type` AS `contact-contact-type`,
2256 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
2257 `contact`.`self` AS `self`,
2258 `contact`.`id` AS `cid`,
2259 `contact`.`alias` AS `alias`,
2260 `contact`.`photo` AS `photo`,
2261 `contact`.`name-date` AS `name-date`,
2262 `contact`.`uri-date` AS `uri-date`,
2263 `contact`.`avatar-date` AS `avatar-date`,
2264 `contact`.`thumb` AS `thumb`,
2265 `post-thread-user`.`author-id` AS `author-id`,
2266 `author`.`uri-id` AS `author-uri-id`,
2267 `author`.`url` AS `author-link`,
2268 `author`.`addr` AS `author-addr`,
2269 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
2270 `author`.`nick` AS `author-nick`,
2271 `author`.`alias` AS `author-alias`,
2272 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
2273 `author`.`network` AS `author-network`,
2274 `author`.`blocked` AS `author-blocked`,
2275 `author`.`hidden` AS `author-hidden`,
2276 `author`.`updated` AS `author-updated`,
2277 `author`.`gsid` AS `author-gsid`,
2278 `post-thread-user`.`owner-id` AS `owner-id`,
2279 `owner`.`uri-id` AS `owner-uri-id`,
2280 `owner`.`url` AS `owner-link`,
2281 `owner`.`addr` AS `owner-addr`,
2282 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
2283 `owner`.`nick` AS `owner-nick`,
2284 `owner`.`alias` AS `owner-alias`,
2285 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
2286 `owner`.`network` AS `owner-network`,
2287 `owner`.`blocked` AS `owner-blocked`,
2288 `owner`.`hidden` AS `owner-hidden`,
2289 `owner`.`updated` AS `owner-updated`,
2290 `owner`.`gsid` AS `owner-gsid`,
2291 `owner`.`contact-type` AS `owner-contact-type`,
2292 `post-thread-user`.`causer-id` AS `causer-id`,
2293 `causer`.`uri-id` AS `causer-uri-id`,
2294 `causer`.`url` AS `causer-link`,
2295 `causer`.`addr` AS `causer-addr`,
2296 `causer`.`name` AS `causer-name`,
2297 `causer`.`nick` AS `causer-nick`,
2298 `causer`.`alias` AS `causer-alias`,
2299 `causer`.`thumb` AS `causer-avatar`,
2300 `causer`.`network` AS `causer-network`,
2301 `causer`.`blocked` AS `causer-blocked`,
2302 `causer`.`hidden` AS `causer-hidden`,
2303 `causer`.`gsid` AS `causer-gsid`,
2304 `causer`.`contact-type` AS `causer-contact-type`,
2305 `post-delivery-data`.`postopts` AS `postopts`,
2306 `post-delivery-data`.`inform` AS `inform`,
2307 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
2308 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
2309 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
2310 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
2311 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
2312 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
2313 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
2314 `post-user`.`event-id` AS `event-id`,
2315 `event`.`created` AS `event-created`,
2316 `event`.`edited` AS `event-edited`,
2317 `event`.`start` AS `event-start`,
2318 `event`.`finish` AS `event-finish`,
2319 `event`.`summary` AS `event-summary`,
2320 `event`.`desc` AS `event-desc`,
2321 `event`.`location` AS `event-location`,
2322 `event`.`type` AS `event-type`,
2323 `event`.`nofinish` AS `event-nofinish`,
2324 `event`.`ignore` AS `event-ignore`,
2325 `post-question`.`id` AS `question-id`,
2326 `post-question`.`multiple` AS `question-multiple`,
2327 `post-question`.`voters` AS `question-voters`,
2328 `post-question`.`end-time` AS `question-end-time`,
2329 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`,
2330 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread-user`.`uri-id`) AS `has-media`,
2331 `diaspora-interaction`.`interaction` AS `signed_text`,
2332 `parent-item-uri`.`guid` AS `parent-guid`,
2333 `post-thread-user`.`network` AS `parent-network`,
2334 `post-thread-user`.`author-id` AS `parent-author-id`,
2335 `author`.`url` AS `parent-author-link`,
2336 `author`.`name` AS `parent-author-name`,
2337 `author`.`nick` AS `parent-author-nick`,
2338 `author`.`network` AS `parent-author-network`
2339 FROM `post-thread-user`
2340 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2341 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2342 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
2343 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
2344 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
2345 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
2346 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
2347 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
2348 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
2349 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
2350 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
2351 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
2352 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
2353 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
2354 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2355 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
2356 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread-user`.`uri-id`
2357 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`;
2362 DROP VIEW IF EXISTS `post-view`;
2363 CREATE VIEW `post-view` AS SELECT
2364 `item-uri`.`uri` AS `uri`,
2365 `post`.`uri-id` AS `uri-id`,
2366 `parent-item-uri`.`uri` AS `parent-uri`,
2367 `post`.`parent-uri-id` AS `parent-uri-id`,
2368 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2369 `post`.`thr-parent-id` AS `thr-parent-id`,
2370 `conversation-item-uri`.`uri` AS `conversation`,
2371 `post-thread`.`conversation-id` AS `conversation-id`,
2372 `quote-item-uri`.`uri` AS `quote-uri`,
2373 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2374 `item-uri`.`guid` AS `guid`,
2375 `post`.`gravity` AS `gravity`,
2376 `external-item-uri`.`uri` AS `extid`,
2377 `post`.`external-id` AS `external-id`,
2378 `post`.`created` AS `created`,
2379 `post`.`edited` AS `edited`,
2380 `post-thread`.`commented` AS `commented`,
2381 `post`.`received` AS `received`,
2382 `post-thread`.`changed` AS `changed`,
2383 `post`.`post-type` AS `post-type`,
2384 `post`.`private` AS `private`,
2385 `post`.`visible` AS `visible`,
2386 `post`.`deleted` AS `deleted`,
2387 `post`.`global` AS `global`,
2388 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post`.`uri-id`) AS `featured`,
2389 `post`.`network` AS `network`,
2390 `post`.`vid` AS `vid`,
2391 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2392 `post-content`.`title` AS `title`,
2393 `post-content`.`content-warning` AS `content-warning`,
2394 `post-content`.`raw-body` AS `raw-body`,
2395 `post-content`.`body` AS `body`,
2396 `post-content`.`rendered-hash` AS `rendered-hash`,
2397 `post-content`.`rendered-html` AS `rendered-html`,
2398 `post-content`.`language` AS `language`,
2399 `post-content`.`plink` AS `plink`,
2400 `post-content`.`location` AS `location`,
2401 `post-content`.`coord` AS `coord`,
2402 `post-content`.`app` AS `app`,
2403 `post-content`.`object-type` AS `object-type`,
2404 `post-content`.`object` AS `object`,
2405 `post-content`.`target-type` AS `target-type`,
2406 `post-content`.`target` AS `target`,
2407 `post-content`.`resource-id` AS `resource-id`,
2408 `post`.`author-id` AS `contact-id`,
2409 `author`.`uri-id` AS `contact-uri-id`,
2410 `author`.`url` AS `contact-link`,
2411 `author`.`addr` AS `contact-addr`,
2412 `author`.`name` AS `contact-name`,
2413 `author`.`nick` AS `contact-nick`,
2414 `author`.`thumb` AS `contact-avatar`,
2415 `author`.`network` AS `contact-network`,
2416 `author`.`blocked` AS `contact-blocked`,
2417 `author`.`hidden` AS `contact-hidden`,
2418 `author`.`readonly` AS `contact-readonly`,
2419 `author`.`archive` AS `contact-archive`,
2420 `author`.`pending` AS `contact-pending`,
2421 `author`.`rel` AS `contact-rel`,
2422 `author`.`uid` AS `contact-uid`,
2423 `author`.`contact-type` AS `contact-contact-type`,
2424 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2426 `author`.`id` AS `cid`,
2427 `author`.`alias` AS `alias`,
2428 `author`.`photo` AS `photo`,
2429 `author`.`name-date` AS `name-date`,
2430 `author`.`uri-date` AS `uri-date`,
2431 `author`.`avatar-date` AS `avatar-date`,
2432 `author`.`thumb` AS `thumb`,
2433 `post`.`author-id` AS `author-id`,
2434 `author`.`uri-id` AS `author-uri-id`,
2435 `author`.`url` AS `author-link`,
2436 `author`.`addr` AS `author-addr`,
2437 `author`.`name` AS `author-name`,
2438 `author`.`nick` AS `author-nick`,
2439 `author`.`alias` AS `author-alias`,
2440 `author`.`thumb` AS `author-avatar`,
2441 `author`.`network` AS `author-network`,
2442 `author`.`blocked` AS `author-blocked`,
2443 `author`.`hidden` AS `author-hidden`,
2444 `author`.`updated` AS `author-updated`,
2445 `author`.`gsid` AS `author-gsid`,
2446 `post`.`owner-id` AS `owner-id`,
2447 `owner`.`uri-id` AS `owner-uri-id`,
2448 `owner`.`url` AS `owner-link`,
2449 `owner`.`addr` AS `owner-addr`,
2450 `owner`.`name` AS `owner-name`,
2451 `owner`.`nick` AS `owner-nick`,
2452 `owner`.`alias` AS `owner-alias`,
2453 `owner`.`thumb` AS `owner-avatar`,
2454 `owner`.`network` AS `owner-network`,
2455 `owner`.`blocked` AS `owner-blocked`,
2456 `owner`.`hidden` AS `owner-hidden`,
2457 `owner`.`updated` AS `owner-updated`,
2458 `owner`.`contact-type` AS `owner-contact-type`,
2459 `owner`.`gsid` AS `owner-gsid`,
2460 `post`.`causer-id` AS `causer-id`,
2461 `causer`.`uri-id` AS `causer-uri-id`,
2462 `causer`.`url` AS `causer-link`,
2463 `causer`.`addr` AS `causer-addr`,
2464 `causer`.`name` AS `causer-name`,
2465 `causer`.`nick` AS `causer-nick`,
2466 `causer`.`alias` AS `causer-alias`,
2467 `causer`.`thumb` AS `causer-avatar`,
2468 `causer`.`network` AS `causer-network`,
2469 `causer`.`blocked` AS `causer-blocked`,
2470 `causer`.`hidden` AS `causer-hidden`,
2471 `causer`.`contact-type` AS `causer-contact-type`,
2472 `causer`.`gsid` AS `causer-gsid`,
2473 `post-question`.`id` AS `question-id`,
2474 `post-question`.`multiple` AS `question-multiple`,
2475 `post-question`.`voters` AS `question-voters`,
2476 `post-question`.`end-time` AS `question-end-time`,
2477 0 AS `has-categories`,
2478 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post`.`uri-id`) AS `has-media`,
2479 `diaspora-interaction`.`interaction` AS `signed_text`,
2480 `parent-item-uri`.`guid` AS `parent-guid`,
2481 `post-thread`.`network` AS `parent-network`,
2482 `post-thread`.`author-id` AS `parent-author-id`,
2483 `parent-post-author`.`url` AS `parent-author-link`,
2484 `parent-post-author`.`name` AS `parent-author-name`,
2485 `parent-post-author`.`nick` AS `parent-author-nick`,
2486 `parent-post-author`.`network` AS `parent-author-network`
2488 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
2489 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
2490 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
2491 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
2492 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
2493 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2494 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2495 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
2496 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2497 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2498 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
2499 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
2500 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2501 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post`.`uri-id`
2502 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `post-thread`.`author-id`;
2505 -- VIEW post-thread-view
2507 DROP VIEW IF EXISTS `post-thread-view`;
2508 CREATE VIEW `post-thread-view` AS SELECT
2509 `item-uri`.`uri` AS `uri`,
2510 `post-thread`.`uri-id` AS `uri-id`,
2511 `parent-item-uri`.`uri` AS `parent-uri`,
2512 `post`.`parent-uri-id` AS `parent-uri-id`,
2513 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2514 `post`.`thr-parent-id` AS `thr-parent-id`,
2515 `conversation-item-uri`.`uri` AS `conversation`,
2516 `post-thread`.`conversation-id` AS `conversation-id`,
2517 `quote-item-uri`.`uri` AS `quote-uri`,
2518 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2519 `item-uri`.`guid` AS `guid`,
2520 `post`.`gravity` AS `gravity`,
2521 `external-item-uri`.`uri` AS `extid`,
2522 `post`.`external-id` AS `external-id`,
2523 `post-thread`.`created` AS `created`,
2524 `post`.`edited` AS `edited`,
2525 `post-thread`.`commented` AS `commented`,
2526 `post-thread`.`received` AS `received`,
2527 `post-thread`.`changed` AS `changed`,
2528 `post`.`post-type` AS `post-type`,
2529 `post`.`private` AS `private`,
2530 `post`.`visible` AS `visible`,
2531 `post`.`deleted` AS `deleted`,
2532 `post`.`global` AS `global`,
2533 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread`.`uri-id`) AS `featured`,
2534 `post-thread`.`network` AS `network`,
2535 `post`.`vid` AS `vid`,
2536 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2537 `post-content`.`title` AS `title`,
2538 `post-content`.`content-warning` AS `content-warning`,
2539 `post-content`.`raw-body` AS `raw-body`,
2540 `post-content`.`body` AS `body`,
2541 `post-content`.`rendered-hash` AS `rendered-hash`,
2542 `post-content`.`rendered-html` AS `rendered-html`,
2543 `post-content`.`language` AS `language`,
2544 `post-content`.`plink` AS `plink`,
2545 `post-content`.`location` AS `location`,
2546 `post-content`.`coord` AS `coord`,
2547 `post-content`.`app` AS `app`,
2548 `post-content`.`object-type` AS `object-type`,
2549 `post-content`.`object` AS `object`,
2550 `post-content`.`target-type` AS `target-type`,
2551 `post-content`.`target` AS `target`,
2552 `post-content`.`resource-id` AS `resource-id`,
2553 `post-thread`.`author-id` AS `contact-id`,
2554 `author`.`uri-id` AS `contact-uri-id`,
2555 `author`.`url` AS `contact-link`,
2556 `author`.`addr` AS `contact-addr`,
2557 `author`.`name` AS `contact-name`,
2558 `author`.`nick` AS `contact-nick`,
2559 `author`.`thumb` AS `contact-avatar`,
2560 `author`.`network` AS `contact-network`,
2561 `author`.`blocked` AS `contact-blocked`,
2562 `author`.`hidden` AS `contact-hidden`,
2563 `author`.`readonly` AS `contact-readonly`,
2564 `author`.`archive` AS `contact-archive`,
2565 `author`.`pending` AS `contact-pending`,
2566 `author`.`rel` AS `contact-rel`,
2567 `author`.`uid` AS `contact-uid`,
2568 `author`.`contact-type` AS `contact-contact-type`,
2569 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2571 `author`.`id` AS `cid`,
2572 `author`.`alias` AS `alias`,
2573 `author`.`photo` AS `photo`,
2574 `author`.`name-date` AS `name-date`,
2575 `author`.`uri-date` AS `uri-date`,
2576 `author`.`avatar-date` AS `avatar-date`,
2577 `author`.`thumb` AS `thumb`,
2578 `post-thread`.`author-id` AS `author-id`,
2579 `author`.`uri-id` AS `author-uri-id`,
2580 `author`.`url` AS `author-link`,
2581 `author`.`addr` AS `author-addr`,
2582 `author`.`name` AS `author-name`,
2583 `author`.`nick` AS `author-nick`,
2584 `author`.`alias` AS `author-alias`,
2585 `author`.`thumb` AS `author-avatar`,
2586 `author`.`network` AS `author-network`,
2587 `author`.`blocked` AS `author-blocked`,
2588 `author`.`hidden` AS `author-hidden`,
2589 `author`.`updated` AS `author-updated`,
2590 `author`.`gsid` AS `author-gsid`,
2591 `post-thread`.`owner-id` AS `owner-id`,
2592 `owner`.`uri-id` AS `owner-uri-id`,
2593 `owner`.`url` AS `owner-link`,
2594 `owner`.`addr` AS `owner-addr`,
2595 `owner`.`name` AS `owner-name`,
2596 `owner`.`nick` AS `owner-nick`,
2597 `owner`.`alias` AS `owner-alias`,
2598 `owner`.`thumb` AS `owner-avatar`,
2599 `owner`.`network` AS `owner-network`,
2600 `owner`.`blocked` AS `owner-blocked`,
2601 `owner`.`hidden` AS `owner-hidden`,
2602 `owner`.`updated` AS `owner-updated`,
2603 `owner`.`gsid` AS `owner-gsid`,
2604 `owner`.`contact-type` AS `owner-contact-type`,
2605 `post-thread`.`causer-id` AS `causer-id`,
2606 `causer`.`uri-id` AS `causer-uri-id`,
2607 `causer`.`url` AS `causer-link`,
2608 `causer`.`addr` AS `causer-addr`,
2609 `causer`.`name` AS `causer-name`,
2610 `causer`.`nick` AS `causer-nick`,
2611 `causer`.`alias` AS `causer-alias`,
2612 `causer`.`thumb` AS `causer-avatar`,
2613 `causer`.`network` AS `causer-network`,
2614 `causer`.`blocked` AS `causer-blocked`,
2615 `causer`.`hidden` AS `causer-hidden`,
2616 `causer`.`gsid` AS `causer-gsid`,
2617 `causer`.`contact-type` AS `causer-contact-type`,
2618 `post-question`.`id` AS `question-id`,
2619 `post-question`.`multiple` AS `question-multiple`,
2620 `post-question`.`voters` AS `question-voters`,
2621 `post-question`.`end-time` AS `question-end-time`,
2622 0 AS `has-categories`,
2623 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread`.`uri-id`) AS `has-media`,
2624 (SELECT COUNT(*) FROM `post` WHERE `parent-uri-id` = `post-thread`.`uri-id` AND `gravity` = 6) AS `total-comments`,
2625 (SELECT COUNT(DISTINCT(`author-id`)) FROM `post` WHERE `parent-uri-id` = `post-thread`.`uri-id` AND `gravity` = 6) AS `total-actors`,
2626 `diaspora-interaction`.`interaction` AS `signed_text`,
2627 `parent-item-uri`.`guid` AS `parent-guid`,
2628 `post-thread`.`network` AS `parent-network`,
2629 `post-thread`.`author-id` AS `parent-author-id`,
2630 `author`.`url` AS `parent-author-link`,
2631 `author`.`name` AS `parent-author-name`,
2632 `author`.`nick` AS `parent-author-nick`,
2633 `author`.`network` AS `parent-author-network`
2635 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
2636 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
2637 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
2638 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
2639 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
2640 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2641 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2642 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
2643 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2644 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2645 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
2646 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
2647 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2648 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread`.`uri-id`;
2651 -- VIEW category-view
2653 DROP VIEW IF EXISTS `category-view`;
2654 CREATE VIEW `category-view` AS SELECT
2655 `post-category`.`uri-id` AS `uri-id`,
2656 `post-category`.`uid` AS `uid`,
2657 `post-category`.`type` AS `type`,
2658 `post-category`.`tid` AS `tid`,
2659 `tag`.`name` AS `name`,
2660 `tag`.`url` AS `url`
2661 FROM `post-category`
2662 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2665 -- VIEW collection-view
2667 DROP VIEW IF EXISTS `collection-view`;
2668 CREATE VIEW `collection-view` AS SELECT
2669 `post-collection`.`uri-id` AS `uri-id`,
2670 `post-collection`.`type` AS `type`,
2671 `post-collection`.`author-id` AS `cid`,
2672 `post`.`received` AS `received`,
2673 `post`.`created` AS `created`,
2674 `post-thread`.`commented` AS `commented`,
2675 `post`.`private` AS `private`,
2676 `post`.`visible` AS `visible`,
2677 `post`.`deleted` AS `deleted`,
2678 `post`.`thr-parent-id` AS `thr-parent-id`,
2679 `post-collection`.`author-id` AS `author-id`,
2680 `post`.`gravity` AS `gravity`
2681 FROM `post-collection`
2682 INNER JOIN `post` ON `post-collection`.`uri-id` = `post`.`uri-id`
2683 INNER JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`;
2688 DROP VIEW IF EXISTS `media-view`;
2689 CREATE VIEW `media-view` AS SELECT
2690 `post-media`.`uri-id` AS `uri-id`,
2691 `post-media`.`type` AS `type`,
2692 `post`.`received` AS `received`,
2693 `post`.`created` AS `created`,
2694 `post`.`private` AS `private`,
2695 `post`.`visible` AS `visible`,
2696 `post`.`deleted` AS `deleted`,
2697 `post`.`thr-parent-id` AS `thr-parent-id`,
2698 `post`.`author-id` AS `author-id`,
2699 `post`.`gravity` AS `gravity`
2701 INNER JOIN `post` ON `post-media`.`uri-id` = `post`.`uri-id`;
2706 DROP VIEW IF EXISTS `tag-view`;
2707 CREATE VIEW `tag-view` AS SELECT
2708 `post-tag`.`uri-id` AS `uri-id`,
2709 `post-tag`.`type` AS `type`,
2710 `post-tag`.`tid` AS `tid`,
2711 `post-tag`.`cid` AS `cid`,
2712 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2713 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`,
2714 CASE `cid` WHEN 0 THEN `tag`.`type` ELSE 1 END AS `tag-type`
2716 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2717 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2720 -- VIEW network-item-view
2722 DROP VIEW IF EXISTS `network-item-view`;
2723 CREATE VIEW `network-item-view` AS SELECT
2724 `post-user`.`uri-id` AS `uri-id`,
2725 `post-thread-user`.`post-user-id` AS `parent`,
2726 `post-user`.`received` AS `received`,
2727 `post-thread-user`.`commented` AS `commented`,
2728 `post-user`.`created` AS `created`,
2729 `post-user`.`uid` AS `uid`,
2730 `post-thread-user`.`starred` AS `starred`,
2731 `post-thread-user`.`mention` AS `mention`,
2732 `post-user`.`network` AS `network`,
2733 `post-user`.`unseen` AS `unseen`,
2734 `post-user`.`gravity` AS `gravity`,
2735 `post-user`.`contact-id` AS `contact-id`,
2736 `ownercontact`.`contact-type` AS `contact-type`
2738 INNER JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2739 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2740 STRAIGHT_JOIN `contact` AS `authorcontact` ON `authorcontact`.`id` = `post-thread-user`.`author-id`
2741 STRAIGHT_JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2742 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2743 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2744 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
2745 AND NOT `authorcontact`.`blocked` AND NOT `ownercontact`.`blocked`
2746 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`))
2747 AND NOT EXISTS(SELECT `gsid` FROM `user-gserver` WHERE `uid` = `post-thread-user`.`uid` AND `gsid` IN (`authorcontact`.`gsid`, `ownercontact`.`gsid`) AND `ignored`);
2750 -- VIEW network-thread-view
2752 DROP VIEW IF EXISTS `network-thread-view`;
2753 CREATE VIEW `network-thread-view` AS SELECT
2754 `post-thread-user`.`uri-id` AS `uri-id`,
2755 `post-thread-user`.`post-user-id` AS `parent`,
2756 `post-thread-user`.`received` AS `received`,
2757 `post-thread-user`.`commented` AS `commented`,
2758 `post-thread-user`.`created` AS `created`,
2759 `post-thread-user`.`uid` AS `uid`,
2760 `post-thread-user`.`starred` AS `starred`,
2761 `post-thread-user`.`mention` AS `mention`,
2762 `post-thread-user`.`network` AS `network`,
2763 `post-thread-user`.`contact-id` AS `contact-id`,
2764 `ownercontact`.`contact-type` AS `contact-type`
2765 FROM `post-thread-user`
2766 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2767 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2768 STRAIGHT_JOIN `contact` AS `authorcontact` ON `authorcontact`.`id` = `post-thread-user`.`author-id`
2769 STRAIGHT_JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2770 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2771 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2772 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2773 AND NOT `authorcontact`.`blocked` AND NOT `ownercontact`.`blocked`
2774 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`))
2775 AND NOT EXISTS(SELECT `gsid` FROM `user-gserver` WHERE `uid` = `post-thread-user`.`uid` AND `gsid` IN (`authorcontact`.`gsid`, `ownercontact`.`gsid`) AND `ignored`);
2780 DROP VIEW IF EXISTS `owner-view`;
2781 CREATE VIEW `owner-view` AS SELECT
2782 `contact`.`id` AS `id`,
2783 `contact`.`uid` AS `uid`,
2784 `contact`.`created` AS `created`,
2785 `contact`.`updated` AS `updated`,
2786 `contact`.`self` AS `self`,
2787 `contact`.`remote_self` AS `remote_self`,
2788 `contact`.`rel` AS `rel`,
2789 `contact`.`network` AS `network`,
2790 `contact`.`protocol` AS `protocol`,
2791 `contact`.`name` AS `name`,
2792 `contact`.`nick` AS `nick`,
2793 `contact`.`location` AS `location`,
2794 `contact`.`about` AS `about`,
2795 `contact`.`keywords` AS `keywords`,
2796 `contact`.`xmpp` AS `xmpp`,
2797 `contact`.`matrix` AS `matrix`,
2798 `contact`.`attag` AS `attag`,
2799 `contact`.`avatar` AS `avatar`,
2800 `contact`.`photo` AS `photo`,
2801 `contact`.`thumb` AS `thumb`,
2802 `contact`.`micro` AS `micro`,
2803 `contact`.`header` AS `header`,
2804 `contact`.`url` AS `url`,
2805 `contact`.`nurl` AS `nurl`,
2806 `contact`.`uri-id` AS `uri-id`,
2807 `contact`.`addr` AS `addr`,
2808 `contact`.`alias` AS `alias`,
2809 `contact`.`pubkey` AS `pubkey`,
2810 `contact`.`prvkey` AS `prvkey`,
2811 `contact`.`batch` AS `batch`,
2812 `contact`.`request` AS `request`,
2813 `contact`.`notify` AS `notify`,
2814 `contact`.`poll` AS `poll`,
2815 `contact`.`confirm` AS `confirm`,
2816 `contact`.`poco` AS `poco`,
2817 `contact`.`subhub` AS `subhub`,
2818 `contact`.`hub-verify` AS `hub-verify`,
2819 `contact`.`last-update` AS `last-update`,
2820 `contact`.`success_update` AS `success_update`,
2821 `contact`.`failure_update` AS `failure_update`,
2822 `contact`.`name-date` AS `name-date`,
2823 `contact`.`uri-date` AS `uri-date`,
2824 `contact`.`avatar-date` AS `avatar-date`,
2825 `contact`.`avatar-date` AS `picdate`,
2826 `contact`.`term-date` AS `term-date`,
2827 `contact`.`last-item` AS `last-item`,
2828 `contact`.`priority` AS `priority`,
2829 `user`.`blocked` AS `blocked`,
2830 `contact`.`block_reason` AS `block_reason`,
2831 `contact`.`readonly` AS `readonly`,
2832 `contact`.`writable` AS `writable`,
2833 `contact`.`forum` AS `forum`,
2834 `contact`.`prv` AS `prv`,
2835 `contact`.`contact-type` AS `contact-type`,
2836 `contact`.`manually-approve` AS `manually-approve`,
2837 `contact`.`hidden` AS `hidden`,
2838 `contact`.`archive` AS `archive`,
2839 `contact`.`pending` AS `pending`,
2840 `contact`.`deleted` AS `deleted`,
2841 `contact`.`unsearchable` AS `unsearchable`,
2842 `contact`.`sensitive` AS `sensitive`,
2843 `contact`.`baseurl` AS `baseurl`,
2844 `contact`.`reason` AS `reason`,
2845 `contact`.`info` AS `info`,
2846 `contact`.`bdyear` AS `bdyear`,
2847 `contact`.`bd` AS `bd`,
2848 `contact`.`notify_new_posts` AS `notify_new_posts`,
2849 `contact`.`fetch_further_information` AS `fetch_further_information`,
2850 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2851 `user`.`parent-uid` AS `parent-uid`,
2852 `user`.`guid` AS `guid`,
2853 `user`.`nickname` AS `nickname`,
2854 `user`.`email` AS `email`,
2855 `user`.`openid` AS `openid`,
2856 `user`.`timezone` AS `timezone`,
2857 `user`.`language` AS `language`,
2858 `user`.`register_date` AS `register_date`,
2859 `user`.`login_date` AS `login_date`,
2860 `user`.`last-activity` AS `last-activity`,
2861 `user`.`default-location` AS `default-location`,
2862 `user`.`allow_location` AS `allow_location`,
2863 `user`.`theme` AS `theme`,
2864 `user`.`pubkey` AS `upubkey`,
2865 `user`.`prvkey` AS `uprvkey`,
2866 `user`.`sprvkey` AS `sprvkey`,
2867 `user`.`spubkey` AS `spubkey`,
2868 `user`.`verified` AS `verified`,
2869 `user`.`blockwall` AS `blockwall`,
2870 `user`.`hidewall` AS `hidewall`,
2871 `user`.`blocktags` AS `blocktags`,
2872 `user`.`unkmail` AS `unkmail`,
2873 `user`.`cntunkmail` AS `cntunkmail`,
2874 `user`.`notify-flags` AS `notify-flags`,
2875 `user`.`page-flags` AS `page-flags`,
2876 `user`.`account-type` AS `account-type`,
2877 `user`.`prvnets` AS `prvnets`,
2878 `user`.`maxreq` AS `maxreq`,
2879 `user`.`expire` AS `expire`,
2880 `user`.`account_removed` AS `account_removed`,
2881 `user`.`account_expired` AS `account_expired`,
2882 `user`.`account_expires_on` AS `account_expires_on`,
2883 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2884 `user`.`def_gid` AS `def_gid`,
2885 `user`.`allow_cid` AS `allow_cid`,
2886 `user`.`allow_gid` AS `allow_gid`,
2887 `user`.`deny_cid` AS `deny_cid`,
2888 `user`.`deny_gid` AS `deny_gid`,
2889 `user`.`openidserver` AS `openidserver`,
2890 `profile`.`publish` AS `publish`,
2891 `profile`.`net-publish` AS `net-publish`,
2892 `profile`.`hide-friends` AS `hide-friends`,
2893 `profile`.`prv_keywords` AS `prv_keywords`,
2894 `profile`.`pub_keywords` AS `pub_keywords`,
2895 `profile`.`address` AS `address`,
2896 `profile`.`locality` AS `locality`,
2897 `profile`.`region` AS `region`,
2898 `profile`.`postal-code` AS `postal-code`,
2899 `profile`.`country-name` AS `country-name`,
2900 `profile`.`homepage` AS `homepage`,
2901 `profile`.`homepage_verified` AS `homepage_verified`,
2902 `profile`.`dob` AS `dob`
2904 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2905 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2908 -- VIEW account-view
2910 DROP VIEW IF EXISTS `account-view`;
2911 CREATE VIEW `account-view` AS SELECT
2912 `contact`.`id` AS `id`,
2913 `contact`.`url` AS `url`,
2914 `contact`.`nurl` AS `nurl`,
2915 `contact`.`uri-id` AS `uri-id`,
2916 `item-uri`.`guid` AS `guid`,
2917 `contact`.`addr` AS `addr`,
2918 `contact`.`alias` AS `alias`,
2919 `contact`.`name` AS `name`,
2920 `contact`.`nick` AS `nick`,
2921 `contact`.`about` AS `about`,
2922 `contact`.`keywords` AS `keywords`,
2923 `contact`.`xmpp` AS `xmpp`,
2924 `contact`.`matrix` AS `matrix`,
2925 `contact`.`avatar` AS `avatar`,
2926 `contact`.`photo` AS `photo`,
2927 `contact`.`thumb` AS `thumb`,
2928 `contact`.`micro` AS `micro`,
2929 `contact`.`header` AS `header`,
2930 `contact`.`created` AS `created`,
2931 `contact`.`updated` AS `updated`,
2932 `contact`.`network` AS `network`,
2933 `contact`.`protocol` AS `protocol`,
2934 `contact`.`location` AS `location`,
2935 `contact`.`attag` AS `attag`,
2936 `contact`.`pubkey` AS `pubkey`,
2937 `contact`.`prvkey` AS `prvkey`,
2938 `contact`.`subscribe` AS `subscribe`,
2939 `contact`.`last-update` AS `last-update`,
2940 `contact`.`success_update` AS `success_update`,
2941 `contact`.`failure_update` AS `failure_update`,
2942 `contact`.`failed` AS `failed`,
2943 `contact`.`last-item` AS `last-item`,
2944 `contact`.`last-discovery` AS `last-discovery`,
2945 `contact`.`contact-type` AS `contact-type`,
2946 `contact`.`manually-approve` AS `manually-approve`,
2947 `contact`.`unsearchable` AS `unsearchable`,
2948 `contact`.`sensitive` AS `sensitive`,
2949 `contact`.`baseurl` AS `baseurl`,
2950 `contact`.`gsid` AS `gsid`,
2951 `contact`.`info` AS `info`,
2952 `contact`.`bdyear` AS `bdyear`,
2953 `contact`.`bd` AS `bd`,
2954 `contact`.`poco` AS `poco`,
2955 `contact`.`name-date` AS `name-date`,
2956 `contact`.`uri-date` AS `uri-date`,
2957 `contact`.`avatar-date` AS `avatar-date`,
2958 `contact`.`term-date` AS `term-date`,
2959 `contact`.`hidden` AS `global-ignored`,
2960 `contact`.`blocked` AS `global-blocked`,
2961 `contact`.`hidden` AS `hidden`,
2962 `contact`.`archive` AS `archive`,
2963 `contact`.`deleted` AS `deleted`,
2964 `contact`.`blocked` AS `blocked`,
2965 `contact`.`notify` AS `dfrn-notify`,
2966 `contact`.`poll` AS `dfrn-poll`,
2967 `item-uri`.`guid` AS `diaspora-guid`,
2968 `diaspora-contact`.`batch` AS `diaspora-batch`,
2969 `diaspora-contact`.`notify` AS `diaspora-notify`,
2970 `diaspora-contact`.`poll` AS `diaspora-poll`,
2971 `diaspora-contact`.`alias` AS `diaspora-alias`,
2972 `apcontact`.`uuid` AS `ap-uuid`,
2973 `apcontact`.`type` AS `ap-type`,
2974 `apcontact`.`following` AS `ap-following`,
2975 `apcontact`.`followers` AS `ap-followers`,
2976 `apcontact`.`inbox` AS `ap-inbox`,
2977 `apcontact`.`outbox` AS `ap-outbox`,
2978 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2979 `apcontact`.`generator` AS `ap-generator`,
2980 `apcontact`.`following_count` AS `ap-following_count`,
2981 `apcontact`.`followers_count` AS `ap-followers_count`,
2982 `apcontact`.`statuses_count` AS `ap-statuses_count`,
2983 `gserver`.`site_name` AS `site_name`,
2984 `gserver`.`platform` AS `platform`,
2985 `gserver`.`version` AS `version`,
2986 `gserver`.`blocked` AS `server-blocked`,
2987 `gserver`.`failed` AS `server-failed`
2989 LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id`
2990 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
2991 LEFT JOIN `diaspora-contact` ON `diaspora-contact`.`uri-id` = contact.`uri-id`
2992 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`
2993 WHERE `contact`.`uid` = 0;
2996 -- VIEW account-user-view
2998 DROP VIEW IF EXISTS `account-user-view`;
2999 CREATE VIEW `account-user-view` AS SELECT
3000 `ucontact`.`id` AS `id`,
3001 `contact`.`id` AS `pid`,
3002 `ucontact`.`uid` AS `uid`,
3003 `contact`.`url` AS `url`,
3004 `contact`.`nurl` AS `nurl`,
3005 `contact`.`uri-id` AS `uri-id`,
3006 `item-uri`.`guid` AS `guid`,
3007 `contact`.`addr` AS `addr`,
3008 `contact`.`alias` AS `alias`,
3009 `contact`.`name` AS `name`,
3010 `contact`.`nick` AS `nick`,
3011 `contact`.`about` AS `about`,
3012 `contact`.`keywords` AS `keywords`,
3013 `contact`.`xmpp` AS `xmpp`,
3014 `contact`.`matrix` AS `matrix`,
3015 `contact`.`avatar` AS `avatar`,
3016 `contact`.`photo` AS `photo`,
3017 `contact`.`thumb` AS `thumb`,
3018 `contact`.`micro` AS `micro`,
3019 `contact`.`header` AS `header`,
3020 `contact`.`created` AS `created`,
3021 `contact`.`updated` AS `updated`,
3022 `ucontact`.`self` AS `self`,
3023 `ucontact`.`remote_self` AS `remote_self`,
3024 `ucontact`.`rel` AS `rel`,
3025 `contact`.`network` AS `network`,
3026 `ucontact`.`protocol` AS `protocol`,
3027 `contact`.`location` AS `location`,
3028 `ucontact`.`attag` AS `attag`,
3029 `contact`.`pubkey` AS `pubkey`,
3030 `contact`.`prvkey` AS `prvkey`,
3031 `contact`.`subscribe` AS `subscribe`,
3032 `contact`.`last-update` AS `last-update`,
3033 `contact`.`success_update` AS `success_update`,
3034 `contact`.`failure_update` AS `failure_update`,
3035 `contact`.`failed` AS `failed`,
3036 `contact`.`last-item` AS `last-item`,
3037 `contact`.`last-discovery` AS `last-discovery`,
3038 `contact`.`contact-type` AS `contact-type`,
3039 `contact`.`manually-approve` AS `manually-approve`,
3040 `contact`.`unsearchable` AS `unsearchable`,
3041 `contact`.`sensitive` AS `sensitive`,
3042 `contact`.`baseurl` AS `baseurl`,
3043 `contact`.`gsid` AS `gsid`,
3044 `ucontact`.`info` AS `info`,
3045 `contact`.`bdyear` AS `bdyear`,
3046 `contact`.`bd` AS `bd`,
3047 `contact`.`poco` AS `poco`,
3048 `contact`.`name-date` AS `name-date`,
3049 `contact`.`uri-date` AS `uri-date`,
3050 `contact`.`avatar-date` AS `avatar-date`,
3051 `contact`.`term-date` AS `term-date`,
3052 `contact`.`hidden` AS `global-ignored`,
3053 `contact`.`blocked` AS `global-blocked`,
3054 `ucontact`.`hidden` AS `hidden`,
3055 `ucontact`.`archive` AS `archive`,
3056 `ucontact`.`pending` AS `pending`,
3057 `ucontact`.`deleted` AS `deleted`,
3058 `ucontact`.`notify_new_posts` AS `notify_new_posts`,
3059 `ucontact`.`fetch_further_information` AS `fetch_further_information`,
3060 `ucontact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
3061 `ucontact`.`rating` AS `rating`,
3062 `ucontact`.`readonly` AS `readonly`,
3063 `ucontact`.`blocked` AS `blocked`,
3064 `ucontact`.`block_reason` AS `block_reason`,
3065 `ucontact`.`subhub` AS `subhub`,
3066 `ucontact`.`hub-verify` AS `hub-verify`,
3067 `ucontact`.`reason` AS `reason`,
3068 `contact`.`notify` AS `dfrn-notify`,
3069 `contact`.`poll` AS `dfrn-poll`,
3070 `item-uri`.`guid` AS `diaspora-guid`,
3071 `diaspora-contact`.`batch` AS `diaspora-batch`,
3072 `diaspora-contact`.`notify` AS `diaspora-notify`,
3073 `diaspora-contact`.`poll` AS `diaspora-poll`,
3074 `diaspora-contact`.`alias` AS `diaspora-alias`,
3075 `diaspora-contact`.`interacting_count` AS `diaspora-interacting_count`,
3076 `diaspora-contact`.`interacted_count` AS `diaspora-interacted_count`,
3077 `diaspora-contact`.`post_count` AS `diaspora-post_count`,
3078 `apcontact`.`uuid` AS `ap-uuid`,
3079 `apcontact`.`type` AS `ap-type`,
3080 `apcontact`.`following` AS `ap-following`,
3081 `apcontact`.`followers` AS `ap-followers`,
3082 `apcontact`.`inbox` AS `ap-inbox`,
3083 `apcontact`.`outbox` AS `ap-outbox`,
3084 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
3085 `apcontact`.`generator` AS `ap-generator`,
3086 `apcontact`.`following_count` AS `ap-following_count`,
3087 `apcontact`.`followers_count` AS `ap-followers_count`,
3088 `apcontact`.`statuses_count` AS `ap-statuses_count`,
3089 `gserver`.`site_name` AS `site_name`,
3090 `gserver`.`platform` AS `platform`,
3091 `gserver`.`version` AS `version`,
3092 `gserver`.`blocked` AS `server-blocked`,
3093 `gserver`.`failed` AS `server-failed`
3094 FROM `contact` AS `ucontact`
3095 INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
3096 LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id`
3097 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
3098 LEFT JOIN `diaspora-contact` ON `diaspora-contact`.`uri-id` = `ucontact`.`uri-id`
3099 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`;
3102 -- VIEW pending-view
3104 DROP VIEW IF EXISTS `pending-view`;
3105 CREATE VIEW `pending-view` AS SELECT
3106 `register`.`id` AS `id`,
3107 `register`.`hash` AS `hash`,
3108 `register`.`created` AS `created`,
3109 `register`.`uid` AS `uid`,
3110 `register`.`password` AS `password`,
3111 `register`.`language` AS `language`,
3112 `register`.`note` AS `note`,
3113 `contact`.`self` AS `self`,
3114 `contact`.`name` AS `name`,
3115 `contact`.`url` AS `url`,
3116 `contact`.`micro` AS `micro`,
3117 `user`.`email` AS `email`,
3118 `contact`.`nick` AS `nick`
3120 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
3121 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
3124 -- VIEW tag-search-view
3126 DROP VIEW IF EXISTS `tag-search-view`;
3127 CREATE VIEW `tag-search-view` AS SELECT
3128 `post-tag`.`uri-id` AS `uri-id`,
3129 `post-user`.`uid` AS `uid`,
3130 `post-user`.`id` AS `iid`,
3131 `post-user`.`private` AS `private`,
3132 `post-user`.`wall` AS `wall`,
3133 `post-user`.`origin` AS `origin`,
3134 `post-user`.`global` AS `global`,
3135 `post-user`.`gravity` AS `gravity`,
3136 `post-user`.`received` AS `received`,
3137 `post-user`.`network` AS `network`,
3138 `post-user`.`author-id` AS `author-id`,
3139 `tag`.`name` AS `name`
3141 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
3142 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
3143 WHERE `post-tag`.`type` = 1;
3146 -- VIEW workerqueue-view
3148 DROP VIEW IF EXISTS `workerqueue-view`;
3149 CREATE VIEW `workerqueue-view` AS SELECT
3150 `process`.`pid` AS `pid`,
3151 `workerqueue`.`priority` AS `priority`
3153 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
3154 WHERE NOT `workerqueue`.`done`;
3157 -- VIEW profile_field-view
3159 DROP VIEW IF EXISTS `profile_field-view`;
3160 CREATE VIEW `profile_field-view` AS SELECT
3161 `profile_field`.`id` AS `id`,
3162 `profile_field`.`uid` AS `uid`,
3163 `profile_field`.`label` AS `label`,
3164 `profile_field`.`value` AS `value`,
3165 `profile_field`.`order` AS `order`,
3166 `profile_field`.`psid` AS `psid`,
3167 `permissionset`.`allow_cid` AS `allow_cid`,
3168 `permissionset`.`allow_gid` AS `allow_gid`,
3169 `permissionset`.`deny_cid` AS `deny_cid`,
3170 `permissionset`.`deny_gid` AS `deny_gid`,
3171 `profile_field`.`created` AS `created`,
3172 `profile_field`.`edited` AS `edited`
3173 FROM `profile_field`
3174 INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`;
3177 -- VIEW diaspora-contact-view
3179 DROP VIEW IF EXISTS `diaspora-contact-view`;
3180 CREATE VIEW `diaspora-contact-view` AS SELECT
3181 `diaspora-contact`.`uri-id` AS `uri-id`,
3182 `item-uri`.`uri` AS `url`,
3183 `item-uri`.`guid` AS `guid`,
3184 `diaspora-contact`.`addr` AS `addr`,
3185 `diaspora-contact`.`alias` AS `alias`,
3186 `diaspora-contact`.`nick` AS `nick`,
3187 `diaspora-contact`.`name` AS `name`,
3188 `diaspora-contact`.`given-name` AS `given-name`,
3189 `diaspora-contact`.`family-name` AS `family-name`,
3190 `diaspora-contact`.`photo` AS `photo`,
3191 `diaspora-contact`.`photo-medium` AS `photo-medium`,
3192 `diaspora-contact`.`photo-small` AS `photo-small`,
3193 `diaspora-contact`.`batch` AS `batch`,
3194 `diaspora-contact`.`notify` AS `notify`,
3195 `diaspora-contact`.`poll` AS `poll`,
3196 `diaspora-contact`.`subscribe` AS `subscribe`,
3197 `diaspora-contact`.`searchable` AS `searchable`,
3198 `diaspora-contact`.`pubkey` AS `pubkey`,
3199 `gserver`.`url` AS `baseurl`,
3200 `diaspora-contact`.`gsid` AS `gsid`,
3201 `diaspora-contact`.`created` AS `created`,
3202 `diaspora-contact`.`updated` AS `updated`,
3203 `diaspora-contact`.`interacting_count` AS `interacting_count`,
3204 `diaspora-contact`.`interacted_count` AS `interacted_count`,
3205 `diaspora-contact`.`post_count` AS `post_count`
3206 FROM `diaspora-contact`
3207 INNER JOIN `item-uri` ON `item-uri`.`id` = `diaspora-contact`.`uri-id`
3208 LEFT JOIN `gserver` ON `gserver`.`id` = `diaspora-contact`.`gsid`;