1 -- ------------------------------------------
2 -- Friendica 2023.03-dev (Giant Rhubarb)
3 -- DB_UPDATE_VERSION 1506
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';
500 CREATE TABLE IF NOT EXISTS `config` (
501 `id` int unsigned NOT NULL auto_increment COMMENT '',
502 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
503 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
504 `v` mediumtext COMMENT '',
506 UNIQUE INDEX `cat_k` (`cat`,`k`)
507 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
510 -- TABLE contact-relation
512 CREATE TABLE IF NOT EXISTS `contact-relation` (
513 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
514 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
515 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
516 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
517 `follows` boolean NOT NULL DEFAULT '0' COMMENT '',
518 PRIMARY KEY(`cid`,`relation-cid`),
519 INDEX `relation-cid` (`relation-cid`),
520 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
521 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
522 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
527 CREATE TABLE IF NOT EXISTS `conv` (
528 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
529 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
530 `recips` text COMMENT 'sender_handle;recipient_handle',
531 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
532 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
533 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
534 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
535 `subject` text COMMENT 'subject of initial message',
538 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
539 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
544 CREATE TABLE IF NOT EXISTS `workerqueue` (
545 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
546 `command` varchar(100) COMMENT 'Task command',
547 `parameter` mediumtext COMMENT 'Task parameter',
548 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
549 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
550 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
551 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
552 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
553 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
554 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
556 INDEX `command` (`command`),
557 INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
558 INDEX `done_executed` (`done`,`executed`),
559 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
560 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
561 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
562 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
563 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
564 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
567 -- TABLE delayed-post
569 CREATE TABLE IF NOT EXISTS `delayed-post` (
570 `id` int unsigned NOT NULL auto_increment,
571 `uri` varbinary(383) COMMENT 'URI of the post that will be distributed later',
572 `uid` mediumint unsigned COMMENT 'Owner User id',
573 `delayed` datetime COMMENT 'delay time',
574 `wid` int unsigned COMMENT 'Workerqueue id',
576 UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
578 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
579 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
580 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
583 -- TABLE delivery-queue
585 CREATE TABLE IF NOT EXISTS `delivery-queue` (
586 `gsid` int unsigned NOT NULL COMMENT 'Target server',
587 `uri-id` int unsigned NOT NULL COMMENT 'Delivered post',
588 `created` datetime COMMENT '',
589 `command` varbinary(32) COMMENT '',
590 `cid` int unsigned COMMENT 'Target contact',
591 `uid` mediumint unsigned COMMENT 'Delivering user',
592 `failed` tinyint DEFAULT 0 COMMENT 'Number of times the delivery has failed',
593 PRIMARY KEY(`uri-id`,`gsid`),
594 INDEX `gsid_created` (`gsid`,`created`),
597 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
598 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
599 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
600 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
601 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for posts for the batch processing';
604 -- TABLE diaspora-contact
606 CREATE TABLE IF NOT EXISTS `diaspora-contact` (
607 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the contact URL',
608 `addr` varchar(255) COMMENT '',
609 `alias` varchar(255) COMMENT '',
610 `nick` varchar(255) COMMENT '',
611 `name` varchar(255) COMMENT '',
612 `given-name` varchar(255) COMMENT '',
613 `family-name` varchar(255) COMMENT '',
614 `photo` varchar(255) COMMENT '',
615 `photo-medium` varchar(255) COMMENT '',
616 `photo-small` varchar(255) COMMENT '',
617 `batch` varchar(255) COMMENT '',
618 `notify` varchar(255) COMMENT '',
619 `poll` varchar(255) COMMENT '',
620 `subscribe` varchar(255) COMMENT '',
621 `searchable` boolean COMMENT '',
622 `pubkey` text COMMENT '',
623 `gsid` int unsigned COMMENT 'Global Server ID',
624 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
625 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
626 `interacting_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts this contact interactes with',
627 `interacted_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts that interacted with this contact',
628 `post_count` int unsigned DEFAULT 0 COMMENT 'Number of posts and comments',
629 PRIMARY KEY(`uri-id`),
630 UNIQUE INDEX `addr` (`addr`),
631 INDEX `alias` (`alias`),
632 INDEX `gsid` (`gsid`),
633 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
634 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
635 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
638 -- TABLE diaspora-interaction
640 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
641 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
642 `interaction` mediumtext COMMENT 'The Diaspora interaction',
643 PRIMARY KEY(`uri-id`),
644 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
645 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
650 CREATE TABLE IF NOT EXISTS `endpoint` (
651 `url` varbinary(383) NOT NULL COMMENT 'URL of the contact',
652 `type` varchar(20) NOT NULL COMMENT '',
653 `owner-uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
655 UNIQUE INDEX `owner-uri-id_type` (`owner-uri-id`,`type`),
656 FOREIGN KEY (`owner-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
657 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub endpoints - used in the ActivityPub implementation';
662 CREATE TABLE IF NOT EXISTS `event` (
663 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
664 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
665 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
666 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
667 `uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
668 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the event uri',
669 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
670 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
671 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
672 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
673 `summary` text COMMENT 'short description or title of the event',
674 `desc` text COMMENT 'event description',
675 `location` text COMMENT 'event location',
676 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
677 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
678 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
679 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
680 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
681 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
682 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
684 INDEX `uid_start` (`uid`,`start`),
686 INDEX `uri-id` (`uri-id`),
687 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
688 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
689 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
690 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
695 CREATE TABLE IF NOT EXISTS `fetch-entry` (
696 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
697 `url` varbinary(383) COMMENT 'url that awaiting to be fetched',
698 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of the fetch request',
699 `wid` int unsigned COMMENT 'Workerqueue id',
701 UNIQUE INDEX `url` (`url`),
702 INDEX `created` (`created`),
704 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
705 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
710 CREATE TABLE IF NOT EXISTS `fsuggest` (
711 `id` int unsigned NOT NULL auto_increment COMMENT '',
712 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
713 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
714 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
715 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
716 `request` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
717 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
718 `note` text COMMENT '',
719 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
723 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
724 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
725 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
730 CREATE TABLE IF NOT EXISTS `group` (
731 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
732 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
733 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
734 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
735 `cid` int unsigned COMMENT 'Contact id of forum. When this field is filled then the members are synced automatically.',
736 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
740 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
741 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
742 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
745 -- TABLE group_member
747 CREATE TABLE IF NOT EXISTS `group_member` (
748 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
749 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
750 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
752 INDEX `contactid` (`contact-id`),
753 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
754 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
755 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
756 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
761 CREATE TABLE IF NOT EXISTS `gserver-tag` (
762 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
763 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
764 PRIMARY KEY(`gserver-id`,`tag`),
766 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
767 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
772 CREATE TABLE IF NOT EXISTS `hook` (
773 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
774 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
775 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
776 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
777 `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',
779 INDEX `priority` (`priority`),
780 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
781 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
786 CREATE TABLE IF NOT EXISTS `inbox-entry` (
787 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
788 `activity-id` varbinary(383) COMMENT 'id of the incoming activity',
789 `object-id` varbinary(383) COMMENT '',
790 `in-reply-to-id` varbinary(383) COMMENT '',
791 `conversation` varbinary(383) COMMENT '',
792 `type` varchar(64) COMMENT 'Type of the activity',
793 `object-type` varchar(64) COMMENT 'Type of the object activity',
794 `object-object-type` varchar(64) COMMENT 'Type of the object\'s object activity',
795 `received` datetime COMMENT 'Receiving date',
796 `activity` mediumtext COMMENT 'The JSON activity',
797 `signer` varchar(255) COMMENT '',
798 `push` boolean COMMENT 'Is the entry pushed or have pulled it?',
799 `trust` boolean COMMENT 'Do we trust this entry?',
800 `wid` int unsigned COMMENT 'Workerqueue id',
802 UNIQUE INDEX `activity-id` (`activity-id`),
803 INDEX `object-id` (`object-id`),
804 INDEX `received` (`received`),
806 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
807 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Incoming activity';
810 -- TABLE inbox-entry-receiver
812 CREATE TABLE IF NOT EXISTS `inbox-entry-receiver` (
813 `queue-id` int unsigned NOT NULL COMMENT '',
814 `uid` mediumint unsigned NOT NULL COMMENT 'User id',
815 PRIMARY KEY(`queue-id`,`uid`),
817 FOREIGN KEY (`queue-id`) REFERENCES `inbox-entry` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
818 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
819 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Receiver for the incoming activity';
822 -- TABLE inbox-status
824 CREATE TABLE IF NOT EXISTS `inbox-status` (
825 `url` varbinary(383) NOT NULL COMMENT 'URL of the inbox',
826 `uri-id` int unsigned COMMENT 'Item-uri id of inbox url',
827 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
828 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
829 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
830 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
831 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
832 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
834 INDEX `uri-id` (`uri-id`),
835 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
836 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
841 CREATE TABLE IF NOT EXISTS `intro` (
842 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
843 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
844 `fid` int unsigned COMMENT 'deprecated',
845 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
846 `suggest-cid` int unsigned COMMENT 'Suggested contact',
847 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
848 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
849 `note` text COMMENT '',
850 `hash` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
851 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
852 `blocked` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
853 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
855 INDEX `contact-id` (`contact-id`),
856 INDEX `suggest-cid` (`suggest-cid`),
858 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
859 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
860 FOREIGN KEY (`suggest-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
861 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
866 CREATE TABLE IF NOT EXISTS `key-value` (
867 `k` varbinary(50) NOT NULL COMMENT '',
868 `v` mediumtext COMMENT '',
869 `updated_at` int unsigned NOT NULL COMMENT 'timestamp of the last update',
871 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='A key value storage';
876 CREATE TABLE IF NOT EXISTS `locks` (
877 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
878 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
879 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
880 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
881 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
883 INDEX `name_expires` (`name`,`expires`)
884 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
889 CREATE TABLE IF NOT EXISTS `mail` (
890 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
891 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
892 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
893 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
894 `from-photo` varbinary(383) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
895 `from-url` varbinary(383) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
896 `contact-id` varbinary(255) COMMENT 'contact.id',
897 `author-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the author of the mail',
898 `convid` int unsigned COMMENT 'conv.id',
899 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
900 `body` mediumtext COMMENT '',
901 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
902 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
903 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
904 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
905 `uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
906 `uri-id` int unsigned COMMENT 'Item-uri id of the related mail',
907 `parent-uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
908 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related mail',
909 `thr-parent` varbinary(383) COMMENT '',
910 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
911 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
913 INDEX `uid_seen` (`uid`,`seen`),
914 INDEX `convid` (`convid`),
915 INDEX `uri` (`uri`(64)),
916 INDEX `parent-uri` (`parent-uri`(64)),
917 INDEX `contactid` (`contact-id`(32)),
918 INDEX `author-id` (`author-id`),
919 INDEX `uri-id` (`uri-id`),
920 INDEX `parent-uri-id` (`parent-uri-id`),
921 INDEX `thr-parent-id` (`thr-parent-id`),
922 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
923 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
924 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
925 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
926 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
927 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
932 CREATE TABLE IF NOT EXISTS `mailacct` (
933 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
934 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
935 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
936 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
937 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
938 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
939 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
940 `pass` text COMMENT '',
941 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
942 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
943 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
944 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
945 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
948 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
949 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
954 CREATE TABLE IF NOT EXISTS `manage` (
955 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
956 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
957 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
959 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
961 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
962 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
963 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
966 -- TABLE notification
968 CREATE TABLE IF NOT EXISTS `notification` (
969 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
970 `uid` mediumint unsigned COMMENT 'Owner User id',
971 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
972 `type` smallint unsigned COMMENT '',
973 `actor-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the actor that caused the notification',
974 `target-uri-id` int unsigned COMMENT 'Item-uri id of the related post',
975 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
976 `created` datetime COMMENT '',
977 `seen` boolean DEFAULT '0' COMMENT 'Seen on the desktop',
978 `dismissed` boolean DEFAULT '0' COMMENT 'Dismissed via the API',
980 UNIQUE INDEX `uid_vid_type_actor-id_target-uri-id` (`uid`,`vid`,`type`,`actor-id`,`target-uri-id`),
982 INDEX `actor-id` (`actor-id`),
983 INDEX `target-uri-id` (`target-uri-id`),
984 INDEX `parent-uri-id` (`parent-uri-id`),
985 INDEX `seen_uid` (`seen`,`uid`),
986 INDEX `uid_type_parent-uri-id_actor-id` (`uid`,`type`,`parent-uri-id`,`actor-id`),
987 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
988 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
989 FOREIGN KEY (`actor-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
990 FOREIGN KEY (`target-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
991 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
992 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
997 CREATE TABLE IF NOT EXISTS `notify` (
998 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
999 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1000 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1001 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1002 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1003 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1004 `msg` mediumtext COMMENT '',
1005 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1006 `link` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1007 `iid` int unsigned COMMENT '',
1008 `parent` int unsigned COMMENT '',
1009 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
1010 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
1011 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
1012 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
1013 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
1014 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
1015 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
1017 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
1018 INDEX `uid_date` (`uid`,`date`),
1019 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
1020 INDEX `uri-id` (`uri-id`),
1021 INDEX `parent-uri-id` (`parent-uri-id`),
1022 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1023 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1024 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1025 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='[Deprecated] User notifications';
1028 -- TABLE notify-threads
1030 CREATE TABLE IF NOT EXISTS `notify-threads` (
1031 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1032 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1033 `master-parent-item` int unsigned COMMENT 'Deprecated',
1034 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
1035 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1036 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1038 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
1039 INDEX `receiver-uid` (`receiver-uid`),
1040 INDEX `notify-id` (`notify-id`),
1041 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1042 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1043 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1044 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1049 CREATE TABLE IF NOT EXISTS `oembed` (
1050 `url` varbinary(383) NOT NULL COMMENT 'page url',
1051 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
1052 `content` mediumtext COMMENT 'OEmbed data of the page',
1053 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1054 PRIMARY KEY(`url`,`maxwidth`),
1055 INDEX `created` (`created`)
1056 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
1059 -- TABLE openwebauth-token
1061 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
1062 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1063 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
1064 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
1065 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
1066 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1067 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1069 INDEX `uid` (`uid`),
1070 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1071 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
1076 CREATE TABLE IF NOT EXISTS `parsed_url` (
1077 `url_hash` binary(64) NOT NULL COMMENT 'page url hash',
1078 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
1079 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
1080 `url` text NOT NULL COMMENT 'page url',
1081 `content` mediumtext COMMENT 'page data',
1082 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1083 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration',
1084 PRIMARY KEY(`url_hash`,`guessing`,`oembed`),
1085 INDEX `created` (`created`),
1086 INDEX `expires` (`expires`)
1087 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
1092 CREATE TABLE IF NOT EXISTS `pconfig` (
1093 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
1094 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1095 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
1096 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
1097 `v` mediumtext COMMENT 'Value',
1099 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
1100 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1101 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
1106 CREATE TABLE IF NOT EXISTS `photo` (
1107 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1108 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1109 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1110 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
1111 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
1112 `hash` char(32) COMMENT 'hash value of the photo',
1113 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
1114 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
1115 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1116 `desc` text COMMENT '',
1117 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
1118 `photo-type` tinyint unsigned COMMENT 'User avatar, user banner, contact avatar, contact banner or default',
1119 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1120 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
1121 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1122 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1123 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1124 `blurhash` varbinary(255) COMMENT 'BlurHash representation of the photo',
1125 `data` mediumblob NOT NULL COMMENT '',
1126 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1127 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
1128 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
1129 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
1130 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
1131 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
1132 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
1133 `backend-class` tinytext COMMENT 'Storage backend class',
1134 `backend-ref` text COMMENT 'Storage backend data reference',
1135 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1137 INDEX `contactid` (`contact-id`),
1138 INDEX `uid_contactid` (`uid`,`contact-id`),
1139 INDEX `uid_profile` (`uid`,`profile`),
1140 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
1141 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
1142 INDEX `resource-id` (`resource-id`),
1143 INDEX `uid_photo-type` (`uid`,`photo-type`),
1144 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1145 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1146 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1151 CREATE TABLE IF NOT EXISTS `post` (
1152 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1153 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1154 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1155 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1156 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1157 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1158 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1159 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1160 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1161 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1162 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1163 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1164 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1165 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1166 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1167 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1168 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1169 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1170 PRIMARY KEY(`uri-id`),
1171 INDEX `parent-uri-id` (`parent-uri-id`),
1172 INDEX `thr-parent-id` (`thr-parent-id`),
1173 INDEX `external-id` (`external-id`),
1174 INDEX `owner-id` (`owner-id`),
1175 INDEX `author-id` (`author-id`),
1176 INDEX `causer-id` (`causer-id`),
1177 INDEX `vid` (`vid`),
1178 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1179 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1180 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1181 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1182 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1183 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1184 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1185 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1186 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
1189 -- TABLE post-activity
1191 CREATE TABLE IF NOT EXISTS `post-activity` (
1192 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1193 `activity` mediumtext COMMENT 'Original activity',
1194 `received` datetime COMMENT '',
1195 PRIMARY KEY(`uri-id`),
1196 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1197 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Original remote activity';
1200 -- TABLE post-category
1202 CREATE TABLE IF NOT EXISTS `post-category` (
1203 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1204 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1205 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1206 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1207 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1208 INDEX `tid` (`tid`),
1209 INDEX `uid_uri-id` (`uid`,`uri-id`),
1210 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1211 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1212 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1213 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1216 -- TABLE post-collection
1218 CREATE TABLE IF NOT EXISTS `post-collection` (
1219 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1220 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0 - Featured',
1221 `author-id` int unsigned COMMENT 'Author of the featured post',
1222 PRIMARY KEY(`uri-id`,`type`),
1223 INDEX `type` (`type`),
1224 INDEX `author-id` (`author-id`),
1225 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1226 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1227 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Collection of posts';
1230 -- TABLE post-content
1232 CREATE TABLE IF NOT EXISTS `post-content` (
1233 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1234 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1235 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1236 `body` mediumtext COMMENT 'item body content',
1237 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1238 `quote-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the quoted uri',
1239 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1240 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1241 `language` text COMMENT 'Language information about this post',
1242 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1243 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1244 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1245 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1246 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1247 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1248 `target` text COMMENT 'JSON encoded target structure if used',
1249 `resource-id` varchar(32) NOT NULL DEFAULT '' COMMENT 'Used to link other tables to items, it identifies the linked resource (e.g. photo) and if set must also set resource_type',
1250 `plink` varbinary(383) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1251 PRIMARY KEY(`uri-id`),
1252 INDEX `plink` (`plink`(191)),
1253 INDEX `resource-id` (`resource-id`),
1254 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
1255 INDEX `quote-uri-id` (`quote-uri-id`),
1256 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1257 FOREIGN KEY (`quote-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1258 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1261 -- TABLE post-delivery
1263 CREATE TABLE IF NOT EXISTS `post-delivery` (
1264 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1265 `inbox-id` int unsigned NOT NULL COMMENT 'Item-uri id of inbox url',
1266 `uid` mediumint unsigned COMMENT 'Delivering user',
1267 `created` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
1268 `command` varbinary(32) COMMENT '',
1269 `failed` tinyint DEFAULT 0 COMMENT 'Number of times the delivery has failed',
1270 `receivers` mediumtext COMMENT 'JSON encoded array with the receiving contacts',
1271 PRIMARY KEY(`uri-id`,`inbox-id`),
1272 INDEX `inbox-id_created` (`inbox-id`,`created`),
1273 INDEX `uid` (`uid`),
1274 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1275 FOREIGN KEY (`inbox-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1276 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1277 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for posts for the batch processing';
1280 -- TABLE post-delivery-data
1282 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1283 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1284 `postopts` text COMMENT 'External post connectors add their network name to this comma-separated string to identify that they should be delivered to these networks during delivery',
1285 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1286 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1287 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1288 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1289 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1290 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1291 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1292 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1293 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1294 PRIMARY KEY(`uri-id`),
1295 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1296 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1299 -- TABLE post-history
1301 CREATE TABLE IF NOT EXISTS `post-history` (
1302 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1303 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of edit',
1304 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1305 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1306 `body` mediumtext COMMENT 'item body content',
1307 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1308 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1309 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1310 `language` text COMMENT 'Language information about this post',
1311 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1312 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1313 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1314 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1315 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1316 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1317 `target` text COMMENT 'JSON encoded target structure if used',
1318 `resource-id` varchar(32) NOT NULL DEFAULT '' COMMENT 'Used to link other tables to items, it identifies the linked resource (e.g. photo) and if set must also set resource_type',
1319 `plink` varbinary(383) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1320 PRIMARY KEY(`uri-id`,`edited`),
1321 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1322 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post history';
1327 CREATE TABLE IF NOT EXISTS `post-link` (
1328 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1329 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1330 `url` varbinary(511) NOT NULL COMMENT 'External URL',
1331 `mimetype` varchar(60) COMMENT '',
1332 `height` smallint unsigned COMMENT 'Height of the media',
1333 `width` smallint unsigned COMMENT 'Width of the media',
1334 `blurhash` varbinary(255) COMMENT 'BlurHash representation of the link',
1336 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1337 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1338 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post related external links';
1343 CREATE TABLE IF NOT EXISTS `post-media` (
1344 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1345 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1346 `url` varbinary(1024) NOT NULL COMMENT 'Media URL',
1347 `media-uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the activities uri-id',
1348 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1349 `mimetype` varchar(60) COMMENT '',
1350 `height` smallint unsigned COMMENT 'Height of the media',
1351 `width` smallint unsigned COMMENT 'Width of the media',
1352 `size` bigint unsigned COMMENT 'Media size',
1353 `blurhash` varbinary(255) COMMENT 'BlurHash representation of the image',
1354 `preview` varbinary(512) COMMENT 'Preview URL',
1355 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1356 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1357 `description` text COMMENT '',
1358 `name` varchar(255) COMMENT 'Name of the media',
1359 `author-url` varbinary(383) COMMENT 'URL of the author of the media',
1360 `author-name` varchar(255) COMMENT 'Name of the author of the media',
1361 `author-image` varbinary(383) COMMENT 'Image of the author of the media',
1362 `publisher-url` varbinary(383) COMMENT 'URL of the publisher of the media',
1363 `publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
1364 `publisher-image` varbinary(383) COMMENT 'Image of the publisher of the media',
1366 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`(512)),
1367 INDEX `uri-id-id` (`uri-id`,`id`),
1368 INDEX `media-uri-id` (`media-uri-id`),
1369 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1370 FOREIGN KEY (`media-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1371 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1374 -- TABLE post-question
1376 CREATE TABLE IF NOT EXISTS `post-question` (
1377 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1378 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1379 `multiple` boolean NOT NULL DEFAULT '0' COMMENT 'Multiple choice',
1380 `voters` int unsigned COMMENT 'Number of voters for this question',
1381 `end-time` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Question end time',
1383 UNIQUE INDEX `uri-id` (`uri-id`),
1384 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1385 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question';
1388 -- TABLE post-question-option
1390 CREATE TABLE IF NOT EXISTS `post-question-option` (
1391 `id` int unsigned NOT NULL COMMENT 'Id of the question',
1392 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1393 `name` varchar(255) COMMENT 'Name of the option',
1394 `replies` int unsigned COMMENT 'Number of replies for this question option',
1395 PRIMARY KEY(`uri-id`,`id`),
1396 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1397 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question option';
1402 CREATE TABLE IF NOT EXISTS `post-tag` (
1403 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1404 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1405 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1406 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1407 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1408 INDEX `tid` (`tid`),
1409 INDEX `cid` (`cid`),
1410 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1411 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1412 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1413 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1416 -- TABLE post-thread
1418 CREATE TABLE IF NOT EXISTS `post-thread` (
1419 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1420 `conversation-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the conversation uri',
1421 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1422 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1423 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1424 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1425 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1426 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1427 `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date that something in the conversation changed, indicating clients should fetch the conversation again',
1428 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1429 PRIMARY KEY(`uri-id`),
1430 INDEX `conversation-id` (`conversation-id`),
1431 INDEX `owner-id` (`owner-id`),
1432 INDEX `author-id` (`author-id`),
1433 INDEX `causer-id` (`causer-id`),
1434 INDEX `received` (`received`),
1435 INDEX `commented` (`commented`),
1436 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1437 FOREIGN KEY (`conversation-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1438 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1439 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1440 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1441 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1446 CREATE TABLE IF NOT EXISTS `post-user` (
1447 `id` int unsigned NOT NULL auto_increment,
1448 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1449 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1450 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1451 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1452 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1453 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1454 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1455 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1456 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1457 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1458 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1459 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1460 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1461 `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
1462 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1463 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1464 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1465 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1466 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1467 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1468 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1469 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1470 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1471 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1472 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1473 `notification-type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1474 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1475 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1476 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1478 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1479 INDEX `uri-id` (`uri-id`),
1480 INDEX `parent-uri-id` (`parent-uri-id`),
1481 INDEX `thr-parent-id` (`thr-parent-id`),
1482 INDEX `external-id` (`external-id`),
1483 INDEX `owner-id` (`owner-id`),
1484 INDEX `author-id` (`author-id`),
1485 INDEX `causer-id` (`causer-id`),
1486 INDEX `vid` (`vid`),
1487 INDEX `contact-id` (`contact-id`),
1488 INDEX `event-id` (`event-id`),
1489 INDEX `psid` (`psid`),
1490 INDEX `author-id_uid` (`author-id`,`uid`),
1491 INDEX `author-id_received` (`author-id`,`received`),
1492 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1493 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1494 INDEX `uid_contactid` (`uid`,`contact-id`),
1495 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1496 INDEX `uid_unseen` (`uid`,`unseen`),
1497 INDEX `uid_hidden_uri-id` (`uid`,`hidden`,`uri-id`),
1498 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1499 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1500 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1501 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1502 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1503 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1504 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1505 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1506 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1507 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1508 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1509 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1510 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1513 -- TABLE post-thread-user
1515 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1516 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1517 `conversation-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the conversation uri',
1518 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1519 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1520 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1521 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1522 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1523 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1524 `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date that something in the conversation changed, indicating clients should fetch the conversation again',
1525 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1526 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1527 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
1528 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1529 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1530 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1531 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1532 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1533 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Deprecated',
1534 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1535 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1536 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1537 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1538 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1539 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1540 PRIMARY KEY(`uid`,`uri-id`),
1541 INDEX `uri-id` (`uri-id`),
1542 INDEX `conversation-id` (`conversation-id`),
1543 INDEX `owner-id` (`owner-id`),
1544 INDEX `author-id` (`author-id`),
1545 INDEX `causer-id` (`causer-id`),
1546 INDEX `uid` (`uid`),
1547 INDEX `contact-id` (`contact-id`),
1548 INDEX `psid` (`psid`),
1549 INDEX `post-user-id` (`post-user-id`),
1550 INDEX `commented` (`commented`),
1551 INDEX `uid_received` (`uid`,`received`),
1552 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1553 INDEX `uid_commented` (`uid`,`commented`),
1554 INDEX `uid_starred` (`uid`,`starred`),
1555 INDEX `uid_mention` (`uid`,`mention`),
1556 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1557 FOREIGN KEY (`conversation-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1558 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1559 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1560 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1561 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1562 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1563 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1564 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1565 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1568 -- TABLE post-user-notification
1570 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1571 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1572 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1573 `notification-type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1574 PRIMARY KEY(`uid`,`uri-id`),
1575 INDEX `uri-id` (`uri-id`),
1576 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1577 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1578 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1583 CREATE TABLE IF NOT EXISTS `process` (
1584 `pid` int unsigned NOT NULL COMMENT 'The ID of the process',
1585 `hostname` varchar(32) NOT NULL COMMENT 'The name of the host the process is ran on',
1586 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1587 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1588 PRIMARY KEY(`pid`,`hostname`),
1589 INDEX `command` (`command`)
1590 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1595 CREATE TABLE IF NOT EXISTS `profile` (
1596 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1597 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1598 `profile-name` varchar(255) COMMENT 'Deprecated',
1599 `is-default` boolean COMMENT 'Deprecated',
1600 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1601 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1602 `pdesc` varchar(255) COMMENT 'Deprecated',
1603 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1604 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1605 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1606 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1607 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1608 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1609 `hometown` varchar(255) COMMENT 'Deprecated',
1610 `gender` varchar(32) COMMENT 'Deprecated',
1611 `marital` varchar(255) COMMENT 'Deprecated',
1612 `with` text COMMENT 'Deprecated',
1613 `howlong` datetime COMMENT 'Deprecated',
1614 `sexual` varchar(255) COMMENT 'Deprecated',
1615 `politic` varchar(255) COMMENT 'Deprecated',
1616 `religion` varchar(255) COMMENT 'Deprecated',
1617 `pub_keywords` text COMMENT '',
1618 `prv_keywords` text COMMENT '',
1619 `likes` text COMMENT 'Deprecated',
1620 `dislikes` text COMMENT 'Deprecated',
1621 `about` text COMMENT 'Profile description',
1622 `summary` varchar(255) COMMENT 'Deprecated',
1623 `music` text COMMENT 'Deprecated',
1624 `book` text COMMENT 'Deprecated',
1625 `tv` text COMMENT 'Deprecated',
1626 `film` text COMMENT 'Deprecated',
1627 `interest` text COMMENT 'Deprecated',
1628 `romance` text COMMENT 'Deprecated',
1629 `work` text COMMENT 'Deprecated',
1630 `education` text COMMENT 'Deprecated',
1631 `contact` text COMMENT 'Deprecated',
1632 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1633 `homepage_verified` boolean NOT NULL DEFAULT '0' COMMENT 'was the homepage verified by a rel-me link back to the profile',
1634 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
1635 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
1636 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1637 `thumb` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1638 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1639 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1641 INDEX `uid_is-default` (`uid`,`is-default`),
1642 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1643 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1644 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1647 -- TABLE profile_field
1649 CREATE TABLE IF NOT EXISTS `profile_field` (
1650 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1651 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1652 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1653 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1654 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1655 `value` text COMMENT 'Value of the field',
1656 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1657 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1659 INDEX `uid` (`uid`),
1660 INDEX `order` (`order`),
1661 INDEX `psid` (`psid`),
1662 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1663 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1664 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1667 -- TABLE push_subscriber
1669 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1670 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1671 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1672 `callback_url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1673 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1674 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1675 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1676 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1677 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1678 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1679 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1681 INDEX `next_try` (`next_try`),
1682 INDEX `uid` (`uid`),
1683 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1684 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1689 CREATE TABLE IF NOT EXISTS `register` (
1690 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1691 `hash` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1692 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1693 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1694 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1695 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1696 `note` text COMMENT '',
1698 INDEX `uid` (`uid`),
1699 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1700 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1705 CREATE TABLE IF NOT EXISTS `report` (
1706 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1707 `uid` mediumint unsigned COMMENT 'Reporting user',
1708 `reporter-id` int unsigned COMMENT 'Reporting contact',
1709 `cid` int unsigned NOT NULL COMMENT 'Reported contact',
1710 `comment` text COMMENT 'Report',
1711 `category` varchar(20) COMMENT 'Category of the report (spam, violation, other)',
1712 `rules` text COMMENT 'Violated rules',
1713 `forward` boolean COMMENT 'Forward the report to the remote server',
1714 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1715 `status` tinyint unsigned COMMENT 'Status of the report',
1717 INDEX `uid` (`uid`),
1718 INDEX `cid` (`cid`),
1719 INDEX `reporter-id` (`reporter-id`),
1720 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1721 FOREIGN KEY (`reporter-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1722 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1723 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1726 -- TABLE report-post
1728 CREATE TABLE IF NOT EXISTS `report-post` (
1729 `rid` int unsigned NOT NULL COMMENT 'Report id',
1730 `uri-id` int unsigned NOT NULL COMMENT 'Uri-id of the reported post',
1731 `status` tinyint unsigned COMMENT 'Status of the reported post',
1732 PRIMARY KEY(`rid`,`uri-id`),
1733 INDEX `uri-id` (`uri-id`),
1734 FOREIGN KEY (`rid`) REFERENCES `report` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1735 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1736 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1741 CREATE TABLE IF NOT EXISTS `search` (
1742 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1743 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1744 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1746 INDEX `uid_term` (`uid`,`term`(64)),
1747 INDEX `term` (`term`(64)),
1748 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1749 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1754 CREATE TABLE IF NOT EXISTS `session` (
1755 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1756 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1757 `data` text COMMENT '',
1758 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1760 INDEX `sid` (`sid`(64)),
1761 INDEX `expire` (`expire`)
1762 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1767 CREATE TABLE IF NOT EXISTS `storage` (
1768 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1769 `data` longblob NOT NULL COMMENT 'file data',
1771 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1774 -- TABLE subscription
1776 CREATE TABLE IF NOT EXISTS `subscription` (
1777 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1778 `application-id` int unsigned NOT NULL COMMENT '',
1779 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
1780 `endpoint` varchar(511) COMMENT 'Endpoint URL',
1781 `pubkey` varchar(127) COMMENT 'User agent public key',
1782 `secret` varchar(32) COMMENT 'Auth secret',
1783 `follow` boolean COMMENT '',
1784 `favourite` boolean COMMENT '',
1785 `reblog` boolean COMMENT '',
1786 `mention` boolean COMMENT '',
1787 `poll` boolean COMMENT '',
1788 `follow_request` boolean COMMENT '',
1789 `status` boolean COMMENT '',
1791 UNIQUE INDEX `application-id_uid` (`application-id`,`uid`),
1792 INDEX `uid_application-id` (`uid`,`application-id`),
1793 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1794 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1795 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Push Subscription for the API';
1800 CREATE TABLE IF NOT EXISTS `userd` (
1801 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1802 `username` varchar(255) NOT NULL COMMENT '',
1804 INDEX `username` (`username`(32))
1805 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1808 -- TABLE user-contact
1810 CREATE TABLE IF NOT EXISTS `user-contact` (
1811 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1812 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1813 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
1814 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1815 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1816 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1817 `hidden` boolean COMMENT 'This contact is hidden from the others',
1818 `is-blocked` boolean COMMENT 'User is blocked by this contact',
1819 `pending` boolean COMMENT '',
1820 `rel` tinyint unsigned COMMENT 'The kind of the relation between the user and the contact',
1821 `info` mediumtext COMMENT '',
1822 `notify_new_posts` boolean COMMENT '',
1823 `remote_self` boolean COMMENT '',
1824 `fetch_further_information` tinyint unsigned COMMENT '',
1825 `ffi_keyword_denylist` text COMMENT '',
1826 `subhub` boolean COMMENT '',
1827 `hub-verify` varbinary(383) COMMENT '',
1828 `protocol` char(4) COMMENT 'Protocol of the contact',
1829 `rating` tinyint COMMENT 'Automatically detected feed poll frequency',
1830 `priority` tinyint unsigned COMMENT 'Feed poll priority',
1831 PRIMARY KEY(`uid`,`cid`),
1832 INDEX `cid` (`cid`),
1833 UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
1834 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1835 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1836 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1837 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1840 -- TABLE arrived-activity
1842 CREATE TABLE IF NOT EXISTS `arrived-activity` (
1843 `object-id` varbinary(383) NOT NULL COMMENT 'object id of the incoming activity',
1844 `received` datetime COMMENT 'Receiving date',
1845 PRIMARY KEY(`object-id`)
1846 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Id of arrived activities';
1849 -- TABLE fetched-activity
1851 CREATE TABLE IF NOT EXISTS `fetched-activity` (
1852 `object-id` varbinary(383) NOT NULL COMMENT 'object id of fetched activity',
1853 `received` datetime COMMENT 'Receiving date',
1854 PRIMARY KEY(`object-id`)
1855 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Id of fetched activities';
1860 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1861 `key` int NOT NULL COMMENT '',
1862 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1864 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1867 -- VIEW application-view
1869 DROP VIEW IF EXISTS `application-view`;
1870 CREATE VIEW `application-view` AS SELECT
1871 `application`.`id` AS `id`,
1872 `application-token`.`uid` AS `uid`,
1873 `application`.`name` AS `name`,
1874 `application`.`redirect_uri` AS `redirect_uri`,
1875 `application`.`website` AS `website`,
1876 `application`.`client_id` AS `client_id`,
1877 `application`.`client_secret` AS `client_secret`,
1878 `application-token`.`code` AS `code`,
1879 `application-token`.`access_token` AS `access_token`,
1880 `application-token`.`created_at` AS `created_at`,
1881 `application-token`.`scopes` AS `scopes`,
1882 `application-token`.`read` AS `read`,
1883 `application-token`.`write` AS `write`,
1884 `application-token`.`follow` AS `follow`,
1885 `application-token`.`push` AS `push`
1886 FROM `application-token`
1887 INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`;
1890 -- VIEW post-user-view
1892 DROP VIEW IF EXISTS `post-user-view`;
1893 CREATE VIEW `post-user-view` AS SELECT
1894 `post-user`.`id` AS `id`,
1895 `post-user`.`id` AS `post-user-id`,
1896 `post-user`.`uid` AS `uid`,
1897 `parent-post`.`id` AS `parent`,
1898 `item-uri`.`uri` AS `uri`,
1899 `post-user`.`uri-id` AS `uri-id`,
1900 `parent-item-uri`.`uri` AS `parent-uri`,
1901 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1902 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1903 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1904 `conversation-item-uri`.`uri` AS `conversation`,
1905 `post-thread-user`.`conversation-id` AS `conversation-id`,
1906 `quote-item-uri`.`uri` AS `quote-uri`,
1907 `post-content`.`quote-uri-id` AS `quote-uri-id`,
1908 `item-uri`.`guid` AS `guid`,
1909 `post-user`.`wall` AS `wall`,
1910 `post-user`.`gravity` AS `gravity`,
1911 `external-item-uri`.`uri` AS `extid`,
1912 `post-user`.`external-id` AS `external-id`,
1913 `post-user`.`created` AS `created`,
1914 `post-user`.`edited` AS `edited`,
1915 `post-thread-user`.`commented` AS `commented`,
1916 `post-user`.`received` AS `received`,
1917 `post-thread-user`.`changed` AS `changed`,
1918 `post-user`.`post-type` AS `post-type`,
1919 `post-user`.`post-reason` AS `post-reason`,
1920 `post-user`.`private` AS `private`,
1921 `post-thread-user`.`pubmail` AS `pubmail`,
1922 `post-user`.`visible` AS `visible`,
1923 `post-thread-user`.`starred` AS `starred`,
1924 `post-user`.`unseen` AS `unseen`,
1925 `post-user`.`deleted` AS `deleted`,
1926 `post-user`.`origin` AS `origin`,
1927 `post-thread-user`.`origin` AS `parent-origin`,
1928 `post-thread-user`.`mention` AS `mention`,
1929 `post-user`.`global` AS `global`,
1930 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-user`.`uri-id`) AS `featured`,
1931 `post-user`.`network` AS `network`,
1932 `post-user`.`protocol` AS `protocol`,
1933 `post-user`.`vid` AS `vid`,
1934 `post-user`.`psid` AS `psid`,
1935 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1936 `post-content`.`title` AS `title`,
1937 `post-content`.`content-warning` AS `content-warning`,
1938 `post-content`.`raw-body` AS `raw-body`,
1939 IFNULL (`post-content`.`body`, '') AS `body`,
1940 `post-content`.`rendered-hash` AS `rendered-hash`,
1941 `post-content`.`rendered-html` AS `rendered-html`,
1942 `post-content`.`language` AS `language`,
1943 `post-content`.`plink` AS `plink`,
1944 `post-content`.`location` AS `location`,
1945 `post-content`.`coord` AS `coord`,
1946 `post-content`.`app` AS `app`,
1947 `post-content`.`object-type` AS `object-type`,
1948 `post-content`.`object` AS `object`,
1949 `post-content`.`target-type` AS `target-type`,
1950 `post-content`.`target` AS `target`,
1951 `post-content`.`resource-id` AS `resource-id`,
1952 `post-user`.`contact-id` AS `contact-id`,
1953 `contact`.`uri-id` AS `contact-uri-id`,
1954 `contact`.`url` AS `contact-link`,
1955 `contact`.`addr` AS `contact-addr`,
1956 `contact`.`name` AS `contact-name`,
1957 `contact`.`nick` AS `contact-nick`,
1958 `contact`.`thumb` AS `contact-avatar`,
1959 `contact`.`network` AS `contact-network`,
1960 `contact`.`blocked` AS `contact-blocked`,
1961 `contact`.`hidden` AS `contact-hidden`,
1962 `contact`.`readonly` AS `contact-readonly`,
1963 `contact`.`archive` AS `contact-archive`,
1964 `contact`.`pending` AS `contact-pending`,
1965 `contact`.`rel` AS `contact-rel`,
1966 `contact`.`uid` AS `contact-uid`,
1967 `contact`.`contact-type` AS `contact-contact-type`,
1968 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1969 `contact`.`self` AS `self`,
1970 `contact`.`id` AS `cid`,
1971 `contact`.`alias` AS `alias`,
1972 `contact`.`photo` AS `photo`,
1973 `contact`.`name-date` AS `name-date`,
1974 `contact`.`uri-date` AS `uri-date`,
1975 `contact`.`avatar-date` AS `avatar-date`,
1976 `contact`.`thumb` AS `thumb`,
1977 `post-user`.`author-id` AS `author-id`,
1978 `author`.`uri-id` AS `author-uri-id`,
1979 `author`.`url` AS `author-link`,
1980 `author`.`addr` AS `author-addr`,
1981 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1982 `author`.`nick` AS `author-nick`,
1983 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1984 `author`.`network` AS `author-network`,
1985 `author`.`blocked` AS `author-blocked`,
1986 `author`.`hidden` AS `author-hidden`,
1987 `author`.`updated` AS `author-updated`,
1988 `author`.`gsid` AS `author-gsid`,
1989 `post-user`.`owner-id` AS `owner-id`,
1990 `owner`.`uri-id` AS `owner-uri-id`,
1991 `owner`.`url` AS `owner-link`,
1992 `owner`.`addr` AS `owner-addr`,
1993 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1994 `owner`.`nick` AS `owner-nick`,
1995 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1996 `owner`.`network` AS `owner-network`,
1997 `owner`.`blocked` AS `owner-blocked`,
1998 `owner`.`hidden` AS `owner-hidden`,
1999 `owner`.`updated` AS `owner-updated`,
2000 `owner`.`contact-type` AS `owner-contact-type`,
2001 `post-user`.`causer-id` AS `causer-id`,
2002 `causer`.`uri-id` AS `causer-uri-id`,
2003 `causer`.`url` AS `causer-link`,
2004 `causer`.`addr` AS `causer-addr`,
2005 `causer`.`name` AS `causer-name`,
2006 `causer`.`nick` AS `causer-nick`,
2007 `causer`.`thumb` AS `causer-avatar`,
2008 `causer`.`network` AS `causer-network`,
2009 `causer`.`blocked` AS `causer-blocked`,
2010 `causer`.`hidden` AS `causer-hidden`,
2011 `causer`.`contact-type` AS `causer-contact-type`,
2012 `post-delivery-data`.`postopts` AS `postopts`,
2013 `post-delivery-data`.`inform` AS `inform`,
2014 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
2015 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
2016 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
2017 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
2018 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
2019 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
2020 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
2021 `post-user`.`event-id` AS `event-id`,
2022 `event`.`created` AS `event-created`,
2023 `event`.`edited` AS `event-edited`,
2024 `event`.`start` AS `event-start`,
2025 `event`.`finish` AS `event-finish`,
2026 `event`.`summary` AS `event-summary`,
2027 `event`.`desc` AS `event-desc`,
2028 `event`.`location` AS `event-location`,
2029 `event`.`type` AS `event-type`,
2030 `event`.`nofinish` AS `event-nofinish`,
2031 `event`.`ignore` AS `event-ignore`,
2032 `post-question`.`id` AS `question-id`,
2033 `post-question`.`multiple` AS `question-multiple`,
2034 `post-question`.`voters` AS `question-voters`,
2035 `post-question`.`end-time` AS `question-end-time`,
2036 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`,
2037 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-user`.`uri-id`) AS `has-media`,
2038 `diaspora-interaction`.`interaction` AS `signed_text`,
2039 `parent-item-uri`.`guid` AS `parent-guid`,
2040 `parent-post`.`network` AS `parent-network`,
2041 `parent-post`.`author-id` AS `parent-author-id`,
2042 `parent-post-author`.`url` AS `parent-author-link`,
2043 `parent-post-author`.`name` AS `parent-author-name`,
2044 `parent-post-author`.`nick` AS `parent-author-nick`,
2045 `parent-post-author`.`network` AS `parent-author-network`
2047 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2048 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
2049 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
2050 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
2051 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
2052 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
2053 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
2054 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
2055 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
2056 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
2057 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
2058 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
2059 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
2060 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
2061 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2062 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
2063 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-user`.`uri-id`
2064 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
2065 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2066 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2069 -- VIEW post-thread-user-view
2071 DROP VIEW IF EXISTS `post-thread-user-view`;
2072 CREATE VIEW `post-thread-user-view` AS SELECT
2073 `post-user`.`id` AS `id`,
2074 `post-user`.`id` AS `post-user-id`,
2075 `post-thread-user`.`uid` AS `uid`,
2076 `parent-post`.`id` AS `parent`,
2077 `item-uri`.`uri` AS `uri`,
2078 `post-thread-user`.`uri-id` AS `uri-id`,
2079 `parent-item-uri`.`uri` AS `parent-uri`,
2080 `post-user`.`parent-uri-id` AS `parent-uri-id`,
2081 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2082 `post-user`.`thr-parent-id` AS `thr-parent-id`,
2083 `conversation-item-uri`.`uri` AS `conversation`,
2084 `post-thread-user`.`conversation-id` AS `conversation-id`,
2085 `quote-item-uri`.`uri` AS `quote-uri`,
2086 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2087 `item-uri`.`guid` AS `guid`,
2088 `post-thread-user`.`wall` AS `wall`,
2089 `post-user`.`gravity` AS `gravity`,
2090 `external-item-uri`.`uri` AS `extid`,
2091 `post-user`.`external-id` AS `external-id`,
2092 `post-thread-user`.`created` AS `created`,
2093 `post-user`.`edited` AS `edited`,
2094 `post-thread-user`.`commented` AS `commented`,
2095 `post-thread-user`.`received` AS `received`,
2096 `post-thread-user`.`changed` AS `changed`,
2097 `post-user`.`post-type` AS `post-type`,
2098 `post-user`.`post-reason` AS `post-reason`,
2099 `post-user`.`private` AS `private`,
2100 `post-thread-user`.`pubmail` AS `pubmail`,
2101 `post-thread-user`.`ignored` AS `ignored`,
2102 `post-user`.`visible` AS `visible`,
2103 `post-thread-user`.`starred` AS `starred`,
2104 `post-thread-user`.`unseen` AS `unseen`,
2105 `post-user`.`deleted` AS `deleted`,
2106 `post-thread-user`.`origin` AS `origin`,
2107 `post-thread-user`.`mention` AS `mention`,
2108 `post-user`.`global` AS `global`,
2109 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread-user`.`uri-id`) AS `featured`,
2110 `post-thread-user`.`network` AS `network`,
2111 `post-user`.`vid` AS `vid`,
2112 `post-thread-user`.`psid` AS `psid`,
2113 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2114 `post-content`.`title` AS `title`,
2115 `post-content`.`content-warning` AS `content-warning`,
2116 `post-content`.`raw-body` AS `raw-body`,
2117 `post-content`.`body` AS `body`,
2118 `post-content`.`rendered-hash` AS `rendered-hash`,
2119 `post-content`.`rendered-html` AS `rendered-html`,
2120 `post-content`.`language` AS `language`,
2121 `post-content`.`plink` AS `plink`,
2122 `post-content`.`location` AS `location`,
2123 `post-content`.`coord` AS `coord`,
2124 `post-content`.`app` AS `app`,
2125 `post-content`.`object-type` AS `object-type`,
2126 `post-content`.`object` AS `object`,
2127 `post-content`.`target-type` AS `target-type`,
2128 `post-content`.`target` AS `target`,
2129 `post-content`.`resource-id` AS `resource-id`,
2130 `post-thread-user`.`contact-id` AS `contact-id`,
2131 `contact`.`uri-id` AS `contact-uri-id`,
2132 `contact`.`url` AS `contact-link`,
2133 `contact`.`addr` AS `contact-addr`,
2134 `contact`.`name` AS `contact-name`,
2135 `contact`.`nick` AS `contact-nick`,
2136 `contact`.`thumb` AS `contact-avatar`,
2137 `contact`.`network` AS `contact-network`,
2138 `contact`.`blocked` AS `contact-blocked`,
2139 `contact`.`hidden` AS `contact-hidden`,
2140 `contact`.`readonly` AS `contact-readonly`,
2141 `contact`.`archive` AS `contact-archive`,
2142 `contact`.`pending` AS `contact-pending`,
2143 `contact`.`rel` AS `contact-rel`,
2144 `contact`.`uid` AS `contact-uid`,
2145 `contact`.`contact-type` AS `contact-contact-type`,
2146 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
2147 `contact`.`self` AS `self`,
2148 `contact`.`id` AS `cid`,
2149 `contact`.`alias` AS `alias`,
2150 `contact`.`photo` AS `photo`,
2151 `contact`.`name-date` AS `name-date`,
2152 `contact`.`uri-date` AS `uri-date`,
2153 `contact`.`avatar-date` AS `avatar-date`,
2154 `contact`.`thumb` AS `thumb`,
2155 `post-thread-user`.`author-id` AS `author-id`,
2156 `author`.`uri-id` AS `author-uri-id`,
2157 `author`.`url` AS `author-link`,
2158 `author`.`addr` AS `author-addr`,
2159 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
2160 `author`.`nick` AS `author-nick`,
2161 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
2162 `author`.`network` AS `author-network`,
2163 `author`.`blocked` AS `author-blocked`,
2164 `author`.`hidden` AS `author-hidden`,
2165 `author`.`updated` AS `author-updated`,
2166 `author`.`gsid` AS `author-gsid`,
2167 `post-thread-user`.`owner-id` AS `owner-id`,
2168 `owner`.`uri-id` AS `owner-uri-id`,
2169 `owner`.`url` AS `owner-link`,
2170 `owner`.`addr` AS `owner-addr`,
2171 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
2172 `owner`.`nick` AS `owner-nick`,
2173 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
2174 `owner`.`network` AS `owner-network`,
2175 `owner`.`blocked` AS `owner-blocked`,
2176 `owner`.`hidden` AS `owner-hidden`,
2177 `owner`.`updated` AS `owner-updated`,
2178 `owner`.`contact-type` AS `owner-contact-type`,
2179 `post-thread-user`.`causer-id` AS `causer-id`,
2180 `causer`.`uri-id` AS `causer-uri-id`,
2181 `causer`.`url` AS `causer-link`,
2182 `causer`.`addr` AS `causer-addr`,
2183 `causer`.`name` AS `causer-name`,
2184 `causer`.`nick` AS `causer-nick`,
2185 `causer`.`thumb` AS `causer-avatar`,
2186 `causer`.`network` AS `causer-network`,
2187 `causer`.`blocked` AS `causer-blocked`,
2188 `causer`.`hidden` AS `causer-hidden`,
2189 `causer`.`contact-type` AS `causer-contact-type`,
2190 `post-delivery-data`.`postopts` AS `postopts`,
2191 `post-delivery-data`.`inform` AS `inform`,
2192 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
2193 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
2194 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
2195 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
2196 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
2197 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
2198 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
2199 `post-user`.`event-id` AS `event-id`,
2200 `event`.`created` AS `event-created`,
2201 `event`.`edited` AS `event-edited`,
2202 `event`.`start` AS `event-start`,
2203 `event`.`finish` AS `event-finish`,
2204 `event`.`summary` AS `event-summary`,
2205 `event`.`desc` AS `event-desc`,
2206 `event`.`location` AS `event-location`,
2207 `event`.`type` AS `event-type`,
2208 `event`.`nofinish` AS `event-nofinish`,
2209 `event`.`ignore` AS `event-ignore`,
2210 `post-question`.`id` AS `question-id`,
2211 `post-question`.`multiple` AS `question-multiple`,
2212 `post-question`.`voters` AS `question-voters`,
2213 `post-question`.`end-time` AS `question-end-time`,
2214 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`,
2215 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread-user`.`uri-id`) AS `has-media`,
2216 `diaspora-interaction`.`interaction` AS `signed_text`,
2217 `parent-item-uri`.`guid` AS `parent-guid`,
2218 `parent-post`.`network` AS `parent-network`,
2219 `parent-post`.`author-id` AS `parent-author-id`,
2220 `parent-post-author`.`url` AS `parent-author-link`,
2221 `parent-post-author`.`name` AS `parent-author-name`,
2222 `parent-post-author`.`network` AS `parent-author-network`
2223 FROM `post-thread-user`
2224 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2225 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2226 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
2227 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
2228 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
2229 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
2230 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
2231 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
2232 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
2233 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
2234 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
2235 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
2236 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
2237 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
2238 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2239 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
2240 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread-user`.`uri-id`
2241 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
2242 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`
2243 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2248 DROP VIEW IF EXISTS `post-view`;
2249 CREATE VIEW `post-view` AS SELECT
2250 `item-uri`.`uri` AS `uri`,
2251 `post`.`uri-id` AS `uri-id`,
2252 `parent-item-uri`.`uri` AS `parent-uri`,
2253 `post`.`parent-uri-id` AS `parent-uri-id`,
2254 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2255 `post`.`thr-parent-id` AS `thr-parent-id`,
2256 `conversation-item-uri`.`uri` AS `conversation`,
2257 `post-thread`.`conversation-id` AS `conversation-id`,
2258 `quote-item-uri`.`uri` AS `quote-uri`,
2259 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2260 `item-uri`.`guid` AS `guid`,
2261 `post`.`gravity` AS `gravity`,
2262 `external-item-uri`.`uri` AS `extid`,
2263 `post`.`external-id` AS `external-id`,
2264 `post`.`created` AS `created`,
2265 `post`.`edited` AS `edited`,
2266 `post-thread`.`commented` AS `commented`,
2267 `post`.`received` AS `received`,
2268 `post-thread`.`changed` AS `changed`,
2269 `post`.`post-type` AS `post-type`,
2270 `post`.`private` AS `private`,
2271 `post`.`visible` AS `visible`,
2272 `post`.`deleted` AS `deleted`,
2273 `post`.`global` AS `global`,
2274 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post`.`uri-id`) AS `featured`,
2275 `post`.`network` AS `network`,
2276 `post`.`vid` AS `vid`,
2277 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2278 `post-content`.`title` AS `title`,
2279 `post-content`.`content-warning` AS `content-warning`,
2280 `post-content`.`raw-body` AS `raw-body`,
2281 `post-content`.`body` AS `body`,
2282 `post-content`.`rendered-hash` AS `rendered-hash`,
2283 `post-content`.`rendered-html` AS `rendered-html`,
2284 `post-content`.`language` AS `language`,
2285 `post-content`.`plink` AS `plink`,
2286 `post-content`.`location` AS `location`,
2287 `post-content`.`coord` AS `coord`,
2288 `post-content`.`app` AS `app`,
2289 `post-content`.`object-type` AS `object-type`,
2290 `post-content`.`object` AS `object`,
2291 `post-content`.`target-type` AS `target-type`,
2292 `post-content`.`target` AS `target`,
2293 `post-content`.`resource-id` AS `resource-id`,
2294 `post`.`author-id` AS `contact-id`,
2295 `author`.`uri-id` AS `contact-uri-id`,
2296 `author`.`url` AS `contact-link`,
2297 `author`.`addr` AS `contact-addr`,
2298 `author`.`name` AS `contact-name`,
2299 `author`.`nick` AS `contact-nick`,
2300 `author`.`thumb` AS `contact-avatar`,
2301 `author`.`network` AS `contact-network`,
2302 `author`.`blocked` AS `contact-blocked`,
2303 `author`.`hidden` AS `contact-hidden`,
2304 `author`.`readonly` AS `contact-readonly`,
2305 `author`.`archive` AS `contact-archive`,
2306 `author`.`pending` AS `contact-pending`,
2307 `author`.`rel` AS `contact-rel`,
2308 `author`.`uid` AS `contact-uid`,
2309 `author`.`contact-type` AS `contact-contact-type`,
2310 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2312 `author`.`id` AS `cid`,
2313 `author`.`alias` AS `alias`,
2314 `author`.`photo` AS `photo`,
2315 `author`.`name-date` AS `name-date`,
2316 `author`.`uri-date` AS `uri-date`,
2317 `author`.`avatar-date` AS `avatar-date`,
2318 `author`.`thumb` AS `thumb`,
2319 `post`.`author-id` AS `author-id`,
2320 `author`.`uri-id` AS `author-uri-id`,
2321 `author`.`url` AS `author-link`,
2322 `author`.`addr` AS `author-addr`,
2323 `author`.`name` AS `author-name`,
2324 `author`.`nick` AS `author-nick`,
2325 `author`.`thumb` AS `author-avatar`,
2326 `author`.`network` AS `author-network`,
2327 `author`.`blocked` AS `author-blocked`,
2328 `author`.`hidden` AS `author-hidden`,
2329 `author`.`updated` AS `author-updated`,
2330 `author`.`gsid` AS `author-gsid`,
2331 `post`.`owner-id` AS `owner-id`,
2332 `owner`.`uri-id` AS `owner-uri-id`,
2333 `owner`.`url` AS `owner-link`,
2334 `owner`.`addr` AS `owner-addr`,
2335 `owner`.`name` AS `owner-name`,
2336 `owner`.`nick` AS `owner-nick`,
2337 `owner`.`thumb` AS `owner-avatar`,
2338 `owner`.`network` AS `owner-network`,
2339 `owner`.`blocked` AS `owner-blocked`,
2340 `owner`.`hidden` AS `owner-hidden`,
2341 `owner`.`updated` AS `owner-updated`,
2342 `owner`.`contact-type` AS `owner-contact-type`,
2343 `post`.`causer-id` AS `causer-id`,
2344 `causer`.`uri-id` AS `causer-uri-id`,
2345 `causer`.`url` AS `causer-link`,
2346 `causer`.`addr` AS `causer-addr`,
2347 `causer`.`name` AS `causer-name`,
2348 `causer`.`nick` AS `causer-nick`,
2349 `causer`.`thumb` AS `causer-avatar`,
2350 `causer`.`network` AS `causer-network`,
2351 `causer`.`blocked` AS `causer-blocked`,
2352 `causer`.`hidden` AS `causer-hidden`,
2353 `causer`.`contact-type` AS `causer-contact-type`,
2354 `post-question`.`id` AS `question-id`,
2355 `post-question`.`multiple` AS `question-multiple`,
2356 `post-question`.`voters` AS `question-voters`,
2357 `post-question`.`end-time` AS `question-end-time`,
2358 0 AS `has-categories`,
2359 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post`.`uri-id`) AS `has-media`,
2360 `diaspora-interaction`.`interaction` AS `signed_text`,
2361 `parent-item-uri`.`guid` AS `parent-guid`,
2362 `parent-post`.`network` AS `parent-network`,
2363 `parent-post`.`author-id` AS `parent-author-id`,
2364 `parent-post-author`.`url` AS `parent-author-link`,
2365 `parent-post-author`.`name` AS `parent-author-name`,
2366 `parent-post-author`.`network` AS `parent-author-network`
2368 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
2369 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
2370 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
2371 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
2372 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
2373 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2374 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2375 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
2376 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2377 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2378 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
2379 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
2380 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2381 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post`.`uri-id`
2382 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2383 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2386 -- VIEW post-thread-view
2388 DROP VIEW IF EXISTS `post-thread-view`;
2389 CREATE VIEW `post-thread-view` AS SELECT
2390 `item-uri`.`uri` AS `uri`,
2391 `post-thread`.`uri-id` AS `uri-id`,
2392 `parent-item-uri`.`uri` AS `parent-uri`,
2393 `post`.`parent-uri-id` AS `parent-uri-id`,
2394 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2395 `post`.`thr-parent-id` AS `thr-parent-id`,
2396 `conversation-item-uri`.`uri` AS `conversation`,
2397 `post-thread`.`conversation-id` AS `conversation-id`,
2398 `quote-item-uri`.`uri` AS `quote-uri`,
2399 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2400 `item-uri`.`guid` AS `guid`,
2401 `post`.`gravity` AS `gravity`,
2402 `external-item-uri`.`uri` AS `extid`,
2403 `post`.`external-id` AS `external-id`,
2404 `post-thread`.`created` AS `created`,
2405 `post`.`edited` AS `edited`,
2406 `post-thread`.`commented` AS `commented`,
2407 `post-thread`.`received` AS `received`,
2408 `post-thread`.`changed` AS `changed`,
2409 `post`.`post-type` AS `post-type`,
2410 `post`.`private` AS `private`,
2411 `post`.`visible` AS `visible`,
2412 `post`.`deleted` AS `deleted`,
2413 `post`.`global` AS `global`,
2414 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread`.`uri-id`) AS `featured`,
2415 `post-thread`.`network` AS `network`,
2416 `post`.`vid` AS `vid`,
2417 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2418 `post-content`.`title` AS `title`,
2419 `post-content`.`content-warning` AS `content-warning`,
2420 `post-content`.`raw-body` AS `raw-body`,
2421 `post-content`.`body` AS `body`,
2422 `post-content`.`rendered-hash` AS `rendered-hash`,
2423 `post-content`.`rendered-html` AS `rendered-html`,
2424 `post-content`.`language` AS `language`,
2425 `post-content`.`plink` AS `plink`,
2426 `post-content`.`location` AS `location`,
2427 `post-content`.`coord` AS `coord`,
2428 `post-content`.`app` AS `app`,
2429 `post-content`.`object-type` AS `object-type`,
2430 `post-content`.`object` AS `object`,
2431 `post-content`.`target-type` AS `target-type`,
2432 `post-content`.`target` AS `target`,
2433 `post-content`.`resource-id` AS `resource-id`,
2434 `post-thread`.`author-id` AS `contact-id`,
2435 `author`.`uri-id` AS `contact-uri-id`,
2436 `author`.`url` AS `contact-link`,
2437 `author`.`addr` AS `contact-addr`,
2438 `author`.`name` AS `contact-name`,
2439 `author`.`nick` AS `contact-nick`,
2440 `author`.`thumb` AS `contact-avatar`,
2441 `author`.`network` AS `contact-network`,
2442 `author`.`blocked` AS `contact-blocked`,
2443 `author`.`hidden` AS `contact-hidden`,
2444 `author`.`readonly` AS `contact-readonly`,
2445 `author`.`archive` AS `contact-archive`,
2446 `author`.`pending` AS `contact-pending`,
2447 `author`.`rel` AS `contact-rel`,
2448 `author`.`uid` AS `contact-uid`,
2449 `author`.`contact-type` AS `contact-contact-type`,
2450 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2452 `author`.`id` AS `cid`,
2453 `author`.`alias` AS `alias`,
2454 `author`.`photo` AS `photo`,
2455 `author`.`name-date` AS `name-date`,
2456 `author`.`uri-date` AS `uri-date`,
2457 `author`.`avatar-date` AS `avatar-date`,
2458 `author`.`thumb` AS `thumb`,
2459 `post-thread`.`author-id` AS `author-id`,
2460 `author`.`uri-id` AS `author-uri-id`,
2461 `author`.`url` AS `author-link`,
2462 `author`.`addr` AS `author-addr`,
2463 `author`.`name` AS `author-name`,
2464 `author`.`nick` AS `author-nick`,
2465 `author`.`thumb` AS `author-avatar`,
2466 `author`.`network` AS `author-network`,
2467 `author`.`blocked` AS `author-blocked`,
2468 `author`.`hidden` AS `author-hidden`,
2469 `author`.`updated` AS `author-updated`,
2470 `author`.`gsid` AS `author-gsid`,
2471 `post-thread`.`owner-id` AS `owner-id`,
2472 `owner`.`uri-id` AS `owner-uri-id`,
2473 `owner`.`url` AS `owner-link`,
2474 `owner`.`addr` AS `owner-addr`,
2475 `owner`.`name` AS `owner-name`,
2476 `owner`.`nick` AS `owner-nick`,
2477 `owner`.`thumb` AS `owner-avatar`,
2478 `owner`.`network` AS `owner-network`,
2479 `owner`.`blocked` AS `owner-blocked`,
2480 `owner`.`hidden` AS `owner-hidden`,
2481 `owner`.`updated` AS `owner-updated`,
2482 `owner`.`contact-type` AS `owner-contact-type`,
2483 `post-thread`.`causer-id` AS `causer-id`,
2484 `causer`.`uri-id` AS `causer-uri-id`,
2485 `causer`.`url` AS `causer-link`,
2486 `causer`.`addr` AS `causer-addr`,
2487 `causer`.`name` AS `causer-name`,
2488 `causer`.`nick` AS `causer-nick`,
2489 `causer`.`thumb` AS `causer-avatar`,
2490 `causer`.`network` AS `causer-network`,
2491 `causer`.`blocked` AS `causer-blocked`,
2492 `causer`.`hidden` AS `causer-hidden`,
2493 `causer`.`contact-type` AS `causer-contact-type`,
2494 `post-question`.`id` AS `question-id`,
2495 `post-question`.`multiple` AS `question-multiple`,
2496 `post-question`.`voters` AS `question-voters`,
2497 `post-question`.`end-time` AS `question-end-time`,
2498 0 AS `has-categories`,
2499 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread`.`uri-id`) AS `has-media`,
2500 (SELECT COUNT(*) FROM `post` WHERE `parent-uri-id` = `post-thread`.`uri-id` AND `gravity` = 6) AS `total-comments`,
2501 (SELECT COUNT(DISTINCT(`author-id`)) FROM `post` WHERE `parent-uri-id` = `post-thread`.`uri-id` AND `gravity` = 6) AS `total-actors`,
2502 `diaspora-interaction`.`interaction` AS `signed_text`,
2503 `parent-item-uri`.`guid` AS `parent-guid`,
2504 `parent-post`.`network` AS `parent-network`,
2505 `parent-post`.`author-id` AS `parent-author-id`,
2506 `parent-post-author`.`url` AS `parent-author-link`,
2507 `parent-post-author`.`name` AS `parent-author-name`,
2508 `parent-post-author`.`network` AS `parent-author-network`
2510 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
2511 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
2512 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
2513 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
2514 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
2515 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2516 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2517 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
2518 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2519 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2520 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
2521 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
2522 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2523 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread`.`uri-id`
2524 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2525 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2528 -- VIEW category-view
2530 DROP VIEW IF EXISTS `category-view`;
2531 CREATE VIEW `category-view` AS SELECT
2532 `post-category`.`uri-id` AS `uri-id`,
2533 `post-category`.`uid` AS `uid`,
2534 `post-category`.`type` AS `type`,
2535 `post-category`.`tid` AS `tid`,
2536 `tag`.`name` AS `name`,
2537 `tag`.`url` AS `url`
2538 FROM `post-category`
2539 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2542 -- VIEW collection-view
2544 DROP VIEW IF EXISTS `collection-view`;
2545 CREATE VIEW `collection-view` AS SELECT
2546 `post-collection`.`uri-id` AS `uri-id`,
2547 `post-collection`.`type` AS `type`,
2548 `post-collection`.`author-id` AS `cid`,
2549 `post`.`received` AS `received`,
2550 `post`.`created` AS `created`,
2551 `post-thread`.`commented` AS `commented`,
2552 `post`.`private` AS `private`,
2553 `post`.`visible` AS `visible`,
2554 `post`.`deleted` AS `deleted`,
2555 `post`.`thr-parent-id` AS `thr-parent-id`,
2556 `post-collection`.`author-id` AS `author-id`,
2557 `post`.`gravity` AS `gravity`
2558 FROM `post-collection`
2559 INNER JOIN `post` ON `post-collection`.`uri-id` = `post`.`uri-id`
2560 INNER JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`;
2565 DROP VIEW IF EXISTS `media-view`;
2566 CREATE VIEW `media-view` AS SELECT
2567 `post-media`.`uri-id` AS `uri-id`,
2568 `post-media`.`type` AS `type`,
2569 `post`.`received` AS `received`,
2570 `post`.`created` AS `created`,
2571 `post`.`private` AS `private`,
2572 `post`.`visible` AS `visible`,
2573 `post`.`deleted` AS `deleted`,
2574 `post`.`thr-parent-id` AS `thr-parent-id`,
2575 `post`.`author-id` AS `author-id`,
2576 `post`.`gravity` AS `gravity`
2578 INNER JOIN `post` ON `post-media`.`uri-id` = `post`.`uri-id`;
2583 DROP VIEW IF EXISTS `tag-view`;
2584 CREATE VIEW `tag-view` AS SELECT
2585 `post-tag`.`uri-id` AS `uri-id`,
2586 `post-tag`.`type` AS `type`,
2587 `post-tag`.`tid` AS `tid`,
2588 `post-tag`.`cid` AS `cid`,
2589 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2590 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`,
2591 CASE `cid` WHEN 0 THEN `tag`.`type` ELSE 1 END AS `tag-type`
2593 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2594 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2597 -- VIEW network-item-view
2599 DROP VIEW IF EXISTS `network-item-view`;
2600 CREATE VIEW `network-item-view` AS SELECT
2601 `post-user`.`uri-id` AS `uri-id`,
2602 `parent-post`.`id` AS `parent`,
2603 `post-user`.`received` AS `received`,
2604 `post-thread-user`.`commented` AS `commented`,
2605 `post-user`.`created` AS `created`,
2606 `post-user`.`uid` AS `uid`,
2607 `post-thread-user`.`starred` AS `starred`,
2608 `post-thread-user`.`mention` AS `mention`,
2609 `post-user`.`network` AS `network`,
2610 `post-user`.`unseen` AS `unseen`,
2611 `post-user`.`gravity` AS `gravity`,
2612 `post-user`.`contact-id` AS `contact-id`,
2613 `ownercontact`.`contact-type` AS `contact-type`
2615 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2616 INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2617 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2618 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2619 INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2620 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2621 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2622 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2623 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
2624 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2625 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2628 -- VIEW network-thread-view
2630 DROP VIEW IF EXISTS `network-thread-view`;
2631 CREATE VIEW `network-thread-view` AS SELECT
2632 `post-thread-user`.`uri-id` AS `uri-id`,
2633 `parent-post`.`id` AS `parent`,
2634 `post-thread-user`.`received` AS `received`,
2635 `post-thread-user`.`commented` AS `commented`,
2636 `post-thread-user`.`created` AS `created`,
2637 `post-thread-user`.`uid` AS `uid`,
2638 `post-thread-user`.`starred` AS `starred`,
2639 `post-thread-user`.`mention` AS `mention`,
2640 `post-thread-user`.`network` AS `network`,
2641 `post-thread-user`.`contact-id` AS `contact-id`,
2642 `ownercontact`.`contact-type` AS `contact-type`
2643 FROM `post-thread-user`
2644 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2645 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2646 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2647 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2648 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2649 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2650 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2651 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2652 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2653 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2654 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2659 DROP VIEW IF EXISTS `owner-view`;
2660 CREATE VIEW `owner-view` AS SELECT
2661 `contact`.`id` AS `id`,
2662 `contact`.`uid` AS `uid`,
2663 `contact`.`created` AS `created`,
2664 `contact`.`updated` AS `updated`,
2665 `contact`.`self` AS `self`,
2666 `contact`.`remote_self` AS `remote_self`,
2667 `contact`.`rel` AS `rel`,
2668 `contact`.`network` AS `network`,
2669 `contact`.`protocol` AS `protocol`,
2670 `contact`.`name` AS `name`,
2671 `contact`.`nick` AS `nick`,
2672 `contact`.`location` AS `location`,
2673 `contact`.`about` AS `about`,
2674 `contact`.`keywords` AS `keywords`,
2675 `contact`.`xmpp` AS `xmpp`,
2676 `contact`.`matrix` AS `matrix`,
2677 `contact`.`attag` AS `attag`,
2678 `contact`.`avatar` AS `avatar`,
2679 `contact`.`photo` AS `photo`,
2680 `contact`.`thumb` AS `thumb`,
2681 `contact`.`micro` AS `micro`,
2682 `contact`.`header` AS `header`,
2683 `contact`.`url` AS `url`,
2684 `contact`.`nurl` AS `nurl`,
2685 `contact`.`uri-id` AS `uri-id`,
2686 `contact`.`addr` AS `addr`,
2687 `contact`.`alias` AS `alias`,
2688 `contact`.`pubkey` AS `pubkey`,
2689 `contact`.`prvkey` AS `prvkey`,
2690 `contact`.`batch` AS `batch`,
2691 `contact`.`request` AS `request`,
2692 `contact`.`notify` AS `notify`,
2693 `contact`.`poll` AS `poll`,
2694 `contact`.`confirm` AS `confirm`,
2695 `contact`.`poco` AS `poco`,
2696 `contact`.`subhub` AS `subhub`,
2697 `contact`.`hub-verify` AS `hub-verify`,
2698 `contact`.`last-update` AS `last-update`,
2699 `contact`.`success_update` AS `success_update`,
2700 `contact`.`failure_update` AS `failure_update`,
2701 `contact`.`name-date` AS `name-date`,
2702 `contact`.`uri-date` AS `uri-date`,
2703 `contact`.`avatar-date` AS `avatar-date`,
2704 `contact`.`avatar-date` AS `picdate`,
2705 `contact`.`term-date` AS `term-date`,
2706 `contact`.`last-item` AS `last-item`,
2707 `contact`.`priority` AS `priority`,
2708 `user`.`blocked` AS `blocked`,
2709 `contact`.`block_reason` AS `block_reason`,
2710 `contact`.`readonly` AS `readonly`,
2711 `contact`.`writable` AS `writable`,
2712 `contact`.`forum` AS `forum`,
2713 `contact`.`prv` AS `prv`,
2714 `contact`.`contact-type` AS `contact-type`,
2715 `contact`.`manually-approve` AS `manually-approve`,
2716 `contact`.`hidden` AS `hidden`,
2717 `contact`.`archive` AS `archive`,
2718 `contact`.`pending` AS `pending`,
2719 `contact`.`deleted` AS `deleted`,
2720 `contact`.`unsearchable` AS `unsearchable`,
2721 `contact`.`sensitive` AS `sensitive`,
2722 `contact`.`baseurl` AS `baseurl`,
2723 `contact`.`reason` AS `reason`,
2724 `contact`.`info` AS `info`,
2725 `contact`.`bdyear` AS `bdyear`,
2726 `contact`.`bd` AS `bd`,
2727 `contact`.`notify_new_posts` AS `notify_new_posts`,
2728 `contact`.`fetch_further_information` AS `fetch_further_information`,
2729 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2730 `user`.`parent-uid` AS `parent-uid`,
2731 `user`.`guid` AS `guid`,
2732 `user`.`nickname` AS `nickname`,
2733 `user`.`email` AS `email`,
2734 `user`.`openid` AS `openid`,
2735 `user`.`timezone` AS `timezone`,
2736 `user`.`language` AS `language`,
2737 `user`.`register_date` AS `register_date`,
2738 `user`.`login_date` AS `login_date`,
2739 `user`.`last-activity` AS `last-activity`,
2740 `user`.`default-location` AS `default-location`,
2741 `user`.`allow_location` AS `allow_location`,
2742 `user`.`theme` AS `theme`,
2743 `user`.`pubkey` AS `upubkey`,
2744 `user`.`prvkey` AS `uprvkey`,
2745 `user`.`sprvkey` AS `sprvkey`,
2746 `user`.`spubkey` AS `spubkey`,
2747 `user`.`verified` AS `verified`,
2748 `user`.`blockwall` AS `blockwall`,
2749 `user`.`hidewall` AS `hidewall`,
2750 `user`.`blocktags` AS `blocktags`,
2751 `user`.`unkmail` AS `unkmail`,
2752 `user`.`cntunkmail` AS `cntunkmail`,
2753 `user`.`notify-flags` AS `notify-flags`,
2754 `user`.`page-flags` AS `page-flags`,
2755 `user`.`account-type` AS `account-type`,
2756 `user`.`prvnets` AS `prvnets`,
2757 `user`.`maxreq` AS `maxreq`,
2758 `user`.`expire` AS `expire`,
2759 `user`.`account_removed` AS `account_removed`,
2760 `user`.`account_expired` AS `account_expired`,
2761 `user`.`account_expires_on` AS `account_expires_on`,
2762 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2763 `user`.`def_gid` AS `def_gid`,
2764 `user`.`allow_cid` AS `allow_cid`,
2765 `user`.`allow_gid` AS `allow_gid`,
2766 `user`.`deny_cid` AS `deny_cid`,
2767 `user`.`deny_gid` AS `deny_gid`,
2768 `user`.`openidserver` AS `openidserver`,
2769 `profile`.`publish` AS `publish`,
2770 `profile`.`net-publish` AS `net-publish`,
2771 `profile`.`hide-friends` AS `hide-friends`,
2772 `profile`.`prv_keywords` AS `prv_keywords`,
2773 `profile`.`pub_keywords` AS `pub_keywords`,
2774 `profile`.`address` AS `address`,
2775 `profile`.`locality` AS `locality`,
2776 `profile`.`region` AS `region`,
2777 `profile`.`postal-code` AS `postal-code`,
2778 `profile`.`country-name` AS `country-name`,
2779 `profile`.`homepage` AS `homepage`,
2780 `profile`.`homepage_verified` AS `homepage_verified`,
2781 `profile`.`dob` AS `dob`
2783 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2784 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2787 -- VIEW account-view
2789 DROP VIEW IF EXISTS `account-view`;
2790 CREATE VIEW `account-view` AS SELECT
2791 `contact`.`id` AS `id`,
2792 `contact`.`url` AS `url`,
2793 `contact`.`nurl` AS `nurl`,
2794 `contact`.`uri-id` AS `uri-id`,
2795 `item-uri`.`guid` AS `guid`,
2796 `contact`.`addr` AS `addr`,
2797 `contact`.`alias` AS `alias`,
2798 `contact`.`name` AS `name`,
2799 `contact`.`nick` AS `nick`,
2800 `contact`.`about` AS `about`,
2801 `contact`.`keywords` AS `keywords`,
2802 `contact`.`xmpp` AS `xmpp`,
2803 `contact`.`matrix` AS `matrix`,
2804 `contact`.`avatar` AS `avatar`,
2805 `contact`.`photo` AS `photo`,
2806 `contact`.`thumb` AS `thumb`,
2807 `contact`.`micro` AS `micro`,
2808 `contact`.`header` AS `header`,
2809 `contact`.`created` AS `created`,
2810 `contact`.`updated` AS `updated`,
2811 `contact`.`network` AS `network`,
2812 `contact`.`protocol` AS `protocol`,
2813 `contact`.`location` AS `location`,
2814 `contact`.`attag` AS `attag`,
2815 `contact`.`pubkey` AS `pubkey`,
2816 `contact`.`prvkey` AS `prvkey`,
2817 `contact`.`subscribe` AS `subscribe`,
2818 `contact`.`last-update` AS `last-update`,
2819 `contact`.`success_update` AS `success_update`,
2820 `contact`.`failure_update` AS `failure_update`,
2821 `contact`.`failed` AS `failed`,
2822 `contact`.`last-item` AS `last-item`,
2823 `contact`.`last-discovery` AS `last-discovery`,
2824 `contact`.`contact-type` AS `contact-type`,
2825 `contact`.`manually-approve` AS `manually-approve`,
2826 `contact`.`unsearchable` AS `unsearchable`,
2827 `contact`.`sensitive` AS `sensitive`,
2828 `contact`.`baseurl` AS `baseurl`,
2829 `contact`.`gsid` AS `gsid`,
2830 `contact`.`info` AS `info`,
2831 `contact`.`bdyear` AS `bdyear`,
2832 `contact`.`bd` AS `bd`,
2833 `contact`.`poco` AS `poco`,
2834 `contact`.`name-date` AS `name-date`,
2835 `contact`.`uri-date` AS `uri-date`,
2836 `contact`.`avatar-date` AS `avatar-date`,
2837 `contact`.`term-date` AS `term-date`,
2838 `contact`.`hidden` AS `global-ignored`,
2839 `contact`.`blocked` AS `global-blocked`,
2840 `contact`.`hidden` AS `hidden`,
2841 `contact`.`archive` AS `archive`,
2842 `contact`.`deleted` AS `deleted`,
2843 `contact`.`blocked` AS `blocked`,
2844 `contact`.`notify` AS `dfrn-notify`,
2845 `contact`.`poll` AS `dfrn-poll`,
2846 `item-uri`.`guid` AS `diaspora-guid`,
2847 `diaspora-contact`.`batch` AS `diaspora-batch`,
2848 `diaspora-contact`.`notify` AS `diaspora-notify`,
2849 `diaspora-contact`.`poll` AS `diaspora-poll`,
2850 `diaspora-contact`.`alias` AS `diaspora-alias`,
2851 `apcontact`.`uuid` AS `ap-uuid`,
2852 `apcontact`.`type` AS `ap-type`,
2853 `apcontact`.`following` AS `ap-following`,
2854 `apcontact`.`followers` AS `ap-followers`,
2855 `apcontact`.`inbox` AS `ap-inbox`,
2856 `apcontact`.`outbox` AS `ap-outbox`,
2857 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2858 `apcontact`.`generator` AS `ap-generator`,
2859 `apcontact`.`following_count` AS `ap-following_count`,
2860 `apcontact`.`followers_count` AS `ap-followers_count`,
2861 `apcontact`.`statuses_count` AS `ap-statuses_count`,
2862 `gserver`.`site_name` AS `site_name`,
2863 `gserver`.`platform` AS `platform`,
2864 `gserver`.`version` AS `version`
2866 LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id`
2867 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
2868 LEFT JOIN `diaspora-contact` ON `diaspora-contact`.`uri-id` = contact.`uri-id`
2869 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`
2870 WHERE `contact`.`uid` = 0;
2873 -- VIEW account-user-view
2875 DROP VIEW IF EXISTS `account-user-view`;
2876 CREATE VIEW `account-user-view` AS SELECT
2877 `ucontact`.`id` AS `id`,
2878 `contact`.`id` AS `pid`,
2879 `ucontact`.`uid` AS `uid`,
2880 `contact`.`url` AS `url`,
2881 `contact`.`nurl` AS `nurl`,
2882 `contact`.`uri-id` AS `uri-id`,
2883 `item-uri`.`guid` AS `guid`,
2884 `contact`.`addr` AS `addr`,
2885 `contact`.`alias` AS `alias`,
2886 `contact`.`name` AS `name`,
2887 `contact`.`nick` AS `nick`,
2888 `contact`.`about` AS `about`,
2889 `contact`.`keywords` AS `keywords`,
2890 `contact`.`xmpp` AS `xmpp`,
2891 `contact`.`matrix` AS `matrix`,
2892 `contact`.`avatar` AS `avatar`,
2893 `contact`.`photo` AS `photo`,
2894 `contact`.`thumb` AS `thumb`,
2895 `contact`.`micro` AS `micro`,
2896 `contact`.`header` AS `header`,
2897 `contact`.`created` AS `created`,
2898 `contact`.`updated` AS `updated`,
2899 `ucontact`.`self` AS `self`,
2900 `ucontact`.`remote_self` AS `remote_self`,
2901 `ucontact`.`rel` AS `rel`,
2902 `contact`.`network` AS `network`,
2903 `ucontact`.`protocol` AS `protocol`,
2904 `contact`.`location` AS `location`,
2905 `ucontact`.`attag` AS `attag`,
2906 `contact`.`pubkey` AS `pubkey`,
2907 `contact`.`prvkey` AS `prvkey`,
2908 `contact`.`subscribe` AS `subscribe`,
2909 `contact`.`last-update` AS `last-update`,
2910 `contact`.`success_update` AS `success_update`,
2911 `contact`.`failure_update` AS `failure_update`,
2912 `contact`.`failed` AS `failed`,
2913 `contact`.`last-item` AS `last-item`,
2914 `contact`.`last-discovery` AS `last-discovery`,
2915 `contact`.`contact-type` AS `contact-type`,
2916 `contact`.`manually-approve` AS `manually-approve`,
2917 `contact`.`unsearchable` AS `unsearchable`,
2918 `contact`.`sensitive` AS `sensitive`,
2919 `contact`.`baseurl` AS `baseurl`,
2920 `contact`.`gsid` AS `gsid`,
2921 `ucontact`.`info` AS `info`,
2922 `contact`.`bdyear` AS `bdyear`,
2923 `contact`.`bd` AS `bd`,
2924 `contact`.`poco` AS `poco`,
2925 `contact`.`name-date` AS `name-date`,
2926 `contact`.`uri-date` AS `uri-date`,
2927 `contact`.`avatar-date` AS `avatar-date`,
2928 `contact`.`term-date` AS `term-date`,
2929 `contact`.`hidden` AS `global-ignored`,
2930 `contact`.`blocked` AS `global-blocked`,
2931 `ucontact`.`hidden` AS `hidden`,
2932 `ucontact`.`archive` AS `archive`,
2933 `ucontact`.`pending` AS `pending`,
2934 `ucontact`.`deleted` AS `deleted`,
2935 `ucontact`.`notify_new_posts` AS `notify_new_posts`,
2936 `ucontact`.`fetch_further_information` AS `fetch_further_information`,
2937 `ucontact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2938 `ucontact`.`rating` AS `rating`,
2939 `ucontact`.`readonly` AS `readonly`,
2940 `ucontact`.`blocked` AS `blocked`,
2941 `ucontact`.`block_reason` AS `block_reason`,
2942 `ucontact`.`subhub` AS `subhub`,
2943 `ucontact`.`hub-verify` AS `hub-verify`,
2944 `ucontact`.`reason` AS `reason`,
2945 `contact`.`notify` AS `dfrn-notify`,
2946 `contact`.`poll` AS `dfrn-poll`,
2947 `item-uri`.`guid` AS `diaspora-guid`,
2948 `diaspora-contact`.`batch` AS `diaspora-batch`,
2949 `diaspora-contact`.`notify` AS `diaspora-notify`,
2950 `diaspora-contact`.`poll` AS `diaspora-poll`,
2951 `diaspora-contact`.`alias` AS `diaspora-alias`,
2952 `diaspora-contact`.`interacting_count` AS `diaspora-interacting_count`,
2953 `diaspora-contact`.`interacted_count` AS `diaspora-interacted_count`,
2954 `diaspora-contact`.`post_count` AS `diaspora-post_count`,
2955 `apcontact`.`uuid` AS `ap-uuid`,
2956 `apcontact`.`type` AS `ap-type`,
2957 `apcontact`.`following` AS `ap-following`,
2958 `apcontact`.`followers` AS `ap-followers`,
2959 `apcontact`.`inbox` AS `ap-inbox`,
2960 `apcontact`.`outbox` AS `ap-outbox`,
2961 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2962 `apcontact`.`generator` AS `ap-generator`,
2963 `apcontact`.`following_count` AS `ap-following_count`,
2964 `apcontact`.`followers_count` AS `ap-followers_count`,
2965 `apcontact`.`statuses_count` AS `ap-statuses_count`,
2966 `gserver`.`site_name` AS `site_name`,
2967 `gserver`.`platform` AS `platform`,
2968 `gserver`.`version` AS `version`
2969 FROM `contact` AS `ucontact`
2970 INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
2971 LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id`
2972 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
2973 LEFT JOIN `diaspora-contact` ON `diaspora-contact`.`uri-id` = `ucontact`.`uri-id`
2974 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`;
2977 -- VIEW pending-view
2979 DROP VIEW IF EXISTS `pending-view`;
2980 CREATE VIEW `pending-view` AS SELECT
2981 `register`.`id` AS `id`,
2982 `register`.`hash` AS `hash`,
2983 `register`.`created` AS `created`,
2984 `register`.`uid` AS `uid`,
2985 `register`.`password` AS `password`,
2986 `register`.`language` AS `language`,
2987 `register`.`note` AS `note`,
2988 `contact`.`self` AS `self`,
2989 `contact`.`name` AS `name`,
2990 `contact`.`url` AS `url`,
2991 `contact`.`micro` AS `micro`,
2992 `user`.`email` AS `email`,
2993 `contact`.`nick` AS `nick`
2995 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2996 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2999 -- VIEW tag-search-view
3001 DROP VIEW IF EXISTS `tag-search-view`;
3002 CREATE VIEW `tag-search-view` AS SELECT
3003 `post-tag`.`uri-id` AS `uri-id`,
3004 `post-user`.`uid` AS `uid`,
3005 `post-user`.`id` AS `iid`,
3006 `post-user`.`private` AS `private`,
3007 `post-user`.`wall` AS `wall`,
3008 `post-user`.`origin` AS `origin`,
3009 `post-user`.`global` AS `global`,
3010 `post-user`.`gravity` AS `gravity`,
3011 `post-user`.`received` AS `received`,
3012 `post-user`.`network` AS `network`,
3013 `post-user`.`author-id` AS `author-id`,
3014 `tag`.`name` AS `name`
3016 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
3017 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
3018 WHERE `post-tag`.`type` = 1;
3021 -- VIEW workerqueue-view
3023 DROP VIEW IF EXISTS `workerqueue-view`;
3024 CREATE VIEW `workerqueue-view` AS SELECT
3025 `process`.`pid` AS `pid`,
3026 `workerqueue`.`priority` AS `priority`
3028 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
3029 WHERE NOT `workerqueue`.`done`;
3032 -- VIEW profile_field-view
3034 DROP VIEW IF EXISTS `profile_field-view`;
3035 CREATE VIEW `profile_field-view` AS SELECT
3036 `profile_field`.`id` AS `id`,
3037 `profile_field`.`uid` AS `uid`,
3038 `profile_field`.`label` AS `label`,
3039 `profile_field`.`value` AS `value`,
3040 `profile_field`.`order` AS `order`,
3041 `profile_field`.`psid` AS `psid`,
3042 `permissionset`.`allow_cid` AS `allow_cid`,
3043 `permissionset`.`allow_gid` AS `allow_gid`,
3044 `permissionset`.`deny_cid` AS `deny_cid`,
3045 `permissionset`.`deny_gid` AS `deny_gid`,
3046 `profile_field`.`created` AS `created`,
3047 `profile_field`.`edited` AS `edited`
3048 FROM `profile_field`
3049 INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`;
3052 -- VIEW diaspora-contact-view
3054 DROP VIEW IF EXISTS `diaspora-contact-view`;
3055 CREATE VIEW `diaspora-contact-view` AS SELECT
3056 `diaspora-contact`.`uri-id` AS `uri-id`,
3057 `item-uri`.`uri` AS `url`,
3058 `item-uri`.`guid` AS `guid`,
3059 `diaspora-contact`.`addr` AS `addr`,
3060 `diaspora-contact`.`alias` AS `alias`,
3061 `diaspora-contact`.`nick` AS `nick`,
3062 `diaspora-contact`.`name` AS `name`,
3063 `diaspora-contact`.`given-name` AS `given-name`,
3064 `diaspora-contact`.`family-name` AS `family-name`,
3065 `diaspora-contact`.`photo` AS `photo`,
3066 `diaspora-contact`.`photo-medium` AS `photo-medium`,
3067 `diaspora-contact`.`photo-small` AS `photo-small`,
3068 `diaspora-contact`.`batch` AS `batch`,
3069 `diaspora-contact`.`notify` AS `notify`,
3070 `diaspora-contact`.`poll` AS `poll`,
3071 `diaspora-contact`.`subscribe` AS `subscribe`,
3072 `diaspora-contact`.`searchable` AS `searchable`,
3073 `diaspora-contact`.`pubkey` AS `pubkey`,
3074 `gserver`.`url` AS `baseurl`,
3075 `diaspora-contact`.`gsid` AS `gsid`,
3076 `diaspora-contact`.`created` AS `created`,
3077 `diaspora-contact`.`updated` AS `updated`,
3078 `diaspora-contact`.`interacting_count` AS `interacting_count`,
3079 `diaspora-contact`.`interacted_count` AS `interacted_count`,
3080 `diaspora-contact`.`post_count` AS `post_count`
3081 FROM `diaspora-contact`
3082 INNER JOIN `item-uri` ON `item-uri`.`id` = `diaspora-contact`.`uri-id`
3083 LEFT JOIN `gserver` ON `gserver`.`id` = `diaspora-contact`.`gsid`;