1 -- ------------------------------------------
2 -- Friendica 2022.12-dev (Giant Rhubarb)
3 -- DB_UPDATE_VERSION 1496
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 `header` varbinary(383) COMMENT 'Header picture',
133 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
134 `nurl` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
135 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
136 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
137 `alias` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
138 `pubkey` text COMMENT 'RSA public key 4096 bit',
139 `prvkey` text COMMENT 'RSA private key 4096 bit',
140 `batch` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
141 `notify` varbinary(383) COMMENT '',
142 `poll` varbinary(383) COMMENT '',
143 `subscribe` varbinary(383) COMMENT '',
144 `last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
145 `next-update` datetime COMMENT 'Next connection request',
146 `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
147 `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
148 `failed` boolean COMMENT 'Connection failed',
149 `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
150 `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
151 `last-discovery` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last follower discovery',
152 `local-data` boolean COMMENT 'Is true when there are posts with this contact on the system',
153 `blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
154 `block_reason` text COMMENT 'Node-wide block reason',
155 `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
156 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Person, organisation, news, community, relay',
157 `manually-approve` boolean COMMENT 'Contact requests have to be approved manually',
158 `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
159 `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
160 `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
161 `baseurl` varbinary(383) DEFAULT '' COMMENT 'baseurl of the contact',
162 `gsid` int unsigned COMMENT 'Global Server ID',
163 `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
164 `reason` text COMMENT '',
165 `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
166 `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
167 `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
168 `protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
169 `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
170 `hub-verify` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
171 `rating` tinyint NOT NULL DEFAULT 0 COMMENT 'Automatically detected feed poll frequency',
172 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Feed poll priority',
173 `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
174 `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
175 `pending` boolean NOT NULL DEFAULT '1' COMMENT 'Contact request is pending',
176 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
177 `info` mediumtext COMMENT '',
178 `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
179 `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
180 `ffi_keyword_denylist` text COMMENT '',
181 `photo` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
182 `thumb` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
183 `micro` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
184 `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
185 `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
186 `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
187 `request` varbinary(383) COMMENT '',
188 `confirm` varbinary(383) COMMENT '',
189 `poco` varbinary(383) COMMENT '',
190 `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
191 `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = false instead',
192 `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = true instead',
193 `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
194 `site-pubkey` text COMMENT 'Deprecated',
195 `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
196 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
197 `issued-id` varbinary(383) NOT NULL DEFAULT '' COMMENT 'Deprecated',
198 `dfrn-id` varbinary(383) NOT NULL DEFAULT '' COMMENT 'Deprecated',
199 `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
200 `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
201 `usehub` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
202 `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT 'Deprecated',
203 `profile-id` int unsigned COMMENT 'Deprecated',
205 INDEX `uid_name` (`uid`,`name`(190)),
206 INDEX `self_uid` (`self`,`uid`),
207 INDEX `alias_uid` (`alias`(128),`uid`),
208 INDEX `pending_uid` (`pending`,`uid`),
209 INDEX `blocked_uid` (`blocked`,`uid`),
210 INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
211 INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
212 INDEX `batch_contact-type` (`batch`(64),`contact-type`),
213 INDEX `addr_uid` (`addr`(128),`uid`),
214 INDEX `nurl_uid` (`nurl`(128),`uid`),
215 INDEX `nick_uid` (`nick`(128),`uid`),
216 INDEX `attag_uid` (`attag`(96),`uid`),
217 INDEX `network_uid_lastupdate` (`network`,`uid`,`last-update`),
218 INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`),
219 INDEX `next-update` (`next-update`),
220 INDEX `local-data-next-update` (`local-data`,`next-update`),
221 INDEX `uid_lastitem` (`uid`,`last-item`),
222 INDEX `baseurl` (`baseurl`(64)),
223 INDEX `uid_contact-type` (`uid`,`contact-type`),
224 INDEX `uid_self_contact-type` (`uid`,`self`,`contact-type`),
225 INDEX `self_network_uid` (`self`,`network`,`uid`),
226 INDEX `gsid_uid_failed` (`gsid`,`uid`,`failed`),
227 INDEX `uri-id` (`uri-id`),
228 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
229 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
230 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
231 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
236 CREATE TABLE IF NOT EXISTS `tag` (
237 `id` int unsigned NOT NULL auto_increment COMMENT '',
238 `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
239 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
240 `type` tinyint unsigned COMMENT 'Type of the tag (Unknown, General Collection, Follower Collection or Account)',
242 UNIQUE INDEX `type_name_url` (`name`,`url`),
244 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
247 -- TABLE permissionset
249 CREATE TABLE IF NOT EXISTS `permissionset` (
250 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
251 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
252 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
253 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
254 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
255 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
257 INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`uid`,`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30)),
258 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
259 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
264 CREATE TABLE IF NOT EXISTS `verb` (
265 `id` smallint unsigned NOT NULL auto_increment,
266 `name` varchar(100) NOT NULL DEFAULT '' COMMENT '',
268 INDEX `name` (`name`)
269 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activity Verbs';
272 -- TABLE 2fa_app_specific_password
274 CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
275 `id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
276 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
277 `description` varchar(255) COMMENT 'Description of the usage of the password',
278 `hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
279 `generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
280 `last_used` datetime COMMENT 'Datetime the password was last used',
282 INDEX `uid_description` (`uid`,`description`(190)),
283 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
284 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
287 -- TABLE 2fa_recovery_codes
289 CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
290 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
291 `code` varchar(50) NOT NULL COMMENT 'Recovery code string',
292 `generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
293 `used` datetime COMMENT 'Datetime the code was used',
294 PRIMARY KEY(`uid`,`code`),
295 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
296 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
299 -- TABLE 2fa_trusted_browser
301 CREATE TABLE IF NOT EXISTS `2fa_trusted_browser` (
302 `cookie_hash` varchar(80) NOT NULL COMMENT 'Trusted cookie hash',
303 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
304 `user_agent` text COMMENT 'User agent string',
305 `trusted` boolean NOT NULL DEFAULT '1' COMMENT 'Whenever this browser should be trusted or not',
306 `created` datetime NOT NULL COMMENT 'Datetime the trusted browser was recorded',
307 `last_used` datetime COMMENT 'Datetime the trusted browser was last used',
308 PRIMARY KEY(`cookie_hash`),
310 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
311 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication trusted browsers';
314 -- TABLE account-suggestion
316 CREATE TABLE IF NOT EXISTS `account-suggestion` (
317 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the account url',
318 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
319 `level` smallint unsigned COMMENT 'level of closeness',
320 `ignore` boolean NOT NULL DEFAULT '0' COMMENT 'If set, this account will not be suggested again',
321 PRIMARY KEY(`uid`,`uri-id`),
322 INDEX `uri-id_uid` (`uri-id`,`uid`),
323 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
324 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
325 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Account suggestion';
328 -- TABLE account-user
330 CREATE TABLE IF NOT EXISTS `account-user` (
331 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
332 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the account url',
333 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
335 UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
336 INDEX `uid_uri-id` (`uid`,`uri-id`),
337 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
338 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
339 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Remote and local accounts';
344 CREATE TABLE IF NOT EXISTS `addon` (
345 `id` int unsigned NOT NULL auto_increment COMMENT '',
346 `name` varchar(50) NOT NULL DEFAULT '' COMMENT 'addon base (file)name',
347 `version` varchar(50) NOT NULL DEFAULT '' COMMENT 'currently unused',
348 `installed` boolean NOT NULL DEFAULT '0' COMMENT 'currently always 1',
349 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'currently unused',
350 `timestamp` int unsigned NOT NULL DEFAULT 0 COMMENT 'file timestamp to check for reloads',
351 `plugin_admin` boolean NOT NULL DEFAULT '0' COMMENT '1 = has admin config, 0 = has no admin config',
353 INDEX `installed_name` (`installed`,`name`),
354 UNIQUE INDEX `name` (`name`)
355 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registered addons';
360 CREATE TABLE IF NOT EXISTS `apcontact` (
361 `url` varbinary(383) NOT NULL COMMENT 'URL of the contact',
362 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
363 `uuid` varbinary(255) COMMENT '',
364 `type` varchar(20) NOT NULL COMMENT '',
365 `following` varbinary(383) COMMENT '',
366 `followers` varbinary(383) COMMENT '',
367 `inbox` varbinary(383) NOT NULL COMMENT '',
368 `outbox` varbinary(383) COMMENT '',
369 `sharedinbox` varbinary(383) COMMENT '',
370 `featured` varbinary(383) COMMENT 'Address for the collection of featured posts',
371 `featured-tags` varbinary(383) COMMENT 'Address for the collection of featured tags',
372 `manually-approve` boolean COMMENT '',
373 `discoverable` boolean COMMENT 'Mastodon extension: true if profile is published in their directory',
374 `suspended` boolean COMMENT 'Mastodon extension: true if profile is suspended',
375 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
376 `name` varchar(255) COMMENT '',
377 `about` text COMMENT '',
378 `xmpp` varchar(255) COMMENT 'XMPP address',
379 `matrix` varchar(255) COMMENT 'Matrix address',
380 `photo` varbinary(383) COMMENT '',
381 `header` varbinary(383) COMMENT 'Header picture',
382 `addr` varchar(255) COMMENT '',
383 `alias` varbinary(383) COMMENT '',
384 `pubkey` text COMMENT '',
385 `subscribe` varbinary(383) COMMENT '',
386 `baseurl` varbinary(383) COMMENT 'baseurl of the ap contact',
387 `gsid` int unsigned COMMENT 'Global Server ID',
388 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
389 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
390 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
391 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
392 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
394 INDEX `addr` (`addr`(32)),
395 INDEX `alias` (`alias`(190)),
396 INDEX `followers` (`followers`(190)),
397 INDEX `baseurl` (`baseurl`(190)),
398 INDEX `sharedinbox` (`sharedinbox`(190)),
399 INDEX `gsid` (`gsid`),
400 UNIQUE INDEX `uri-id` (`uri-id`),
401 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
402 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
403 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
408 CREATE TABLE IF NOT EXISTS `application` (
409 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
410 `client_id` varchar(64) NOT NULL COMMENT '',
411 `client_secret` varchar(64) NOT NULL COMMENT '',
412 `name` varchar(255) NOT NULL COMMENT '',
413 `redirect_uri` varbinary(383) NOT NULL COMMENT '',
414 `website` varbinary(383) COMMENT '',
415 `scopes` varchar(255) COMMENT '',
416 `read` boolean COMMENT 'Read scope',
417 `write` boolean COMMENT 'Write scope',
418 `follow` boolean COMMENT 'Follow scope',
419 `push` boolean COMMENT 'Push scope',
421 UNIQUE INDEX `client_id` (`client_id`)
422 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth application';
425 -- TABLE application-marker
427 CREATE TABLE IF NOT EXISTS `application-marker` (
428 `application-id` int unsigned NOT NULL COMMENT '',
429 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
430 `timeline` varchar(64) NOT NULL COMMENT 'Marker (home, notifications)',
431 `last_read_id` varbinary(383) COMMENT 'Marker id for the timeline',
432 `version` smallint unsigned COMMENT 'Version number',
433 `updated_at` datetime COMMENT 'creation time',
434 PRIMARY KEY(`application-id`,`uid`,`timeline`),
435 INDEX `uid_id` (`uid`),
436 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
437 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
438 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Timeline marker';
441 -- TABLE application-token
443 CREATE TABLE IF NOT EXISTS `application-token` (
444 `application-id` int unsigned NOT NULL COMMENT '',
445 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
446 `code` varchar(64) NOT NULL COMMENT '',
447 `access_token` varchar(64) NOT NULL COMMENT '',
448 `created_at` datetime NOT NULL COMMENT 'creation time',
449 `scopes` varchar(255) COMMENT '',
450 `read` boolean COMMENT 'Read scope',
451 `write` boolean COMMENT 'Write scope',
452 `follow` boolean COMMENT 'Follow scope',
453 `push` boolean COMMENT 'Push scope',
454 PRIMARY KEY(`application-id`,`uid`),
455 INDEX `uid_id` (`uid`,`application-id`),
456 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
457 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
458 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth user token';
463 CREATE TABLE IF NOT EXISTS `attach` (
464 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
465 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
466 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
467 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
468 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
469 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
470 `data` longblob NOT NULL COMMENT 'file data',
471 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
472 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
473 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
474 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
475 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
476 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
477 `backend-class` tinytext COMMENT 'Storage backend class',
478 `backend-ref` text COMMENT 'Storage backend data reference',
481 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
482 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
487 CREATE TABLE IF NOT EXISTS `cache` (
488 `k` varbinary(255) NOT NULL COMMENT 'cache key',
489 `v` mediumtext COMMENT 'cached serialized value',
490 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
491 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
493 INDEX `k_expires` (`k`,`expires`)
494 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
499 CREATE TABLE IF NOT EXISTS `config` (
500 `id` int unsigned NOT NULL auto_increment COMMENT '',
501 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
502 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
503 `v` mediumtext COMMENT '',
505 UNIQUE INDEX `cat_k` (`cat`,`k`)
506 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
509 -- TABLE contact-relation
511 CREATE TABLE IF NOT EXISTS `contact-relation` (
512 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
513 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
514 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
515 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
516 `follows` boolean NOT NULL DEFAULT '0' COMMENT '',
517 PRIMARY KEY(`cid`,`relation-cid`),
518 INDEX `relation-cid` (`relation-cid`),
519 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
520 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
521 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
526 CREATE TABLE IF NOT EXISTS `conv` (
527 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
528 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
529 `recips` text COMMENT 'sender_handle;recipient_handle',
530 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
531 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
532 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
533 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
534 `subject` text COMMENT 'subject of initial message',
537 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
538 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
543 CREATE TABLE IF NOT EXISTS `workerqueue` (
544 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
545 `command` varchar(100) COMMENT 'Task command',
546 `parameter` mediumtext COMMENT 'Task parameter',
547 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
548 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
549 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
550 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
551 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
552 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
553 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
555 INDEX `command` (`command`),
556 INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
557 INDEX `done_executed` (`done`,`executed`),
558 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
559 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
560 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
561 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
562 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
563 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
566 -- TABLE delayed-post
568 CREATE TABLE IF NOT EXISTS `delayed-post` (
569 `id` int unsigned NOT NULL auto_increment,
570 `uri` varbinary(383) COMMENT 'URI of the post that will be distributed later',
571 `uid` mediumint unsigned COMMENT 'Owner User id',
572 `delayed` datetime COMMENT 'delay time',
573 `wid` int unsigned COMMENT 'Workerqueue id',
575 UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
577 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
578 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
579 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
582 -- TABLE diaspora-interaction
584 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
585 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
586 `interaction` mediumtext COMMENT 'The Diaspora interaction',
587 PRIMARY KEY(`uri-id`),
588 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
589 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
594 CREATE TABLE IF NOT EXISTS `endpoint` (
595 `url` varbinary(383) NOT NULL COMMENT 'URL of the contact',
596 `type` varchar(20) NOT NULL COMMENT '',
597 `owner-uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
599 UNIQUE INDEX `owner-uri-id_type` (`owner-uri-id`,`type`),
600 FOREIGN KEY (`owner-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
601 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub endpoints - used in the ActivityPub implementation';
606 CREATE TABLE IF NOT EXISTS `event` (
607 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
608 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
609 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
610 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
611 `uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
612 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the event uri',
613 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
614 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
615 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
616 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
617 `summary` text COMMENT 'short description or title of the event',
618 `desc` text COMMENT 'event description',
619 `location` text COMMENT 'event location',
620 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
621 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
622 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
623 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
624 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
625 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
626 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
628 INDEX `uid_start` (`uid`,`start`),
630 INDEX `uri-id` (`uri-id`),
631 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
632 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
633 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
634 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
639 CREATE TABLE IF NOT EXISTS `fcontact` (
640 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
641 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'unique id',
642 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
643 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the fcontact url',
644 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
645 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
646 `request` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
647 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
648 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
649 `batch` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
650 `notify` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
651 `poll` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
652 `confirm` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
653 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
654 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
655 `alias` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
656 `pubkey` text COMMENT '',
657 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
658 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
659 `interacting_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts this contact interactes with',
660 `interacted_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts that interacted with this contact',
661 `post_count` int unsigned DEFAULT 0 COMMENT 'Number of posts and comments',
663 INDEX `addr` (`addr`(32)),
664 UNIQUE INDEX `url` (`url`(190)),
665 UNIQUE INDEX `uri-id` (`uri-id`),
666 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
667 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
672 CREATE TABLE IF NOT EXISTS `fetch-entry` (
673 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
674 `url` varbinary(383) COMMENT 'url that awaiting to be fetched',
675 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of the fetch request',
676 `wid` int unsigned COMMENT 'Workerqueue id',
678 UNIQUE INDEX `url` (`url`),
679 INDEX `created` (`created`),
681 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
682 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
687 CREATE TABLE IF NOT EXISTS `fsuggest` (
688 `id` int unsigned NOT NULL auto_increment COMMENT '',
689 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
690 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
691 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
692 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
693 `request` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
694 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
695 `note` text COMMENT '',
696 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
700 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
701 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
702 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
707 CREATE TABLE IF NOT EXISTS `group` (
708 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
709 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
710 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
711 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
712 `cid` int unsigned COMMENT 'Contact id of forum. When this field is filled then the members are synced automatically.',
713 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
717 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
718 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
719 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
722 -- TABLE group_member
724 CREATE TABLE IF NOT EXISTS `group_member` (
725 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
726 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
727 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
729 INDEX `contactid` (`contact-id`),
730 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
731 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
732 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
733 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
738 CREATE TABLE IF NOT EXISTS `gserver-tag` (
739 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
740 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
741 PRIMARY KEY(`gserver-id`,`tag`),
743 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
744 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
749 CREATE TABLE IF NOT EXISTS `hook` (
750 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
751 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
752 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
753 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
754 `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',
756 INDEX `priority` (`priority`),
757 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
758 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
763 CREATE TABLE IF NOT EXISTS `inbox-entry` (
764 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
765 `activity-id` varbinary(383) COMMENT 'id of the incoming activity',
766 `object-id` varbinary(383) COMMENT '',
767 `in-reply-to-id` varbinary(383) COMMENT '',
768 `conversation` varbinary(383) COMMENT '',
769 `type` varchar(64) COMMENT 'Type of the activity',
770 `object-type` varchar(64) COMMENT 'Type of the object activity',
771 `object-object-type` varchar(64) COMMENT 'Type of the object\'s object activity',
772 `received` datetime COMMENT 'Receiving date',
773 `activity` mediumtext COMMENT 'The JSON activity',
774 `signer` varchar(255) COMMENT '',
775 `push` boolean COMMENT 'Is the entry pushed or have pulled it?',
776 `trust` boolean COMMENT 'Do we trust this entry?',
777 `wid` int unsigned COMMENT 'Workerqueue id',
779 UNIQUE INDEX `activity-id` (`activity-id`),
780 INDEX `object-id` (`object-id`),
781 INDEX `received` (`received`),
783 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
784 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Incoming activity';
787 -- TABLE inbox-entry-receiver
789 CREATE TABLE IF NOT EXISTS `inbox-entry-receiver` (
790 `queue-id` int unsigned NOT NULL COMMENT '',
791 `uid` mediumint unsigned NOT NULL COMMENT 'User id',
792 PRIMARY KEY(`queue-id`,`uid`),
794 FOREIGN KEY (`queue-id`) REFERENCES `inbox-entry` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
795 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
796 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Receiver for the incoming activity';
799 -- TABLE inbox-status
801 CREATE TABLE IF NOT EXISTS `inbox-status` (
802 `url` varbinary(383) NOT NULL COMMENT 'URL of the inbox',
803 `uri-id` int unsigned COMMENT 'Item-uri id of inbox url',
804 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
805 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
806 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
807 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
808 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
809 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
811 INDEX `uri-id` (`uri-id`),
812 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
813 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
818 CREATE TABLE IF NOT EXISTS `intro` (
819 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
820 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
821 `fid` int unsigned COMMENT 'deprecated',
822 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
823 `suggest-cid` int unsigned COMMENT 'Suggested contact',
824 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
825 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
826 `note` text COMMENT '',
827 `hash` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
828 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
829 `blocked` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
830 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
832 INDEX `contact-id` (`contact-id`),
833 INDEX `suggest-cid` (`suggest-cid`),
835 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
836 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
837 FOREIGN KEY (`suggest-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
838 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
843 CREATE TABLE IF NOT EXISTS `locks` (
844 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
845 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
846 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
847 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
848 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
850 INDEX `name_expires` (`name`,`expires`)
851 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
856 CREATE TABLE IF NOT EXISTS `mail` (
857 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
858 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
859 `guid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
860 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
861 `from-photo` varbinary(383) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
862 `from-url` varbinary(383) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
863 `contact-id` varbinary(255) COMMENT 'contact.id',
864 `author-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the author of the mail',
865 `convid` int unsigned COMMENT 'conv.id',
866 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
867 `body` mediumtext COMMENT '',
868 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
869 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
870 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
871 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
872 `uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
873 `uri-id` int unsigned COMMENT 'Item-uri id of the related mail',
874 `parent-uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
875 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related mail',
876 `thr-parent` varbinary(383) COMMENT '',
877 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
878 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
880 INDEX `uid_seen` (`uid`,`seen`),
881 INDEX `convid` (`convid`),
882 INDEX `uri` (`uri`(64)),
883 INDEX `parent-uri` (`parent-uri`(64)),
884 INDEX `contactid` (`contact-id`(32)),
885 INDEX `author-id` (`author-id`),
886 INDEX `uri-id` (`uri-id`),
887 INDEX `parent-uri-id` (`parent-uri-id`),
888 INDEX `thr-parent-id` (`thr-parent-id`),
889 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
890 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
891 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
892 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
893 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
894 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
899 CREATE TABLE IF NOT EXISTS `mailacct` (
900 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
901 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
902 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
903 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
904 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
905 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
906 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
907 `pass` text COMMENT '',
908 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
909 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
910 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
911 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
912 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
915 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
916 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
921 CREATE TABLE IF NOT EXISTS `manage` (
922 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
923 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
924 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
926 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
928 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
929 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
930 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
933 -- TABLE notification
935 CREATE TABLE IF NOT EXISTS `notification` (
936 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
937 `uid` mediumint unsigned COMMENT 'Owner User id',
938 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
939 `type` smallint unsigned COMMENT '',
940 `actor-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the actor that caused the notification',
941 `target-uri-id` int unsigned COMMENT 'Item-uri id of the related post',
942 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
943 `created` datetime COMMENT '',
944 `seen` boolean DEFAULT '0' COMMENT 'Seen on the desktop',
945 `dismissed` boolean DEFAULT '0' COMMENT 'Dismissed via the API',
947 UNIQUE INDEX `uid_vid_type_actor-id_target-uri-id` (`uid`,`vid`,`type`,`actor-id`,`target-uri-id`),
949 INDEX `actor-id` (`actor-id`),
950 INDEX `target-uri-id` (`target-uri-id`),
951 INDEX `parent-uri-id` (`parent-uri-id`),
952 INDEX `seen_uid` (`seen`,`uid`),
953 INDEX `uid_type_parent-uri-id_actor-id` (`uid`,`type`,`parent-uri-id`,`actor-id`),
954 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
955 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
956 FOREIGN KEY (`actor-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
957 FOREIGN KEY (`target-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
958 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
959 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
964 CREATE TABLE IF NOT EXISTS `notify` (
965 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
966 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
967 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
968 `url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
969 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
970 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
971 `msg` mediumtext COMMENT '',
972 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
973 `link` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
974 `iid` int unsigned COMMENT '',
975 `parent` int unsigned COMMENT '',
976 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
977 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
978 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
979 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
980 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
981 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
982 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
984 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
985 INDEX `uid_date` (`uid`,`date`),
986 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
987 INDEX `uri-id` (`uri-id`),
988 INDEX `parent-uri-id` (`parent-uri-id`),
989 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
990 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
991 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
992 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='[Deprecated] User notifications';
995 -- TABLE notify-threads
997 CREATE TABLE IF NOT EXISTS `notify-threads` (
998 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
999 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1000 `master-parent-item` int unsigned COMMENT 'Deprecated',
1001 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
1002 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1003 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1005 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
1006 INDEX `receiver-uid` (`receiver-uid`),
1007 INDEX `notify-id` (`notify-id`),
1008 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1009 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1010 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1011 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1016 CREATE TABLE IF NOT EXISTS `oembed` (
1017 `url` varbinary(383) NOT NULL COMMENT 'page url',
1018 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
1019 `content` mediumtext COMMENT 'OEmbed data of the page',
1020 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1021 PRIMARY KEY(`url`,`maxwidth`),
1022 INDEX `created` (`created`)
1023 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
1026 -- TABLE openwebauth-token
1028 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
1029 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1030 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
1031 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
1032 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
1033 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1034 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1036 INDEX `uid` (`uid`),
1037 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1038 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
1043 CREATE TABLE IF NOT EXISTS `parsed_url` (
1044 `url_hash` binary(64) NOT NULL COMMENT 'page url hash',
1045 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
1046 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
1047 `url` text NOT NULL COMMENT 'page url',
1048 `content` mediumtext COMMENT 'page data',
1049 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1050 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration',
1051 PRIMARY KEY(`url_hash`,`guessing`,`oembed`),
1052 INDEX `created` (`created`),
1053 INDEX `expires` (`expires`)
1054 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
1059 CREATE TABLE IF NOT EXISTS `pconfig` (
1060 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
1061 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1062 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
1063 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
1064 `v` mediumtext COMMENT 'Value',
1066 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
1067 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1068 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
1073 CREATE TABLE IF NOT EXISTS `photo` (
1074 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1075 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1076 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1077 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
1078 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
1079 `hash` char(32) COMMENT 'hash value of the photo',
1080 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
1081 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
1082 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1083 `desc` text COMMENT '',
1084 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
1085 `photo-type` tinyint unsigned COMMENT 'User avatar, user banner, contact avatar, contact banner or default',
1086 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1087 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
1088 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1089 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1090 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1091 `data` mediumblob NOT NULL COMMENT '',
1092 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1093 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
1094 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
1095 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
1096 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
1097 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
1098 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
1099 `backend-class` tinytext COMMENT 'Storage backend class',
1100 `backend-ref` text COMMENT 'Storage backend data reference',
1101 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1103 INDEX `contactid` (`contact-id`),
1104 INDEX `uid_contactid` (`uid`,`contact-id`),
1105 INDEX `uid_profile` (`uid`,`profile`),
1106 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
1107 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
1108 INDEX `resource-id` (`resource-id`),
1109 INDEX `uid_photo-type` (`uid`,`photo-type`),
1110 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1111 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1112 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1117 CREATE TABLE IF NOT EXISTS `post` (
1118 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1119 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1120 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1121 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1122 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1123 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1124 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1125 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1126 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1127 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1128 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1129 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1130 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1131 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1132 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1133 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1134 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1135 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1136 PRIMARY KEY(`uri-id`),
1137 INDEX `parent-uri-id` (`parent-uri-id`),
1138 INDEX `thr-parent-id` (`thr-parent-id`),
1139 INDEX `external-id` (`external-id`),
1140 INDEX `owner-id` (`owner-id`),
1141 INDEX `author-id` (`author-id`),
1142 INDEX `causer-id` (`causer-id`),
1143 INDEX `vid` (`vid`),
1144 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1145 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1146 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1147 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1148 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1149 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1150 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1151 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1152 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
1155 -- TABLE post-activity
1157 CREATE TABLE IF NOT EXISTS `post-activity` (
1158 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1159 `activity` mediumtext COMMENT 'Original activity',
1160 `received` datetime COMMENT '',
1161 PRIMARY KEY(`uri-id`),
1162 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1163 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Original remote activity';
1166 -- TABLE post-category
1168 CREATE TABLE IF NOT EXISTS `post-category` (
1169 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1170 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1171 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1172 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1173 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1174 INDEX `tid` (`tid`),
1175 INDEX `uid_uri-id` (`uid`,`uri-id`),
1176 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1177 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1178 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1179 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1182 -- TABLE post-collection
1184 CREATE TABLE IF NOT EXISTS `post-collection` (
1185 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1186 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0 - Featured',
1187 `author-id` int unsigned COMMENT 'Author of the featured post',
1188 PRIMARY KEY(`uri-id`,`type`),
1189 INDEX `type` (`type`),
1190 INDEX `author-id` (`author-id`),
1191 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1192 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1193 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Collection of posts';
1196 -- TABLE post-content
1198 CREATE TABLE IF NOT EXISTS `post-content` (
1199 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1200 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1201 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1202 `body` mediumtext COMMENT 'item body content',
1203 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1204 `quote-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the quoted uri',
1205 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1206 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1207 `language` text COMMENT 'Language information about this post',
1208 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1209 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1210 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1211 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1212 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1213 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1214 `target` text COMMENT 'JSON encoded target structure if used',
1215 `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',
1216 `plink` varbinary(383) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1217 PRIMARY KEY(`uri-id`),
1218 INDEX `plink` (`plink`(191)),
1219 INDEX `resource-id` (`resource-id`),
1220 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
1221 INDEX `quote-uri-id` (`quote-uri-id`),
1222 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1223 FOREIGN KEY (`quote-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1224 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1227 -- TABLE post-delivery
1229 CREATE TABLE IF NOT EXISTS `post-delivery` (
1230 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1231 `inbox-id` int unsigned NOT NULL COMMENT 'Item-uri id of inbox url',
1232 `uid` mediumint unsigned COMMENT 'Delivering user',
1233 `created` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
1234 `command` varbinary(32) COMMENT '',
1235 `failed` tinyint DEFAULT 0 COMMENT 'Number of times the delivery has failed',
1236 `receivers` mediumtext COMMENT 'JSON encoded array with the receiving contacts',
1237 PRIMARY KEY(`uri-id`,`inbox-id`),
1238 INDEX `inbox-id_created` (`inbox-id`,`created`),
1239 INDEX `uid` (`uid`),
1240 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1241 FOREIGN KEY (`inbox-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1242 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1243 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for posts for the batch processing';
1246 -- TABLE post-delivery-data
1248 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1249 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1250 `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',
1251 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1252 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1253 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1254 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1255 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1256 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1257 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1258 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1259 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1260 PRIMARY KEY(`uri-id`),
1261 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1262 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1265 -- TABLE post-history
1267 CREATE TABLE IF NOT EXISTS `post-history` (
1268 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1269 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of edit',
1270 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1271 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1272 `body` mediumtext COMMENT 'item body content',
1273 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1274 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1275 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1276 `language` text COMMENT 'Language information about this post',
1277 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1278 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1279 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1280 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1281 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1282 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1283 `target` text COMMENT 'JSON encoded target structure if used',
1284 `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',
1285 `plink` varbinary(383) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1286 PRIMARY KEY(`uri-id`,`edited`),
1287 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1288 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post history';
1293 CREATE TABLE IF NOT EXISTS `post-link` (
1294 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1295 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1296 `url` varbinary(511) NOT NULL COMMENT 'External URL',
1297 `mimetype` varchar(60) COMMENT '',
1299 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1300 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1301 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post related external links';
1306 CREATE TABLE IF NOT EXISTS `post-media` (
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(1024) NOT NULL COMMENT 'Media URL',
1310 `media-uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the activities uri-id',
1311 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1312 `mimetype` varchar(60) COMMENT '',
1313 `height` smallint unsigned COMMENT 'Height of the media',
1314 `width` smallint unsigned COMMENT 'Width of the media',
1315 `size` bigint unsigned COMMENT 'Media size',
1316 `preview` varbinary(512) COMMENT 'Preview URL',
1317 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1318 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1319 `description` text COMMENT '',
1320 `name` varchar(255) COMMENT 'Name of the media',
1321 `author-url` varbinary(383) COMMENT 'URL of the author of the media',
1322 `author-name` varchar(255) COMMENT 'Name of the author of the media',
1323 `author-image` varbinary(383) COMMENT 'Image of the author of the media',
1324 `publisher-url` varbinary(383) COMMENT 'URL of the publisher of the media',
1325 `publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
1326 `publisher-image` varbinary(383) COMMENT 'Image of the publisher of the media',
1328 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`(512)),
1329 INDEX `uri-id-id` (`uri-id`,`id`),
1330 INDEX `media-uri-id` (`media-uri-id`),
1331 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1332 FOREIGN KEY (`media-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1333 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1336 -- TABLE post-question
1338 CREATE TABLE IF NOT EXISTS `post-question` (
1339 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1340 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1341 `multiple` boolean NOT NULL DEFAULT '0' COMMENT 'Multiple choice',
1342 `voters` int unsigned COMMENT 'Number of voters for this question',
1343 `end-time` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Question end time',
1345 UNIQUE INDEX `uri-id` (`uri-id`),
1346 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1347 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question';
1350 -- TABLE post-question-option
1352 CREATE TABLE IF NOT EXISTS `post-question-option` (
1353 `id` int unsigned NOT NULL COMMENT 'Id of the question',
1354 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1355 `name` varchar(255) COMMENT 'Name of the option',
1356 `replies` int unsigned COMMENT 'Number of replies for this question option',
1357 PRIMARY KEY(`uri-id`,`id`),
1358 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1359 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question option';
1364 CREATE TABLE IF NOT EXISTS `post-tag` (
1365 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1366 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1367 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1368 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1369 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1370 INDEX `tid` (`tid`),
1371 INDEX `cid` (`cid`),
1372 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1373 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1374 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1375 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1378 -- TABLE post-thread
1380 CREATE TABLE IF NOT EXISTS `post-thread` (
1381 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1382 `conversation-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the conversation uri',
1383 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1384 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1385 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1386 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1387 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1388 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1389 `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',
1390 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1391 PRIMARY KEY(`uri-id`),
1392 INDEX `conversation-id` (`conversation-id`),
1393 INDEX `owner-id` (`owner-id`),
1394 INDEX `author-id` (`author-id`),
1395 INDEX `causer-id` (`causer-id`),
1396 INDEX `received` (`received`),
1397 INDEX `commented` (`commented`),
1398 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1399 FOREIGN KEY (`conversation-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1400 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1401 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1402 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1403 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1408 CREATE TABLE IF NOT EXISTS `post-user` (
1409 `id` int unsigned NOT NULL auto_increment,
1410 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1411 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1412 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1413 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1414 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1415 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1416 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1417 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1418 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1419 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1420 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1421 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1422 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1423 `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
1424 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1425 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1426 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1427 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1428 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1429 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1430 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1431 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1432 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1433 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1434 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1435 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1436 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1437 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1438 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1440 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1441 INDEX `uri-id` (`uri-id`),
1442 INDEX `parent-uri-id` (`parent-uri-id`),
1443 INDEX `thr-parent-id` (`thr-parent-id`),
1444 INDEX `external-id` (`external-id`),
1445 INDEX `owner-id` (`owner-id`),
1446 INDEX `author-id` (`author-id`),
1447 INDEX `causer-id` (`causer-id`),
1448 INDEX `vid` (`vid`),
1449 INDEX `contact-id` (`contact-id`),
1450 INDEX `event-id` (`event-id`),
1451 INDEX `psid` (`psid`),
1452 INDEX `author-id_uid` (`author-id`,`uid`),
1453 INDEX `author-id_received` (`author-id`,`received`),
1454 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1455 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1456 INDEX `uid_contactid` (`uid`,`contact-id`),
1457 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1458 INDEX `uid_unseen` (`uid`,`unseen`),
1459 INDEX `uid_hidden_uri-id` (`uid`,`hidden`,`uri-id`),
1460 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1461 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1462 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1463 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1464 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1465 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1466 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1467 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1468 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1469 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1470 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1471 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1472 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1475 -- TABLE post-thread-user
1477 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1478 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1479 `conversation-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the conversation uri',
1480 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1481 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1482 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1483 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1484 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1485 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1486 `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',
1487 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1488 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1489 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
1490 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1491 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1492 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1493 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1494 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1495 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Deprecated',
1496 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1497 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1498 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1499 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1500 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1501 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1502 PRIMARY KEY(`uid`,`uri-id`),
1503 INDEX `uri-id` (`uri-id`),
1504 INDEX `conversation-id` (`conversation-id`),
1505 INDEX `owner-id` (`owner-id`),
1506 INDEX `author-id` (`author-id`),
1507 INDEX `causer-id` (`causer-id`),
1508 INDEX `uid` (`uid`),
1509 INDEX `contact-id` (`contact-id`),
1510 INDEX `psid` (`psid`),
1511 INDEX `post-user-id` (`post-user-id`),
1512 INDEX `commented` (`commented`),
1513 INDEX `uid_received` (`uid`,`received`),
1514 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1515 INDEX `uid_commented` (`uid`,`commented`),
1516 INDEX `uid_starred` (`uid`,`starred`),
1517 INDEX `uid_mention` (`uid`,`mention`),
1518 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1519 FOREIGN KEY (`conversation-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1520 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1521 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1522 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1523 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1524 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1525 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1526 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1527 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1530 -- TABLE post-user-notification
1532 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1533 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1534 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1535 `notification-type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1536 PRIMARY KEY(`uid`,`uri-id`),
1537 INDEX `uri-id` (`uri-id`),
1538 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1539 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1540 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1545 CREATE TABLE IF NOT EXISTS `process` (
1546 `pid` int unsigned NOT NULL COMMENT 'The ID of the process',
1547 `hostname` varchar(32) NOT NULL COMMENT 'The name of the host the process is ran on',
1548 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1549 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1550 PRIMARY KEY(`pid`,`hostname`),
1551 INDEX `command` (`command`)
1552 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1557 CREATE TABLE IF NOT EXISTS `profile` (
1558 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1559 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1560 `profile-name` varchar(255) COMMENT 'Deprecated',
1561 `is-default` boolean COMMENT 'Deprecated',
1562 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1563 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1564 `pdesc` varchar(255) COMMENT 'Deprecated',
1565 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1566 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1567 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1568 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1569 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1570 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1571 `hometown` varchar(255) COMMENT 'Deprecated',
1572 `gender` varchar(32) COMMENT 'Deprecated',
1573 `marital` varchar(255) COMMENT 'Deprecated',
1574 `with` text COMMENT 'Deprecated',
1575 `howlong` datetime COMMENT 'Deprecated',
1576 `sexual` varchar(255) COMMENT 'Deprecated',
1577 `politic` varchar(255) COMMENT 'Deprecated',
1578 `religion` varchar(255) COMMENT 'Deprecated',
1579 `pub_keywords` text COMMENT '',
1580 `prv_keywords` text COMMENT '',
1581 `likes` text COMMENT 'Deprecated',
1582 `dislikes` text COMMENT 'Deprecated',
1583 `about` text COMMENT 'Profile description',
1584 `summary` varchar(255) COMMENT 'Deprecated',
1585 `music` text COMMENT 'Deprecated',
1586 `book` text COMMENT 'Deprecated',
1587 `tv` text COMMENT 'Deprecated',
1588 `film` text COMMENT 'Deprecated',
1589 `interest` text COMMENT 'Deprecated',
1590 `romance` text COMMENT 'Deprecated',
1591 `work` text COMMENT 'Deprecated',
1592 `education` text COMMENT 'Deprecated',
1593 `contact` text COMMENT 'Deprecated',
1594 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1595 `homepage_verified` boolean NOT NULL DEFAULT '0' COMMENT 'was the homepage verified by a rel-me link back to the profile',
1596 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
1597 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
1598 `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1599 `thumb` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1600 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1601 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1603 INDEX `uid_is-default` (`uid`,`is-default`),
1604 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1605 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1606 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1609 -- TABLE profile_field
1611 CREATE TABLE IF NOT EXISTS `profile_field` (
1612 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1613 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1614 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1615 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1616 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1617 `value` text COMMENT 'Value of the field',
1618 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1619 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1621 INDEX `uid` (`uid`),
1622 INDEX `order` (`order`),
1623 INDEX `psid` (`psid`),
1624 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1625 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1626 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1629 -- TABLE push_subscriber
1631 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1632 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1633 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1634 `callback_url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
1635 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1636 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1637 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1638 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1639 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1640 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1641 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1643 INDEX `next_try` (`next_try`),
1644 INDEX `uid` (`uid`),
1645 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1646 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1651 CREATE TABLE IF NOT EXISTS `register` (
1652 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1653 `hash` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1654 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1655 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1656 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1657 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1658 `note` text COMMENT '',
1660 INDEX `uid` (`uid`),
1661 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1662 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1667 CREATE TABLE IF NOT EXISTS `report` (
1668 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1669 `uid` mediumint unsigned COMMENT 'Reporting user',
1670 `cid` int unsigned NOT NULL COMMENT 'Reported contact',
1671 `comment` text COMMENT 'Report',
1672 `forward` boolean COMMENT 'Forward the report to the remote server',
1673 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1674 `status` tinyint unsigned COMMENT 'Status of the report',
1676 INDEX `uid` (`uid`),
1677 INDEX `cid` (`cid`),
1678 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1679 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1680 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1683 -- TABLE report-post
1685 CREATE TABLE IF NOT EXISTS `report-post` (
1686 `rid` int unsigned NOT NULL COMMENT 'Report id',
1687 `uri-id` int unsigned NOT NULL COMMENT 'Uri-id of the reported post',
1688 `status` tinyint unsigned COMMENT 'Status of the reported post',
1689 PRIMARY KEY(`rid`,`uri-id`),
1690 INDEX `uri-id` (`uri-id`),
1691 FOREIGN KEY (`rid`) REFERENCES `report` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1692 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1693 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1698 CREATE TABLE IF NOT EXISTS `search` (
1699 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1700 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1701 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1703 INDEX `uid_term` (`uid`,`term`(64)),
1704 INDEX `term` (`term`(64)),
1705 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1706 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1711 CREATE TABLE IF NOT EXISTS `session` (
1712 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1713 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1714 `data` text COMMENT '',
1715 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1717 INDEX `sid` (`sid`(64)),
1718 INDEX `expire` (`expire`)
1719 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1724 CREATE TABLE IF NOT EXISTS `storage` (
1725 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1726 `data` longblob NOT NULL COMMENT 'file data',
1728 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1731 -- TABLE subscription
1733 CREATE TABLE IF NOT EXISTS `subscription` (
1734 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1735 `application-id` int unsigned NOT NULL COMMENT '',
1736 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
1737 `endpoint` varchar(511) COMMENT 'Endpoint URL',
1738 `pubkey` varchar(127) COMMENT 'User agent public key',
1739 `secret` varchar(32) COMMENT 'Auth secret',
1740 `follow` boolean COMMENT '',
1741 `favourite` boolean COMMENT '',
1742 `reblog` boolean COMMENT '',
1743 `mention` boolean COMMENT '',
1744 `poll` boolean COMMENT '',
1745 `follow_request` boolean COMMENT '',
1746 `status` boolean COMMENT '',
1748 UNIQUE INDEX `application-id_uid` (`application-id`,`uid`),
1749 INDEX `uid_application-id` (`uid`,`application-id`),
1750 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1751 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1752 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Push Subscription for the API';
1757 CREATE TABLE IF NOT EXISTS `userd` (
1758 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1759 `username` varchar(255) NOT NULL COMMENT '',
1761 INDEX `username` (`username`(32))
1762 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1765 -- TABLE user-contact
1767 CREATE TABLE IF NOT EXISTS `user-contact` (
1768 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1769 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1770 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
1771 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1772 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1773 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1774 `hidden` boolean COMMENT 'This contact is hidden from the others',
1775 `is-blocked` boolean COMMENT 'User is blocked by this contact',
1776 `pending` boolean COMMENT '',
1777 `rel` tinyint unsigned COMMENT 'The kind of the relation between the user and the contact',
1778 `info` mediumtext COMMENT '',
1779 `notify_new_posts` boolean COMMENT '',
1780 `remote_self` boolean COMMENT '',
1781 `fetch_further_information` tinyint unsigned COMMENT '',
1782 `ffi_keyword_denylist` text COMMENT '',
1783 `subhub` boolean COMMENT '',
1784 `hub-verify` varbinary(383) COMMENT '',
1785 `protocol` char(4) COMMENT 'Protocol of the contact',
1786 `rating` tinyint COMMENT 'Automatically detected feed poll frequency',
1787 `priority` tinyint unsigned COMMENT 'Feed poll priority',
1788 PRIMARY KEY(`uid`,`cid`),
1789 INDEX `cid` (`cid`),
1790 UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
1791 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1792 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1793 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1794 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1797 -- TABLE arrived-activity
1799 CREATE TABLE IF NOT EXISTS `arrived-activity` (
1800 `object-id` varbinary(383) NOT NULL COMMENT 'object id of the incoming activity',
1801 `received` datetime COMMENT 'Receiving date',
1802 PRIMARY KEY(`object-id`)
1803 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Id of arrived activities';
1806 -- TABLE fetched-activity
1808 CREATE TABLE IF NOT EXISTS `fetched-activity` (
1809 `object-id` varbinary(383) NOT NULL COMMENT 'object id of fetched activity',
1810 `received` datetime COMMENT 'Receiving date',
1811 PRIMARY KEY(`object-id`)
1812 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Id of fetched activities';
1817 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1818 `key` int NOT NULL COMMENT '',
1819 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1821 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1824 -- VIEW application-view
1826 DROP VIEW IF EXISTS `application-view`;
1827 CREATE VIEW `application-view` AS SELECT
1828 `application`.`id` AS `id`,
1829 `application-token`.`uid` AS `uid`,
1830 `application`.`name` AS `name`,
1831 `application`.`redirect_uri` AS `redirect_uri`,
1832 `application`.`website` AS `website`,
1833 `application`.`client_id` AS `client_id`,
1834 `application`.`client_secret` AS `client_secret`,
1835 `application-token`.`code` AS `code`,
1836 `application-token`.`access_token` AS `access_token`,
1837 `application-token`.`created_at` AS `created_at`,
1838 `application-token`.`scopes` AS `scopes`,
1839 `application-token`.`read` AS `read`,
1840 `application-token`.`write` AS `write`,
1841 `application-token`.`follow` AS `follow`,
1842 `application-token`.`push` AS `push`
1843 FROM `application-token`
1844 INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`;
1847 -- VIEW post-user-view
1849 DROP VIEW IF EXISTS `post-user-view`;
1850 CREATE VIEW `post-user-view` AS SELECT
1851 `post-user`.`id` AS `id`,
1852 `post-user`.`id` AS `post-user-id`,
1853 `post-user`.`uid` AS `uid`,
1854 `parent-post`.`id` AS `parent`,
1855 `item-uri`.`uri` AS `uri`,
1856 `post-user`.`uri-id` AS `uri-id`,
1857 `parent-item-uri`.`uri` AS `parent-uri`,
1858 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1859 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1860 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1861 `conversation-item-uri`.`uri` AS `conversation`,
1862 `post-thread-user`.`conversation-id` AS `conversation-id`,
1863 `quote-item-uri`.`uri` AS `quote-uri`,
1864 `post-content`.`quote-uri-id` AS `quote-uri-id`,
1865 `item-uri`.`guid` AS `guid`,
1866 `post-user`.`wall` AS `wall`,
1867 `post-user`.`gravity` AS `gravity`,
1868 `external-item-uri`.`uri` AS `extid`,
1869 `post-user`.`external-id` AS `external-id`,
1870 `post-user`.`created` AS `created`,
1871 `post-user`.`edited` AS `edited`,
1872 `post-thread-user`.`commented` AS `commented`,
1873 `post-user`.`received` AS `received`,
1874 `post-thread-user`.`changed` AS `changed`,
1875 `post-user`.`post-type` AS `post-type`,
1876 `post-user`.`post-reason` AS `post-reason`,
1877 `post-user`.`private` AS `private`,
1878 `post-thread-user`.`pubmail` AS `pubmail`,
1879 `post-user`.`visible` AS `visible`,
1880 `post-thread-user`.`starred` AS `starred`,
1881 `post-user`.`unseen` AS `unseen`,
1882 `post-user`.`deleted` AS `deleted`,
1883 `post-user`.`origin` AS `origin`,
1884 `post-thread-user`.`origin` AS `parent-origin`,
1885 `post-thread-user`.`mention` AS `mention`,
1886 `post-user`.`global` AS `global`,
1887 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-user`.`uri-id`) AS `featured`,
1888 `post-user`.`network` AS `network`,
1889 `post-user`.`protocol` AS `protocol`,
1890 `post-user`.`vid` AS `vid`,
1891 `post-user`.`psid` AS `psid`,
1892 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1893 `post-content`.`title` AS `title`,
1894 `post-content`.`content-warning` AS `content-warning`,
1895 `post-content`.`raw-body` AS `raw-body`,
1896 IFNULL (`post-content`.`body`, '') AS `body`,
1897 `post-content`.`rendered-hash` AS `rendered-hash`,
1898 `post-content`.`rendered-html` AS `rendered-html`,
1899 `post-content`.`language` AS `language`,
1900 `post-content`.`plink` AS `plink`,
1901 `post-content`.`location` AS `location`,
1902 `post-content`.`coord` AS `coord`,
1903 `post-content`.`app` AS `app`,
1904 `post-content`.`object-type` AS `object-type`,
1905 `post-content`.`object` AS `object`,
1906 `post-content`.`target-type` AS `target-type`,
1907 `post-content`.`target` AS `target`,
1908 `post-content`.`resource-id` AS `resource-id`,
1909 `post-user`.`contact-id` AS `contact-id`,
1910 `contact`.`uri-id` AS `contact-uri-id`,
1911 `contact`.`url` AS `contact-link`,
1912 `contact`.`addr` AS `contact-addr`,
1913 `contact`.`name` AS `contact-name`,
1914 `contact`.`nick` AS `contact-nick`,
1915 `contact`.`thumb` AS `contact-avatar`,
1916 `contact`.`network` AS `contact-network`,
1917 `contact`.`blocked` AS `contact-blocked`,
1918 `contact`.`hidden` AS `contact-hidden`,
1919 `contact`.`readonly` AS `contact-readonly`,
1920 `contact`.`archive` AS `contact-archive`,
1921 `contact`.`pending` AS `contact-pending`,
1922 `contact`.`rel` AS `contact-rel`,
1923 `contact`.`uid` AS `contact-uid`,
1924 `contact`.`contact-type` AS `contact-contact-type`,
1925 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1926 `contact`.`self` AS `self`,
1927 `contact`.`id` AS `cid`,
1928 `contact`.`alias` AS `alias`,
1929 `contact`.`photo` AS `photo`,
1930 `contact`.`name-date` AS `name-date`,
1931 `contact`.`uri-date` AS `uri-date`,
1932 `contact`.`avatar-date` AS `avatar-date`,
1933 `contact`.`thumb` AS `thumb`,
1934 `post-user`.`author-id` AS `author-id`,
1935 `author`.`uri-id` AS `author-uri-id`,
1936 `author`.`url` AS `author-link`,
1937 `author`.`addr` AS `author-addr`,
1938 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1939 `author`.`nick` AS `author-nick`,
1940 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1941 `author`.`network` AS `author-network`,
1942 `author`.`blocked` AS `author-blocked`,
1943 `author`.`hidden` AS `author-hidden`,
1944 `author`.`updated` AS `author-updated`,
1945 `author`.`gsid` AS `author-gsid`,
1946 `post-user`.`owner-id` AS `owner-id`,
1947 `owner`.`uri-id` AS `owner-uri-id`,
1948 `owner`.`url` AS `owner-link`,
1949 `owner`.`addr` AS `owner-addr`,
1950 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1951 `owner`.`nick` AS `owner-nick`,
1952 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1953 `owner`.`network` AS `owner-network`,
1954 `owner`.`blocked` AS `owner-blocked`,
1955 `owner`.`hidden` AS `owner-hidden`,
1956 `owner`.`updated` AS `owner-updated`,
1957 `owner`.`contact-type` AS `owner-contact-type`,
1958 `post-user`.`causer-id` AS `causer-id`,
1959 `causer`.`uri-id` AS `causer-uri-id`,
1960 `causer`.`url` AS `causer-link`,
1961 `causer`.`addr` AS `causer-addr`,
1962 `causer`.`name` AS `causer-name`,
1963 `causer`.`nick` AS `causer-nick`,
1964 `causer`.`thumb` AS `causer-avatar`,
1965 `causer`.`network` AS `causer-network`,
1966 `causer`.`blocked` AS `causer-blocked`,
1967 `causer`.`hidden` AS `causer-hidden`,
1968 `causer`.`contact-type` AS `causer-contact-type`,
1969 `post-delivery-data`.`postopts` AS `postopts`,
1970 `post-delivery-data`.`inform` AS `inform`,
1971 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1972 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1973 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1974 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1975 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1976 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1977 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1978 `post-user`.`event-id` AS `event-id`,
1979 `event`.`created` AS `event-created`,
1980 `event`.`edited` AS `event-edited`,
1981 `event`.`start` AS `event-start`,
1982 `event`.`finish` AS `event-finish`,
1983 `event`.`summary` AS `event-summary`,
1984 `event`.`desc` AS `event-desc`,
1985 `event`.`location` AS `event-location`,
1986 `event`.`type` AS `event-type`,
1987 `event`.`nofinish` AS `event-nofinish`,
1988 `event`.`ignore` AS `event-ignore`,
1989 `post-question`.`id` AS `question-id`,
1990 `post-question`.`multiple` AS `question-multiple`,
1991 `post-question`.`voters` AS `question-voters`,
1992 `post-question`.`end-time` AS `question-end-time`,
1993 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`,
1994 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-user`.`uri-id`) AS `has-media`,
1995 `diaspora-interaction`.`interaction` AS `signed_text`,
1996 `parent-item-uri`.`guid` AS `parent-guid`,
1997 `parent-post`.`network` AS `parent-network`,
1998 `parent-post`.`author-id` AS `parent-author-id`,
1999 `parent-post-author`.`url` AS `parent-author-link`,
2000 `parent-post-author`.`name` AS `parent-author-name`,
2001 `parent-post-author`.`nick` AS `parent-author-nick`,
2002 `parent-post-author`.`network` AS `parent-author-network`
2004 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2005 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
2006 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
2007 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
2008 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
2009 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
2010 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
2011 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
2012 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
2013 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
2014 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
2015 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
2016 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
2017 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
2018 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2019 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
2020 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-user`.`uri-id`
2021 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
2022 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2023 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2026 -- VIEW post-thread-user-view
2028 DROP VIEW IF EXISTS `post-thread-user-view`;
2029 CREATE VIEW `post-thread-user-view` AS SELECT
2030 `post-user`.`id` AS `id`,
2031 `post-user`.`id` AS `post-user-id`,
2032 `post-thread-user`.`uid` AS `uid`,
2033 `parent-post`.`id` AS `parent`,
2034 `item-uri`.`uri` AS `uri`,
2035 `post-thread-user`.`uri-id` AS `uri-id`,
2036 `parent-item-uri`.`uri` AS `parent-uri`,
2037 `post-user`.`parent-uri-id` AS `parent-uri-id`,
2038 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2039 `post-user`.`thr-parent-id` AS `thr-parent-id`,
2040 `conversation-item-uri`.`uri` AS `conversation`,
2041 `post-thread-user`.`conversation-id` AS `conversation-id`,
2042 `quote-item-uri`.`uri` AS `quote-uri`,
2043 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2044 `item-uri`.`guid` AS `guid`,
2045 `post-thread-user`.`wall` AS `wall`,
2046 `post-user`.`gravity` AS `gravity`,
2047 `external-item-uri`.`uri` AS `extid`,
2048 `post-user`.`external-id` AS `external-id`,
2049 `post-thread-user`.`created` AS `created`,
2050 `post-user`.`edited` AS `edited`,
2051 `post-thread-user`.`commented` AS `commented`,
2052 `post-thread-user`.`received` AS `received`,
2053 `post-thread-user`.`changed` AS `changed`,
2054 `post-user`.`post-type` AS `post-type`,
2055 `post-user`.`post-reason` AS `post-reason`,
2056 `post-user`.`private` AS `private`,
2057 `post-thread-user`.`pubmail` AS `pubmail`,
2058 `post-thread-user`.`ignored` AS `ignored`,
2059 `post-user`.`visible` AS `visible`,
2060 `post-thread-user`.`starred` AS `starred`,
2061 `post-thread-user`.`unseen` AS `unseen`,
2062 `post-user`.`deleted` AS `deleted`,
2063 `post-thread-user`.`origin` AS `origin`,
2064 `post-thread-user`.`mention` AS `mention`,
2065 `post-user`.`global` AS `global`,
2066 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread-user`.`uri-id`) AS `featured`,
2067 `post-thread-user`.`network` AS `network`,
2068 `post-user`.`vid` AS `vid`,
2069 `post-thread-user`.`psid` AS `psid`,
2070 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2071 `post-content`.`title` AS `title`,
2072 `post-content`.`content-warning` AS `content-warning`,
2073 `post-content`.`raw-body` AS `raw-body`,
2074 `post-content`.`body` AS `body`,
2075 `post-content`.`rendered-hash` AS `rendered-hash`,
2076 `post-content`.`rendered-html` AS `rendered-html`,
2077 `post-content`.`language` AS `language`,
2078 `post-content`.`plink` AS `plink`,
2079 `post-content`.`location` AS `location`,
2080 `post-content`.`coord` AS `coord`,
2081 `post-content`.`app` AS `app`,
2082 `post-content`.`object-type` AS `object-type`,
2083 `post-content`.`object` AS `object`,
2084 `post-content`.`target-type` AS `target-type`,
2085 `post-content`.`target` AS `target`,
2086 `post-content`.`resource-id` AS `resource-id`,
2087 `post-thread-user`.`contact-id` AS `contact-id`,
2088 `contact`.`uri-id` AS `contact-uri-id`,
2089 `contact`.`url` AS `contact-link`,
2090 `contact`.`addr` AS `contact-addr`,
2091 `contact`.`name` AS `contact-name`,
2092 `contact`.`nick` AS `contact-nick`,
2093 `contact`.`thumb` AS `contact-avatar`,
2094 `contact`.`network` AS `contact-network`,
2095 `contact`.`blocked` AS `contact-blocked`,
2096 `contact`.`hidden` AS `contact-hidden`,
2097 `contact`.`readonly` AS `contact-readonly`,
2098 `contact`.`archive` AS `contact-archive`,
2099 `contact`.`pending` AS `contact-pending`,
2100 `contact`.`rel` AS `contact-rel`,
2101 `contact`.`uid` AS `contact-uid`,
2102 `contact`.`contact-type` AS `contact-contact-type`,
2103 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
2104 `contact`.`self` AS `self`,
2105 `contact`.`id` AS `cid`,
2106 `contact`.`alias` AS `alias`,
2107 `contact`.`photo` AS `photo`,
2108 `contact`.`name-date` AS `name-date`,
2109 `contact`.`uri-date` AS `uri-date`,
2110 `contact`.`avatar-date` AS `avatar-date`,
2111 `contact`.`thumb` AS `thumb`,
2112 `post-thread-user`.`author-id` AS `author-id`,
2113 `author`.`uri-id` AS `author-uri-id`,
2114 `author`.`url` AS `author-link`,
2115 `author`.`addr` AS `author-addr`,
2116 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
2117 `author`.`nick` AS `author-nick`,
2118 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
2119 `author`.`network` AS `author-network`,
2120 `author`.`blocked` AS `author-blocked`,
2121 `author`.`hidden` AS `author-hidden`,
2122 `author`.`updated` AS `author-updated`,
2123 `author`.`gsid` AS `author-gsid`,
2124 `post-thread-user`.`owner-id` AS `owner-id`,
2125 `owner`.`uri-id` AS `owner-uri-id`,
2126 `owner`.`url` AS `owner-link`,
2127 `owner`.`addr` AS `owner-addr`,
2128 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
2129 `owner`.`nick` AS `owner-nick`,
2130 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
2131 `owner`.`network` AS `owner-network`,
2132 `owner`.`blocked` AS `owner-blocked`,
2133 `owner`.`hidden` AS `owner-hidden`,
2134 `owner`.`updated` AS `owner-updated`,
2135 `owner`.`contact-type` AS `owner-contact-type`,
2136 `post-thread-user`.`causer-id` AS `causer-id`,
2137 `causer`.`uri-id` AS `causer-uri-id`,
2138 `causer`.`url` AS `causer-link`,
2139 `causer`.`addr` AS `causer-addr`,
2140 `causer`.`name` AS `causer-name`,
2141 `causer`.`nick` AS `causer-nick`,
2142 `causer`.`thumb` AS `causer-avatar`,
2143 `causer`.`network` AS `causer-network`,
2144 `causer`.`blocked` AS `causer-blocked`,
2145 `causer`.`hidden` AS `causer-hidden`,
2146 `causer`.`contact-type` AS `causer-contact-type`,
2147 `post-delivery-data`.`postopts` AS `postopts`,
2148 `post-delivery-data`.`inform` AS `inform`,
2149 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
2150 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
2151 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
2152 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
2153 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
2154 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
2155 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
2156 `post-user`.`event-id` AS `event-id`,
2157 `event`.`created` AS `event-created`,
2158 `event`.`edited` AS `event-edited`,
2159 `event`.`start` AS `event-start`,
2160 `event`.`finish` AS `event-finish`,
2161 `event`.`summary` AS `event-summary`,
2162 `event`.`desc` AS `event-desc`,
2163 `event`.`location` AS `event-location`,
2164 `event`.`type` AS `event-type`,
2165 `event`.`nofinish` AS `event-nofinish`,
2166 `event`.`ignore` AS `event-ignore`,
2167 `post-question`.`id` AS `question-id`,
2168 `post-question`.`multiple` AS `question-multiple`,
2169 `post-question`.`voters` AS `question-voters`,
2170 `post-question`.`end-time` AS `question-end-time`,
2171 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`,
2172 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread-user`.`uri-id`) AS `has-media`,
2173 `diaspora-interaction`.`interaction` AS `signed_text`,
2174 `parent-item-uri`.`guid` AS `parent-guid`,
2175 `parent-post`.`network` AS `parent-network`,
2176 `parent-post`.`author-id` AS `parent-author-id`,
2177 `parent-post-author`.`url` AS `parent-author-link`,
2178 `parent-post-author`.`name` AS `parent-author-name`,
2179 `parent-post-author`.`network` AS `parent-author-network`
2180 FROM `post-thread-user`
2181 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2182 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2183 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
2184 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
2185 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
2186 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
2187 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
2188 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
2189 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
2190 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
2191 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
2192 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
2193 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
2194 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
2195 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2196 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
2197 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread-user`.`uri-id`
2198 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
2199 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`
2200 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2205 DROP VIEW IF EXISTS `post-view`;
2206 CREATE VIEW `post-view` AS SELECT
2207 `item-uri`.`uri` AS `uri`,
2208 `post`.`uri-id` AS `uri-id`,
2209 `parent-item-uri`.`uri` AS `parent-uri`,
2210 `post`.`parent-uri-id` AS `parent-uri-id`,
2211 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2212 `post`.`thr-parent-id` AS `thr-parent-id`,
2213 `conversation-item-uri`.`uri` AS `conversation`,
2214 `post-thread`.`conversation-id` AS `conversation-id`,
2215 `quote-item-uri`.`uri` AS `quote-uri`,
2216 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2217 `item-uri`.`guid` AS `guid`,
2218 `post`.`gravity` AS `gravity`,
2219 `external-item-uri`.`uri` AS `extid`,
2220 `post`.`external-id` AS `external-id`,
2221 `post`.`created` AS `created`,
2222 `post`.`edited` AS `edited`,
2223 `post-thread`.`commented` AS `commented`,
2224 `post`.`received` AS `received`,
2225 `post-thread`.`changed` AS `changed`,
2226 `post`.`post-type` AS `post-type`,
2227 `post`.`private` AS `private`,
2228 `post`.`visible` AS `visible`,
2229 `post`.`deleted` AS `deleted`,
2230 `post`.`global` AS `global`,
2231 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post`.`uri-id`) AS `featured`,
2232 `post`.`network` AS `network`,
2233 `post`.`vid` AS `vid`,
2234 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2235 `post-content`.`title` AS `title`,
2236 `post-content`.`content-warning` AS `content-warning`,
2237 `post-content`.`raw-body` AS `raw-body`,
2238 `post-content`.`body` AS `body`,
2239 `post-content`.`rendered-hash` AS `rendered-hash`,
2240 `post-content`.`rendered-html` AS `rendered-html`,
2241 `post-content`.`language` AS `language`,
2242 `post-content`.`plink` AS `plink`,
2243 `post-content`.`location` AS `location`,
2244 `post-content`.`coord` AS `coord`,
2245 `post-content`.`app` AS `app`,
2246 `post-content`.`object-type` AS `object-type`,
2247 `post-content`.`object` AS `object`,
2248 `post-content`.`target-type` AS `target-type`,
2249 `post-content`.`target` AS `target`,
2250 `post-content`.`resource-id` AS `resource-id`,
2251 `post`.`author-id` AS `contact-id`,
2252 `author`.`uri-id` AS `contact-uri-id`,
2253 `author`.`url` AS `contact-link`,
2254 `author`.`addr` AS `contact-addr`,
2255 `author`.`name` AS `contact-name`,
2256 `author`.`nick` AS `contact-nick`,
2257 `author`.`thumb` AS `contact-avatar`,
2258 `author`.`network` AS `contact-network`,
2259 `author`.`blocked` AS `contact-blocked`,
2260 `author`.`hidden` AS `contact-hidden`,
2261 `author`.`readonly` AS `contact-readonly`,
2262 `author`.`archive` AS `contact-archive`,
2263 `author`.`pending` AS `contact-pending`,
2264 `author`.`rel` AS `contact-rel`,
2265 `author`.`uid` AS `contact-uid`,
2266 `author`.`contact-type` AS `contact-contact-type`,
2267 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2269 `author`.`id` AS `cid`,
2270 `author`.`alias` AS `alias`,
2271 `author`.`photo` AS `photo`,
2272 `author`.`name-date` AS `name-date`,
2273 `author`.`uri-date` AS `uri-date`,
2274 `author`.`avatar-date` AS `avatar-date`,
2275 `author`.`thumb` AS `thumb`,
2276 `post`.`author-id` AS `author-id`,
2277 `author`.`uri-id` AS `author-uri-id`,
2278 `author`.`url` AS `author-link`,
2279 `author`.`addr` AS `author-addr`,
2280 `author`.`name` AS `author-name`,
2281 `author`.`nick` AS `author-nick`,
2282 `author`.`thumb` AS `author-avatar`,
2283 `author`.`network` AS `author-network`,
2284 `author`.`blocked` AS `author-blocked`,
2285 `author`.`hidden` AS `author-hidden`,
2286 `author`.`updated` AS `author-updated`,
2287 `author`.`gsid` AS `author-gsid`,
2288 `post`.`owner-id` AS `owner-id`,
2289 `owner`.`uri-id` AS `owner-uri-id`,
2290 `owner`.`url` AS `owner-link`,
2291 `owner`.`addr` AS `owner-addr`,
2292 `owner`.`name` AS `owner-name`,
2293 `owner`.`nick` AS `owner-nick`,
2294 `owner`.`thumb` AS `owner-avatar`,
2295 `owner`.`network` AS `owner-network`,
2296 `owner`.`blocked` AS `owner-blocked`,
2297 `owner`.`hidden` AS `owner-hidden`,
2298 `owner`.`updated` AS `owner-updated`,
2299 `owner`.`contact-type` AS `owner-contact-type`,
2300 `post`.`causer-id` AS `causer-id`,
2301 `causer`.`uri-id` AS `causer-uri-id`,
2302 `causer`.`url` AS `causer-link`,
2303 `causer`.`addr` AS `causer-addr`,
2304 `causer`.`name` AS `causer-name`,
2305 `causer`.`nick` AS `causer-nick`,
2306 `causer`.`thumb` AS `causer-avatar`,
2307 `causer`.`network` AS `causer-network`,
2308 `causer`.`blocked` AS `causer-blocked`,
2309 `causer`.`hidden` AS `causer-hidden`,
2310 `causer`.`contact-type` AS `causer-contact-type`,
2311 `post-question`.`id` AS `question-id`,
2312 `post-question`.`multiple` AS `question-multiple`,
2313 `post-question`.`voters` AS `question-voters`,
2314 `post-question`.`end-time` AS `question-end-time`,
2315 0 AS `has-categories`,
2316 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post`.`uri-id`) AS `has-media`,
2317 `diaspora-interaction`.`interaction` AS `signed_text`,
2318 `parent-item-uri`.`guid` AS `parent-guid`,
2319 `parent-post`.`network` AS `parent-network`,
2320 `parent-post`.`author-id` AS `parent-author-id`,
2321 `parent-post-author`.`url` AS `parent-author-link`,
2322 `parent-post-author`.`name` AS `parent-author-name`,
2323 `parent-post-author`.`network` AS `parent-author-network`
2325 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
2326 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
2327 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
2328 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
2329 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
2330 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2331 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2332 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
2333 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2334 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2335 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
2336 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
2337 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2338 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post`.`uri-id`
2339 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2340 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2343 -- VIEW post-thread-view
2345 DROP VIEW IF EXISTS `post-thread-view`;
2346 CREATE VIEW `post-thread-view` AS SELECT
2347 `item-uri`.`uri` AS `uri`,
2348 `post-thread`.`uri-id` AS `uri-id`,
2349 `parent-item-uri`.`uri` AS `parent-uri`,
2350 `post`.`parent-uri-id` AS `parent-uri-id`,
2351 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2352 `post`.`thr-parent-id` AS `thr-parent-id`,
2353 `conversation-item-uri`.`uri` AS `conversation`,
2354 `post-thread`.`conversation-id` AS `conversation-id`,
2355 `quote-item-uri`.`uri` AS `quote-uri`,
2356 `post-content`.`quote-uri-id` AS `quote-uri-id`,
2357 `item-uri`.`guid` AS `guid`,
2358 `post`.`gravity` AS `gravity`,
2359 `external-item-uri`.`uri` AS `extid`,
2360 `post`.`external-id` AS `external-id`,
2361 `post-thread`.`created` AS `created`,
2362 `post`.`edited` AS `edited`,
2363 `post-thread`.`commented` AS `commented`,
2364 `post-thread`.`received` AS `received`,
2365 `post-thread`.`changed` AS `changed`,
2366 `post`.`post-type` AS `post-type`,
2367 `post`.`private` AS `private`,
2368 `post`.`visible` AS `visible`,
2369 `post`.`deleted` AS `deleted`,
2370 `post`.`global` AS `global`,
2371 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread`.`uri-id`) AS `featured`,
2372 `post-thread`.`network` AS `network`,
2373 `post`.`vid` AS `vid`,
2374 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2375 `post-content`.`title` AS `title`,
2376 `post-content`.`content-warning` AS `content-warning`,
2377 `post-content`.`raw-body` AS `raw-body`,
2378 `post-content`.`body` AS `body`,
2379 `post-content`.`rendered-hash` AS `rendered-hash`,
2380 `post-content`.`rendered-html` AS `rendered-html`,
2381 `post-content`.`language` AS `language`,
2382 `post-content`.`plink` AS `plink`,
2383 `post-content`.`location` AS `location`,
2384 `post-content`.`coord` AS `coord`,
2385 `post-content`.`app` AS `app`,
2386 `post-content`.`object-type` AS `object-type`,
2387 `post-content`.`object` AS `object`,
2388 `post-content`.`target-type` AS `target-type`,
2389 `post-content`.`target` AS `target`,
2390 `post-content`.`resource-id` AS `resource-id`,
2391 `post-thread`.`author-id` AS `contact-id`,
2392 `author`.`uri-id` AS `contact-uri-id`,
2393 `author`.`url` AS `contact-link`,
2394 `author`.`addr` AS `contact-addr`,
2395 `author`.`name` AS `contact-name`,
2396 `author`.`nick` AS `contact-nick`,
2397 `author`.`thumb` AS `contact-avatar`,
2398 `author`.`network` AS `contact-network`,
2399 `author`.`blocked` AS `contact-blocked`,
2400 `author`.`hidden` AS `contact-hidden`,
2401 `author`.`readonly` AS `contact-readonly`,
2402 `author`.`archive` AS `contact-archive`,
2403 `author`.`pending` AS `contact-pending`,
2404 `author`.`rel` AS `contact-rel`,
2405 `author`.`uid` AS `contact-uid`,
2406 `author`.`contact-type` AS `contact-contact-type`,
2407 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2409 `author`.`id` AS `cid`,
2410 `author`.`alias` AS `alias`,
2411 `author`.`photo` AS `photo`,
2412 `author`.`name-date` AS `name-date`,
2413 `author`.`uri-date` AS `uri-date`,
2414 `author`.`avatar-date` AS `avatar-date`,
2415 `author`.`thumb` AS `thumb`,
2416 `post-thread`.`author-id` AS `author-id`,
2417 `author`.`uri-id` AS `author-uri-id`,
2418 `author`.`url` AS `author-link`,
2419 `author`.`addr` AS `author-addr`,
2420 `author`.`name` AS `author-name`,
2421 `author`.`nick` AS `author-nick`,
2422 `author`.`thumb` AS `author-avatar`,
2423 `author`.`network` AS `author-network`,
2424 `author`.`blocked` AS `author-blocked`,
2425 `author`.`hidden` AS `author-hidden`,
2426 `author`.`updated` AS `author-updated`,
2427 `author`.`gsid` AS `author-gsid`,
2428 `post-thread`.`owner-id` AS `owner-id`,
2429 `owner`.`uri-id` AS `owner-uri-id`,
2430 `owner`.`url` AS `owner-link`,
2431 `owner`.`addr` AS `owner-addr`,
2432 `owner`.`name` AS `owner-name`,
2433 `owner`.`nick` AS `owner-nick`,
2434 `owner`.`thumb` AS `owner-avatar`,
2435 `owner`.`network` AS `owner-network`,
2436 `owner`.`blocked` AS `owner-blocked`,
2437 `owner`.`hidden` AS `owner-hidden`,
2438 `owner`.`updated` AS `owner-updated`,
2439 `owner`.`contact-type` AS `owner-contact-type`,
2440 `post-thread`.`causer-id` AS `causer-id`,
2441 `causer`.`uri-id` AS `causer-uri-id`,
2442 `causer`.`url` AS `causer-link`,
2443 `causer`.`addr` AS `causer-addr`,
2444 `causer`.`name` AS `causer-name`,
2445 `causer`.`nick` AS `causer-nick`,
2446 `causer`.`thumb` AS `causer-avatar`,
2447 `causer`.`network` AS `causer-network`,
2448 `causer`.`blocked` AS `causer-blocked`,
2449 `causer`.`hidden` AS `causer-hidden`,
2450 `causer`.`contact-type` AS `causer-contact-type`,
2451 `post-question`.`id` AS `question-id`,
2452 `post-question`.`multiple` AS `question-multiple`,
2453 `post-question`.`voters` AS `question-voters`,
2454 `post-question`.`end-time` AS `question-end-time`,
2455 0 AS `has-categories`,
2456 EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread`.`uri-id`) AS `has-media`,
2457 (SELECT COUNT(*) FROM `post` WHERE `parent-uri-id` = `post-thread`.`uri-id` AND `gravity` = 6) AS `total-comments`,
2458 (SELECT COUNT(DISTINCT(`author-id`)) FROM `post` WHERE `parent-uri-id` = `post-thread`.`uri-id` AND `gravity` = 6) AS `total-actors`,
2459 `diaspora-interaction`.`interaction` AS `signed_text`,
2460 `parent-item-uri`.`guid` AS `parent-guid`,
2461 `parent-post`.`network` AS `parent-network`,
2462 `parent-post`.`author-id` AS `parent-author-id`,
2463 `parent-post-author`.`url` AS `parent-author-link`,
2464 `parent-post-author`.`name` AS `parent-author-name`,
2465 `parent-post-author`.`network` AS `parent-author-network`
2467 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
2468 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
2469 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
2470 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
2471 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
2472 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2473 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2474 LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
2475 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2476 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2477 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
2478 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
2479 LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
2480 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread`.`uri-id`
2481 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2482 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2485 -- VIEW category-view
2487 DROP VIEW IF EXISTS `category-view`;
2488 CREATE VIEW `category-view` AS SELECT
2489 `post-category`.`uri-id` AS `uri-id`,
2490 `post-category`.`uid` AS `uid`,
2491 `post-category`.`type` AS `type`,
2492 `post-category`.`tid` AS `tid`,
2493 `tag`.`name` AS `name`,
2494 `tag`.`url` AS `url`
2495 FROM `post-category`
2496 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2499 -- VIEW collection-view
2501 DROP VIEW IF EXISTS `collection-view`;
2502 CREATE VIEW `collection-view` AS SELECT
2503 `post-collection`.`uri-id` AS `uri-id`,
2504 `post-collection`.`type` AS `type`,
2505 `post-collection`.`author-id` AS `cid`,
2506 `post`.`received` AS `received`,
2507 `post`.`created` AS `created`,
2508 `post-thread`.`commented` AS `commented`,
2509 `post`.`private` AS `private`,
2510 `post`.`visible` AS `visible`,
2511 `post`.`deleted` AS `deleted`,
2512 `post`.`thr-parent-id` AS `thr-parent-id`,
2513 `post-collection`.`author-id` AS `author-id`,
2514 `post`.`gravity` AS `gravity`
2515 FROM `post-collection`
2516 INNER JOIN `post` ON `post-collection`.`uri-id` = `post`.`uri-id`
2517 INNER JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`;
2522 DROP VIEW IF EXISTS `media-view`;
2523 CREATE VIEW `media-view` AS SELECT
2524 `post-media`.`uri-id` AS `uri-id`,
2525 `post-media`.`type` AS `type`,
2526 `post`.`received` AS `received`,
2527 `post`.`created` AS `created`,
2528 `post`.`private` AS `private`,
2529 `post`.`visible` AS `visible`,
2530 `post`.`deleted` AS `deleted`,
2531 `post`.`thr-parent-id` AS `thr-parent-id`,
2532 `post`.`author-id` AS `author-id`,
2533 `post`.`gravity` AS `gravity`
2535 INNER JOIN `post` ON `post-media`.`uri-id` = `post`.`uri-id`;
2540 DROP VIEW IF EXISTS `tag-view`;
2541 CREATE VIEW `tag-view` AS SELECT
2542 `post-tag`.`uri-id` AS `uri-id`,
2543 `post-tag`.`type` AS `type`,
2544 `post-tag`.`tid` AS `tid`,
2545 `post-tag`.`cid` AS `cid`,
2546 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2547 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`,
2548 CASE `cid` WHEN 0 THEN `tag`.`type` ELSE 1 END AS `tag-type`
2550 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2551 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2554 -- VIEW network-item-view
2556 DROP VIEW IF EXISTS `network-item-view`;
2557 CREATE VIEW `network-item-view` AS SELECT
2558 `post-user`.`uri-id` AS `uri-id`,
2559 `parent-post`.`id` AS `parent`,
2560 `post-user`.`received` AS `received`,
2561 `post-thread-user`.`commented` AS `commented`,
2562 `post-user`.`created` AS `created`,
2563 `post-user`.`uid` AS `uid`,
2564 `post-thread-user`.`starred` AS `starred`,
2565 `post-thread-user`.`mention` AS `mention`,
2566 `post-user`.`network` AS `network`,
2567 `post-user`.`unseen` AS `unseen`,
2568 `post-user`.`gravity` AS `gravity`,
2569 `post-user`.`contact-id` AS `contact-id`,
2570 `ownercontact`.`contact-type` AS `contact-type`
2572 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2573 INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2574 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2575 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2576 INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2577 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2578 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2579 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2580 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
2581 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2582 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2585 -- VIEW network-thread-view
2587 DROP VIEW IF EXISTS `network-thread-view`;
2588 CREATE VIEW `network-thread-view` AS SELECT
2589 `post-thread-user`.`uri-id` AS `uri-id`,
2590 `parent-post`.`id` AS `parent`,
2591 `post-thread-user`.`received` AS `received`,
2592 `post-thread-user`.`commented` AS `commented`,
2593 `post-thread-user`.`created` AS `created`,
2594 `post-thread-user`.`uid` AS `uid`,
2595 `post-thread-user`.`starred` AS `starred`,
2596 `post-thread-user`.`mention` AS `mention`,
2597 `post-thread-user`.`network` AS `network`,
2598 `post-thread-user`.`contact-id` AS `contact-id`,
2599 `ownercontact`.`contact-type` AS `contact-type`
2600 FROM `post-thread-user`
2601 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2602 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2603 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2604 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2605 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2606 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2607 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2608 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2609 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2610 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2611 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2616 DROP VIEW IF EXISTS `owner-view`;
2617 CREATE VIEW `owner-view` AS SELECT
2618 `contact`.`id` AS `id`,
2619 `contact`.`uid` AS `uid`,
2620 `contact`.`created` AS `created`,
2621 `contact`.`updated` AS `updated`,
2622 `contact`.`self` AS `self`,
2623 `contact`.`remote_self` AS `remote_self`,
2624 `contact`.`rel` AS `rel`,
2625 `contact`.`network` AS `network`,
2626 `contact`.`protocol` AS `protocol`,
2627 `contact`.`name` AS `name`,
2628 `contact`.`nick` AS `nick`,
2629 `contact`.`location` AS `location`,
2630 `contact`.`about` AS `about`,
2631 `contact`.`keywords` AS `keywords`,
2632 `contact`.`xmpp` AS `xmpp`,
2633 `contact`.`matrix` AS `matrix`,
2634 `contact`.`attag` AS `attag`,
2635 `contact`.`avatar` AS `avatar`,
2636 `contact`.`photo` AS `photo`,
2637 `contact`.`thumb` AS `thumb`,
2638 `contact`.`micro` AS `micro`,
2639 `contact`.`header` AS `header`,
2640 `contact`.`url` AS `url`,
2641 `contact`.`nurl` AS `nurl`,
2642 `contact`.`uri-id` AS `uri-id`,
2643 `contact`.`addr` AS `addr`,
2644 `contact`.`alias` AS `alias`,
2645 `contact`.`pubkey` AS `pubkey`,
2646 `contact`.`prvkey` AS `prvkey`,
2647 `contact`.`batch` AS `batch`,
2648 `contact`.`request` AS `request`,
2649 `contact`.`notify` AS `notify`,
2650 `contact`.`poll` AS `poll`,
2651 `contact`.`confirm` AS `confirm`,
2652 `contact`.`poco` AS `poco`,
2653 `contact`.`subhub` AS `subhub`,
2654 `contact`.`hub-verify` AS `hub-verify`,
2655 `contact`.`last-update` AS `last-update`,
2656 `contact`.`success_update` AS `success_update`,
2657 `contact`.`failure_update` AS `failure_update`,
2658 `contact`.`name-date` AS `name-date`,
2659 `contact`.`uri-date` AS `uri-date`,
2660 `contact`.`avatar-date` AS `avatar-date`,
2661 `contact`.`avatar-date` AS `picdate`,
2662 `contact`.`term-date` AS `term-date`,
2663 `contact`.`last-item` AS `last-item`,
2664 `contact`.`priority` AS `priority`,
2665 `user`.`blocked` AS `blocked`,
2666 `contact`.`block_reason` AS `block_reason`,
2667 `contact`.`readonly` AS `readonly`,
2668 `contact`.`writable` AS `writable`,
2669 `contact`.`forum` AS `forum`,
2670 `contact`.`prv` AS `prv`,
2671 `contact`.`contact-type` AS `contact-type`,
2672 `contact`.`manually-approve` AS `manually-approve`,
2673 `contact`.`hidden` AS `hidden`,
2674 `contact`.`archive` AS `archive`,
2675 `contact`.`pending` AS `pending`,
2676 `contact`.`deleted` AS `deleted`,
2677 `contact`.`unsearchable` AS `unsearchable`,
2678 `contact`.`sensitive` AS `sensitive`,
2679 `contact`.`baseurl` AS `baseurl`,
2680 `contact`.`reason` AS `reason`,
2681 `contact`.`info` AS `info`,
2682 `contact`.`bdyear` AS `bdyear`,
2683 `contact`.`bd` AS `bd`,
2684 `contact`.`notify_new_posts` AS `notify_new_posts`,
2685 `contact`.`fetch_further_information` AS `fetch_further_information`,
2686 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2687 `user`.`parent-uid` AS `parent-uid`,
2688 `user`.`guid` AS `guid`,
2689 `user`.`nickname` AS `nickname`,
2690 `user`.`email` AS `email`,
2691 `user`.`openid` AS `openid`,
2692 `user`.`timezone` AS `timezone`,
2693 `user`.`language` AS `language`,
2694 `user`.`register_date` AS `register_date`,
2695 `user`.`login_date` AS `login_date`,
2696 `user`.`default-location` AS `default-location`,
2697 `user`.`allow_location` AS `allow_location`,
2698 `user`.`theme` AS `theme`,
2699 `user`.`pubkey` AS `upubkey`,
2700 `user`.`prvkey` AS `uprvkey`,
2701 `user`.`sprvkey` AS `sprvkey`,
2702 `user`.`spubkey` AS `spubkey`,
2703 `user`.`verified` AS `verified`,
2704 `user`.`blockwall` AS `blockwall`,
2705 `user`.`hidewall` AS `hidewall`,
2706 `user`.`blocktags` AS `blocktags`,
2707 `user`.`unkmail` AS `unkmail`,
2708 `user`.`cntunkmail` AS `cntunkmail`,
2709 `user`.`notify-flags` AS `notify-flags`,
2710 `user`.`page-flags` AS `page-flags`,
2711 `user`.`account-type` AS `account-type`,
2712 `user`.`prvnets` AS `prvnets`,
2713 `user`.`maxreq` AS `maxreq`,
2714 `user`.`expire` AS `expire`,
2715 `user`.`account_removed` AS `account_removed`,
2716 `user`.`account_expired` AS `account_expired`,
2717 `user`.`account_expires_on` AS `account_expires_on`,
2718 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2719 `user`.`def_gid` AS `def_gid`,
2720 `user`.`allow_cid` AS `allow_cid`,
2721 `user`.`allow_gid` AS `allow_gid`,
2722 `user`.`deny_cid` AS `deny_cid`,
2723 `user`.`deny_gid` AS `deny_gid`,
2724 `user`.`openidserver` AS `openidserver`,
2725 `profile`.`publish` AS `publish`,
2726 `profile`.`net-publish` AS `net-publish`,
2727 `profile`.`hide-friends` AS `hide-friends`,
2728 `profile`.`prv_keywords` AS `prv_keywords`,
2729 `profile`.`pub_keywords` AS `pub_keywords`,
2730 `profile`.`address` AS `address`,
2731 `profile`.`locality` AS `locality`,
2732 `profile`.`region` AS `region`,
2733 `profile`.`postal-code` AS `postal-code`,
2734 `profile`.`country-name` AS `country-name`,
2735 `profile`.`homepage` AS `homepage`,
2736 `profile`.`homepage_verified` AS `homepage_verified`,
2737 `profile`.`dob` AS `dob`
2739 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2740 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2743 -- VIEW account-view
2745 DROP VIEW IF EXISTS `account-view`;
2746 CREATE VIEW `account-view` AS SELECT
2747 `contact`.`id` AS `id`,
2748 `contact`.`url` AS `url`,
2749 `contact`.`nurl` AS `nurl`,
2750 `contact`.`uri-id` AS `uri-id`,
2751 `item-uri`.`guid` AS `guid`,
2752 `contact`.`addr` AS `addr`,
2753 `contact`.`alias` AS `alias`,
2754 `contact`.`name` AS `name`,
2755 `contact`.`nick` AS `nick`,
2756 `contact`.`about` AS `about`,
2757 `contact`.`keywords` AS `keywords`,
2758 `contact`.`xmpp` AS `xmpp`,
2759 `contact`.`matrix` AS `matrix`,
2760 `contact`.`avatar` AS `avatar`,
2761 `contact`.`photo` AS `photo`,
2762 `contact`.`thumb` AS `thumb`,
2763 `contact`.`micro` AS `micro`,
2764 `contact`.`header` AS `header`,
2765 `contact`.`created` AS `created`,
2766 `contact`.`updated` AS `updated`,
2767 `contact`.`network` AS `network`,
2768 `contact`.`protocol` AS `protocol`,
2769 `contact`.`location` AS `location`,
2770 `contact`.`attag` AS `attag`,
2771 `contact`.`pubkey` AS `pubkey`,
2772 `contact`.`prvkey` AS `prvkey`,
2773 `contact`.`subscribe` AS `subscribe`,
2774 `contact`.`last-update` AS `last-update`,
2775 `contact`.`success_update` AS `success_update`,
2776 `contact`.`failure_update` AS `failure_update`,
2777 `contact`.`failed` AS `failed`,
2778 `contact`.`last-item` AS `last-item`,
2779 `contact`.`last-discovery` AS `last-discovery`,
2780 `contact`.`contact-type` AS `contact-type`,
2781 `contact`.`manually-approve` AS `manually-approve`,
2782 `contact`.`unsearchable` AS `unsearchable`,
2783 `contact`.`sensitive` AS `sensitive`,
2784 `contact`.`baseurl` AS `baseurl`,
2785 `contact`.`gsid` AS `gsid`,
2786 `contact`.`info` AS `info`,
2787 `contact`.`bdyear` AS `bdyear`,
2788 `contact`.`bd` AS `bd`,
2789 `contact`.`poco` AS `poco`,
2790 `contact`.`name-date` AS `name-date`,
2791 `contact`.`uri-date` AS `uri-date`,
2792 `contact`.`avatar-date` AS `avatar-date`,
2793 `contact`.`term-date` AS `term-date`,
2794 `contact`.`hidden` AS `global-ignored`,
2795 `contact`.`blocked` AS `global-blocked`,
2796 `contact`.`hidden` AS `hidden`,
2797 `contact`.`archive` AS `archive`,
2798 `contact`.`deleted` AS `deleted`,
2799 `contact`.`blocked` AS `blocked`,
2800 `contact`.`notify` AS `dfrn-notify`,
2801 `contact`.`poll` AS `dfrn-poll`,
2802 `fcontact`.`guid` AS `diaspora-guid`,
2803 `fcontact`.`batch` AS `diaspora-batch`,
2804 `fcontact`.`notify` AS `diaspora-notify`,
2805 `fcontact`.`poll` AS `diaspora-poll`,
2806 `fcontact`.`alias` AS `diaspora-alias`,
2807 `apcontact`.`uuid` AS `ap-uuid`,
2808 `apcontact`.`type` AS `ap-type`,
2809 `apcontact`.`following` AS `ap-following`,
2810 `apcontact`.`followers` AS `ap-followers`,
2811 `apcontact`.`inbox` AS `ap-inbox`,
2812 `apcontact`.`outbox` AS `ap-outbox`,
2813 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2814 `apcontact`.`generator` AS `ap-generator`,
2815 `apcontact`.`following_count` AS `ap-following_count`,
2816 `apcontact`.`followers_count` AS `ap-followers_count`,
2817 `apcontact`.`statuses_count` AS `ap-statuses_count`,
2818 `gserver`.`site_name` AS `site_name`,
2819 `gserver`.`platform` AS `platform`,
2820 `gserver`.`version` AS `version`
2822 LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id`
2823 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
2824 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = contact.`uri-id`
2825 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`
2826 WHERE `contact`.`uid` = 0;
2829 -- VIEW account-user-view
2831 DROP VIEW IF EXISTS `account-user-view`;
2832 CREATE VIEW `account-user-view` AS SELECT
2833 `ucontact`.`id` AS `id`,
2834 `contact`.`id` AS `pid`,
2835 `ucontact`.`uid` AS `uid`,
2836 `contact`.`url` AS `url`,
2837 `contact`.`nurl` AS `nurl`,
2838 `contact`.`uri-id` AS `uri-id`,
2839 `item-uri`.`guid` AS `guid`,
2840 `contact`.`addr` AS `addr`,
2841 `contact`.`alias` AS `alias`,
2842 `contact`.`name` AS `name`,
2843 `contact`.`nick` AS `nick`,
2844 `contact`.`about` AS `about`,
2845 `contact`.`keywords` AS `keywords`,
2846 `contact`.`xmpp` AS `xmpp`,
2847 `contact`.`matrix` AS `matrix`,
2848 `contact`.`avatar` AS `avatar`,
2849 `contact`.`photo` AS `photo`,
2850 `contact`.`thumb` AS `thumb`,
2851 `contact`.`micro` AS `micro`,
2852 `contact`.`header` AS `header`,
2853 `contact`.`created` AS `created`,
2854 `contact`.`updated` AS `updated`,
2855 `ucontact`.`self` AS `self`,
2856 `ucontact`.`remote_self` AS `remote_self`,
2857 `ucontact`.`rel` AS `rel`,
2858 `contact`.`network` AS `network`,
2859 `ucontact`.`protocol` AS `protocol`,
2860 `contact`.`location` AS `location`,
2861 `ucontact`.`attag` AS `attag`,
2862 `contact`.`pubkey` AS `pubkey`,
2863 `contact`.`prvkey` AS `prvkey`,
2864 `contact`.`subscribe` AS `subscribe`,
2865 `contact`.`last-update` AS `last-update`,
2866 `contact`.`success_update` AS `success_update`,
2867 `contact`.`failure_update` AS `failure_update`,
2868 `contact`.`failed` AS `failed`,
2869 `contact`.`last-item` AS `last-item`,
2870 `contact`.`last-discovery` AS `last-discovery`,
2871 `contact`.`contact-type` AS `contact-type`,
2872 `contact`.`manually-approve` AS `manually-approve`,
2873 `contact`.`unsearchable` AS `unsearchable`,
2874 `contact`.`sensitive` AS `sensitive`,
2875 `contact`.`baseurl` AS `baseurl`,
2876 `contact`.`gsid` AS `gsid`,
2877 `ucontact`.`info` AS `info`,
2878 `contact`.`bdyear` AS `bdyear`,
2879 `contact`.`bd` AS `bd`,
2880 `contact`.`poco` AS `poco`,
2881 `contact`.`name-date` AS `name-date`,
2882 `contact`.`uri-date` AS `uri-date`,
2883 `contact`.`avatar-date` AS `avatar-date`,
2884 `contact`.`term-date` AS `term-date`,
2885 `contact`.`hidden` AS `global-ignored`,
2886 `contact`.`blocked` AS `global-blocked`,
2887 `ucontact`.`hidden` AS `hidden`,
2888 `ucontact`.`archive` AS `archive`,
2889 `ucontact`.`pending` AS `pending`,
2890 `ucontact`.`deleted` AS `deleted`,
2891 `ucontact`.`notify_new_posts` AS `notify_new_posts`,
2892 `ucontact`.`fetch_further_information` AS `fetch_further_information`,
2893 `ucontact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2894 `ucontact`.`rating` AS `rating`,
2895 `ucontact`.`readonly` AS `readonly`,
2896 `ucontact`.`blocked` AS `blocked`,
2897 `ucontact`.`block_reason` AS `block_reason`,
2898 `ucontact`.`subhub` AS `subhub`,
2899 `ucontact`.`hub-verify` AS `hub-verify`,
2900 `ucontact`.`reason` AS `reason`,
2901 `contact`.`notify` AS `dfrn-notify`,
2902 `contact`.`poll` AS `dfrn-poll`,
2903 `fcontact`.`guid` AS `diaspora-guid`,
2904 `fcontact`.`batch` AS `diaspora-batch`,
2905 `fcontact`.`notify` AS `diaspora-notify`,
2906 `fcontact`.`poll` AS `diaspora-poll`,
2907 `fcontact`.`alias` AS `diaspora-alias`,
2908 `fcontact`.`interacting_count` AS `diaspora-interacting_count`,
2909 `fcontact`.`interacted_count` AS `diaspora-interacted_count`,
2910 `fcontact`.`post_count` AS `diaspora-post_count`,
2911 `apcontact`.`uuid` AS `ap-uuid`,
2912 `apcontact`.`type` AS `ap-type`,
2913 `apcontact`.`following` AS `ap-following`,
2914 `apcontact`.`followers` AS `ap-followers`,
2915 `apcontact`.`inbox` AS `ap-inbox`,
2916 `apcontact`.`outbox` AS `ap-outbox`,
2917 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2918 `apcontact`.`generator` AS `ap-generator`,
2919 `apcontact`.`following_count` AS `ap-following_count`,
2920 `apcontact`.`followers_count` AS `ap-followers_count`,
2921 `apcontact`.`statuses_count` AS `ap-statuses_count`,
2922 `gserver`.`site_name` AS `site_name`,
2923 `gserver`.`platform` AS `platform`,
2924 `gserver`.`version` AS `version`
2925 FROM `contact` AS `ucontact`
2926 INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
2927 LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id`
2928 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
2929 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = `ucontact`.`uri-id` AND `fcontact`.`network` = 'dspr'
2930 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`;
2933 -- VIEW pending-view
2935 DROP VIEW IF EXISTS `pending-view`;
2936 CREATE VIEW `pending-view` AS SELECT
2937 `register`.`id` AS `id`,
2938 `register`.`hash` AS `hash`,
2939 `register`.`created` AS `created`,
2940 `register`.`uid` AS `uid`,
2941 `register`.`password` AS `password`,
2942 `register`.`language` AS `language`,
2943 `register`.`note` AS `note`,
2944 `contact`.`self` AS `self`,
2945 `contact`.`name` AS `name`,
2946 `contact`.`url` AS `url`,
2947 `contact`.`micro` AS `micro`,
2948 `user`.`email` AS `email`,
2949 `contact`.`nick` AS `nick`
2951 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2952 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2955 -- VIEW tag-search-view
2957 DROP VIEW IF EXISTS `tag-search-view`;
2958 CREATE VIEW `tag-search-view` AS SELECT
2959 `post-tag`.`uri-id` AS `uri-id`,
2960 `post-user`.`uid` AS `uid`,
2961 `post-user`.`id` AS `iid`,
2962 `post-user`.`private` AS `private`,
2963 `post-user`.`wall` AS `wall`,
2964 `post-user`.`origin` AS `origin`,
2965 `post-user`.`global` AS `global`,
2966 `post-user`.`gravity` AS `gravity`,
2967 `post-user`.`received` AS `received`,
2968 `post-user`.`network` AS `network`,
2969 `post-user`.`author-id` AS `author-id`,
2970 `tag`.`name` AS `name`
2972 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
2973 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
2974 WHERE `post-tag`.`type` = 1;
2977 -- VIEW workerqueue-view
2979 DROP VIEW IF EXISTS `workerqueue-view`;
2980 CREATE VIEW `workerqueue-view` AS SELECT
2981 `process`.`pid` AS `pid`,
2982 `workerqueue`.`priority` AS `priority`
2984 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
2985 WHERE NOT `workerqueue`.`done`;
2988 -- VIEW profile_field-view
2990 DROP VIEW IF EXISTS `profile_field-view`;
2991 CREATE VIEW `profile_field-view` AS SELECT
2992 `profile_field`.`id` AS `id`,
2993 `profile_field`.`uid` AS `uid`,
2994 `profile_field`.`label` AS `label`,
2995 `profile_field`.`value` AS `value`,
2996 `profile_field`.`order` AS `order`,
2997 `profile_field`.`psid` AS `psid`,
2998 `permissionset`.`allow_cid` AS `allow_cid`,
2999 `permissionset`.`allow_gid` AS `allow_gid`,
3000 `permissionset`.`deny_cid` AS `deny_cid`,
3001 `permissionset`.`deny_gid` AS `deny_gid`,
3002 `profile_field`.`created` AS `created`,
3003 `profile_field`.`edited` AS `edited`
3004 FROM `profile_field`
3005 INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`;