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