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