1 -- ------------------------------------------
2 -- Friendica 2023.03-dev (Giant Rhubarb)
3 -- DB_UPDATE_VERSION 1508
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 `failed` boolean COMMENT 'Connection failed',
38 `next_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Next connection request',
40 UNIQUE INDEX `nurl` (`nurl`(190)),
41 INDEX `next_contact` (`next_contact`),
42 INDEX `network` (`network`)
43 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Global servers';
48 CREATE TABLE IF NOT EXISTS `user` (
49 `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
50 `parent-uid` mediumint unsigned COMMENT 'The parent user that has full control about this user',
51 `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
52 `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
53 `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
54 `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
55 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
56 `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
57 `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
58 `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
59 `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
60 `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
61 `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
62 `last-activity` date COMMENT 'Day of the last activity',
63 `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
64 `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
65 `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
66 `pubkey` text COMMENT 'RSA public key 4096 bit',
67 `prvkey` text COMMENT 'RSA private key 4096 bit',
68 `spubkey` text COMMENT '',
69 `sprvkey` text COMMENT '',
70 `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
71 `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
72 `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
73 `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unkown viewers',
74 `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
75 `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
76 `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
77 `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
78 `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
79 `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
80 `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
81 `pwdreset` varchar(255) COMMENT 'Password reset request token',
82 `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
83 `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
84 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT 'Delay in days before deleting user-related posts. Scope is controlled by pConfig.',
85 `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
86 `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
87 `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
88 `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
89 `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
90 `allow_cid` mediumtext COMMENT 'default permission for this user',
91 `allow_gid` mediumtext COMMENT 'default permission for this user',
92 `deny_cid` mediumtext COMMENT 'default permission for this user',
93 `deny_gid` mediumtext COMMENT 'default permission for this user',
94 `openidserver` text COMMENT '',
96 INDEX `nickname` (`nickname`(32)),
97 INDEX `parent-uid` (`parent-uid`),
98 INDEX `guid` (`guid`),
99 INDEX `email` (`email`(64)),
100 FOREIGN KEY (`parent-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
101 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
106 CREATE TABLE IF NOT EXISTS `item-uri` (
107 `id` int unsigned NOT NULL auto_increment,
108 `uri` varbinary(383) NOT NULL COMMENT 'URI of an item',
109 `guid` varbinary(255) COMMENT 'A unique identifier for an item',
111 UNIQUE INDEX `uri` (`uri`),
112 INDEX `guid` (`guid`)
113 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
118 CREATE TABLE IF NOT EXISTS `contact` (
119 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
120 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
121 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
122 `updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last contact update',
123 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network of the contact',
124 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
125 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
126 `location` varchar(255) DEFAULT '' COMMENT '',
127 `about` text COMMENT '',
128 `keywords` text COMMENT 'public keywords (interests) of the contact',
129 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
130 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
131 `avatar` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
132 `blurhash` varbinary(255) COMMENT 'BlurHash representation of the avatar',
133 `header` varbinary(383) COMMENT 'Header picture',
134 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
135 `nurl` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
136 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
137 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
138 `alias` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
139 `pubkey` text COMMENT 'RSA public key 4096 bit',
140 `prvkey` text COMMENT 'RSA private key 4096 bit',
141 `batch` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
142 `notify` varbinary(383) COMMENT '',
143 `poll` varbinary(383) COMMENT '',
144 `subscribe` varbinary(383) COMMENT '',
145 `last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
146 `next-update` datetime COMMENT 'Next connection request',
147 `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
148 `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
149 `failed` boolean COMMENT 'Connection failed',
150 `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
151 `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
152 `last-discovery` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last follower discovery',
153 `local-data` boolean COMMENT 'Is true when there are posts with this contact on the system',
154 `blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
155 `block_reason` text COMMENT 'Node-wide block reason',
156 `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
157 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Person, organisation, news, community, relay',
158 `manually-approve` boolean COMMENT 'Contact requests have to be approved manually',
159 `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
160 `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
161 `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
162 `baseurl` varbinary(383) DEFAULT '' COMMENT 'baseurl of the contact',
163 `gsid` int unsigned COMMENT 'Global Server ID',
164 `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
165 `reason` text COMMENT '',
166 `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
167 `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
168 `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
169 `protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
170 `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
171 `hub-verify` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
172 `rating` tinyint NOT NULL DEFAULT 0 COMMENT 'Automatically detected feed poll frequency',
173 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Feed poll priority',
174 `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
175 `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
176 `pending` boolean NOT NULL DEFAULT '1' COMMENT 'Contact request is pending',
177 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
178 `info` mediumtext COMMENT '',
179 `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
180 `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
181 `ffi_keyword_denylist` text COMMENT '',
182 `photo` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
183 `thumb` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
184 `micro` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
185 `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
186 `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
187 `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
188 `request` varbinary(383) COMMENT '',
189 `confirm` varbinary(383) COMMENT '',
190 `poco` varbinary(383) COMMENT '',
191 `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
192 `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = false instead',
193 `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = true instead',
194 `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
195 `site-pubkey` text COMMENT 'Deprecated',
196 `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
197 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
198 `issued-id` varbinary(383) NOT NULL DEFAULT '' COMMENT 'Deprecated',
199 `dfrn-id` varbinary(383) NOT NULL DEFAULT '' COMMENT 'Deprecated',
200 `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
201 `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
202 `usehub` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
203 `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT 'Deprecated',
204 `profile-id` int unsigned COMMENT 'Deprecated',
206 INDEX `uid_name` (`uid`,`name`(190)),
207 INDEX `self_uid` (`self`,`uid`),
208 INDEX `alias_uid` (`alias`(128),`uid`),
209 INDEX `pending_uid` (`pending`,`uid`),
210 INDEX `blocked_uid` (`blocked`,`uid`),
211 INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
212 INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
213 INDEX `batch_contact-type` (`batch`(64),`contact-type`),
214 INDEX `addr_uid` (`addr`(128),`uid`),
215 INDEX `nurl_uid` (`nurl`(128),`uid`),
216 INDEX `nick_uid` (`nick`(128),`uid`),
217 INDEX `attag_uid` (`attag`(96),`uid`),
218 INDEX `network_uid_lastupdate` (`network`,`uid`,`last-update`),
219 INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`),
220 INDEX `next-update` (`next-update`),
221 INDEX `local-data-next-update` (`local-data`,`next-update`),
222 INDEX `uid_lastitem` (`uid`,`last-item`),
223 INDEX `baseurl` (`baseurl`(64)),
224 INDEX `uid_contact-type` (`uid`,`contact-type`),
225 INDEX `uid_self_contact-type` (`uid`,`self`,`contact-type`),
226 INDEX `self_network_uid` (`self`,`network`,`uid`),
227 INDEX `gsid_uid_failed` (`gsid`,`uid`,`failed`),
228 INDEX `uri-id` (`uri-id`),
229 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
230 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
231 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
232 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
237 CREATE TABLE IF NOT EXISTS `tag` (
238 `id` int unsigned NOT NULL auto_increment COMMENT '',
239 `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
240 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
241 `type` tinyint unsigned COMMENT 'Type of the tag (Unknown, General Collection, Follower Collection or Account)',
243 UNIQUE INDEX `type_name_url` (`name`,`url`),
245 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
248 -- TABLE permissionset
250 CREATE TABLE IF NOT EXISTS `permissionset` (
251 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
252 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
253 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
254 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
255 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
256 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
258 INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`uid`,`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30)),
259 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
260 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
265 CREATE TABLE IF NOT EXISTS `verb` (
266 `id` smallint unsigned NOT NULL auto_increment,
267 `name` varchar(100) NOT NULL DEFAULT '' COMMENT '',
269 INDEX `name` (`name`)
270 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activity Verbs';
273 -- TABLE 2fa_app_specific_password
275 CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
276 `id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
277 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
278 `description` varchar(255) COMMENT 'Description of the usage of the password',
279 `hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
280 `generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
281 `last_used` datetime COMMENT 'Datetime the password was last used',
283 INDEX `uid_description` (`uid`,`description`(190)),
284 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
285 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
288 -- TABLE 2fa_recovery_codes
290 CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
291 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
292 `code` varchar(50) NOT NULL COMMENT 'Recovery code string',
293 `generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
294 `used` datetime COMMENT 'Datetime the code was used',
295 PRIMARY KEY(`uid`,`code`),
296 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
297 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
300 -- TABLE 2fa_trusted_browser
302 CREATE TABLE IF NOT EXISTS `2fa_trusted_browser` (
303 `cookie_hash` varchar(80) NOT NULL COMMENT 'Trusted cookie hash',
304 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
305 `user_agent` text COMMENT 'User agent string',
306 `trusted` boolean NOT NULL DEFAULT '1' COMMENT 'Whenever this browser should be trusted or not',
307 `created` datetime NOT NULL COMMENT 'Datetime the trusted browser was recorded',
308 `last_used` datetime COMMENT 'Datetime the trusted browser was last used',
309 PRIMARY KEY(`cookie_hash`),
311 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
312 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication trusted browsers';
315 -- TABLE account-suggestion
317 CREATE TABLE IF NOT EXISTS `account-suggestion` (
318 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the account url',
319 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
320 `level` smallint unsigned COMMENT 'level of closeness',
321 `ignore` boolean NOT NULL DEFAULT '0' COMMENT 'If set, this account will not be suggested again',
322 PRIMARY KEY(`uid`,`uri-id`),
323 INDEX `uri-id_uid` (`uri-id`,`uid`),
324 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
325 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
326 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Account suggestion';
329 -- TABLE account-user
331 CREATE TABLE IF NOT EXISTS `account-user` (
332 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
333 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the account url',
334 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
336 UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
337 INDEX `uid_uri-id` (`uid`,`uri-id`),
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='Remote and local accounts';
345 CREATE TABLE IF NOT EXISTS `addon` (
346 `id` int unsigned NOT NULL auto_increment COMMENT '',
347 `name` varchar(50) NOT NULL DEFAULT '' COMMENT 'addon base (file)name',
348 `version` varchar(50) NOT NULL DEFAULT '' COMMENT 'currently unused',
349 `installed` boolean NOT NULL DEFAULT '0' COMMENT 'currently always 1',
350 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'currently unused',
351 `timestamp` int unsigned NOT NULL DEFAULT 0 COMMENT 'file timestamp to check for reloads',
352 `plugin_admin` boolean NOT NULL DEFAULT '0' COMMENT '1 = has admin config, 0 = has no admin config',
354 INDEX `installed_name` (`installed`,`name`),
355 UNIQUE INDEX `name` (`name`)
356 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registered addons';
361 CREATE TABLE IF NOT EXISTS `apcontact` (
362 `url` varbinary(383) NOT NULL COMMENT 'URL of the contact',
363 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
364 `uuid` varbinary(255) COMMENT '',
365 `type` varchar(20) NOT NULL COMMENT '',
366 `following` varbinary(383) COMMENT '',
367 `followers` varbinary(383) COMMENT '',
368 `inbox` varbinary(383) NOT NULL COMMENT '',
369 `outbox` varbinary(383) COMMENT '',
370 `sharedinbox` varbinary(383) COMMENT '',
371 `featured` varbinary(383) COMMENT 'Address for the collection of featured posts',
372 `featured-tags` varbinary(383) COMMENT 'Address for the collection of featured tags',
373 `manually-approve` boolean COMMENT '',
374 `discoverable` boolean COMMENT 'Mastodon extension: true if profile is published in their directory',
375 `suspended` boolean COMMENT 'Mastodon extension: true if profile is suspended',
376 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
377 `name` varchar(255) COMMENT '',
378 `about` text COMMENT '',
379 `xmpp` varchar(255) COMMENT 'XMPP address',
380 `matrix` varchar(255) COMMENT 'Matrix address',
381 `photo` varbinary(383) COMMENT '',
382 `header` varbinary(383) COMMENT 'Header picture',
383 `addr` varchar(255) COMMENT '',
384 `alias` varbinary(383) COMMENT '',
385 `pubkey` text COMMENT '',
386 `subscribe` varbinary(383) COMMENT '',
387 `baseurl` varbinary(383) COMMENT 'baseurl of the ap contact',
388 `gsid` int unsigned COMMENT 'Global Server ID',
389 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
390 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
391 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
392 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
393 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
395 INDEX `addr` (`addr`(32)),
396 INDEX `alias` (`alias`(190)),
397 INDEX `followers` (`followers`(190)),
398 INDEX `baseurl` (`baseurl`(190)),
399 INDEX `sharedinbox` (`sharedinbox`(190)),
400 INDEX `gsid` (`gsid`),
401 UNIQUE INDEX `uri-id` (`uri-id`),
402 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
403 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
404 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
409 CREATE TABLE IF NOT EXISTS `application` (
410 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
411 `client_id` varchar(64) NOT NULL COMMENT '',
412 `client_secret` varchar(64) NOT NULL COMMENT '',
413 `name` varchar(255) NOT NULL COMMENT '',
414 `redirect_uri` varbinary(383) NOT NULL COMMENT '',
415 `website` varbinary(383) COMMENT '',
416 `scopes` varchar(255) COMMENT '',
417 `read` boolean COMMENT 'Read scope',
418 `write` boolean COMMENT 'Write scope',
419 `follow` boolean COMMENT 'Follow scope',
420 `push` boolean COMMENT 'Push scope',
422 UNIQUE INDEX `client_id` (`client_id`)
423 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth application';
426 -- TABLE application-marker
428 CREATE TABLE IF NOT EXISTS `application-marker` (
429 `application-id` int unsigned NOT NULL COMMENT '',
430 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
431 `timeline` varchar(64) NOT NULL COMMENT 'Marker (home, notifications)',
432 `last_read_id` varbinary(383) COMMENT 'Marker id for the timeline',
433 `version` smallint unsigned COMMENT 'Version number',
434 `updated_at` datetime COMMENT 'creation time',
435 PRIMARY KEY(`application-id`,`uid`,`timeline`),
436 INDEX `uid_id` (`uid`),
437 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
438 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
439 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Timeline marker';
442 -- TABLE application-token
444 CREATE TABLE IF NOT EXISTS `application-token` (
445 `application-id` int unsigned NOT NULL COMMENT '',
446 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
447 `code` varchar(64) NOT NULL COMMENT '',
448 `access_token` varchar(64) NOT NULL COMMENT '',
449 `created_at` datetime NOT NULL COMMENT 'creation time',
450 `scopes` varchar(255) COMMENT '',
451 `read` boolean COMMENT 'Read scope',
452 `write` boolean COMMENT 'Write scope',
453 `follow` boolean COMMENT 'Follow scope',
454 `push` boolean COMMENT 'Push scope',
455 PRIMARY KEY(`application-id`,`uid`),
456 INDEX `uid_id` (`uid`,`application-id`),
457 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
458 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
459 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth user token';
464 CREATE TABLE IF NOT EXISTS `attach` (
465 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
466 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
467 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
468 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
469 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
470 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
471 `data` longblob NOT NULL COMMENT 'file data',
472 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
473 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
474 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
475 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
476 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
477 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
478 `backend-class` tinytext COMMENT 'Storage backend class',
479 `backend-ref` text COMMENT 'Storage backend data reference',
482 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
483 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
488 CREATE TABLE IF NOT EXISTS `cache` (
489 `k` varbinary(255) NOT NULL COMMENT 'cache key',
490 `v` mediumtext COMMENT 'cached serialized value',
491 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
492 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
494 INDEX `k_expires` (`k`,`expires`)
495 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
498 -- TABLE contact-relation
500 CREATE TABLE IF NOT EXISTS `contact-relation` (
501 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
502 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
503 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
504 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
505 `follows` boolean NOT NULL DEFAULT '0' COMMENT '',
506 PRIMARY KEY(`cid`,`relation-cid`),
507 INDEX `relation-cid` (`relation-cid`),
508 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
509 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
510 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
515 CREATE TABLE IF NOT EXISTS `conv` (
516 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
517 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
518 `recips` text COMMENT 'sender_handle;recipient_handle',
519 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
520 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
521 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
522 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
523 `subject` text COMMENT 'subject of initial message',
526 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
527 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
532 CREATE TABLE IF NOT EXISTS `workerqueue` (
533 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
534 `command` varchar(100) COMMENT 'Task command',
535 `parameter` mediumtext COMMENT 'Task parameter',
536 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
537 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
538 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
539 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
540 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
541 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
542 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
544 INDEX `command` (`command`),
545 INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
546 INDEX `done_executed` (`done`,`executed`),
547 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
548 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
549 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
550 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
551 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
552 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
555 -- TABLE delayed-post
557 CREATE TABLE IF NOT EXISTS `delayed-post` (
558 `id` int unsigned NOT NULL auto_increment,
559 `uri` varbinary(383) COMMENT 'URI of the post that will be distributed later',
560 `uid` mediumint unsigned COMMENT 'Owner User id',
561 `delayed` datetime COMMENT 'delay time',
562 `wid` int unsigned COMMENT 'Workerqueue id',
564 UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
566 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
567 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
568 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
571 -- TABLE delivery-queue
573 CREATE TABLE IF NOT EXISTS `delivery-queue` (
574 `gsid` int unsigned NOT NULL COMMENT 'Target server',
575 `uri-id` int unsigned NOT NULL COMMENT 'Delivered post',
576 `created` datetime COMMENT '',
577 `command` varbinary(32) COMMENT '',
578 `cid` int unsigned COMMENT 'Target contact',
579 `uid` mediumint unsigned COMMENT 'Delivering user',
580 `failed` tinyint DEFAULT 0 COMMENT 'Number of times the delivery has failed',
581 PRIMARY KEY(`uri-id`,`gsid`),
582 INDEX `gsid_created` (`gsid`,`created`),
585 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
586 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
587 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
588 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
589 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for posts for the batch processing';
592 -- TABLE diaspora-contact
594 CREATE TABLE IF NOT EXISTS `diaspora-contact` (
595 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the contact URL',
596 `addr` varchar(255) COMMENT '',
597 `alias` varchar(255) COMMENT '',
598 `nick` varchar(255) COMMENT '',
599 `name` varchar(255) COMMENT '',
600 `given-name` varchar(255) COMMENT '',
601 `family-name` varchar(255) COMMENT '',
602 `photo` varchar(255) COMMENT '',
603 `photo-medium` varchar(255) COMMENT '',
604 `photo-small` varchar(255) COMMENT '',
605 `batch` varchar(255) COMMENT '',
606 `notify` varchar(255) COMMENT '',
607 `poll` varchar(255) COMMENT '',
608 `subscribe` varchar(255) COMMENT '',
609 `searchable` boolean COMMENT '',
610 `pubkey` text COMMENT '',
611 `gsid` int unsigned COMMENT 'Global Server ID',
612 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
613 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
614 `interacting_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts this contact interactes with',
615 `interacted_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts that interacted with this contact',
616 `post_count` int unsigned DEFAULT 0 COMMENT 'Number of posts and comments',
617 PRIMARY KEY(`uri-id`),
618 UNIQUE INDEX `addr` (`addr`),
619 INDEX `alias` (`alias`),
620 INDEX `gsid` (`gsid`),
621 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
622 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
623 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
626 -- TABLE diaspora-interaction
628 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
629 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
630 `interaction` mediumtext COMMENT 'The Diaspora interaction',
631 PRIMARY KEY(`uri-id`),
632 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
633 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
638 CREATE TABLE IF NOT EXISTS `endpoint` (
639 `url` varbinary(383) NOT NULL COMMENT 'URL of the contact',
640 `type` varchar(20) NOT NULL COMMENT '',
641 `owner-uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
643 UNIQUE INDEX `owner-uri-id_type` (`owner-uri-id`,`type`),
644 FOREIGN KEY (`owner-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
645 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub endpoints - used in the ActivityPub implementation';
650 CREATE TABLE IF NOT EXISTS `event` (
651 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
652 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
653 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
654 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
655 `uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
656 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the event uri',
657 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
658 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
659 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
660 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
661 `summary` text COMMENT 'short description or title of the event',
662 `desc` text COMMENT 'event description',
663 `location` text COMMENT 'event location',
664 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
665 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
666 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
667 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
668 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
669 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
670 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
672 INDEX `uid_start` (`uid`,`start`),
674 INDEX `uri-id` (`uri-id`),
675 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
676 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
677 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
678 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
683 CREATE TABLE IF NOT EXISTS `fetch-entry` (
684 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
685 `url` varbinary(383) COMMENT 'url that awaiting to be fetched',
686 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of the fetch request',
687 `wid` int unsigned COMMENT 'Workerqueue id',
689 UNIQUE INDEX `url` (`url`),
690 INDEX `created` (`created`),
692 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
693 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
698 CREATE TABLE IF NOT EXISTS `fsuggest` (
699 `id` int unsigned NOT NULL auto_increment COMMENT '',
700 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
701 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
702 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
703 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
704 `request` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
705 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
706 `note` text COMMENT '',
707 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
711 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
712 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
713 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
718 CREATE TABLE IF NOT EXISTS `group` (
719 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
720 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
721 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
722 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
723 `cid` int unsigned COMMENT 'Contact id of forum. When this field is filled then the members are synced automatically.',
724 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
728 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
729 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
730 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
733 -- TABLE group_member
735 CREATE TABLE IF NOT EXISTS `group_member` (
736 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
737 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
738 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
740 INDEX `contactid` (`contact-id`),
741 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
742 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
743 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
744 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
749 CREATE TABLE IF NOT EXISTS `gserver-tag` (
750 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
751 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
752 PRIMARY KEY(`gserver-id`,`tag`),
754 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
755 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
760 CREATE TABLE IF NOT EXISTS `hook` (
761 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
762 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
763 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
764 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
765 `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',
767 INDEX `priority` (`priority`),
768 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
769 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
774 CREATE TABLE IF NOT EXISTS `inbox-entry` (
775 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
776 `activity-id` varbinary(383) COMMENT 'id of the incoming activity',
777 `object-id` varbinary(383) COMMENT '',
778 `in-reply-to-id` varbinary(383) COMMENT '',
779 `conversation` varbinary(383) COMMENT '',
780 `type` varchar(64) COMMENT 'Type of the activity',
781 `object-type` varchar(64) COMMENT 'Type of the object activity',
782 `object-object-type` varchar(64) COMMENT 'Type of the object\'s object activity',
783 `received` datetime COMMENT 'Receiving date',
784 `activity` mediumtext COMMENT 'The JSON activity',
785 `signer` varchar(255) COMMENT '',
786 `push` boolean COMMENT 'Is the entry pushed or have pulled it?',
787 `trust` boolean COMMENT 'Do we trust this entry?',
788 `wid` int unsigned COMMENT 'Workerqueue id',
790 UNIQUE INDEX `activity-id` (`activity-id`),
791 INDEX `object-id` (`object-id`),
792 INDEX `received` (`received`),
794 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
795 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Incoming activity';
798 -- TABLE inbox-entry-receiver
800 CREATE TABLE IF NOT EXISTS `inbox-entry-receiver` (
801 `queue-id` int unsigned NOT NULL COMMENT '',
802 `uid` mediumint unsigned NOT NULL COMMENT 'User id',
803 PRIMARY KEY(`queue-id`,`uid`),
805 FOREIGN KEY (`queue-id`) REFERENCES `inbox-entry` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
806 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
807 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Receiver for the incoming activity';
810 -- TABLE inbox-status
812 CREATE TABLE IF NOT EXISTS `inbox-status` (
813 `url` varbinary(383) NOT NULL COMMENT 'URL of the inbox',
814 `uri-id` int unsigned COMMENT 'Item-uri id of inbox url',
815 `gsid` int unsigned COMMENT 'ID of the related server',
816 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
817 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
818 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
819 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
820 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
821 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
823 INDEX `uri-id` (`uri-id`),
824 INDEX `gsid` (`gsid`),
825 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
826 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
827 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
832 CREATE TABLE IF NOT EXISTS `intro` (
833 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
834 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
835 `fid` int unsigned COMMENT 'deprecated',
836 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
837 `suggest-cid` int unsigned COMMENT 'Suggested contact',
838 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
839 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
840 `note` text COMMENT '',
841 `hash` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
842 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
843 `blocked` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
844 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
846 INDEX `contact-id` (`contact-id`),
847 INDEX `suggest-cid` (`suggest-cid`),
849 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
850 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
851 FOREIGN KEY (`suggest-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
852 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
857 CREATE TABLE IF NOT EXISTS `key-value` (
858 `k` varbinary(50) NOT NULL COMMENT '',
859 `v` mediumtext COMMENT '',
860 `updated_at` int unsigned NOT NULL COMMENT 'timestamp of the last update',
862 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='A key value storage';
867 CREATE TABLE IF NOT EXISTS `locks` (
868 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
869 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
870 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
871 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
872 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
874 INDEX `name_expires` (`name`,`expires`)
875 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
880 CREATE TABLE IF NOT EXISTS `mail` (
881 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
882 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
883 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
884 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
885 `from-photo` varbinary(383) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
886 `from-url` varbinary(383) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
887 `contact-id` varbinary(255) COMMENT 'contact.id',
888 `author-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the author of the mail',
889 `convid` int unsigned COMMENT 'conv.id',
890 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
891 `body` mediumtext COMMENT '',
892 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
893 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
894 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
895 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
896 `uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
897 `uri-id` int unsigned COMMENT 'Item-uri id of the related mail',
898 `parent-uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
899 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related mail',
900 `thr-parent` varbinary(383) COMMENT '',
901 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
902 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
904 INDEX `uid_seen` (`uid`,`seen`),
905 INDEX `convid` (`convid`),
906 INDEX `uri` (`uri`(64)),
907 INDEX `parent-uri` (`parent-uri`(64)),
908 INDEX `contactid` (`contact-id`(32)),
909 INDEX `author-id` (`author-id`),
910 INDEX `uri-id` (`uri-id`),
911 INDEX `parent-uri-id` (`parent-uri-id`),
912 INDEX `thr-parent-id` (`thr-parent-id`),
913 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
914 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
915 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
916 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
917 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
918 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
923 CREATE TABLE IF NOT EXISTS `mailacct` (
924 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
925 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
926 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
927 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
928 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
929 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
930 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
931 `pass` text COMMENT '',
932 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
933 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
934 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
935 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
936 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
939 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
940 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
945 CREATE TABLE IF NOT EXISTS `manage` (
946 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
947 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
948 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
950 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
952 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
953 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
954 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
957 -- TABLE notification
959 CREATE TABLE IF NOT EXISTS `notification` (
960 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
961 `uid` mediumint unsigned COMMENT 'Owner User id',
962 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
963 `type` smallint unsigned COMMENT '',
964 `actor-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the actor that caused the notification',
965 `target-uri-id` int unsigned COMMENT 'Item-uri id of the related post',
966 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
967 `created` datetime COMMENT '',
968 `seen` boolean DEFAULT '0' COMMENT 'Seen on the desktop',
969 `dismissed` boolean DEFAULT '0' COMMENT 'Dismissed via the API',
971 UNIQUE INDEX `uid_vid_type_actor-id_target-uri-id` (`uid`,`vid`,`type`,`actor-id`,`target-uri-id`),
973 INDEX `actor-id` (`actor-id`),
974 INDEX `target-uri-id` (`target-uri-id`),
975 INDEX `parent-uri-id` (`parent-uri-id`),
976 INDEX `seen_uid` (`seen`,`uid`),
977 INDEX `uid_type_parent-uri-id_actor-id` (`uid`,`type`,`parent-uri-id`,`actor-id`),
978 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
979 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
980 FOREIGN KEY (`actor-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
981 FOREIGN KEY (`target-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
982 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
983 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
988 CREATE TABLE IF NOT EXISTS `notify` (
989 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
990 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
991 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
992 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
993 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
994 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
995 `msg` mediumtext COMMENT '',
996 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
997 `link` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
998 `iid` int unsigned COMMENT '',
999 `parent` int unsigned COMMENT '',
1000 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
1001 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
1002 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
1003 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
1004 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
1005 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
1006 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
1008 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
1009 INDEX `uid_date` (`uid`,`date`),
1010 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
1011 INDEX `uri-id` (`uri-id`),
1012 INDEX `parent-uri-id` (`parent-uri-id`),
1013 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1014 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1015 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1016 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='[Deprecated] User notifications';
1019 -- TABLE notify-threads
1021 CREATE TABLE IF NOT EXISTS `notify-threads` (
1022 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1023 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1024 `master-parent-item` int unsigned COMMENT 'Deprecated',
1025 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
1026 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1027 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1029 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
1030 INDEX `receiver-uid` (`receiver-uid`),
1031 INDEX `notify-id` (`notify-id`),
1032 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1033 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1034 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1035 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1040 CREATE TABLE IF NOT EXISTS `oembed` (
1041 `url` varbinary(383) NOT NULL COMMENT 'page url',
1042 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
1043 `content` mediumtext COMMENT 'OEmbed data of the page',
1044 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1045 PRIMARY KEY(`url`,`maxwidth`),
1046 INDEX `created` (`created`)
1047 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
1050 -- TABLE openwebauth-token
1052 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
1053 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1054 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
1055 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
1056 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
1057 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1058 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1060 INDEX `uid` (`uid`),
1061 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1062 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
1067 CREATE TABLE IF NOT EXISTS `parsed_url` (
1068 `url_hash` binary(64) NOT NULL COMMENT 'page url hash',
1069 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
1070 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
1071 `url` text NOT NULL COMMENT 'page url',
1072 `content` mediumtext COMMENT 'page data',
1073 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1074 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration',
1075 PRIMARY KEY(`url_hash`,`guessing`,`oembed`),
1076 INDEX `created` (`created`),
1077 INDEX `expires` (`expires`)
1078 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
1083 CREATE TABLE IF NOT EXISTS `pconfig` (
1084 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
1085 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1086 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
1087 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
1088 `v` mediumtext COMMENT 'Value',
1090 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
1091 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1092 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
1097 CREATE TABLE IF NOT EXISTS `photo` (
1098 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1099 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1100 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1101 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
1102 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
1103 `hash` char(32) COMMENT 'hash value of the photo',
1104 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
1105 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
1106 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1107 `desc` text COMMENT '',
1108 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
1109 `photo-type` tinyint unsigned COMMENT 'User avatar, user banner, contact avatar, contact banner or default',
1110 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1111 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
1112 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1113 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1114 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1115 `blurhash` varbinary(255) COMMENT 'BlurHash representation of the photo',
1116 `data` mediumblob NOT NULL COMMENT '',
1117 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1118 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
1119 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
1120 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
1121 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
1122 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
1123 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
1124 `backend-class` tinytext COMMENT 'Storage backend class',
1125 `backend-ref` text COMMENT 'Storage backend data reference',
1126 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1128 INDEX `contactid` (`contact-id`),
1129 INDEX `uid_contactid` (`uid`,`contact-id`),
1130 INDEX `uid_profile` (`uid`,`profile`),
1131 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
1132 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
1133 INDEX `resource-id` (`resource-id`),
1134 INDEX `uid_photo-type` (`uid`,`photo-type`),
1135 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1136 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1137 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1142 CREATE TABLE IF NOT EXISTS `post` (
1143 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1144 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1145 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1146 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1147 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1148 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1149 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1150 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1151 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1152 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1153 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1154 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1155 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1156 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1157 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1158 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1159 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1160 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1161 PRIMARY KEY(`uri-id`),
1162 INDEX `parent-uri-id` (`parent-uri-id`),
1163 INDEX `thr-parent-id` (`thr-parent-id`),
1164 INDEX `external-id` (`external-id`),
1165 INDEX `owner-id` (`owner-id`),
1166 INDEX `author-id` (`author-id`),
1167 INDEX `causer-id` (`causer-id`),
1168 INDEX `vid` (`vid`),
1169 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1170 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1171 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1172 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1173 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1174 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1175 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1176 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1177 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
1180 -- TABLE post-activity
1182 CREATE TABLE IF NOT EXISTS `post-activity` (
1183 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1184 `activity` mediumtext COMMENT 'Original activity',
1185 `received` datetime COMMENT '',
1186 PRIMARY KEY(`uri-id`),
1187 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1188 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Original remote activity';
1191 -- TABLE post-category
1193 CREATE TABLE IF NOT EXISTS `post-category` (
1194 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1195 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1196 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1197 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1198 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1199 INDEX `tid` (`tid`),
1200 INDEX `uid_uri-id` (`uid`,`uri-id`),
1201 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1202 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1203 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1204 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1207 -- TABLE post-collection
1209 CREATE TABLE IF NOT EXISTS `post-collection` (
1210 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1211 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0 - Featured',
1212 `author-id` int unsigned COMMENT 'Author of the featured post',
1213 PRIMARY KEY(`uri-id`,`type`),
1214 INDEX `type` (`type`),
1215 INDEX `author-id` (`author-id`),
1216 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1217 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1218 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Collection of posts';
1221 -- TABLE post-content
1223 CREATE TABLE IF NOT EXISTS `post-content` (
1224 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1225 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1226 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1227 `body` mediumtext COMMENT 'item body content',
1228 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1229 `quote-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the quoted uri',
1230 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1231 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1232 `language` text COMMENT 'Language information about this post',
1233 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1234 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1235 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1236 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1237 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1238 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1239 `target` text COMMENT 'JSON encoded target structure if used',
1240 `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',
1241 `plink` varbinary(383) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1242 PRIMARY KEY(`uri-id`),
1243 INDEX `plink` (`plink`(191)),
1244 INDEX `resource-id` (`resource-id`),
1245 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
1246 INDEX `quote-uri-id` (`quote-uri-id`),
1247 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1248 FOREIGN KEY (`quote-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1249 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1252 -- TABLE post-delivery
1254 CREATE TABLE IF NOT EXISTS `post-delivery` (
1255 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1256 `inbox-id` int unsigned NOT NULL COMMENT 'Item-uri id of inbox url',
1257 `uid` mediumint unsigned COMMENT 'Delivering user',
1258 `created` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
1259 `command` varbinary(32) COMMENT '',
1260 `failed` tinyint DEFAULT 0 COMMENT 'Number of times the delivery has failed',
1261 `receivers` mediumtext COMMENT 'JSON encoded array with the receiving contacts',
1262 PRIMARY KEY(`uri-id`,`inbox-id`),
1263 INDEX `inbox-id_created` (`inbox-id`,`created`),
1264 INDEX `uid` (`uid`),
1265 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1266 FOREIGN KEY (`inbox-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1267 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1268 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for posts for the batch processing';
1271 -- TABLE post-delivery-data
1273 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1274 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1275 `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',
1276 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1277 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1278 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1279 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1280 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1281 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1282 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1283 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1284 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1285 PRIMARY KEY(`uri-id`),
1286 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1287 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1290 -- TABLE post-history
1292 CREATE TABLE IF NOT EXISTS `post-history` (
1293 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1294 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of edit',
1295 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1296 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1297 `body` mediumtext COMMENT 'item body content',
1298 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1299 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1300 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1301 `language` text COMMENT 'Language information about this post',
1302 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1303 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1304 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1305 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1306 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1307 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1308 `target` text COMMENT 'JSON encoded target structure if used',
1309 `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',
1310 `plink` varbinary(383) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1311 PRIMARY KEY(`uri-id`,`edited`),
1312 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1313 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post history';
1318 CREATE TABLE IF NOT EXISTS `post-link` (
1319 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1320 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1321 `url` varbinary(511) NOT NULL COMMENT 'External URL',
1322 `mimetype` varchar(60) COMMENT '',
1323 `height` smallint unsigned COMMENT 'Height of the media',
1324 `width` smallint unsigned COMMENT 'Width of the media',
1325 `blurhash` varbinary(255) COMMENT 'BlurHash representation of the link',
1327 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1328 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1329 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post related external links';
1334 CREATE TABLE IF NOT EXISTS `post-media` (
1335 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1336 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1337 `url` varbinary(1024) NOT NULL COMMENT 'Media URL',
1338 `media-uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the activities uri-id',
1339 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1340 `mimetype` varchar(60) COMMENT '',
1341 `height` smallint unsigned COMMENT 'Height of the media',
1342 `width` smallint unsigned COMMENT 'Width of the media',
1343 `size` bigint unsigned COMMENT 'Media size',
1344 `blurhash` varbinary(255) COMMENT 'BlurHash representation of the image',
1345 `preview` varbinary(512) COMMENT 'Preview URL',
1346 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1347 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1348 `description` text COMMENT '',
1349 `name` varchar(255) COMMENT 'Name of the media',
1350 `author-url` varbinary(383) COMMENT 'URL of the author of the media',
1351 `author-name` varchar(255) COMMENT 'Name of the author of the media',
1352 `author-image` varbinary(383) COMMENT 'Image of the author of the media',
1353 `publisher-url` varbinary(383) COMMENT 'URL of the publisher of the media',
1354 `publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
1355 `publisher-image` varbinary(383) COMMENT 'Image of the publisher of the media',
1357 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`(512)),
1358 INDEX `uri-id-id` (`uri-id`,`id`),
1359 INDEX `media-uri-id` (`media-uri-id`),
1360 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1361 FOREIGN KEY (`media-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1362 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1365 -- TABLE post-question
1367 CREATE TABLE IF NOT EXISTS `post-question` (
1368 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1369 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1370 `multiple` boolean NOT NULL DEFAULT '0' COMMENT 'Multiple choice',
1371 `voters` int unsigned COMMENT 'Number of voters for this question',
1372 `end-time` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Question end time',
1374 UNIQUE INDEX `uri-id` (`uri-id`),
1375 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1376 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question';
1379 -- TABLE post-question-option
1381 CREATE TABLE IF NOT EXISTS `post-question-option` (
1382 `id` int unsigned NOT NULL COMMENT 'Id of the question',
1383 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1384 `name` varchar(255) COMMENT 'Name of the option',
1385 `replies` int unsigned COMMENT 'Number of replies for this question option',
1386 PRIMARY KEY(`uri-id`,`id`),
1387 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1388 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question option';
1393 CREATE TABLE IF NOT EXISTS `post-tag` (
1394 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1395 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1396 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1397 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1398 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1399 INDEX `tid` (`tid`),
1400 INDEX `cid` (`cid`),
1401 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1402 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1403 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1404 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1407 -- TABLE post-thread
1409 CREATE TABLE IF NOT EXISTS `post-thread` (
1410 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1411 `conversation-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the conversation uri',
1412 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1413 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1414 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1415 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1416 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1417 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1418 `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',
1419 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1420 PRIMARY KEY(`uri-id`),
1421 INDEX `conversation-id` (`conversation-id`),
1422 INDEX `owner-id` (`owner-id`),
1423 INDEX `author-id` (`author-id`),
1424 INDEX `causer-id` (`causer-id`),
1425 INDEX `received` (`received`),
1426 INDEX `commented` (`commented`),
1427 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1428 FOREIGN KEY (`conversation-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1429 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1430 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1431 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1432 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1437 CREATE TABLE IF NOT EXISTS `post-user` (
1438 `id` int unsigned NOT NULL auto_increment,
1439 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1440 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1441 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1442 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1443 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1444 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1445 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1446 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1447 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1448 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1449 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1450 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1451 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1452 `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
1453 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1454 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1455 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1456 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1457 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1458 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1459 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1460 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1461 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1462 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1463 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1464 `notification-type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1465 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1466 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1467 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1469 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1470 INDEX `uri-id` (`uri-id`),
1471 INDEX `parent-uri-id` (`parent-uri-id`),
1472 INDEX `thr-parent-id` (`thr-parent-id`),
1473 INDEX `external-id` (`external-id`),
1474 INDEX `owner-id` (`owner-id`),
1475 INDEX `author-id` (`author-id`),
1476 INDEX `causer-id` (`causer-id`),
1477 INDEX `vid` (`vid`),
1478 INDEX `contact-id` (`contact-id`),
1479 INDEX `event-id` (`event-id`),
1480 INDEX `psid` (`psid`),
1481 INDEX `author-id_uid` (`author-id`,`uid`),
1482 INDEX `author-id_received` (`author-id`,`received`),
1483 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1484 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1485 INDEX `uid_contactid` (`uid`,`contact-id`),
1486 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1487 INDEX `uid_unseen` (`uid`,`unseen`),
1488 INDEX `uid_hidden_uri-id` (`uid`,`hidden`,`uri-id`),
1489 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1490 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1491 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1492 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1493 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1494 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1495 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1496 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1497 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1498 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1499 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1500 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1501 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1504 -- TABLE post-thread-user
1506 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1507 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1508 `conversation-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the conversation uri',
1509 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1510 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1511 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1512 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1513 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1514 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1515 `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',
1516 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1517 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1518 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
1519 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1520 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1521 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1522 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1523 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1524 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Deprecated',
1525 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1526 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1527 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1528 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1529 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1530 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1531 PRIMARY KEY(`uid`,`uri-id`),
1532 INDEX `uri-id` (`uri-id`),
1533 INDEX `conversation-id` (`conversation-id`),
1534 INDEX `owner-id` (`owner-id`),
1535 INDEX `author-id` (`author-id`),
1536 INDEX `causer-id` (`causer-id`),
1537 INDEX `uid` (`uid`),
1538 INDEX `contact-id` (`contact-id`),
1539 INDEX `psid` (`psid`),
1540 INDEX `post-user-id` (`post-user-id`),
1541 INDEX `commented` (`commented`),
1542 INDEX `uid_received` (`uid`,`received`),
1543 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1544 INDEX `uid_commented` (`uid`,`commented`),
1545 INDEX `uid_starred` (`uid`,`starred`),
1546 INDEX `uid_mention` (`uid`,`mention`),
1547 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1548 FOREIGN KEY (`conversation-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1549 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1550 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1551 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1552 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1553 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1554 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1555 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1556 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1559 -- TABLE post-user-notification
1561 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1562 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1563 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1564 `notification-type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1565 PRIMARY KEY(`uid`,`uri-id`),
1566 INDEX `uri-id` (`uri-id`),
1567 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1568 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1569 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1574 CREATE TABLE IF NOT EXISTS `process` (
1575 `pid` int unsigned NOT NULL COMMENT 'The ID of the process',
1576 `hostname` varchar(32) NOT NULL COMMENT 'The name of the host the process is ran on',
1577 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1578 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1579 PRIMARY KEY(`pid`,`hostname`),
1580 INDEX `command` (`command`)
1581 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1586 CREATE TABLE IF NOT EXISTS `profile` (
1587 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1588 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1589 `profile-name` varchar(255) COMMENT 'Deprecated',
1590 `is-default` boolean COMMENT 'Deprecated',
1591 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1592 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1593 `pdesc` varchar(255) COMMENT 'Deprecated',
1594 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1595 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1596 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1597 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1598 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1599 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1600 `hometown` varchar(255) COMMENT 'Deprecated',
1601 `gender` varchar(32) COMMENT 'Deprecated',
1602 `marital` varchar(255) COMMENT 'Deprecated',
1603 `with` text COMMENT 'Deprecated',
1604 `howlong` datetime COMMENT 'Deprecated',
1605 `sexual` varchar(255) COMMENT 'Deprecated',
1606 `politic` varchar(255) COMMENT 'Deprecated',
1607 `religion` varchar(255) COMMENT 'Deprecated',
1608 `pub_keywords` text COMMENT '',
1609 `prv_keywords` text COMMENT '',
1610 `likes` text COMMENT 'Deprecated',
1611 `dislikes` text COMMENT 'Deprecated',
1612 `about` text COMMENT 'Profile description',
1613 `summary` varchar(255) COMMENT 'Deprecated',
1614 `music` text COMMENT 'Deprecated',
1615 `book` text COMMENT 'Deprecated',
1616 `tv` text COMMENT 'Deprecated',
1617 `film` text COMMENT 'Deprecated',
1618 `interest` text COMMENT 'Deprecated',
1619 `romance` text COMMENT 'Deprecated',
1620 `work` text COMMENT 'Deprecated',
1621 `education` text COMMENT 'Deprecated',
1622 `contact` text COMMENT 'Deprecated',
1623 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1624 `homepage_verified` boolean NOT NULL DEFAULT '0' COMMENT 'was the homepage verified by a rel-me link back to the profile',
1625 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
1626 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
1627 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1628 `thumb` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1629 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1630 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1632 INDEX `uid_is-default` (`uid`,`is-default`),
1633 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1634 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1635 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1638 -- TABLE profile_field
1640 CREATE TABLE IF NOT EXISTS `profile_field` (
1641 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1642 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1643 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1644 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1645 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1646 `value` text COMMENT 'Value of the field',
1647 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1648 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1650 INDEX `uid` (`uid`),
1651 INDEX `order` (`order`),
1652 INDEX `psid` (`psid`),
1653 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1654 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1655 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1658 -- TABLE push_subscriber
1660 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1661 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1662 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1663 `callback_url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1664 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1665 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1666 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1667 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1668 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1669 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1670 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1672 INDEX `next_try` (`next_try`),
1673 INDEX `uid` (`uid`),
1674 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1675 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1680 CREATE TABLE IF NOT EXISTS `register` (
1681 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1682 `hash` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1683 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1684 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1685 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1686 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1687 `note` text COMMENT '',
1689 INDEX `uid` (`uid`),
1690 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1691 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1696 CREATE TABLE IF NOT EXISTS `report` (
1697 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1698 `uid` mediumint unsigned COMMENT 'Reporting user',
1699 `reporter-id` int unsigned COMMENT 'Reporting contact',
1700 `cid` int unsigned NOT NULL COMMENT 'Reported contact',
1701 `comment` text COMMENT 'Report',
1702 `category` varchar(20) COMMENT 'Category of the report (spam, violation, other)',
1703 `rules` text COMMENT 'Violated rules',
1704 `forward` boolean COMMENT 'Forward the report to the remote server',
1705 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1706 `status` tinyint unsigned COMMENT 'Status of the report',
1708 INDEX `uid` (`uid`),
1709 INDEX `cid` (`cid`),
1710 INDEX `reporter-id` (`reporter-id`),
1711 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1712 FOREIGN KEY (`reporter-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1713 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1714 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1717 -- TABLE report-post
1719 CREATE TABLE IF NOT EXISTS `report-post` (
1720 `rid` int unsigned NOT NULL COMMENT 'Report id',
1721 `uri-id` int unsigned NOT NULL COMMENT 'Uri-id of the reported post',
1722 `status` tinyint unsigned COMMENT 'Status of the reported post',
1723 PRIMARY KEY(`rid`,`uri-id`),
1724 INDEX `uri-id` (`uri-id`),
1725 FOREIGN KEY (`rid`) REFERENCES `report` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1726 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1727 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1732 CREATE TABLE IF NOT EXISTS `search` (
1733 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1734 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1735 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1737 INDEX `uid_term` (`uid`,`term`(64)),
1738 INDEX `term` (`term`(64)),
1739 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1740 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1745 CREATE TABLE IF NOT EXISTS `session` (
1746 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1747 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1748 `data` text COMMENT '',
1749 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1751 INDEX `sid` (`sid`(64)),
1752 INDEX `expire` (`expire`)
1753 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1758 CREATE TABLE IF NOT EXISTS `storage` (
1759 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1760 `data` longblob NOT NULL COMMENT 'file data',
1762 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1765 -- TABLE subscription
1767 CREATE TABLE IF NOT EXISTS `subscription` (
1768 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1769 `application-id` int unsigned NOT NULL COMMENT '',
1770 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
1771 `endpoint` varchar(511) COMMENT 'Endpoint URL',
1772 `pubkey` varchar(127) COMMENT 'User agent public key',
1773 `secret` varchar(32) COMMENT 'Auth secret',
1774 `follow` boolean COMMENT '',
1775 `favourite` boolean COMMENT '',
1776 `reblog` boolean COMMENT '',
1777 `mention` boolean COMMENT '',
1778 `poll` boolean COMMENT '',
1779 `follow_request` boolean COMMENT '',
1780 `status` boolean COMMENT '',
1782 UNIQUE INDEX `application-id_uid` (`application-id`,`uid`),
1783 INDEX `uid_application-id` (`uid`,`application-id`),
1784 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1785 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1786 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Push Subscription for the API';
1791 CREATE TABLE IF NOT EXISTS `userd` (
1792 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1793 `username` varchar(255) NOT NULL COMMENT '',
1795 INDEX `username` (`username`(32))
1796 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1799 -- TABLE user-contact
1801 CREATE TABLE IF NOT EXISTS `user-contact` (
1802 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1803 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1804 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
1805 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1806 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1807 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1808 `hidden` boolean COMMENT 'This contact is hidden from the others',
1809 `is-blocked` boolean COMMENT 'User is blocked by this contact',
1810 `pending` boolean COMMENT '',
1811 `rel` tinyint unsigned COMMENT 'The kind of the relation between the user and the contact',
1812 `info` mediumtext COMMENT '',
1813 `notify_new_posts` boolean COMMENT '',
1814 `remote_self` boolean COMMENT '',
1815 `fetch_further_information` tinyint unsigned COMMENT '',
1816 `ffi_keyword_denylist` text COMMENT '',
1817 `subhub` boolean COMMENT '',
1818 `hub-verify` varbinary(383) COMMENT '',
1819 `protocol` char(4) COMMENT 'Protocol of the contact',
1820 `rating` tinyint COMMENT 'Automatically detected feed poll frequency',
1821 `priority` tinyint unsigned COMMENT 'Feed poll priority',
1822 PRIMARY KEY(`uid`,`cid`),
1823 INDEX `cid` (`cid`),
1824 UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
1825 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1826 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1827 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1828 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1831 -- TABLE arrived-activity
1833 CREATE TABLE IF NOT EXISTS `arrived-activity` (
1834 `object-id` varbinary(383) NOT NULL COMMENT 'object id of the incoming activity',
1835 `received` datetime COMMENT 'Receiving date',
1836 PRIMARY KEY(`object-id`)
1837 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Id of arrived activities';
1840 -- TABLE fetched-activity
1842 CREATE TABLE IF NOT EXISTS `fetched-activity` (
1843 `object-id` varbinary(383) NOT NULL COMMENT 'object id of fetched activity',
1844 `received` datetime COMMENT 'Receiving date',
1845 PRIMARY KEY(`object-id`)
1846 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Id of fetched activities';
1851 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1852 `key` int NOT NULL COMMENT '',
1853 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1855 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1858 -- VIEW application-view
1860 DROP VIEW IF EXISTS `application-view`;
1861 CREATE VIEW `application-view` AS SELECT
1862 `application`.`id` AS `id`,
1863 `application-token`.`uid` AS `uid`,
1864 `application`.`name` AS `name`,
1865 `application`.`redirect_uri` AS `redirect_uri`,
1866 `application`.`website` AS `website`,
1867 `application`.`client_id` AS `client_id`,
1868 `application`.`client_secret` AS `client_secret`,
1869 `application-token`.`code` AS `code`,
1870 `application-token`.`access_token` AS `access_token`,
1871 `application-token`.`created_at` AS `created_at`,
1872 `application-token`.`scopes` AS `scopes`,
1873 `application-token`.`read` AS `read`,
1874 `application-token`.`write` AS `write`,
1875 `application-token`.`follow` AS `follow`,
1876 `application-token`.`push` AS `push`
1877 FROM `application-token`
1878 INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`;
1881 -- VIEW post-user-view
1883 DROP VIEW IF EXISTS `post-user-view`;
1884 CREATE VIEW `post-user-view` AS SELECT
1885 `post-user`.`id` AS `id`,
1886 `post-user`.`id` AS `post-user-id`,
1887 `post-user`.`uid` AS `uid`,
1888 `parent-post`.`id` AS `parent`,
1889 `item-uri`.`uri` AS `uri`,
1890 `post-user`.`uri-id` AS `uri-id`,
1891 `parent-item-uri`.`uri` AS `parent-uri`,
1892 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1893 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1894 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1895 `conversation-item-uri`.`uri` AS `conversation`,
1896 `post-thread-user`.`conversation-id` AS `conversation-id`,
1897 `quote-item-uri`.`uri` AS `quote-uri`,
1898 `post-content`.`quote-uri-id` AS `quote-uri-id`,
1899 `item-uri`.`guid` AS `guid`,
1900 `post-user`.`wall` AS `wall`,
1901 `post-user`.`gravity` AS `gravity`,
1902 `external-item-uri`.`uri` AS `extid`,
1903 `post-user`.`external-id` AS `external-id`,
1904 `post-user`.`created` AS `created`,
1905 `post-user`.`edited` AS `edited`,
1906 `post-thread-user`.`commented` AS `commented`,
1907 `post-user`.`received` AS `received`,
1908 `post-thread-user`.`changed` AS `changed`,
1909 `post-user`.`post-type` AS `post-type`,
1910 `post-user`.`post-reason` AS `post-reason`,
1911 `post-user`.`private` AS `private`,
1912 `post-thread-user`.`pubmail` AS `pubmail`,
1913 `post-user`.`visible` AS `visible`,
1914 `post-thread-user`.`starred` AS `starred`,
1915 `post-user`.`unseen` AS `unseen`,
1916 `post-user`.`deleted` AS `deleted`,
1917 `post-user`.`origin` AS `origin`,
1918 `post-thread-user`.`origin` AS `parent-origin`,
1919 `post-thread-user`.`mention` AS `mention`,
1920 `post-user`.`global` AS `global`,
1921 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-user`.`uri-id`) AS `featured`,
1922 `post-user`.`network` AS `network`,
1923 `post-user`.`protocol` AS `protocol`,
1924 `post-user`.`vid` AS `vid`,
1925 `post-user`.`psid` AS `psid`,
1926 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1927 `post-content`.`title` AS `title`,
1928 `post-content`.`content-warning` AS `content-warning`,
1929 `post-content`.`raw-body` AS `raw-body`,
1930 IFNULL (`post-content`.`body`, '') AS `body`,
1931 `post-content`.`rendered-hash` AS `rendered-hash`,
1932 `post-content`.`rendered-html` AS `rendered-html`,
1933 `post-content`.`language` AS `language`,
1934 `post-content`.`plink` AS `plink`,
1935 `post-content`.`location` AS `location`,
1936 `post-content`.`coord` AS `coord`,
1937 `post-content`.`app` AS `app`,
1938 `post-content`.`object-type` AS `object-type`,
1939 `post-content`.`object` AS `object`,
1940 `post-content`.`target-type` AS `target-type`,
1941 `post-content`.`target` AS `target`,
1942 `post-content`.`resource-id` AS `resource-id`,
1943 `post-user`.`contact-id` AS `contact-id`,
1944 `contact`.`uri-id` AS `contact-uri-id`,
1945 `contact`.`url` AS `contact-link`,
1946 `contact`.`addr` AS `contact-addr`,
1947 `contact`.`name` AS `contact-name`,
1948 `contact`.`nick` AS `contact-nick`,
1949 `contact`.`thumb` AS `contact-avatar`,
1950 `contact`.`network` AS `contact-network`,
1951 `contact`.`blocked` AS `contact-blocked`,
1952 `contact`.`hidden` AS `contact-hidden`,
1953 `contact`.`readonly` AS `contact-readonly`,
1954 `contact`.`archive` AS `contact-archive`,
1955 `contact`.`pending` AS `contact-pending`,
1956 `contact`.`rel` AS `contact-rel`,
1957 `contact`.`uid` AS `contact-uid`,
1958 `contact`.`contact-type` AS `contact-contact-type`,
1959 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1960 `contact`.`self` AS `self`,
1961 `contact`.`id` AS `cid`,
1962 `contact`.`alias` AS `alias`,
1963 `contact`.`photo` AS `photo`,
1964 `contact`.`name-date` AS `name-date`,
1965 `contact`.`uri-date` AS `uri-date`,
1966 `contact`.`avatar-date` AS `avatar-date`,
1967 `contact`.`thumb` AS `thumb`,
1968 `post-user`.`author-id` AS `author-id`,
1969 `author`.`uri-id` AS `author-uri-id`,
1970 `author`.`url` AS `author-link`,
1971 `author`.`addr` AS `author-addr`,
1972 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1973 `author`.`nick` AS `author-nick`,
1974 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1975 `author`.`network` AS `author-network`,
1976 `author`.`blocked` AS `author-blocked`,
1977 `author`.`hidden` AS `author-hidden`,
1978 `author`.`updated` AS `author-updated`,
1979 `author`.`gsid` AS `author-gsid`,
1980 `post-user`.`owner-id` AS `owner-id`,
1981 `owner`.`uri-id` AS `owner-uri-id`,
1982 `owner`.`url` AS `owner-link`,
1983 `owner`.`addr` AS `owner-addr`,
1984 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1985 `owner`.`nick` AS `owner-nick`,
1986 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1987 `owner`.`network` AS `owner-network`,
1988 `owner`.`blocked` AS `owner-blocked`,
1989 `owner`.`hidden` AS `owner-hidden`,
1990 `owner`.`updated` AS `owner-updated`,
1991 `owner`.`contact-type` AS `owner-contact-type`,
1992 `post-user`.`causer-id` AS `causer-id`,
1993 `causer`.`uri-id` AS `causer-uri-id`,
1994 `causer`.`url` AS `causer-link`,
1995 `causer`.`addr` AS `causer-addr`,
1996 `causer`.`name` AS `causer-name`,
1997 `causer`.`nick` AS `causer-nick`,
1998 `causer`.`thumb` AS `causer-avatar`,
1999 `causer`.`network` AS `causer-network`,
2000 `causer`.`blocked` AS `causer-blocked`,
2001 `causer`.`hidden` AS `causer-hidden`,
2002 `causer`.`contact-type` AS `causer-contact-type`,
2003 `post-delivery-data`.`postopts` AS `postopts`,
2004 `post-delivery-data`.`inform` AS `inform`,
2005 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
2006 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
2007 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
2008 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
2009 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
2010 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
2011 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
2012 `post-user`.`event-id` AS `event-id`,
2013 `event`.`created` AS `event-created`,
2014 `event`.`edited` AS `event-edited`,
2015 `event`.`start` AS `event-start`,
2016 `event`.`finish` AS `event-finish`,
2017 `event`.`summary` AS `event-summary`,
2018 `event`.`desc` AS `event-desc`,
2019 `event`.`location` AS `event-location`,
2020 `event`.`type` AS `event-type`,
2021 `event`.`nofinish` AS `event-nofinish`,
2022 `event`.`ignore` AS `event-ignore`,
2023 `post-question`.`id` AS `question-id`,
2024 `post-question`.`multiple` AS `question-multiple`,
2025 `post-question`.`voters` AS `question-voters`,
2026 `post-question`.`end-time` AS `question-end-time`,
2027 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`,
2028 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-user`.`uri-id`) AS `has-media`,
2029 `diaspora-interaction`.`interaction` AS `signed_text`,
2030 `parent-item-uri`.`guid` AS `parent-guid`,
2031 `parent-post`.`network` AS `parent-network`,
2032 `parent-post`.`author-id` AS `parent-author-id`,
2033 `parent-post-author`.`url` AS `parent-author-link`,
2034 `parent-post-author`.`name` AS `parent-author-name`,
2035 `parent-post-author`.`nick` AS `parent-author-nick`,
2036 `parent-post-author`.`network` AS `parent-author-network`
2038 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2039 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
2040 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
2041 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
2042 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
2043 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
2044 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
2045 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
2046 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
2047 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
2048 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
2049 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
2050 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
2051 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
2052 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2053 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
2054 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-user`.`uri-id`
2055 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
2056 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2057 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2060 -- VIEW post-thread-user-view
2062 DROP VIEW IF EXISTS `post-thread-user-view`;
2063 CREATE VIEW `post-thread-user-view` AS SELECT
2064 `post-user`.`id` AS `id`,
2065 `post-user`.`id` AS `post-user-id`,
2066 `post-thread-user`.`uid` AS `uid`,
2067 `parent-post`.`id` AS `parent`,
2068 `item-uri`.`uri` AS `uri`,
2069 `post-thread-user`.`uri-id` AS `uri-id`,
2070 `parent-item-uri`.`uri` AS `parent-uri`,
2071 `post-user`.`parent-uri-id` AS `parent-uri-id`,
2072 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2073 `post-user`.`thr-parent-id` AS `thr-parent-id`,
2074 `conversation-item-uri`.`uri` AS `conversation`,
2075 `post-thread-user`.`conversation-id` AS `conversation-id`,
2076 `quote-item-uri`.`uri` AS `quote-uri`,
2077 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2078 `item-uri`.`guid` AS `guid`,
2079 `post-thread-user`.`wall` AS `wall`,
2080 `post-user`.`gravity` AS `gravity`,
2081 `external-item-uri`.`uri` AS `extid`,
2082 `post-user`.`external-id` AS `external-id`,
2083 `post-thread-user`.`created` AS `created`,
2084 `post-user`.`edited` AS `edited`,
2085 `post-thread-user`.`commented` AS `commented`,
2086 `post-thread-user`.`received` AS `received`,
2087 `post-thread-user`.`changed` AS `changed`,
2088 `post-user`.`post-type` AS `post-type`,
2089 `post-user`.`post-reason` AS `post-reason`,
2090 `post-user`.`private` AS `private`,
2091 `post-thread-user`.`pubmail` AS `pubmail`,
2092 `post-thread-user`.`ignored` AS `ignored`,
2093 `post-user`.`visible` AS `visible`,
2094 `post-thread-user`.`starred` AS `starred`,
2095 `post-thread-user`.`unseen` AS `unseen`,
2096 `post-user`.`deleted` AS `deleted`,
2097 `post-thread-user`.`origin` AS `origin`,
2098 `post-thread-user`.`mention` AS `mention`,
2099 `post-user`.`global` AS `global`,
2100 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread-user`.`uri-id`) AS `featured`,
2101 `post-thread-user`.`network` AS `network`,
2102 `post-user`.`vid` AS `vid`,
2103 `post-thread-user`.`psid` AS `psid`,
2104 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2105 `post-content`.`title` AS `title`,
2106 `post-content`.`content-warning` AS `content-warning`,
2107 `post-content`.`raw-body` AS `raw-body`,
2108 `post-content`.`body` AS `body`,
2109 `post-content`.`rendered-hash` AS `rendered-hash`,
2110 `post-content`.`rendered-html` AS `rendered-html`,
2111 `post-content`.`language` AS `language`,
2112 `post-content`.`plink` AS `plink`,
2113 `post-content`.`location` AS `location`,
2114 `post-content`.`coord` AS `coord`,
2115 `post-content`.`app` AS `app`,
2116 `post-content`.`object-type` AS `object-type`,
2117 `post-content`.`object` AS `object`,
2118 `post-content`.`target-type` AS `target-type`,
2119 `post-content`.`target` AS `target`,
2120 `post-content`.`resource-id` AS `resource-id`,
2121 `post-thread-user`.`contact-id` AS `contact-id`,
2122 `contact`.`uri-id` AS `contact-uri-id`,
2123 `contact`.`url` AS `contact-link`,
2124 `contact`.`addr` AS `contact-addr`,
2125 `contact`.`name` AS `contact-name`,
2126 `contact`.`nick` AS `contact-nick`,
2127 `contact`.`thumb` AS `contact-avatar`,
2128 `contact`.`network` AS `contact-network`,
2129 `contact`.`blocked` AS `contact-blocked`,
2130 `contact`.`hidden` AS `contact-hidden`,
2131 `contact`.`readonly` AS `contact-readonly`,
2132 `contact`.`archive` AS `contact-archive`,
2133 `contact`.`pending` AS `contact-pending`,
2134 `contact`.`rel` AS `contact-rel`,
2135 `contact`.`uid` AS `contact-uid`,
2136 `contact`.`contact-type` AS `contact-contact-type`,
2137 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
2138 `contact`.`self` AS `self`,
2139 `contact`.`id` AS `cid`,
2140 `contact`.`alias` AS `alias`,
2141 `contact`.`photo` AS `photo`,
2142 `contact`.`name-date` AS `name-date`,
2143 `contact`.`uri-date` AS `uri-date`,
2144 `contact`.`avatar-date` AS `avatar-date`,
2145 `contact`.`thumb` AS `thumb`,
2146 `post-thread-user`.`author-id` AS `author-id`,
2147 `author`.`uri-id` AS `author-uri-id`,
2148 `author`.`url` AS `author-link`,
2149 `author`.`addr` AS `author-addr`,
2150 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
2151 `author`.`nick` AS `author-nick`,
2152 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
2153 `author`.`network` AS `author-network`,
2154 `author`.`blocked` AS `author-blocked`,
2155 `author`.`hidden` AS `author-hidden`,
2156 `author`.`updated` AS `author-updated`,
2157 `author`.`gsid` AS `author-gsid`,
2158 `post-thread-user`.`owner-id` AS `owner-id`,
2159 `owner`.`uri-id` AS `owner-uri-id`,
2160 `owner`.`url` AS `owner-link`,
2161 `owner`.`addr` AS `owner-addr`,
2162 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
2163 `owner`.`nick` AS `owner-nick`,
2164 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
2165 `owner`.`network` AS `owner-network`,
2166 `owner`.`blocked` AS `owner-blocked`,
2167 `owner`.`hidden` AS `owner-hidden`,
2168 `owner`.`updated` AS `owner-updated`,
2169 `owner`.`contact-type` AS `owner-contact-type`,
2170 `post-thread-user`.`causer-id` AS `causer-id`,
2171 `causer`.`uri-id` AS `causer-uri-id`,
2172 `causer`.`url` AS `causer-link`,
2173 `causer`.`addr` AS `causer-addr`,
2174 `causer`.`name` AS `causer-name`,
2175 `causer`.`nick` AS `causer-nick`,
2176 `causer`.`thumb` AS `causer-avatar`,
2177 `causer`.`network` AS `causer-network`,
2178 `causer`.`blocked` AS `causer-blocked`,
2179 `causer`.`hidden` AS `causer-hidden`,
2180 `causer`.`contact-type` AS `causer-contact-type`,
2181 `post-delivery-data`.`postopts` AS `postopts`,
2182 `post-delivery-data`.`inform` AS `inform`,
2183 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
2184 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
2185 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
2186 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
2187 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
2188 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
2189 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
2190 `post-user`.`event-id` AS `event-id`,
2191 `event`.`created` AS `event-created`,
2192 `event`.`edited` AS `event-edited`,
2193 `event`.`start` AS `event-start`,
2194 `event`.`finish` AS `event-finish`,
2195 `event`.`summary` AS `event-summary`,
2196 `event`.`desc` AS `event-desc`,
2197 `event`.`location` AS `event-location`,
2198 `event`.`type` AS `event-type`,
2199 `event`.`nofinish` AS `event-nofinish`,
2200 `event`.`ignore` AS `event-ignore`,
2201 `post-question`.`id` AS `question-id`,
2202 `post-question`.`multiple` AS `question-multiple`,
2203 `post-question`.`voters` AS `question-voters`,
2204 `post-question`.`end-time` AS `question-end-time`,
2205 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`,
2206 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread-user`.`uri-id`) AS `has-media`,
2207 `diaspora-interaction`.`interaction` AS `signed_text`,
2208 `parent-item-uri`.`guid` AS `parent-guid`,
2209 `parent-post`.`network` AS `parent-network`,
2210 `parent-post`.`author-id` AS `parent-author-id`,
2211 `parent-post-author`.`url` AS `parent-author-link`,
2212 `parent-post-author`.`name` AS `parent-author-name`,
2213 `parent-post-author`.`network` AS `parent-author-network`
2214 FROM `post-thread-user`
2215 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2216 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2217 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
2218 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
2219 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
2220 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
2221 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
2222 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
2223 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
2224 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
2225 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
2226 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
2227 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
2228 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
2229 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2230 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
2231 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread-user`.`uri-id`
2232 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
2233 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-thread-user`.`uid`
2234 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2239 DROP VIEW IF EXISTS `post-view`;
2240 CREATE VIEW `post-view` AS SELECT
2241 `item-uri`.`uri` AS `uri`,
2242 `post`.`uri-id` AS `uri-id`,
2243 `parent-item-uri`.`uri` AS `parent-uri`,
2244 `post`.`parent-uri-id` AS `parent-uri-id`,
2245 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2246 `post`.`thr-parent-id` AS `thr-parent-id`,
2247 `conversation-item-uri`.`uri` AS `conversation`,
2248 `post-thread`.`conversation-id` AS `conversation-id`,
2249 `quote-item-uri`.`uri` AS `quote-uri`,
2250 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2251 `item-uri`.`guid` AS `guid`,
2252 `post`.`gravity` AS `gravity`,
2253 `external-item-uri`.`uri` AS `extid`,
2254 `post`.`external-id` AS `external-id`,
2255 `post`.`created` AS `created`,
2256 `post`.`edited` AS `edited`,
2257 `post-thread`.`commented` AS `commented`,
2258 `post`.`received` AS `received`,
2259 `post-thread`.`changed` AS `changed`,
2260 `post`.`post-type` AS `post-type`,
2261 `post`.`private` AS `private`,
2262 `post`.`visible` AS `visible`,
2263 `post`.`deleted` AS `deleted`,
2264 `post`.`global` AS `global`,
2265 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post`.`uri-id`) AS `featured`,
2266 `post`.`network` AS `network`,
2267 `post`.`vid` AS `vid`,
2268 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2269 `post-content`.`title` AS `title`,
2270 `post-content`.`content-warning` AS `content-warning`,
2271 `post-content`.`raw-body` AS `raw-body`,
2272 `post-content`.`body` AS `body`,
2273 `post-content`.`rendered-hash` AS `rendered-hash`,
2274 `post-content`.`rendered-html` AS `rendered-html`,
2275 `post-content`.`language` AS `language`,
2276 `post-content`.`plink` AS `plink`,
2277 `post-content`.`location` AS `location`,
2278 `post-content`.`coord` AS `coord`,
2279 `post-content`.`app` AS `app`,
2280 `post-content`.`object-type` AS `object-type`,
2281 `post-content`.`object` AS `object`,
2282 `post-content`.`target-type` AS `target-type`,
2283 `post-content`.`target` AS `target`,
2284 `post-content`.`resource-id` AS `resource-id`,
2285 `post`.`author-id` AS `contact-id`,
2286 `author`.`uri-id` AS `contact-uri-id`,
2287 `author`.`url` AS `contact-link`,
2288 `author`.`addr` AS `contact-addr`,
2289 `author`.`name` AS `contact-name`,
2290 `author`.`nick` AS `contact-nick`,
2291 `author`.`thumb` AS `contact-avatar`,
2292 `author`.`network` AS `contact-network`,
2293 `author`.`blocked` AS `contact-blocked`,
2294 `author`.`hidden` AS `contact-hidden`,
2295 `author`.`readonly` AS `contact-readonly`,
2296 `author`.`archive` AS `contact-archive`,
2297 `author`.`pending` AS `contact-pending`,
2298 `author`.`rel` AS `contact-rel`,
2299 `author`.`uid` AS `contact-uid`,
2300 `author`.`contact-type` AS `contact-contact-type`,
2301 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2303 `author`.`id` AS `cid`,
2304 `author`.`alias` AS `alias`,
2305 `author`.`photo` AS `photo`,
2306 `author`.`name-date` AS `name-date`,
2307 `author`.`uri-date` AS `uri-date`,
2308 `author`.`avatar-date` AS `avatar-date`,
2309 `author`.`thumb` AS `thumb`,
2310 `post`.`author-id` AS `author-id`,
2311 `author`.`uri-id` AS `author-uri-id`,
2312 `author`.`url` AS `author-link`,
2313 `author`.`addr` AS `author-addr`,
2314 `author`.`name` AS `author-name`,
2315 `author`.`nick` AS `author-nick`,
2316 `author`.`thumb` AS `author-avatar`,
2317 `author`.`network` AS `author-network`,
2318 `author`.`blocked` AS `author-blocked`,
2319 `author`.`hidden` AS `author-hidden`,
2320 `author`.`updated` AS `author-updated`,
2321 `author`.`gsid` AS `author-gsid`,
2322 `post`.`owner-id` AS `owner-id`,
2323 `owner`.`uri-id` AS `owner-uri-id`,
2324 `owner`.`url` AS `owner-link`,
2325 `owner`.`addr` AS `owner-addr`,
2326 `owner`.`name` AS `owner-name`,
2327 `owner`.`nick` AS `owner-nick`,
2328 `owner`.`thumb` AS `owner-avatar`,
2329 `owner`.`network` AS `owner-network`,
2330 `owner`.`blocked` AS `owner-blocked`,
2331 `owner`.`hidden` AS `owner-hidden`,
2332 `owner`.`updated` AS `owner-updated`,
2333 `owner`.`contact-type` AS `owner-contact-type`,
2334 `post`.`causer-id` AS `causer-id`,
2335 `causer`.`uri-id` AS `causer-uri-id`,
2336 `causer`.`url` AS `causer-link`,
2337 `causer`.`addr` AS `causer-addr`,
2338 `causer`.`name` AS `causer-name`,
2339 `causer`.`nick` AS `causer-nick`,
2340 `causer`.`thumb` AS `causer-avatar`,
2341 `causer`.`network` AS `causer-network`,
2342 `causer`.`blocked` AS `causer-blocked`,
2343 `causer`.`hidden` AS `causer-hidden`,
2344 `causer`.`contact-type` AS `causer-contact-type`,
2345 `post-question`.`id` AS `question-id`,
2346 `post-question`.`multiple` AS `question-multiple`,
2347 `post-question`.`voters` AS `question-voters`,
2348 `post-question`.`end-time` AS `question-end-time`,
2349 0 AS `has-categories`,
2350 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post`.`uri-id`) AS `has-media`,
2351 `diaspora-interaction`.`interaction` AS `signed_text`,
2352 `parent-item-uri`.`guid` AS `parent-guid`,
2353 `parent-post`.`network` AS `parent-network`,
2354 `parent-post`.`author-id` AS `parent-author-id`,
2355 `parent-post-author`.`url` AS `parent-author-link`,
2356 `parent-post-author`.`name` AS `parent-author-name`,
2357 `parent-post-author`.`network` AS `parent-author-network`
2359 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
2360 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
2361 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
2362 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
2363 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
2364 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2365 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2366 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
2367 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2368 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2369 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
2370 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
2371 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2372 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post`.`uri-id`
2373 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2374 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2377 -- VIEW post-thread-view
2379 DROP VIEW IF EXISTS `post-thread-view`;
2380 CREATE VIEW `post-thread-view` AS SELECT
2381 `item-uri`.`uri` AS `uri`,
2382 `post-thread`.`uri-id` AS `uri-id`,
2383 `parent-item-uri`.`uri` AS `parent-uri`,
2384 `post`.`parent-uri-id` AS `parent-uri-id`,
2385 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2386 `post`.`thr-parent-id` AS `thr-parent-id`,
2387 `conversation-item-uri`.`uri` AS `conversation`,
2388 `post-thread`.`conversation-id` AS `conversation-id`,
2389 `quote-item-uri`.`uri` AS `quote-uri`,
2390 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2391 `item-uri`.`guid` AS `guid`,
2392 `post`.`gravity` AS `gravity`,
2393 `external-item-uri`.`uri` AS `extid`,
2394 `post`.`external-id` AS `external-id`,
2395 `post-thread`.`created` AS `created`,
2396 `post`.`edited` AS `edited`,
2397 `post-thread`.`commented` AS `commented`,
2398 `post-thread`.`received` AS `received`,
2399 `post-thread`.`changed` AS `changed`,
2400 `post`.`post-type` AS `post-type`,
2401 `post`.`private` AS `private`,
2402 `post`.`visible` AS `visible`,
2403 `post`.`deleted` AS `deleted`,
2404 `post`.`global` AS `global`,
2405 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread`.`uri-id`) AS `featured`,
2406 `post-thread`.`network` AS `network`,
2407 `post`.`vid` AS `vid`,
2408 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2409 `post-content`.`title` AS `title`,
2410 `post-content`.`content-warning` AS `content-warning`,
2411 `post-content`.`raw-body` AS `raw-body`,
2412 `post-content`.`body` AS `body`,
2413 `post-content`.`rendered-hash` AS `rendered-hash`,
2414 `post-content`.`rendered-html` AS `rendered-html`,
2415 `post-content`.`language` AS `language`,
2416 `post-content`.`plink` AS `plink`,
2417 `post-content`.`location` AS `location`,
2418 `post-content`.`coord` AS `coord`,
2419 `post-content`.`app` AS `app`,
2420 `post-content`.`object-type` AS `object-type`,
2421 `post-content`.`object` AS `object`,
2422 `post-content`.`target-type` AS `target-type`,
2423 `post-content`.`target` AS `target`,
2424 `post-content`.`resource-id` AS `resource-id`,
2425 `post-thread`.`author-id` AS `contact-id`,
2426 `author`.`uri-id` AS `contact-uri-id`,
2427 `author`.`url` AS `contact-link`,
2428 `author`.`addr` AS `contact-addr`,
2429 `author`.`name` AS `contact-name`,
2430 `author`.`nick` AS `contact-nick`,
2431 `author`.`thumb` AS `contact-avatar`,
2432 `author`.`network` AS `contact-network`,
2433 `author`.`blocked` AS `contact-blocked`,
2434 `author`.`hidden` AS `contact-hidden`,
2435 `author`.`readonly` AS `contact-readonly`,
2436 `author`.`archive` AS `contact-archive`,
2437 `author`.`pending` AS `contact-pending`,
2438 `author`.`rel` AS `contact-rel`,
2439 `author`.`uid` AS `contact-uid`,
2440 `author`.`contact-type` AS `contact-contact-type`,
2441 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2443 `author`.`id` AS `cid`,
2444 `author`.`alias` AS `alias`,
2445 `author`.`photo` AS `photo`,
2446 `author`.`name-date` AS `name-date`,
2447 `author`.`uri-date` AS `uri-date`,
2448 `author`.`avatar-date` AS `avatar-date`,
2449 `author`.`thumb` AS `thumb`,
2450 `post-thread`.`author-id` AS `author-id`,
2451 `author`.`uri-id` AS `author-uri-id`,
2452 `author`.`url` AS `author-link`,
2453 `author`.`addr` AS `author-addr`,
2454 `author`.`name` AS `author-name`,
2455 `author`.`nick` AS `author-nick`,
2456 `author`.`thumb` AS `author-avatar`,
2457 `author`.`network` AS `author-network`,
2458 `author`.`blocked` AS `author-blocked`,
2459 `author`.`hidden` AS `author-hidden`,
2460 `author`.`updated` AS `author-updated`,
2461 `author`.`gsid` AS `author-gsid`,
2462 `post-thread`.`owner-id` AS `owner-id`,
2463 `owner`.`uri-id` AS `owner-uri-id`,
2464 `owner`.`url` AS `owner-link`,
2465 `owner`.`addr` AS `owner-addr`,
2466 `owner`.`name` AS `owner-name`,
2467 `owner`.`nick` AS `owner-nick`,
2468 `owner`.`thumb` AS `owner-avatar`,
2469 `owner`.`network` AS `owner-network`,
2470 `owner`.`blocked` AS `owner-blocked`,
2471 `owner`.`hidden` AS `owner-hidden`,
2472 `owner`.`updated` AS `owner-updated`,
2473 `owner`.`contact-type` AS `owner-contact-type`,
2474 `post-thread`.`causer-id` AS `causer-id`,
2475 `causer`.`uri-id` AS `causer-uri-id`,
2476 `causer`.`url` AS `causer-link`,
2477 `causer`.`addr` AS `causer-addr`,
2478 `causer`.`name` AS `causer-name`,
2479 `causer`.`nick` AS `causer-nick`,
2480 `causer`.`thumb` AS `causer-avatar`,
2481 `causer`.`network` AS `causer-network`,
2482 `causer`.`blocked` AS `causer-blocked`,
2483 `causer`.`hidden` AS `causer-hidden`,
2484 `causer`.`contact-type` AS `causer-contact-type`,
2485 `post-question`.`id` AS `question-id`,
2486 `post-question`.`multiple` AS `question-multiple`,
2487 `post-question`.`voters` AS `question-voters`,
2488 `post-question`.`end-time` AS `question-end-time`,
2489 0 AS `has-categories`,
2490 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread`.`uri-id`) AS `has-media`,
2491 (SELECT COUNT(*) FROM `post` WHERE `parent-uri-id` = `post-thread`.`uri-id` AND `gravity` = 6) AS `total-comments`,
2492 (SELECT COUNT(DISTINCT(`author-id`)) FROM `post` WHERE `parent-uri-id` = `post-thread`.`uri-id` AND `gravity` = 6) AS `total-actors`,
2493 `diaspora-interaction`.`interaction` AS `signed_text`,
2494 `parent-item-uri`.`guid` AS `parent-guid`,
2495 `parent-post`.`network` AS `parent-network`,
2496 `parent-post`.`author-id` AS `parent-author-id`,
2497 `parent-post-author`.`url` AS `parent-author-link`,
2498 `parent-post-author`.`name` AS `parent-author-name`,
2499 `parent-post-author`.`network` AS `parent-author-network`
2501 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
2502 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
2503 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
2504 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
2505 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
2506 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2507 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2508 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
2509 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2510 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2511 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
2512 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
2513 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2514 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread`.`uri-id`
2515 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2516 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2519 -- VIEW category-view
2521 DROP VIEW IF EXISTS `category-view`;
2522 CREATE VIEW `category-view` AS SELECT
2523 `post-category`.`uri-id` AS `uri-id`,
2524 `post-category`.`uid` AS `uid`,
2525 `post-category`.`type` AS `type`,
2526 `post-category`.`tid` AS `tid`,
2527 `tag`.`name` AS `name`,
2528 `tag`.`url` AS `url`
2529 FROM `post-category`
2530 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2533 -- VIEW collection-view
2535 DROP VIEW IF EXISTS `collection-view`;
2536 CREATE VIEW `collection-view` AS SELECT
2537 `post-collection`.`uri-id` AS `uri-id`,
2538 `post-collection`.`type` AS `type`,
2539 `post-collection`.`author-id` AS `cid`,
2540 `post`.`received` AS `received`,
2541 `post`.`created` AS `created`,
2542 `post-thread`.`commented` AS `commented`,
2543 `post`.`private` AS `private`,
2544 `post`.`visible` AS `visible`,
2545 `post`.`deleted` AS `deleted`,
2546 `post`.`thr-parent-id` AS `thr-parent-id`,
2547 `post-collection`.`author-id` AS `author-id`,
2548 `post`.`gravity` AS `gravity`
2549 FROM `post-collection`
2550 INNER JOIN `post` ON `post-collection`.`uri-id` = `post`.`uri-id`
2551 INNER JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`;
2556 DROP VIEW IF EXISTS `media-view`;
2557 CREATE VIEW `media-view` AS SELECT
2558 `post-media`.`uri-id` AS `uri-id`,
2559 `post-media`.`type` AS `type`,
2560 `post`.`received` AS `received`,
2561 `post`.`created` AS `created`,
2562 `post`.`private` AS `private`,
2563 `post`.`visible` AS `visible`,
2564 `post`.`deleted` AS `deleted`,
2565 `post`.`thr-parent-id` AS `thr-parent-id`,
2566 `post`.`author-id` AS `author-id`,
2567 `post`.`gravity` AS `gravity`
2569 INNER JOIN `post` ON `post-media`.`uri-id` = `post`.`uri-id`;
2574 DROP VIEW IF EXISTS `tag-view`;
2575 CREATE VIEW `tag-view` AS SELECT
2576 `post-tag`.`uri-id` AS `uri-id`,
2577 `post-tag`.`type` AS `type`,
2578 `post-tag`.`tid` AS `tid`,
2579 `post-tag`.`cid` AS `cid`,
2580 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2581 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`,
2582 CASE `cid` WHEN 0 THEN `tag`.`type` ELSE 1 END AS `tag-type`
2584 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2585 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2588 -- VIEW network-item-view
2590 DROP VIEW IF EXISTS `network-item-view`;
2591 CREATE VIEW `network-item-view` AS SELECT
2592 `post-user`.`uri-id` AS `uri-id`,
2593 `parent-post`.`id` AS `parent`,
2594 `post-user`.`received` AS `received`,
2595 `post-thread-user`.`commented` AS `commented`,
2596 `post-user`.`created` AS `created`,
2597 `post-user`.`uid` AS `uid`,
2598 `post-thread-user`.`starred` AS `starred`,
2599 `post-thread-user`.`mention` AS `mention`,
2600 `post-user`.`network` AS `network`,
2601 `post-user`.`unseen` AS `unseen`,
2602 `post-user`.`gravity` AS `gravity`,
2603 `post-user`.`contact-id` AS `contact-id`,
2604 `ownercontact`.`contact-type` AS `contact-type`
2606 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2607 INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2608 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2609 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2610 INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2611 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2612 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2613 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2614 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
2615 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2616 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2619 -- VIEW network-thread-view
2621 DROP VIEW IF EXISTS `network-thread-view`;
2622 CREATE VIEW `network-thread-view` AS SELECT
2623 `post-thread-user`.`uri-id` AS `uri-id`,
2624 `parent-post`.`id` AS `parent`,
2625 `post-thread-user`.`received` AS `received`,
2626 `post-thread-user`.`commented` AS `commented`,
2627 `post-thread-user`.`created` AS `created`,
2628 `post-thread-user`.`uid` AS `uid`,
2629 `post-thread-user`.`starred` AS `starred`,
2630 `post-thread-user`.`mention` AS `mention`,
2631 `post-thread-user`.`network` AS `network`,
2632 `post-thread-user`.`contact-id` AS `contact-id`,
2633 `ownercontact`.`contact-type` AS `contact-type`
2634 FROM `post-thread-user`
2635 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2636 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2637 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2638 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2639 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2640 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2641 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2642 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2643 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2644 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2645 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2650 DROP VIEW IF EXISTS `owner-view`;
2651 CREATE VIEW `owner-view` AS SELECT
2652 `contact`.`id` AS `id`,
2653 `contact`.`uid` AS `uid`,
2654 `contact`.`created` AS `created`,
2655 `contact`.`updated` AS `updated`,
2656 `contact`.`self` AS `self`,
2657 `contact`.`remote_self` AS `remote_self`,
2658 `contact`.`rel` AS `rel`,
2659 `contact`.`network` AS `network`,
2660 `contact`.`protocol` AS `protocol`,
2661 `contact`.`name` AS `name`,
2662 `contact`.`nick` AS `nick`,
2663 `contact`.`location` AS `location`,
2664 `contact`.`about` AS `about`,
2665 `contact`.`keywords` AS `keywords`,
2666 `contact`.`xmpp` AS `xmpp`,
2667 `contact`.`matrix` AS `matrix`,
2668 `contact`.`attag` AS `attag`,
2669 `contact`.`avatar` AS `avatar`,
2670 `contact`.`photo` AS `photo`,
2671 `contact`.`thumb` AS `thumb`,
2672 `contact`.`micro` AS `micro`,
2673 `contact`.`header` AS `header`,
2674 `contact`.`url` AS `url`,
2675 `contact`.`nurl` AS `nurl`,
2676 `contact`.`uri-id` AS `uri-id`,
2677 `contact`.`addr` AS `addr`,
2678 `contact`.`alias` AS `alias`,
2679 `contact`.`pubkey` AS `pubkey`,
2680 `contact`.`prvkey` AS `prvkey`,
2681 `contact`.`batch` AS `batch`,
2682 `contact`.`request` AS `request`,
2683 `contact`.`notify` AS `notify`,
2684 `contact`.`poll` AS `poll`,
2685 `contact`.`confirm` AS `confirm`,
2686 `contact`.`poco` AS `poco`,
2687 `contact`.`subhub` AS `subhub`,
2688 `contact`.`hub-verify` AS `hub-verify`,
2689 `contact`.`last-update` AS `last-update`,
2690 `contact`.`success_update` AS `success_update`,
2691 `contact`.`failure_update` AS `failure_update`,
2692 `contact`.`name-date` AS `name-date`,
2693 `contact`.`uri-date` AS `uri-date`,
2694 `contact`.`avatar-date` AS `avatar-date`,
2695 `contact`.`avatar-date` AS `picdate`,
2696 `contact`.`term-date` AS `term-date`,
2697 `contact`.`last-item` AS `last-item`,
2698 `contact`.`priority` AS `priority`,
2699 `user`.`blocked` AS `blocked`,
2700 `contact`.`block_reason` AS `block_reason`,
2701 `contact`.`readonly` AS `readonly`,
2702 `contact`.`writable` AS `writable`,
2703 `contact`.`forum` AS `forum`,
2704 `contact`.`prv` AS `prv`,
2705 `contact`.`contact-type` AS `contact-type`,
2706 `contact`.`manually-approve` AS `manually-approve`,
2707 `contact`.`hidden` AS `hidden`,
2708 `contact`.`archive` AS `archive`,
2709 `contact`.`pending` AS `pending`,
2710 `contact`.`deleted` AS `deleted`,
2711 `contact`.`unsearchable` AS `unsearchable`,
2712 `contact`.`sensitive` AS `sensitive`,
2713 `contact`.`baseurl` AS `baseurl`,
2714 `contact`.`reason` AS `reason`,
2715 `contact`.`info` AS `info`,
2716 `contact`.`bdyear` AS `bdyear`,
2717 `contact`.`bd` AS `bd`,
2718 `contact`.`notify_new_posts` AS `notify_new_posts`,
2719 `contact`.`fetch_further_information` AS `fetch_further_information`,
2720 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2721 `user`.`parent-uid` AS `parent-uid`,
2722 `user`.`guid` AS `guid`,
2723 `user`.`nickname` AS `nickname`,
2724 `user`.`email` AS `email`,
2725 `user`.`openid` AS `openid`,
2726 `user`.`timezone` AS `timezone`,
2727 `user`.`language` AS `language`,
2728 `user`.`register_date` AS `register_date`,
2729 `user`.`login_date` AS `login_date`,
2730 `user`.`last-activity` AS `last-activity`,
2731 `user`.`default-location` AS `default-location`,
2732 `user`.`allow_location` AS `allow_location`,
2733 `user`.`theme` AS `theme`,
2734 `user`.`pubkey` AS `upubkey`,
2735 `user`.`prvkey` AS `uprvkey`,
2736 `user`.`sprvkey` AS `sprvkey`,
2737 `user`.`spubkey` AS `spubkey`,
2738 `user`.`verified` AS `verified`,
2739 `user`.`blockwall` AS `blockwall`,
2740 `user`.`hidewall` AS `hidewall`,
2741 `user`.`blocktags` AS `blocktags`,
2742 `user`.`unkmail` AS `unkmail`,
2743 `user`.`cntunkmail` AS `cntunkmail`,
2744 `user`.`notify-flags` AS `notify-flags`,
2745 `user`.`page-flags` AS `page-flags`,
2746 `user`.`account-type` AS `account-type`,
2747 `user`.`prvnets` AS `prvnets`,
2748 `user`.`maxreq` AS `maxreq`,
2749 `user`.`expire` AS `expire`,
2750 `user`.`account_removed` AS `account_removed`,
2751 `user`.`account_expired` AS `account_expired`,
2752 `user`.`account_expires_on` AS `account_expires_on`,
2753 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2754 `user`.`def_gid` AS `def_gid`,
2755 `user`.`allow_cid` AS `allow_cid`,
2756 `user`.`allow_gid` AS `allow_gid`,
2757 `user`.`deny_cid` AS `deny_cid`,
2758 `user`.`deny_gid` AS `deny_gid`,
2759 `user`.`openidserver` AS `openidserver`,
2760 `profile`.`publish` AS `publish`,
2761 `profile`.`net-publish` AS `net-publish`,
2762 `profile`.`hide-friends` AS `hide-friends`,
2763 `profile`.`prv_keywords` AS `prv_keywords`,
2764 `profile`.`pub_keywords` AS `pub_keywords`,
2765 `profile`.`address` AS `address`,
2766 `profile`.`locality` AS `locality`,
2767 `profile`.`region` AS `region`,
2768 `profile`.`postal-code` AS `postal-code`,
2769 `profile`.`country-name` AS `country-name`,
2770 `profile`.`homepage` AS `homepage`,
2771 `profile`.`homepage_verified` AS `homepage_verified`,
2772 `profile`.`dob` AS `dob`
2774 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2775 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2778 -- VIEW account-view
2780 DROP VIEW IF EXISTS `account-view`;
2781 CREATE VIEW `account-view` AS SELECT
2782 `contact`.`id` AS `id`,
2783 `contact`.`url` AS `url`,
2784 `contact`.`nurl` AS `nurl`,
2785 `contact`.`uri-id` AS `uri-id`,
2786 `item-uri`.`guid` AS `guid`,
2787 `contact`.`addr` AS `addr`,
2788 `contact`.`alias` AS `alias`,
2789 `contact`.`name` AS `name`,
2790 `contact`.`nick` AS `nick`,
2791 `contact`.`about` AS `about`,
2792 `contact`.`keywords` AS `keywords`,
2793 `contact`.`xmpp` AS `xmpp`,
2794 `contact`.`matrix` AS `matrix`,
2795 `contact`.`avatar` AS `avatar`,
2796 `contact`.`photo` AS `photo`,
2797 `contact`.`thumb` AS `thumb`,
2798 `contact`.`micro` AS `micro`,
2799 `contact`.`header` AS `header`,
2800 `contact`.`created` AS `created`,
2801 `contact`.`updated` AS `updated`,
2802 `contact`.`network` AS `network`,
2803 `contact`.`protocol` AS `protocol`,
2804 `contact`.`location` AS `location`,
2805 `contact`.`attag` AS `attag`,
2806 `contact`.`pubkey` AS `pubkey`,
2807 `contact`.`prvkey` AS `prvkey`,
2808 `contact`.`subscribe` AS `subscribe`,
2809 `contact`.`last-update` AS `last-update`,
2810 `contact`.`success_update` AS `success_update`,
2811 `contact`.`failure_update` AS `failure_update`,
2812 `contact`.`failed` AS `failed`,
2813 `contact`.`last-item` AS `last-item`,
2814 `contact`.`last-discovery` AS `last-discovery`,
2815 `contact`.`contact-type` AS `contact-type`,
2816 `contact`.`manually-approve` AS `manually-approve`,
2817 `contact`.`unsearchable` AS `unsearchable`,
2818 `contact`.`sensitive` AS `sensitive`,
2819 `contact`.`baseurl` AS `baseurl`,
2820 `contact`.`gsid` AS `gsid`,
2821 `contact`.`info` AS `info`,
2822 `contact`.`bdyear` AS `bdyear`,
2823 `contact`.`bd` AS `bd`,
2824 `contact`.`poco` AS `poco`,
2825 `contact`.`name-date` AS `name-date`,
2826 `contact`.`uri-date` AS `uri-date`,
2827 `contact`.`avatar-date` AS `avatar-date`,
2828 `contact`.`term-date` AS `term-date`,
2829 `contact`.`hidden` AS `global-ignored`,
2830 `contact`.`blocked` AS `global-blocked`,
2831 `contact`.`hidden` AS `hidden`,
2832 `contact`.`archive` AS `archive`,
2833 `contact`.`deleted` AS `deleted`,
2834 `contact`.`blocked` AS `blocked`,
2835 `contact`.`notify` AS `dfrn-notify`,
2836 `contact`.`poll` AS `dfrn-poll`,
2837 `item-uri`.`guid` AS `diaspora-guid`,
2838 `diaspora-contact`.`batch` AS `diaspora-batch`,
2839 `diaspora-contact`.`notify` AS `diaspora-notify`,
2840 `diaspora-contact`.`poll` AS `diaspora-poll`,
2841 `diaspora-contact`.`alias` AS `diaspora-alias`,
2842 `apcontact`.`uuid` AS `ap-uuid`,
2843 `apcontact`.`type` AS `ap-type`,
2844 `apcontact`.`following` AS `ap-following`,
2845 `apcontact`.`followers` AS `ap-followers`,
2846 `apcontact`.`inbox` AS `ap-inbox`,
2847 `apcontact`.`outbox` AS `ap-outbox`,
2848 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2849 `apcontact`.`generator` AS `ap-generator`,
2850 `apcontact`.`following_count` AS `ap-following_count`,
2851 `apcontact`.`followers_count` AS `ap-followers_count`,
2852 `apcontact`.`statuses_count` AS `ap-statuses_count`,
2853 `gserver`.`site_name` AS `site_name`,
2854 `gserver`.`platform` AS `platform`,
2855 `gserver`.`version` AS `version`
2857 LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id`
2858 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
2859 LEFT JOIN `diaspora-contact` ON `diaspora-contact`.`uri-id` = contact.`uri-id`
2860 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`
2861 WHERE `contact`.`uid` = 0;
2864 -- VIEW account-user-view
2866 DROP VIEW IF EXISTS `account-user-view`;
2867 CREATE VIEW `account-user-view` AS SELECT
2868 `ucontact`.`id` AS `id`,
2869 `contact`.`id` AS `pid`,
2870 `ucontact`.`uid` AS `uid`,
2871 `contact`.`url` AS `url`,
2872 `contact`.`nurl` AS `nurl`,
2873 `contact`.`uri-id` AS `uri-id`,
2874 `item-uri`.`guid` AS `guid`,
2875 `contact`.`addr` AS `addr`,
2876 `contact`.`alias` AS `alias`,
2877 `contact`.`name` AS `name`,
2878 `contact`.`nick` AS `nick`,
2879 `contact`.`about` AS `about`,
2880 `contact`.`keywords` AS `keywords`,
2881 `contact`.`xmpp` AS `xmpp`,
2882 `contact`.`matrix` AS `matrix`,
2883 `contact`.`avatar` AS `avatar`,
2884 `contact`.`photo` AS `photo`,
2885 `contact`.`thumb` AS `thumb`,
2886 `contact`.`micro` AS `micro`,
2887 `contact`.`header` AS `header`,
2888 `contact`.`created` AS `created`,
2889 `contact`.`updated` AS `updated`,
2890 `ucontact`.`self` AS `self`,
2891 `ucontact`.`remote_self` AS `remote_self`,
2892 `ucontact`.`rel` AS `rel`,
2893 `contact`.`network` AS `network`,
2894 `ucontact`.`protocol` AS `protocol`,
2895 `contact`.`location` AS `location`,
2896 `ucontact`.`attag` AS `attag`,
2897 `contact`.`pubkey` AS `pubkey`,
2898 `contact`.`prvkey` AS `prvkey`,
2899 `contact`.`subscribe` AS `subscribe`,
2900 `contact`.`last-update` AS `last-update`,
2901 `contact`.`success_update` AS `success_update`,
2902 `contact`.`failure_update` AS `failure_update`,
2903 `contact`.`failed` AS `failed`,
2904 `contact`.`last-item` AS `last-item`,
2905 `contact`.`last-discovery` AS `last-discovery`,
2906 `contact`.`contact-type` AS `contact-type`,
2907 `contact`.`manually-approve` AS `manually-approve`,
2908 `contact`.`unsearchable` AS `unsearchable`,
2909 `contact`.`sensitive` AS `sensitive`,
2910 `contact`.`baseurl` AS `baseurl`,
2911 `contact`.`gsid` AS `gsid`,
2912 `ucontact`.`info` AS `info`,
2913 `contact`.`bdyear` AS `bdyear`,
2914 `contact`.`bd` AS `bd`,
2915 `contact`.`poco` AS `poco`,
2916 `contact`.`name-date` AS `name-date`,
2917 `contact`.`uri-date` AS `uri-date`,
2918 `contact`.`avatar-date` AS `avatar-date`,
2919 `contact`.`term-date` AS `term-date`,
2920 `contact`.`hidden` AS `global-ignored`,
2921 `contact`.`blocked` AS `global-blocked`,
2922 `ucontact`.`hidden` AS `hidden`,
2923 `ucontact`.`archive` AS `archive`,
2924 `ucontact`.`pending` AS `pending`,
2925 `ucontact`.`deleted` AS `deleted`,
2926 `ucontact`.`notify_new_posts` AS `notify_new_posts`,
2927 `ucontact`.`fetch_further_information` AS `fetch_further_information`,
2928 `ucontact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2929 `ucontact`.`rating` AS `rating`,
2930 `ucontact`.`readonly` AS `readonly`,
2931 `ucontact`.`blocked` AS `blocked`,
2932 `ucontact`.`block_reason` AS `block_reason`,
2933 `ucontact`.`subhub` AS `subhub`,
2934 `ucontact`.`hub-verify` AS `hub-verify`,
2935 `ucontact`.`reason` AS `reason`,
2936 `contact`.`notify` AS `dfrn-notify`,
2937 `contact`.`poll` AS `dfrn-poll`,
2938 `item-uri`.`guid` AS `diaspora-guid`,
2939 `diaspora-contact`.`batch` AS `diaspora-batch`,
2940 `diaspora-contact`.`notify` AS `diaspora-notify`,
2941 `diaspora-contact`.`poll` AS `diaspora-poll`,
2942 `diaspora-contact`.`alias` AS `diaspora-alias`,
2943 `diaspora-contact`.`interacting_count` AS `diaspora-interacting_count`,
2944 `diaspora-contact`.`interacted_count` AS `diaspora-interacted_count`,
2945 `diaspora-contact`.`post_count` AS `diaspora-post_count`,
2946 `apcontact`.`uuid` AS `ap-uuid`,
2947 `apcontact`.`type` AS `ap-type`,
2948 `apcontact`.`following` AS `ap-following`,
2949 `apcontact`.`followers` AS `ap-followers`,
2950 `apcontact`.`inbox` AS `ap-inbox`,
2951 `apcontact`.`outbox` AS `ap-outbox`,
2952 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2953 `apcontact`.`generator` AS `ap-generator`,
2954 `apcontact`.`following_count` AS `ap-following_count`,
2955 `apcontact`.`followers_count` AS `ap-followers_count`,
2956 `apcontact`.`statuses_count` AS `ap-statuses_count`,
2957 `gserver`.`site_name` AS `site_name`,
2958 `gserver`.`platform` AS `platform`,
2959 `gserver`.`version` AS `version`
2960 FROM `contact` AS `ucontact`
2961 INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
2962 LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id`
2963 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
2964 LEFT JOIN `diaspora-contact` ON `diaspora-contact`.`uri-id` = `ucontact`.`uri-id`
2965 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`;
2968 -- VIEW pending-view
2970 DROP VIEW IF EXISTS `pending-view`;
2971 CREATE VIEW `pending-view` AS SELECT
2972 `register`.`id` AS `id`,
2973 `register`.`hash` AS `hash`,
2974 `register`.`created` AS `created`,
2975 `register`.`uid` AS `uid`,
2976 `register`.`password` AS `password`,
2977 `register`.`language` AS `language`,
2978 `register`.`note` AS `note`,
2979 `contact`.`self` AS `self`,
2980 `contact`.`name` AS `name`,
2981 `contact`.`url` AS `url`,
2982 `contact`.`micro` AS `micro`,
2983 `user`.`email` AS `email`,
2984 `contact`.`nick` AS `nick`
2986 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2987 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2990 -- VIEW tag-search-view
2992 DROP VIEW IF EXISTS `tag-search-view`;
2993 CREATE VIEW `tag-search-view` AS SELECT
2994 `post-tag`.`uri-id` AS `uri-id`,
2995 `post-user`.`uid` AS `uid`,
2996 `post-user`.`id` AS `iid`,
2997 `post-user`.`private` AS `private`,
2998 `post-user`.`wall` AS `wall`,
2999 `post-user`.`origin` AS `origin`,
3000 `post-user`.`global` AS `global`,
3001 `post-user`.`gravity` AS `gravity`,
3002 `post-user`.`received` AS `received`,
3003 `post-user`.`network` AS `network`,
3004 `post-user`.`author-id` AS `author-id`,
3005 `tag`.`name` AS `name`
3007 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
3008 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
3009 WHERE `post-tag`.`type` = 1;
3012 -- VIEW workerqueue-view
3014 DROP VIEW IF EXISTS `workerqueue-view`;
3015 CREATE VIEW `workerqueue-view` AS SELECT
3016 `process`.`pid` AS `pid`,
3017 `workerqueue`.`priority` AS `priority`
3019 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
3020 WHERE NOT `workerqueue`.`done`;
3023 -- VIEW profile_field-view
3025 DROP VIEW IF EXISTS `profile_field-view`;
3026 CREATE VIEW `profile_field-view` AS SELECT
3027 `profile_field`.`id` AS `id`,
3028 `profile_field`.`uid` AS `uid`,
3029 `profile_field`.`label` AS `label`,
3030 `profile_field`.`value` AS `value`,
3031 `profile_field`.`order` AS `order`,
3032 `profile_field`.`psid` AS `psid`,
3033 `permissionset`.`allow_cid` AS `allow_cid`,
3034 `permissionset`.`allow_gid` AS `allow_gid`,
3035 `permissionset`.`deny_cid` AS `deny_cid`,
3036 `permissionset`.`deny_gid` AS `deny_gid`,
3037 `profile_field`.`created` AS `created`,
3038 `profile_field`.`edited` AS `edited`
3039 FROM `profile_field`
3040 INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`;
3043 -- VIEW diaspora-contact-view
3045 DROP VIEW IF EXISTS `diaspora-contact-view`;
3046 CREATE VIEW `diaspora-contact-view` AS SELECT
3047 `diaspora-contact`.`uri-id` AS `uri-id`,
3048 `item-uri`.`uri` AS `url`,
3049 `item-uri`.`guid` AS `guid`,
3050 `diaspora-contact`.`addr` AS `addr`,
3051 `diaspora-contact`.`alias` AS `alias`,
3052 `diaspora-contact`.`nick` AS `nick`,
3053 `diaspora-contact`.`name` AS `name`,
3054 `diaspora-contact`.`given-name` AS `given-name`,
3055 `diaspora-contact`.`family-name` AS `family-name`,
3056 `diaspora-contact`.`photo` AS `photo`,
3057 `diaspora-contact`.`photo-medium` AS `photo-medium`,
3058 `diaspora-contact`.`photo-small` AS `photo-small`,
3059 `diaspora-contact`.`batch` AS `batch`,
3060 `diaspora-contact`.`notify` AS `notify`,
3061 `diaspora-contact`.`poll` AS `poll`,
3062 `diaspora-contact`.`subscribe` AS `subscribe`,
3063 `diaspora-contact`.`searchable` AS `searchable`,
3064 `diaspora-contact`.`pubkey` AS `pubkey`,
3065 `gserver`.`url` AS `baseurl`,
3066 `diaspora-contact`.`gsid` AS `gsid`,
3067 `diaspora-contact`.`created` AS `created`,
3068 `diaspora-contact`.`updated` AS `updated`,
3069 `diaspora-contact`.`interacting_count` AS `interacting_count`,
3070 `diaspora-contact`.`interacted_count` AS `interacted_count`,
3071 `diaspora-contact`.`post_count` AS `post_count`
3072 FROM `diaspora-contact`
3073 INNER JOIN `item-uri` ON `item-uri`.`id` = `diaspora-contact`.`uri-id`
3074 LEFT JOIN `gserver` ON `gserver`.`id` = `diaspora-contact`.`gsid`;