1 -- ------------------------------------------
2 -- Friendica 2022.05-dev (Siberian Iris)
3 -- DB_UPDATE_VERSION 1458
4 -- ------------------------------------------
10 CREATE TABLE IF NOT EXISTS `gserver` (
11 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
12 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
13 `nurl` varchar(255) 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` varchar(255) NOT NULL DEFAULT '' COMMENT '',
26 `noscrape` varchar(255) 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 `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
63 `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
64 `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
65 `pubkey` text COMMENT 'RSA public key 4096 bit',
66 `prvkey` text COMMENT 'RSA private key 4096 bit',
67 `spubkey` text COMMENT '',
68 `sprvkey` text COMMENT '',
69 `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
70 `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
71 `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
72 `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unkown viewers',
73 `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
74 `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
75 `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
76 `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
77 `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
78 `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
79 `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
80 `pwdreset` varchar(255) COMMENT 'Password reset request token',
81 `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
82 `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
83 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
84 `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
85 `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
86 `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
87 `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
88 `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
89 `allow_cid` mediumtext COMMENT 'default permission for this user',
90 `allow_gid` mediumtext COMMENT 'default permission for this user',
91 `deny_cid` mediumtext COMMENT 'default permission for this user',
92 `deny_gid` mediumtext COMMENT 'default permission for this user',
93 `openidserver` text COMMENT '',
95 INDEX `nickname` (`nickname`(32)),
96 INDEX `parent-uid` (`parent-uid`),
97 INDEX `guid` (`guid`),
98 INDEX `email` (`email`(64)),
99 FOREIGN KEY (`parent-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
100 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
105 CREATE TABLE IF NOT EXISTS `item-uri` (
106 `id` int unsigned NOT NULL auto_increment,
107 `uri` varbinary(255) NOT NULL COMMENT 'URI of an item',
108 `guid` varbinary(255) COMMENT 'A unique identifier for an item',
110 UNIQUE INDEX `uri` (`uri`),
111 INDEX `guid` (`guid`)
112 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
117 CREATE TABLE IF NOT EXISTS `contact` (
118 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
119 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
120 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
121 `updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last contact update',
122 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network of the contact',
123 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
124 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
125 `location` varchar(255) DEFAULT '' COMMENT '',
126 `about` text COMMENT '',
127 `keywords` text COMMENT 'public keywords (interests) of the contact',
128 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
129 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
130 `avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '',
131 `header` varchar(255) COMMENT 'Header picture',
132 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
133 `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
134 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
135 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
136 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
137 `pubkey` text COMMENT 'RSA public key 4096 bit',
138 `prvkey` text COMMENT 'RSA private key 4096 bit',
139 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
140 `notify` varchar(255) COMMENT '',
141 `poll` varchar(255) COMMENT '',
142 `subscribe` varchar(255) COMMENT '',
143 `last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
144 `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
145 `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
146 `failed` boolean COMMENT 'Connection failed',
147 `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
148 `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
149 `last-discovery` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last follower discovery',
150 `blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
151 `block_reason` text COMMENT 'Node-wide block reason',
152 `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
153 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Person, organisation, news, community, relay',
154 `manually-approve` boolean COMMENT 'Contact requests have to be approved manually',
155 `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
156 `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
157 `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
158 `baseurl` varchar(255) DEFAULT '' COMMENT 'baseurl of the contact',
159 `gsid` int unsigned COMMENT 'Global Server ID',
160 `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
161 `reason` text COMMENT '',
162 `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
163 `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
164 `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
165 `protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
166 `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
167 `hub-verify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
168 `rating` tinyint NOT NULL DEFAULT 0 COMMENT 'Automatically detected feed poll frequency',
169 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Feed poll priority',
170 `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
171 `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
172 `pending` boolean NOT NULL DEFAULT '1' COMMENT 'Contact request is pending',
173 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
174 `info` mediumtext COMMENT '',
175 `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
176 `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
177 `ffi_keyword_denylist` text COMMENT '',
178 `photo` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
179 `thumb` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
180 `micro` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
181 `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
182 `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
183 `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
184 `request` varchar(255) COMMENT '',
185 `confirm` varchar(255) COMMENT '',
186 `poco` varchar(255) COMMENT '',
187 `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
188 `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = false instead',
189 `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = true instead',
190 `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
191 `site-pubkey` text COMMENT 'Deprecated',
192 `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
193 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
194 `issued-id` varchar(255) NOT NULL DEFAULT '' COMMENT 'Deprecated',
195 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT 'Deprecated',
196 `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
197 `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
198 `usehub` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
199 `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT 'Deprecated',
200 `profile-id` int unsigned COMMENT 'Deprecated',
202 INDEX `uid_name` (`uid`,`name`(190)),
203 INDEX `self_uid` (`self`,`uid`),
204 INDEX `alias_uid` (`alias`(128),`uid`),
205 INDEX `pending_uid` (`pending`,`uid`),
206 INDEX `blocked_uid` (`blocked`,`uid`),
207 INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
208 INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
209 INDEX `batch_contact-type` (`batch`(64),`contact-type`),
210 INDEX `addr_uid` (`addr`(128),`uid`),
211 INDEX `nurl_uid` (`nurl`(128),`uid`),
212 INDEX `nick_uid` (`nick`(128),`uid`),
213 INDEX `attag_uid` (`attag`(96),`uid`),
214 INDEX `network_uid_lastupdate` (`network`,`uid`,`last-update`),
215 INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`),
216 INDEX `uid_lastitem` (`uid`,`last-item`),
217 INDEX `baseurl` (`baseurl`(64)),
218 INDEX `uid_contact-type` (`uid`,`contact-type`),
219 INDEX `uid_self_contact-type` (`uid`,`self`,`contact-type`),
220 INDEX `self_network_uid` (`self`,`network`,`uid`),
221 INDEX `gsid` (`gsid`),
222 INDEX `uri-id` (`uri-id`),
223 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
224 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
225 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
226 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
231 CREATE TABLE IF NOT EXISTS `tag` (
232 `id` int unsigned NOT NULL auto_increment COMMENT '',
233 `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
234 `url` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
236 UNIQUE INDEX `type_name_url` (`name`,`url`),
238 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
241 -- TABLE permissionset
243 CREATE TABLE IF NOT EXISTS `permissionset` (
244 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
245 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
246 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
247 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
248 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
249 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
251 INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`uid`,`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30)),
252 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
253 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
258 CREATE TABLE IF NOT EXISTS `verb` (
259 `id` smallint unsigned NOT NULL auto_increment,
260 `name` varchar(100) NOT NULL DEFAULT '' COMMENT '',
262 INDEX `name` (`name`)
263 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activity Verbs';
266 -- TABLE 2fa_app_specific_password
268 CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
269 `id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
270 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
271 `description` varchar(255) COMMENT 'Description of the usage of the password',
272 `hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
273 `generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
274 `last_used` datetime COMMENT 'Datetime the password was last used',
276 INDEX `uid_description` (`uid`,`description`(190)),
277 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
278 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
281 -- TABLE 2fa_recovery_codes
283 CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
284 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
285 `code` varchar(50) NOT NULL COMMENT 'Recovery code string',
286 `generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
287 `used` datetime COMMENT 'Datetime the code was used',
288 PRIMARY KEY(`uid`,`code`),
289 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
290 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
293 -- TABLE 2fa_trusted_browser
295 CREATE TABLE IF NOT EXISTS `2fa_trusted_browser` (
296 `cookie_hash` varchar(80) NOT NULL COMMENT 'Trusted cookie hash',
297 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
298 `user_agent` text COMMENT 'User agent string',
299 `created` datetime NOT NULL COMMENT 'Datetime the trusted browser was recorded',
300 `last_used` datetime COMMENT 'Datetime the trusted browser was last used',
301 PRIMARY KEY(`cookie_hash`),
303 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
304 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication trusted browsers';
309 CREATE TABLE IF NOT EXISTS `addon` (
310 `id` int unsigned NOT NULL auto_increment COMMENT '',
311 `name` varchar(50) NOT NULL DEFAULT '' COMMENT 'addon base (file)name',
312 `version` varchar(50) NOT NULL DEFAULT '' COMMENT 'currently unused',
313 `installed` boolean NOT NULL DEFAULT '0' COMMENT 'currently always 1',
314 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'currently unused',
315 `timestamp` int unsigned NOT NULL DEFAULT 0 COMMENT 'file timestamp to check for reloads',
316 `plugin_admin` boolean NOT NULL DEFAULT '0' COMMENT '1 = has admin config, 0 = has no admin config',
318 INDEX `installed_name` (`installed`,`name`),
319 UNIQUE INDEX `name` (`name`)
320 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registered addons';
325 CREATE TABLE IF NOT EXISTS `apcontact` (
326 `url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
327 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
328 `uuid` varchar(255) COMMENT '',
329 `type` varchar(20) NOT NULL COMMENT '',
330 `following` varchar(255) COMMENT '',
331 `followers` varchar(255) COMMENT '',
332 `inbox` varchar(255) NOT NULL COMMENT '',
333 `outbox` varchar(255) COMMENT '',
334 `sharedinbox` varchar(255) COMMENT '',
335 `featured` varchar(255) COMMENT 'Address for the collection of featured posts',
336 `featured-tags` varchar(255) COMMENT 'Address for the collection of featured tags',
337 `manually-approve` boolean COMMENT '',
338 `discoverable` boolean COMMENT 'Mastodon extension: true if profile is published in their directory',
339 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
340 `name` varchar(255) COMMENT '',
341 `about` text COMMENT '',
342 `xmpp` varchar(255) COMMENT 'XMPP address',
343 `matrix` varchar(255) COMMENT 'Matrix address',
344 `photo` varchar(255) COMMENT '',
345 `header` varchar(255) COMMENT 'Header picture',
346 `addr` varchar(255) COMMENT '',
347 `alias` varchar(255) COMMENT '',
348 `pubkey` text COMMENT '',
349 `subscribe` varchar(255) COMMENT '',
350 `baseurl` varchar(255) COMMENT 'baseurl of the ap contact',
351 `gsid` int unsigned COMMENT 'Global Server ID',
352 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
353 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
354 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
355 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
356 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
358 INDEX `addr` (`addr`(32)),
359 INDEX `alias` (`alias`(190)),
360 INDEX `followers` (`followers`(190)),
361 INDEX `baseurl` (`baseurl`(190)),
362 INDEX `sharedinbox` (`sharedinbox`(190)),
363 INDEX `gsid` (`gsid`),
364 UNIQUE INDEX `uri-id` (`uri-id`),
365 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
366 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
367 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
372 CREATE TABLE IF NOT EXISTS `application` (
373 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
374 `client_id` varchar(64) NOT NULL COMMENT '',
375 `client_secret` varchar(64) NOT NULL COMMENT '',
376 `name` varchar(255) NOT NULL COMMENT '',
377 `redirect_uri` varchar(255) NOT NULL COMMENT '',
378 `website` varchar(255) COMMENT '',
379 `scopes` varchar(255) COMMENT '',
380 `read` boolean COMMENT 'Read scope',
381 `write` boolean COMMENT 'Write scope',
382 `follow` boolean COMMENT 'Follow scope',
383 `push` boolean COMMENT 'Push scope',
385 UNIQUE INDEX `client_id` (`client_id`)
386 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth application';
389 -- TABLE application-token
391 CREATE TABLE IF NOT EXISTS `application-token` (
392 `application-id` int unsigned NOT NULL COMMENT '',
393 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
394 `code` varchar(64) NOT NULL COMMENT '',
395 `access_token` varchar(64) NOT NULL COMMENT '',
396 `created_at` datetime NOT NULL COMMENT 'creation time',
397 `scopes` varchar(255) COMMENT '',
398 `read` boolean COMMENT 'Read scope',
399 `write` boolean COMMENT 'Write scope',
400 `follow` boolean COMMENT 'Follow scope',
401 `push` boolean COMMENT 'Push scope',
402 PRIMARY KEY(`application-id`,`uid`),
403 INDEX `uid_id` (`uid`,`application-id`),
404 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
405 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
406 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth user token';
411 CREATE TABLE IF NOT EXISTS `attach` (
412 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
413 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
414 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
415 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
416 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
417 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
418 `data` longblob NOT NULL COMMENT 'file data',
419 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
420 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
421 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
422 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
423 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
424 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
425 `backend-class` tinytext COMMENT 'Storage backend class',
426 `backend-ref` text COMMENT 'Storage backend data reference',
429 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
430 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
435 CREATE TABLE IF NOT EXISTS `cache` (
436 `k` varbinary(255) NOT NULL COMMENT 'cache key',
437 `v` mediumtext COMMENT 'cached serialized value',
438 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
439 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
441 INDEX `k_expires` (`k`,`expires`)
442 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
447 CREATE TABLE IF NOT EXISTS `config` (
448 `id` int unsigned NOT NULL auto_increment COMMENT '',
449 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
450 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
451 `v` mediumtext COMMENT '',
453 UNIQUE INDEX `cat_k` (`cat`,`k`)
454 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
457 -- TABLE contact-relation
459 CREATE TABLE IF NOT EXISTS `contact-relation` (
460 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
461 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
462 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
463 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
464 `follows` boolean NOT NULL DEFAULT '0' COMMENT '',
465 PRIMARY KEY(`cid`,`relation-cid`),
466 INDEX `relation-cid` (`relation-cid`),
467 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
468 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
469 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
474 CREATE TABLE IF NOT EXISTS `conv` (
475 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
476 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
477 `recips` text COMMENT 'sender_handle;recipient_handle',
478 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
479 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
480 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
481 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
482 `subject` text COMMENT 'subject of initial message',
485 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
486 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
489 -- TABLE conversation
491 CREATE TABLE IF NOT EXISTS `conversation` (
492 `item-uri` varbinary(255) NOT NULL COMMENT 'Original URI of the item - unrelated to the table with the same name',
493 `reply-to-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'URI to which this item is a reply',
494 `conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI',
495 `conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link',
496 `protocol` tinyint unsigned NOT NULL DEFAULT 255 COMMENT 'The protocol of the item',
497 `direction` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'How the message arrived here: 1=push, 2=pull',
498 `source` mediumtext COMMENT 'Original source',
499 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Receiving date',
500 PRIMARY KEY(`item-uri`),
501 INDEX `conversation-uri` (`conversation-uri`),
502 INDEX `received` (`received`)
503 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Raw data and structure information for messages';
508 CREATE TABLE IF NOT EXISTS `workerqueue` (
509 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
510 `command` varchar(100) COMMENT 'Task command',
511 `parameter` mediumtext COMMENT 'Task parameter',
512 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
513 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
514 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
515 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
516 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
517 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
518 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
520 INDEX `command` (`command`),
521 INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
522 INDEX `done_executed` (`done`,`executed`),
523 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
524 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
525 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
526 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
527 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
528 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
531 -- TABLE delayed-post
533 CREATE TABLE IF NOT EXISTS `delayed-post` (
534 `id` int unsigned NOT NULL auto_increment,
535 `uri` varchar(255) COMMENT 'URI of the post that will be distributed later',
536 `uid` mediumint unsigned COMMENT 'Owner User id',
537 `delayed` datetime COMMENT 'delay time',
538 `wid` int unsigned COMMENT 'Workerqueue id',
540 UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
542 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
543 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
544 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
547 -- TABLE diaspora-interaction
549 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
550 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
551 `interaction` mediumtext COMMENT 'The Diaspora interaction',
552 PRIMARY KEY(`uri-id`),
553 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
554 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
559 CREATE TABLE IF NOT EXISTS `event` (
560 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
561 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
562 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
563 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
564 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
565 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the event uri',
566 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
567 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
568 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
569 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
570 `summary` text COMMENT 'short description or title of the event',
571 `desc` text COMMENT 'event description',
572 `location` text COMMENT 'event location',
573 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
574 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
575 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
576 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
577 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
578 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
579 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
581 INDEX `uid_start` (`uid`,`start`),
583 INDEX `uri-id` (`uri-id`),
584 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
585 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
586 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
587 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
592 CREATE TABLE IF NOT EXISTS `fcontact` (
593 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
594 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
595 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
596 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the fcontact url',
597 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
598 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
599 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
600 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
601 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
602 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
603 `notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
604 `poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
605 `confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
606 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
607 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
608 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
609 `pubkey` text COMMENT '',
610 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
611 `interacting_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts this contact interactes with',
612 `interacted_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts that interacted with this contact',
613 `post_count` int unsigned DEFAULT 0 COMMENT 'Number of posts and comments',
615 INDEX `addr` (`addr`(32)),
616 UNIQUE INDEX `url` (`url`(190)),
617 UNIQUE INDEX `uri-id` (`uri-id`),
618 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
619 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
624 CREATE TABLE IF NOT EXISTS `fsuggest` (
625 `id` int unsigned NOT NULL auto_increment COMMENT '',
626 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
627 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
628 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
629 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
630 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
631 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
632 `note` text COMMENT '',
633 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
637 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
638 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
639 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
644 CREATE TABLE IF NOT EXISTS `group` (
645 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
646 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
647 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
648 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
649 `cid` int unsigned COMMENT 'Contact id of forum. When this field is filled then the members are synced automatically.',
650 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
654 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
655 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
656 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
659 -- TABLE group_member
661 CREATE TABLE IF NOT EXISTS `group_member` (
662 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
663 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
664 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
666 INDEX `contactid` (`contact-id`),
667 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
668 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
669 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
670 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
675 CREATE TABLE IF NOT EXISTS `gserver-tag` (
676 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
677 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
678 PRIMARY KEY(`gserver-id`,`tag`),
680 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
681 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
686 CREATE TABLE IF NOT EXISTS `hook` (
687 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
688 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
689 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
690 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
691 `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',
693 INDEX `priority` (`priority`),
694 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
695 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
698 -- TABLE inbox-status
700 CREATE TABLE IF NOT EXISTS `inbox-status` (
701 `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
702 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
703 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
704 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
705 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
706 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
707 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
709 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
714 CREATE TABLE IF NOT EXISTS `intro` (
715 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
716 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
717 `fid` int unsigned COMMENT 'deprecated',
718 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
719 `suggest-cid` int unsigned COMMENT 'Suggested contact',
720 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
721 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
722 `note` text COMMENT '',
723 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
724 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
725 `blocked` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
726 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
728 INDEX `contact-id` (`contact-id`),
729 INDEX `suggest-cid` (`suggest-cid`),
731 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
732 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
733 FOREIGN KEY (`suggest-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
734 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
739 CREATE TABLE IF NOT EXISTS `locks` (
740 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
741 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
742 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
743 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
744 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
746 INDEX `name_expires` (`name`,`expires`)
747 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
752 CREATE TABLE IF NOT EXISTS `mail` (
753 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
754 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
755 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
756 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
757 `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
758 `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
759 `contact-id` varchar(255) COMMENT 'contact.id',
760 `author-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the author of the mail',
761 `convid` int unsigned COMMENT 'conv.id',
762 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
763 `body` mediumtext COMMENT '',
764 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
765 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
766 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
767 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
768 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
769 `uri-id` int unsigned COMMENT 'Item-uri id of the related mail',
770 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
771 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related mail',
772 `thr-parent` varchar(255) COMMENT '',
773 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
774 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
776 INDEX `uid_seen` (`uid`,`seen`),
777 INDEX `convid` (`convid`),
778 INDEX `uri` (`uri`(64)),
779 INDEX `parent-uri` (`parent-uri`(64)),
780 INDEX `contactid` (`contact-id`(32)),
781 INDEX `author-id` (`author-id`),
782 INDEX `uri-id` (`uri-id`),
783 INDEX `parent-uri-id` (`parent-uri-id`),
784 INDEX `thr-parent-id` (`thr-parent-id`),
785 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
786 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
787 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
788 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
789 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
790 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
795 CREATE TABLE IF NOT EXISTS `mailacct` (
796 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
797 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
798 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
799 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
800 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
801 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
802 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
803 `pass` text COMMENT '',
804 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
805 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
806 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
807 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
808 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
811 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
812 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
817 CREATE TABLE IF NOT EXISTS `manage` (
818 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
819 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
820 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
822 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
824 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
825 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
826 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
829 -- TABLE notification
831 CREATE TABLE IF NOT EXISTS `notification` (
832 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
833 `uid` mediumint unsigned COMMENT 'Owner User id',
834 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
835 `type` tinyint unsigned COMMENT '',
836 `actor-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the actor that caused the notification',
837 `target-uri-id` int unsigned COMMENT 'Item-uri id of the related post',
838 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
839 `created` datetime COMMENT '',
840 `seen` boolean DEFAULT '0' COMMENT 'Seen on the desktop',
841 `dismissed` boolean DEFAULT '0' COMMENT 'Dismissed via the API',
843 UNIQUE INDEX `uid_vid_type_actor-id_target-uri-id` (`uid`,`vid`,`type`,`actor-id`,`target-uri-id`),
845 INDEX `actor-id` (`actor-id`),
846 INDEX `target-uri-id` (`target-uri-id`),
847 INDEX `parent-uri-id` (`parent-uri-id`),
848 INDEX `seen_uid` (`seen`,`uid`),
849 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
850 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
851 FOREIGN KEY (`actor-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
852 FOREIGN KEY (`target-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
853 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
854 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
859 CREATE TABLE IF NOT EXISTS `notify` (
860 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
861 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
862 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
863 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
864 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
865 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
866 `msg` mediumtext COMMENT '',
867 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
868 `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
869 `iid` int unsigned COMMENT '',
870 `parent` int unsigned COMMENT '',
871 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
872 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
873 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
874 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
875 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
876 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
877 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
879 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
880 INDEX `uid_date` (`uid`,`date`),
881 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
882 INDEX `uri-id` (`uri-id`),
883 INDEX `parent-uri-id` (`parent-uri-id`),
884 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
885 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
886 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
887 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='[Deprecated] User notifications';
890 -- TABLE notify-threads
892 CREATE TABLE IF NOT EXISTS `notify-threads` (
893 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
894 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
895 `master-parent-item` int unsigned COMMENT 'Deprecated',
896 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
897 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
898 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
900 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
901 INDEX `receiver-uid` (`receiver-uid`),
902 INDEX `notify-id` (`notify-id`),
903 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
904 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
905 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
906 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
911 CREATE TABLE IF NOT EXISTS `oembed` (
912 `url` varbinary(255) NOT NULL COMMENT 'page url',
913 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
914 `content` mediumtext COMMENT 'OEmbed data of the page',
915 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
916 PRIMARY KEY(`url`,`maxwidth`),
917 INDEX `created` (`created`)
918 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
921 -- TABLE openwebauth-token
923 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
924 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
925 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
926 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
927 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
928 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
929 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
932 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
933 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
938 CREATE TABLE IF NOT EXISTS `parsed_url` (
939 `url_hash` binary(64) NOT NULL COMMENT 'page url hash',
940 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
941 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
942 `url` text NOT NULL COMMENT 'page url',
943 `content` mediumtext COMMENT 'page data',
944 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
945 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration',
946 PRIMARY KEY(`url_hash`,`guessing`,`oembed`),
947 INDEX `created` (`created`),
948 INDEX `expires` (`expires`)
949 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
954 CREATE TABLE IF NOT EXISTS `pconfig` (
955 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
956 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
957 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
958 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
959 `v` mediumtext COMMENT 'Value',
961 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
962 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
963 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
968 CREATE TABLE IF NOT EXISTS `photo` (
969 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
970 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
971 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
972 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
973 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
974 `hash` char(32) COMMENT 'hash value of the photo',
975 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
976 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
977 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
978 `desc` text COMMENT '',
979 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
980 `photo-type` tinyint unsigned COMMENT 'User avatar, user banner, contact avatar, contact banner or default',
981 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
982 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
983 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
984 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
985 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
986 `data` mediumblob NOT NULL COMMENT '',
987 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
988 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
989 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
990 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
991 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
992 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
993 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
994 `backend-class` tinytext COMMENT 'Storage backend class',
995 `backend-ref` text COMMENT 'Storage backend data reference',
996 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
998 INDEX `contactid` (`contact-id`),
999 INDEX `uid_contactid` (`uid`,`contact-id`),
1000 INDEX `uid_profile` (`uid`,`profile`),
1001 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
1002 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
1003 INDEX `resource-id` (`resource-id`),
1004 INDEX `uid_photo-type` (`uid`,`photo-type`),
1005 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1006 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1007 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1012 CREATE TABLE IF NOT EXISTS `post` (
1013 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1014 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1015 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1016 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1017 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1018 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1019 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1020 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1021 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1022 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1023 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1024 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1025 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1026 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1027 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1028 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1029 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1030 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1031 PRIMARY KEY(`uri-id`),
1032 INDEX `parent-uri-id` (`parent-uri-id`),
1033 INDEX `thr-parent-id` (`thr-parent-id`),
1034 INDEX `external-id` (`external-id`),
1035 INDEX `owner-id` (`owner-id`),
1036 INDEX `author-id` (`author-id`),
1037 INDEX `causer-id` (`causer-id`),
1038 INDEX `vid` (`vid`),
1039 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1040 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1041 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1042 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1043 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1044 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1045 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1046 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1047 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
1050 -- TABLE post-category
1052 CREATE TABLE IF NOT EXISTS `post-category` (
1053 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1054 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1055 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1056 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1057 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1058 INDEX `uri-id` (`tid`),
1059 INDEX `uid` (`uid`),
1060 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1061 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1062 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1063 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1066 -- TABLE post-collection
1068 CREATE TABLE IF NOT EXISTS `post-collection` (
1069 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1070 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0 - Featured',
1071 PRIMARY KEY(`uri-id`,`type`),
1072 INDEX `type` (`type`),
1073 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1074 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Collection of posts';
1077 -- TABLE post-content
1079 CREATE TABLE IF NOT EXISTS `post-content` (
1080 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1081 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1082 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1083 `body` mediumtext COMMENT 'item body content',
1084 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1085 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1086 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1087 `language` text COMMENT 'Language information about this post',
1088 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1089 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1090 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1091 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1092 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1093 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1094 `target` text COMMENT 'JSON encoded target structure if used',
1095 `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',
1096 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1097 PRIMARY KEY(`uri-id`),
1098 INDEX `plink` (`plink`(191)),
1099 INDEX `resource-id` (`resource-id`),
1100 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
1101 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1102 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1105 -- TABLE post-delivery-data
1107 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1108 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1109 `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',
1110 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1111 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1112 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1113 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1114 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1115 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1116 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1117 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1118 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1119 PRIMARY KEY(`uri-id`),
1120 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1121 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1126 CREATE TABLE IF NOT EXISTS `post-link` (
1127 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1128 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1129 `url` varbinary(511) NOT NULL COMMENT 'External URL',
1130 `mimetype` varchar(60) COMMENT '',
1132 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1133 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1134 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post related external links';
1139 CREATE TABLE IF NOT EXISTS `post-media` (
1140 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1141 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1142 `url` varbinary(511) NOT NULL COMMENT 'Media URL',
1143 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1144 `mimetype` varchar(60) COMMENT '',
1145 `height` smallint unsigned COMMENT 'Height of the media',
1146 `width` smallint unsigned COMMENT 'Width of the media',
1147 `size` int unsigned COMMENT 'Media size',
1148 `preview` varbinary(255) COMMENT 'Preview URL',
1149 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1150 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1151 `description` text COMMENT '',
1152 `name` varchar(255) COMMENT 'Name of the media',
1153 `author-url` varbinary(255) COMMENT 'URL of the author of the media',
1154 `author-name` varchar(255) COMMENT 'Name of the author of the media',
1155 `author-image` varbinary(255) COMMENT 'Image of the author of the media',
1156 `publisher-url` varbinary(255) COMMENT 'URL of the publisher of the media',
1157 `publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
1158 `publisher-image` varbinary(255) COMMENT 'Image of the publisher of the media',
1160 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1161 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1162 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1165 -- TABLE post-question
1167 CREATE TABLE IF NOT EXISTS `post-question` (
1168 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1169 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1170 `multiple` boolean NOT NULL DEFAULT '0' COMMENT 'Multiple choice',
1171 `voters` int unsigned COMMENT 'Number of voters for this question',
1172 `end-time` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Question end time',
1174 UNIQUE INDEX `uri-id` (`uri-id`),
1175 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1176 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question';
1179 -- TABLE post-question-option
1181 CREATE TABLE IF NOT EXISTS `post-question-option` (
1182 `id` int unsigned NOT NULL COMMENT 'Id of the question',
1183 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1184 `name` varchar(255) COMMENT 'Name of the option',
1185 `replies` int unsigned COMMENT 'Number of replies for this question option',
1186 PRIMARY KEY(`uri-id`,`id`),
1187 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1188 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Question option';
1193 CREATE TABLE IF NOT EXISTS `post-tag` (
1194 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1195 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1196 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1197 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1198 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1199 INDEX `tid` (`tid`),
1200 INDEX `cid` (`cid`),
1201 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1202 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1203 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1204 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1207 -- TABLE post-thread
1209 CREATE TABLE IF NOT EXISTS `post-thread` (
1210 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1211 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1212 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1213 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1214 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1215 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1216 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1217 `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',
1218 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1219 PRIMARY KEY(`uri-id`),
1220 INDEX `owner-id` (`owner-id`),
1221 INDEX `author-id` (`author-id`),
1222 INDEX `causer-id` (`causer-id`),
1223 INDEX `received` (`received`),
1224 INDEX `commented` (`commented`),
1225 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1226 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1227 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1228 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1229 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1234 CREATE TABLE IF NOT EXISTS `post-user` (
1235 `id` int unsigned NOT NULL auto_increment,
1236 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1237 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1238 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1239 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1240 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1241 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1242 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1243 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1244 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1245 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1246 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1247 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1248 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1249 `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
1250 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1251 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1252 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1253 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1254 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1255 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1256 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1257 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1258 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1259 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1260 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1261 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1262 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1263 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1264 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1266 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1267 INDEX `uri-id` (`uri-id`),
1268 INDEX `parent-uri-id` (`parent-uri-id`),
1269 INDEX `thr-parent-id` (`thr-parent-id`),
1270 INDEX `external-id` (`external-id`),
1271 INDEX `owner-id` (`owner-id`),
1272 INDEX `author-id` (`author-id`),
1273 INDEX `causer-id` (`causer-id`),
1274 INDEX `vid` (`vid`),
1275 INDEX `contact-id` (`contact-id`),
1276 INDEX `event-id` (`event-id`),
1277 INDEX `psid` (`psid`),
1278 INDEX `author-id_uid` (`author-id`,`uid`),
1279 INDEX `author-id_received` (`author-id`,`received`),
1280 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1281 INDEX `uid_contactid` (`uid`,`contact-id`),
1282 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1283 INDEX `uid_unseen` (`uid`,`unseen`),
1284 INDEX `uid_hidden_uri-id` (`uid`,`hidden`,`uri-id`),
1285 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1286 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1287 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1288 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1289 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1290 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1291 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1292 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1293 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1294 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1295 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1296 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1297 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1300 -- TABLE post-thread-user
1302 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1303 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1304 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1305 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1306 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1307 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1308 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1309 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1310 `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',
1311 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1312 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1313 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
1314 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1315 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1316 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1317 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1318 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1319 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Deprecated',
1320 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1321 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1322 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1323 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1324 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1325 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1326 PRIMARY KEY(`uid`,`uri-id`),
1327 INDEX `uri-id` (`uri-id`),
1328 INDEX `owner-id` (`owner-id`),
1329 INDEX `author-id` (`author-id`),
1330 INDEX `causer-id` (`causer-id`),
1331 INDEX `uid` (`uid`),
1332 INDEX `contact-id` (`contact-id`),
1333 INDEX `psid` (`psid`),
1334 INDEX `post-user-id` (`post-user-id`),
1335 INDEX `commented` (`commented`),
1336 INDEX `uid_received` (`uid`,`received`),
1337 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1338 INDEX `uid_commented` (`uid`,`commented`),
1339 INDEX `uid_starred` (`uid`,`starred`),
1340 INDEX `uid_mention` (`uid`,`mention`),
1341 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1342 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1343 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1344 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1345 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1346 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1347 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1348 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1349 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1352 -- TABLE post-user-notification
1354 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1355 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1356 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1357 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1358 PRIMARY KEY(`uid`,`uri-id`),
1359 INDEX `uri-id` (`uri-id`),
1360 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1361 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1362 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1367 CREATE TABLE IF NOT EXISTS `process` (
1368 `pid` int unsigned NOT NULL COMMENT 'The ID of the process',
1369 `hostname` varchar(32) NOT NULL COMMENT 'The name of the host the process is ran on',
1370 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1371 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1372 PRIMARY KEY(`pid`,`hostname`),
1373 INDEX `command` (`command`)
1374 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1379 CREATE TABLE IF NOT EXISTS `profile` (
1380 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1381 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1382 `profile-name` varchar(255) COMMENT 'Deprecated',
1383 `is-default` boolean COMMENT 'Deprecated',
1384 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1385 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1386 `pdesc` varchar(255) COMMENT 'Deprecated',
1387 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1388 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1389 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1390 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1391 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1392 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1393 `hometown` varchar(255) COMMENT 'Deprecated',
1394 `gender` varchar(32) COMMENT 'Deprecated',
1395 `marital` varchar(255) COMMENT 'Deprecated',
1396 `with` text COMMENT 'Deprecated',
1397 `howlong` datetime COMMENT 'Deprecated',
1398 `sexual` varchar(255) COMMENT 'Deprecated',
1399 `politic` varchar(255) COMMENT 'Deprecated',
1400 `religion` varchar(255) COMMENT 'Deprecated',
1401 `pub_keywords` text COMMENT '',
1402 `prv_keywords` text COMMENT '',
1403 `likes` text COMMENT 'Deprecated',
1404 `dislikes` text COMMENT 'Deprecated',
1405 `about` text COMMENT 'Profile description',
1406 `summary` varchar(255) COMMENT 'Deprecated',
1407 `music` text COMMENT 'Deprecated',
1408 `book` text COMMENT 'Deprecated',
1409 `tv` text COMMENT 'Deprecated',
1410 `film` text COMMENT 'Deprecated',
1411 `interest` text COMMENT 'Deprecated',
1412 `romance` text COMMENT 'Deprecated',
1413 `work` text COMMENT 'Deprecated',
1414 `education` text COMMENT 'Deprecated',
1415 `contact` text COMMENT 'Deprecated',
1416 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1417 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
1418 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
1419 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1420 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1421 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1422 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1424 INDEX `uid_is-default` (`uid`,`is-default`),
1425 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1426 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1427 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1430 -- TABLE profile_field
1432 CREATE TABLE IF NOT EXISTS `profile_field` (
1433 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1434 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1435 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1436 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1437 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1438 `value` text COMMENT 'Value of the field',
1439 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1440 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1442 INDEX `uid` (`uid`),
1443 INDEX `order` (`order`),
1444 INDEX `psid` (`psid`),
1445 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1446 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1447 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1450 -- TABLE push_subscriber
1452 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1453 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1454 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1455 `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1456 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1457 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1458 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1459 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1460 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1461 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1462 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1464 INDEX `next_try` (`next_try`),
1465 INDEX `uid` (`uid`),
1466 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1467 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1472 CREATE TABLE IF NOT EXISTS `register` (
1473 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1474 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1475 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1476 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1477 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1478 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1479 `note` text COMMENT '',
1481 INDEX `uid` (`uid`),
1482 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1483 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1488 CREATE TABLE IF NOT EXISTS `search` (
1489 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1490 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1491 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1493 INDEX `uid_term` (`uid`,`term`(64)),
1494 INDEX `term` (`term`(64)),
1495 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1496 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1501 CREATE TABLE IF NOT EXISTS `session` (
1502 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1503 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1504 `data` text COMMENT '',
1505 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1507 INDEX `sid` (`sid`(64)),
1508 INDEX `expire` (`expire`)
1509 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1514 CREATE TABLE IF NOT EXISTS `storage` (
1515 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1516 `data` longblob NOT NULL COMMENT 'file data',
1518 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1521 -- TABLE subscription
1523 CREATE TABLE IF NOT EXISTS `subscription` (
1524 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1525 `application-id` int unsigned NOT NULL COMMENT '',
1526 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
1527 `endpoint` varchar(511) COMMENT 'Endpoint URL',
1528 `pubkey` varchar(127) COMMENT 'User agent public key',
1529 `secret` varchar(32) COMMENT 'Auth secret',
1530 `follow` boolean COMMENT '',
1531 `favourite` boolean COMMENT '',
1532 `reblog` boolean COMMENT '',
1533 `mention` boolean COMMENT '',
1534 `poll` boolean COMMENT '',
1535 `follow_request` boolean COMMENT '',
1536 `status` boolean COMMENT '',
1538 UNIQUE INDEX `application-id_uid` (`application-id`,`uid`),
1539 INDEX `uid_application-id` (`uid`,`application-id`),
1540 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1541 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1542 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Push Subscription for the API';
1547 CREATE TABLE IF NOT EXISTS `userd` (
1548 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1549 `username` varchar(255) NOT NULL COMMENT '',
1551 INDEX `username` (`username`(32))
1552 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1555 -- TABLE user-contact
1557 CREATE TABLE IF NOT EXISTS `user-contact` (
1558 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1559 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1560 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
1561 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1562 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1563 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1564 `hidden` boolean COMMENT 'This contact is hidden from the others',
1565 `is-blocked` boolean COMMENT 'User is blocked by this contact',
1566 `pending` boolean COMMENT '',
1567 `rel` tinyint unsigned COMMENT 'The kind of the relation between the user and the contact',
1568 `info` mediumtext COMMENT '',
1569 `notify_new_posts` boolean COMMENT '',
1570 `remote_self` boolean COMMENT '',
1571 `fetch_further_information` tinyint unsigned COMMENT '',
1572 `ffi_keyword_denylist` text COMMENT '',
1573 `subhub` boolean COMMENT '',
1574 `hub-verify` varchar(255) COMMENT '',
1575 `protocol` char(4) COMMENT 'Protocol of the contact',
1576 `rating` tinyint COMMENT 'Automatically detected feed poll frequency',
1577 `priority` tinyint unsigned COMMENT 'Feed poll priority',
1578 PRIMARY KEY(`uid`,`cid`),
1579 INDEX `cid` (`cid`),
1580 UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
1581 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1582 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1583 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1584 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1589 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1590 `key` int NOT NULL COMMENT '',
1591 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1593 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1596 -- VIEW application-view
1598 DROP VIEW IF EXISTS `application-view`;
1599 CREATE VIEW `application-view` AS SELECT
1600 `application`.`id` AS `id`,
1601 `application-token`.`uid` AS `uid`,
1602 `application`.`name` AS `name`,
1603 `application`.`redirect_uri` AS `redirect_uri`,
1604 `application`.`website` AS `website`,
1605 `application`.`client_id` AS `client_id`,
1606 `application`.`client_secret` AS `client_secret`,
1607 `application-token`.`code` AS `code`,
1608 `application-token`.`access_token` AS `access_token`,
1609 `application-token`.`created_at` AS `created_at`,
1610 `application-token`.`scopes` AS `scopes`,
1611 `application-token`.`read` AS `read`,
1612 `application-token`.`write` AS `write`,
1613 `application-token`.`follow` AS `follow`,
1614 `application-token`.`push` AS `push`
1615 FROM `application-token`
1616 INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`;
1619 -- VIEW post-user-view
1621 DROP VIEW IF EXISTS `post-user-view`;
1622 CREATE VIEW `post-user-view` AS SELECT
1623 `post-user`.`id` AS `id`,
1624 `post-user`.`id` AS `post-user-id`,
1625 `post-user`.`uid` AS `uid`,
1626 `parent-post`.`id` AS `parent`,
1627 `item-uri`.`uri` AS `uri`,
1628 `post-user`.`uri-id` AS `uri-id`,
1629 `parent-item-uri`.`uri` AS `parent-uri`,
1630 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1631 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1632 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1633 `item-uri`.`guid` AS `guid`,
1634 `post-user`.`wall` AS `wall`,
1635 `post-user`.`gravity` AS `gravity`,
1636 `external-item-uri`.`uri` AS `extid`,
1637 `post-user`.`external-id` AS `external-id`,
1638 `post-user`.`created` AS `created`,
1639 `post-user`.`edited` AS `edited`,
1640 `post-thread-user`.`commented` AS `commented`,
1641 `post-user`.`received` AS `received`,
1642 `post-thread-user`.`changed` AS `changed`,
1643 `post-user`.`post-type` AS `post-type`,
1644 `post-user`.`post-reason` AS `post-reason`,
1645 `post-user`.`private` AS `private`,
1646 `post-thread-user`.`pubmail` AS `pubmail`,
1647 `post-user`.`visible` AS `visible`,
1648 `post-thread-user`.`starred` AS `starred`,
1649 `post-user`.`unseen` AS `unseen`,
1650 `post-user`.`deleted` AS `deleted`,
1651 `post-user`.`origin` AS `origin`,
1652 `post-thread-user`.`origin` AS `parent-origin`,
1653 `post-thread-user`.`mention` AS `mention`,
1654 `post-user`.`global` AS `global`,
1655 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-user`.`uri-id`) AS `featured`,
1656 `post-user`.`network` AS `network`,
1657 `post-user`.`vid` AS `vid`,
1658 `post-user`.`psid` AS `psid`,
1659 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1660 `post-content`.`title` AS `title`,
1661 `post-content`.`content-warning` AS `content-warning`,
1662 `post-content`.`raw-body` AS `raw-body`,
1663 IFNULL (`post-content`.`body`, '') AS `body`,
1664 `post-content`.`rendered-hash` AS `rendered-hash`,
1665 `post-content`.`rendered-html` AS `rendered-html`,
1666 `post-content`.`language` AS `language`,
1667 `post-content`.`plink` AS `plink`,
1668 `post-content`.`location` AS `location`,
1669 `post-content`.`coord` AS `coord`,
1670 `post-content`.`app` AS `app`,
1671 `post-content`.`object-type` AS `object-type`,
1672 `post-content`.`object` AS `object`,
1673 `post-content`.`target-type` AS `target-type`,
1674 `post-content`.`target` AS `target`,
1675 `post-content`.`resource-id` AS `resource-id`,
1676 `post-user`.`contact-id` AS `contact-id`,
1677 `contact`.`url` AS `contact-link`,
1678 `contact`.`addr` AS `contact-addr`,
1679 `contact`.`name` AS `contact-name`,
1680 `contact`.`nick` AS `contact-nick`,
1681 `contact`.`thumb` AS `contact-avatar`,
1682 `contact`.`network` AS `contact-network`,
1683 `contact`.`blocked` AS `contact-blocked`,
1684 `contact`.`hidden` AS `contact-hidden`,
1685 `contact`.`readonly` AS `contact-readonly`,
1686 `contact`.`archive` AS `contact-archive`,
1687 `contact`.`pending` AS `contact-pending`,
1688 `contact`.`rel` AS `contact-rel`,
1689 `contact`.`uid` AS `contact-uid`,
1690 `contact`.`contact-type` AS `contact-contact-type`,
1691 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1692 `contact`.`self` AS `self`,
1693 `contact`.`id` AS `cid`,
1694 `contact`.`alias` AS `alias`,
1695 `contact`.`photo` AS `photo`,
1696 `contact`.`name-date` AS `name-date`,
1697 `contact`.`uri-date` AS `uri-date`,
1698 `contact`.`avatar-date` AS `avatar-date`,
1699 `contact`.`thumb` AS `thumb`,
1700 `post-user`.`author-id` AS `author-id`,
1701 `author`.`url` AS `author-link`,
1702 `author`.`addr` AS `author-addr`,
1703 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1704 `author`.`nick` AS `author-nick`,
1705 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1706 `author`.`network` AS `author-network`,
1707 `author`.`blocked` AS `author-blocked`,
1708 `author`.`hidden` AS `author-hidden`,
1709 `post-user`.`owner-id` AS `owner-id`,
1710 `owner`.`url` AS `owner-link`,
1711 `owner`.`addr` AS `owner-addr`,
1712 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1713 `owner`.`nick` AS `owner-nick`,
1714 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1715 `owner`.`network` AS `owner-network`,
1716 `owner`.`blocked` AS `owner-blocked`,
1717 `owner`.`hidden` AS `owner-hidden`,
1718 `owner`.`contact-type` AS `owner-contact-type`,
1719 `post-user`.`causer-id` AS `causer-id`,
1720 `causer`.`url` AS `causer-link`,
1721 `causer`.`addr` AS `causer-addr`,
1722 `causer`.`name` AS `causer-name`,
1723 `causer`.`nick` AS `causer-nick`,
1724 `causer`.`thumb` AS `causer-avatar`,
1725 `causer`.`network` AS `causer-network`,
1726 `causer`.`blocked` AS `causer-blocked`,
1727 `causer`.`hidden` AS `causer-hidden`,
1728 `causer`.`contact-type` AS `causer-contact-type`,
1729 `post-delivery-data`.`postopts` AS `postopts`,
1730 `post-delivery-data`.`inform` AS `inform`,
1731 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1732 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1733 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1734 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1735 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1736 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1737 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1738 `post-user`.`event-id` AS `event-id`,
1739 `event`.`created` AS `event-created`,
1740 `event`.`edited` AS `event-edited`,
1741 `event`.`start` AS `event-start`,
1742 `event`.`finish` AS `event-finish`,
1743 `event`.`summary` AS `event-summary`,
1744 `event`.`desc` AS `event-desc`,
1745 `event`.`location` AS `event-location`,
1746 `event`.`type` AS `event-type`,
1747 `event`.`nofinish` AS `event-nofinish`,
1748 `event`.`ignore` AS `event-ignore`,
1749 `post-question`.`id` AS `question-id`,
1750 `post-question`.`multiple` AS `question-multiple`,
1751 `post-question`.`voters` AS `question-voters`,
1752 `post-question`.`end-time` AS `question-end-time`,
1753 `diaspora-interaction`.`interaction` AS `signed_text`,
1754 `parent-item-uri`.`guid` AS `parent-guid`,
1755 `parent-post`.`network` AS `parent-network`,
1756 `parent-post`.`author-id` AS `parent-author-id`,
1757 `parent-post-author`.`url` AS `parent-author-link`,
1758 `parent-post-author`.`name` AS `parent-author-name`,
1759 `parent-post-author`.`nick` AS `parent-author-nick`,
1760 `parent-post-author`.`network` AS `parent-author-network`,
1761 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1762 `parent-post-author`.`hidden` AS `parent-author-hidden`
1764 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
1765 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
1766 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
1767 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
1768 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
1769 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
1770 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1771 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1772 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1773 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1774 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1775 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
1776 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
1777 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
1778 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-user`.`uri-id`
1779 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
1780 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
1781 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1784 -- VIEW post-thread-user-view
1786 DROP VIEW IF EXISTS `post-thread-user-view`;
1787 CREATE VIEW `post-thread-user-view` AS SELECT
1788 `post-user`.`id` AS `id`,
1789 `post-user`.`id` AS `post-user-id`,
1790 `post-thread-user`.`uid` AS `uid`,
1791 `parent-post`.`id` AS `parent`,
1792 `item-uri`.`uri` AS `uri`,
1793 `post-thread-user`.`uri-id` AS `uri-id`,
1794 `parent-item-uri`.`uri` AS `parent-uri`,
1795 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1796 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1797 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1798 `item-uri`.`guid` AS `guid`,
1799 `post-thread-user`.`wall` AS `wall`,
1800 `post-user`.`gravity` AS `gravity`,
1801 `external-item-uri`.`uri` AS `extid`,
1802 `post-user`.`external-id` AS `external-id`,
1803 `post-thread-user`.`created` AS `created`,
1804 `post-user`.`edited` AS `edited`,
1805 `post-thread-user`.`commented` AS `commented`,
1806 `post-thread-user`.`received` AS `received`,
1807 `post-thread-user`.`changed` AS `changed`,
1808 `post-user`.`post-type` AS `post-type`,
1809 `post-user`.`post-reason` AS `post-reason`,
1810 `post-user`.`private` AS `private`,
1811 `post-thread-user`.`pubmail` AS `pubmail`,
1812 `post-thread-user`.`ignored` AS `ignored`,
1813 `post-user`.`visible` AS `visible`,
1814 `post-thread-user`.`starred` AS `starred`,
1815 `post-thread-user`.`unseen` AS `unseen`,
1816 `post-user`.`deleted` AS `deleted`,
1817 `post-thread-user`.`origin` AS `origin`,
1818 `post-thread-user`.`mention` AS `mention`,
1819 `post-user`.`global` AS `global`,
1820 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread-user`.`uri-id`) AS `featured`,
1821 `post-thread-user`.`network` AS `network`,
1822 `post-user`.`vid` AS `vid`,
1823 `post-thread-user`.`psid` AS `psid`,
1824 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1825 `post-content`.`title` AS `title`,
1826 `post-content`.`content-warning` AS `content-warning`,
1827 `post-content`.`raw-body` AS `raw-body`,
1828 `post-content`.`body` AS `body`,
1829 `post-content`.`rendered-hash` AS `rendered-hash`,
1830 `post-content`.`rendered-html` AS `rendered-html`,
1831 `post-content`.`language` AS `language`,
1832 `post-content`.`plink` AS `plink`,
1833 `post-content`.`location` AS `location`,
1834 `post-content`.`coord` AS `coord`,
1835 `post-content`.`app` AS `app`,
1836 `post-content`.`object-type` AS `object-type`,
1837 `post-content`.`object` AS `object`,
1838 `post-content`.`target-type` AS `target-type`,
1839 `post-content`.`target` AS `target`,
1840 `post-content`.`resource-id` AS `resource-id`,
1841 `post-thread-user`.`contact-id` AS `contact-id`,
1842 `contact`.`url` AS `contact-link`,
1843 `contact`.`addr` AS `contact-addr`,
1844 `contact`.`name` AS `contact-name`,
1845 `contact`.`nick` AS `contact-nick`,
1846 `contact`.`thumb` AS `contact-avatar`,
1847 `contact`.`network` AS `contact-network`,
1848 `contact`.`blocked` AS `contact-blocked`,
1849 `contact`.`hidden` AS `contact-hidden`,
1850 `contact`.`readonly` AS `contact-readonly`,
1851 `contact`.`archive` AS `contact-archive`,
1852 `contact`.`pending` AS `contact-pending`,
1853 `contact`.`rel` AS `contact-rel`,
1854 `contact`.`uid` AS `contact-uid`,
1855 `contact`.`contact-type` AS `contact-contact-type`,
1856 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1857 `contact`.`self` AS `self`,
1858 `contact`.`id` AS `cid`,
1859 `contact`.`alias` AS `alias`,
1860 `contact`.`photo` AS `photo`,
1861 `contact`.`name-date` AS `name-date`,
1862 `contact`.`uri-date` AS `uri-date`,
1863 `contact`.`avatar-date` AS `avatar-date`,
1864 `contact`.`thumb` AS `thumb`,
1865 `post-thread-user`.`author-id` AS `author-id`,
1866 `author`.`url` AS `author-link`,
1867 `author`.`addr` AS `author-addr`,
1868 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1869 `author`.`nick` AS `author-nick`,
1870 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1871 `author`.`network` AS `author-network`,
1872 `author`.`blocked` AS `author-blocked`,
1873 `author`.`hidden` AS `author-hidden`,
1874 `post-thread-user`.`owner-id` AS `owner-id`,
1875 `owner`.`url` AS `owner-link`,
1876 `owner`.`addr` AS `owner-addr`,
1877 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1878 `owner`.`nick` AS `owner-nick`,
1879 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1880 `owner`.`network` AS `owner-network`,
1881 `owner`.`blocked` AS `owner-blocked`,
1882 `owner`.`hidden` AS `owner-hidden`,
1883 `owner`.`contact-type` AS `owner-contact-type`,
1884 `post-thread-user`.`causer-id` AS `causer-id`,
1885 `causer`.`url` AS `causer-link`,
1886 `causer`.`addr` AS `causer-addr`,
1887 `causer`.`name` AS `causer-name`,
1888 `causer`.`nick` AS `causer-nick`,
1889 `causer`.`thumb` AS `causer-avatar`,
1890 `causer`.`network` AS `causer-network`,
1891 `causer`.`blocked` AS `causer-blocked`,
1892 `causer`.`hidden` AS `causer-hidden`,
1893 `causer`.`contact-type` AS `causer-contact-type`,
1894 `post-delivery-data`.`postopts` AS `postopts`,
1895 `post-delivery-data`.`inform` AS `inform`,
1896 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1897 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1898 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1899 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1900 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1901 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1902 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1903 `post-user`.`event-id` AS `event-id`,
1904 `event`.`created` AS `event-created`,
1905 `event`.`edited` AS `event-edited`,
1906 `event`.`start` AS `event-start`,
1907 `event`.`finish` AS `event-finish`,
1908 `event`.`summary` AS `event-summary`,
1909 `event`.`desc` AS `event-desc`,
1910 `event`.`location` AS `event-location`,
1911 `event`.`type` AS `event-type`,
1912 `event`.`nofinish` AS `event-nofinish`,
1913 `event`.`ignore` AS `event-ignore`,
1914 `post-question`.`id` AS `question-id`,
1915 `post-question`.`multiple` AS `question-multiple`,
1916 `post-question`.`voters` AS `question-voters`,
1917 `post-question`.`end-time` AS `question-end-time`,
1918 `diaspora-interaction`.`interaction` AS `signed_text`,
1919 `parent-item-uri`.`guid` AS `parent-guid`,
1920 `parent-post`.`network` AS `parent-network`,
1921 `parent-post`.`author-id` AS `parent-author-id`,
1922 `parent-post-author`.`url` AS `parent-author-link`,
1923 `parent-post-author`.`name` AS `parent-author-name`,
1924 `parent-post-author`.`network` AS `parent-author-network`,
1925 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1926 `parent-post-author`.`hidden` AS `parent-author-hidden`
1927 FROM `post-thread-user`
1928 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
1929 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
1930 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
1931 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
1932 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
1933 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
1934 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1935 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1936 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1937 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1938 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1939 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
1940 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
1941 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
1942 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread-user`.`uri-id`
1943 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
1944 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`
1945 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1950 DROP VIEW IF EXISTS `post-view`;
1951 CREATE VIEW `post-view` AS SELECT
1952 `item-uri`.`uri` AS `uri`,
1953 `post`.`uri-id` AS `uri-id`,
1954 `parent-item-uri`.`uri` AS `parent-uri`,
1955 `post`.`parent-uri-id` AS `parent-uri-id`,
1956 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1957 `post`.`thr-parent-id` AS `thr-parent-id`,
1958 `item-uri`.`guid` AS `guid`,
1959 `post`.`gravity` AS `gravity`,
1960 `external-item-uri`.`uri` AS `extid`,
1961 `post`.`external-id` AS `external-id`,
1962 `post`.`created` AS `created`,
1963 `post`.`edited` AS `edited`,
1964 `post-thread`.`commented` AS `commented`,
1965 `post`.`received` AS `received`,
1966 `post-thread`.`changed` AS `changed`,
1967 `post`.`post-type` AS `post-type`,
1968 `post`.`private` AS `private`,
1969 `post`.`visible` AS `visible`,
1970 `post`.`deleted` AS `deleted`,
1971 `post`.`global` AS `global`,
1972 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post`.`uri-id`) AS `featured`,
1973 `post`.`network` AS `network`,
1974 `post`.`vid` AS `vid`,
1975 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1976 `post-content`.`title` AS `title`,
1977 `post-content`.`content-warning` AS `content-warning`,
1978 `post-content`.`raw-body` AS `raw-body`,
1979 `post-content`.`body` AS `body`,
1980 `post-content`.`rendered-hash` AS `rendered-hash`,
1981 `post-content`.`rendered-html` AS `rendered-html`,
1982 `post-content`.`language` AS `language`,
1983 `post-content`.`plink` AS `plink`,
1984 `post-content`.`location` AS `location`,
1985 `post-content`.`coord` AS `coord`,
1986 `post-content`.`app` AS `app`,
1987 `post-content`.`object-type` AS `object-type`,
1988 `post-content`.`object` AS `object`,
1989 `post-content`.`target-type` AS `target-type`,
1990 `post-content`.`target` AS `target`,
1991 `post-content`.`resource-id` AS `resource-id`,
1992 `post`.`author-id` AS `contact-id`,
1993 `author`.`url` AS `contact-link`,
1994 `author`.`addr` AS `contact-addr`,
1995 `author`.`name` AS `contact-name`,
1996 `author`.`nick` AS `contact-nick`,
1997 `author`.`thumb` AS `contact-avatar`,
1998 `author`.`network` AS `contact-network`,
1999 `author`.`blocked` AS `contact-blocked`,
2000 `author`.`hidden` AS `contact-hidden`,
2001 `author`.`readonly` AS `contact-readonly`,
2002 `author`.`archive` AS `contact-archive`,
2003 `author`.`pending` AS `contact-pending`,
2004 `author`.`rel` AS `contact-rel`,
2005 `author`.`uid` AS `contact-uid`,
2006 `author`.`contact-type` AS `contact-contact-type`,
2007 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2009 `author`.`id` AS `cid`,
2010 `author`.`alias` AS `alias`,
2011 `author`.`photo` AS `photo`,
2012 `author`.`name-date` AS `name-date`,
2013 `author`.`uri-date` AS `uri-date`,
2014 `author`.`avatar-date` AS `avatar-date`,
2015 `author`.`thumb` AS `thumb`,
2016 `post`.`author-id` AS `author-id`,
2017 `author`.`url` AS `author-link`,
2018 `author`.`addr` AS `author-addr`,
2019 `author`.`name` AS `author-name`,
2020 `author`.`nick` AS `author-nick`,
2021 `author`.`thumb` AS `author-avatar`,
2022 `author`.`network` AS `author-network`,
2023 `author`.`blocked` AS `author-blocked`,
2024 `author`.`hidden` AS `author-hidden`,
2025 `post`.`owner-id` AS `owner-id`,
2026 `owner`.`url` AS `owner-link`,
2027 `owner`.`addr` AS `owner-addr`,
2028 `owner`.`name` AS `owner-name`,
2029 `owner`.`nick` AS `owner-nick`,
2030 `owner`.`thumb` AS `owner-avatar`,
2031 `owner`.`network` AS `owner-network`,
2032 `owner`.`blocked` AS `owner-blocked`,
2033 `owner`.`hidden` AS `owner-hidden`,
2034 `owner`.`contact-type` AS `owner-contact-type`,
2035 `post`.`causer-id` AS `causer-id`,
2036 `causer`.`url` AS `causer-link`,
2037 `causer`.`addr` AS `causer-addr`,
2038 `causer`.`name` AS `causer-name`,
2039 `causer`.`nick` AS `causer-nick`,
2040 `causer`.`thumb` AS `causer-avatar`,
2041 `causer`.`network` AS `causer-network`,
2042 `causer`.`blocked` AS `causer-blocked`,
2043 `causer`.`hidden` AS `causer-hidden`,
2044 `causer`.`contact-type` AS `causer-contact-type`,
2045 `post-question`.`id` AS `question-id`,
2046 `post-question`.`multiple` AS `question-multiple`,
2047 `post-question`.`voters` AS `question-voters`,
2048 `post-question`.`end-time` AS `question-end-time`,
2049 `diaspora-interaction`.`interaction` AS `signed_text`,
2050 `parent-item-uri`.`guid` AS `parent-guid`,
2051 `parent-post`.`network` AS `parent-network`,
2052 `parent-post`.`author-id` AS `parent-author-id`,
2053 `parent-post-author`.`url` AS `parent-author-link`,
2054 `parent-post-author`.`name` AS `parent-author-name`,
2055 `parent-post-author`.`network` AS `parent-author-network`,
2056 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2057 `parent-post-author`.`hidden` AS `parent-author-hidden`
2059 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
2060 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
2061 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
2062 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
2063 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
2064 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2065 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2066 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2067 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2068 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
2069 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
2070 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post`.`uri-id`
2071 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2072 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2075 -- VIEW post-thread-view
2077 DROP VIEW IF EXISTS `post-thread-view`;
2078 CREATE VIEW `post-thread-view` AS SELECT
2079 `item-uri`.`uri` AS `uri`,
2080 `post-thread`.`uri-id` AS `uri-id`,
2081 `parent-item-uri`.`uri` AS `parent-uri`,
2082 `post`.`parent-uri-id` AS `parent-uri-id`,
2083 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2084 `post`.`thr-parent-id` AS `thr-parent-id`,
2085 `item-uri`.`guid` AS `guid`,
2086 `post`.`gravity` AS `gravity`,
2087 `external-item-uri`.`uri` AS `extid`,
2088 `post`.`external-id` AS `external-id`,
2089 `post-thread`.`created` AS `created`,
2090 `post`.`edited` AS `edited`,
2091 `post-thread`.`commented` AS `commented`,
2092 `post-thread`.`received` AS `received`,
2093 `post-thread`.`changed` AS `changed`,
2094 `post`.`post-type` AS `post-type`,
2095 `post`.`private` AS `private`,
2096 `post`.`visible` AS `visible`,
2097 `post`.`deleted` AS `deleted`,
2098 `post`.`global` AS `global`,
2099 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread`.`uri-id`) AS `featured`,
2100 `post-thread`.`network` AS `network`,
2101 `post`.`vid` AS `vid`,
2102 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2103 `post-content`.`title` AS `title`,
2104 `post-content`.`content-warning` AS `content-warning`,
2105 `post-content`.`raw-body` AS `raw-body`,
2106 `post-content`.`body` AS `body`,
2107 `post-content`.`rendered-hash` AS `rendered-hash`,
2108 `post-content`.`rendered-html` AS `rendered-html`,
2109 `post-content`.`language` AS `language`,
2110 `post-content`.`plink` AS `plink`,
2111 `post-content`.`location` AS `location`,
2112 `post-content`.`coord` AS `coord`,
2113 `post-content`.`app` AS `app`,
2114 `post-content`.`object-type` AS `object-type`,
2115 `post-content`.`object` AS `object`,
2116 `post-content`.`target-type` AS `target-type`,
2117 `post-content`.`target` AS `target`,
2118 `post-content`.`resource-id` AS `resource-id`,
2119 `post-thread`.`author-id` AS `contact-id`,
2120 `author`.`url` AS `contact-link`,
2121 `author`.`addr` AS `contact-addr`,
2122 `author`.`name` AS `contact-name`,
2123 `author`.`nick` AS `contact-nick`,
2124 `author`.`thumb` AS `contact-avatar`,
2125 `author`.`network` AS `contact-network`,
2126 `author`.`blocked` AS `contact-blocked`,
2127 `author`.`hidden` AS `contact-hidden`,
2128 `author`.`readonly` AS `contact-readonly`,
2129 `author`.`archive` AS `contact-archive`,
2130 `author`.`pending` AS `contact-pending`,
2131 `author`.`rel` AS `contact-rel`,
2132 `author`.`uid` AS `contact-uid`,
2133 `author`.`contact-type` AS `contact-contact-type`,
2134 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2136 `author`.`id` AS `cid`,
2137 `author`.`alias` AS `alias`,
2138 `author`.`photo` AS `photo`,
2139 `author`.`name-date` AS `name-date`,
2140 `author`.`uri-date` AS `uri-date`,
2141 `author`.`avatar-date` AS `avatar-date`,
2142 `author`.`thumb` AS `thumb`,
2143 `post-thread`.`author-id` AS `author-id`,
2144 `author`.`url` AS `author-link`,
2145 `author`.`addr` AS `author-addr`,
2146 `author`.`name` AS `author-name`,
2147 `author`.`nick` AS `author-nick`,
2148 `author`.`thumb` AS `author-avatar`,
2149 `author`.`network` AS `author-network`,
2150 `author`.`blocked` AS `author-blocked`,
2151 `author`.`hidden` AS `author-hidden`,
2152 `post-thread`.`owner-id` AS `owner-id`,
2153 `owner`.`url` AS `owner-link`,
2154 `owner`.`addr` AS `owner-addr`,
2155 `owner`.`name` AS `owner-name`,
2156 `owner`.`nick` AS `owner-nick`,
2157 `owner`.`thumb` AS `owner-avatar`,
2158 `owner`.`network` AS `owner-network`,
2159 `owner`.`blocked` AS `owner-blocked`,
2160 `owner`.`hidden` AS `owner-hidden`,
2161 `owner`.`contact-type` AS `owner-contact-type`,
2162 `post-thread`.`causer-id` AS `causer-id`,
2163 `causer`.`url` AS `causer-link`,
2164 `causer`.`addr` AS `causer-addr`,
2165 `causer`.`name` AS `causer-name`,
2166 `causer`.`nick` AS `causer-nick`,
2167 `causer`.`thumb` AS `causer-avatar`,
2168 `causer`.`network` AS `causer-network`,
2169 `causer`.`blocked` AS `causer-blocked`,
2170 `causer`.`hidden` AS `causer-hidden`,
2171 `causer`.`contact-type` AS `causer-contact-type`,
2172 `post-question`.`id` AS `question-id`,
2173 `post-question`.`multiple` AS `question-multiple`,
2174 `post-question`.`voters` AS `question-voters`,
2175 `post-question`.`end-time` AS `question-end-time`,
2176 `diaspora-interaction`.`interaction` AS `signed_text`,
2177 `parent-item-uri`.`guid` AS `parent-guid`,
2178 `parent-post`.`network` AS `parent-network`,
2179 `parent-post`.`author-id` AS `parent-author-id`,
2180 `parent-post-author`.`url` AS `parent-author-link`,
2181 `parent-post-author`.`name` AS `parent-author-name`,
2182 `parent-post-author`.`network` AS `parent-author-network`,
2183 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2184 `parent-post-author`.`hidden` AS `parent-author-hidden`
2186 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
2187 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
2188 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
2189 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
2190 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
2191 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2192 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2193 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2194 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2195 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
2196 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
2197 LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread`.`uri-id`
2198 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2199 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2202 -- VIEW category-view
2204 DROP VIEW IF EXISTS `category-view`;
2205 CREATE VIEW `category-view` AS SELECT
2206 `post-category`.`uri-id` AS `uri-id`,
2207 `post-category`.`uid` AS `uid`,
2208 `post-category`.`type` AS `type`,
2209 `post-category`.`tid` AS `tid`,
2210 `tag`.`name` AS `name`,
2211 `tag`.`url` AS `url`
2212 FROM `post-category`
2213 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2216 -- VIEW collection-view
2218 DROP VIEW IF EXISTS `collection-view`;
2219 CREATE VIEW `collection-view` AS SELECT
2220 `post-collection`.`uri-id` AS `uri-id`,
2221 `post-collection`.`type` AS `type`,
2222 `post`.`author-id` AS `cid`,
2223 `post`.`received` AS `received`,
2224 `post`.`created` AS `created`
2225 FROM `post-collection`
2226 INNER JOIN `post` ON `post-collection`.`uri-id` = `post`.`uri-id`;
2231 DROP VIEW IF EXISTS `tag-view`;
2232 CREATE VIEW `tag-view` AS SELECT
2233 `post-tag`.`uri-id` AS `uri-id`,
2234 `post-tag`.`type` AS `type`,
2235 `post-tag`.`tid` AS `tid`,
2236 `post-tag`.`cid` AS `cid`,
2237 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2238 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
2240 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2241 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2244 -- VIEW network-item-view
2246 DROP VIEW IF EXISTS `network-item-view`;
2247 CREATE VIEW `network-item-view` AS SELECT
2248 `post-user`.`uri-id` AS `uri-id`,
2249 `parent-post`.`id` AS `parent`,
2250 `post-user`.`received` AS `received`,
2251 `post-thread-user`.`commented` AS `commented`,
2252 `post-user`.`created` AS `created`,
2253 `post-user`.`uid` AS `uid`,
2254 `post-thread-user`.`starred` AS `starred`,
2255 `post-thread-user`.`mention` AS `mention`,
2256 `post-user`.`network` AS `network`,
2257 `post-user`.`unseen` AS `unseen`,
2258 `post-user`.`gravity` AS `gravity`,
2259 `post-user`.`contact-id` AS `contact-id`,
2260 `ownercontact`.`contact-type` AS `contact-type`
2262 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2263 INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2264 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2265 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2266 INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2267 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2268 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2269 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2270 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
2271 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2272 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2275 -- VIEW network-thread-view
2277 DROP VIEW IF EXISTS `network-thread-view`;
2278 CREATE VIEW `network-thread-view` AS SELECT
2279 `post-thread-user`.`uri-id` AS `uri-id`,
2280 `parent-post`.`id` AS `parent`,
2281 `post-thread-user`.`received` AS `received`,
2282 `post-thread-user`.`commented` AS `commented`,
2283 `post-thread-user`.`created` AS `created`,
2284 `post-thread-user`.`uid` AS `uid`,
2285 `post-thread-user`.`starred` AS `starred`,
2286 `post-thread-user`.`mention` AS `mention`,
2287 `post-thread-user`.`network` AS `network`,
2288 `post-thread-user`.`contact-id` AS `contact-id`,
2289 `ownercontact`.`contact-type` AS `contact-type`
2290 FROM `post-thread-user`
2291 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2292 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2293 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2294 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2295 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2296 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2297 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2298 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2299 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2300 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2301 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2306 DROP VIEW IF EXISTS `owner-view`;
2307 CREATE VIEW `owner-view` AS SELECT
2308 `contact`.`id` AS `id`,
2309 `contact`.`uid` AS `uid`,
2310 `contact`.`created` AS `created`,
2311 `contact`.`updated` AS `updated`,
2312 `contact`.`self` AS `self`,
2313 `contact`.`remote_self` AS `remote_self`,
2314 `contact`.`rel` AS `rel`,
2315 `contact`.`network` AS `network`,
2316 `contact`.`protocol` AS `protocol`,
2317 `contact`.`name` AS `name`,
2318 `contact`.`nick` AS `nick`,
2319 `contact`.`location` AS `location`,
2320 `contact`.`about` AS `about`,
2321 `contact`.`keywords` AS `keywords`,
2322 `contact`.`xmpp` AS `xmpp`,
2323 `contact`.`matrix` AS `matrix`,
2324 `contact`.`attag` AS `attag`,
2325 `contact`.`avatar` AS `avatar`,
2326 `contact`.`photo` AS `photo`,
2327 `contact`.`thumb` AS `thumb`,
2328 `contact`.`micro` AS `micro`,
2329 `contact`.`header` AS `header`,
2330 `contact`.`url` AS `url`,
2331 `contact`.`nurl` AS `nurl`,
2332 `contact`.`uri-id` AS `uri-id`,
2333 `contact`.`addr` AS `addr`,
2334 `contact`.`alias` AS `alias`,
2335 `contact`.`pubkey` AS `pubkey`,
2336 `contact`.`prvkey` AS `prvkey`,
2337 `contact`.`batch` AS `batch`,
2338 `contact`.`request` AS `request`,
2339 `contact`.`notify` AS `notify`,
2340 `contact`.`poll` AS `poll`,
2341 `contact`.`confirm` AS `confirm`,
2342 `contact`.`poco` AS `poco`,
2343 `contact`.`subhub` AS `subhub`,
2344 `contact`.`hub-verify` AS `hub-verify`,
2345 `contact`.`last-update` AS `last-update`,
2346 `contact`.`success_update` AS `success_update`,
2347 `contact`.`failure_update` AS `failure_update`,
2348 `contact`.`name-date` AS `name-date`,
2349 `contact`.`uri-date` AS `uri-date`,
2350 `contact`.`avatar-date` AS `avatar-date`,
2351 `contact`.`avatar-date` AS `picdate`,
2352 `contact`.`term-date` AS `term-date`,
2353 `contact`.`last-item` AS `last-item`,
2354 `contact`.`priority` AS `priority`,
2355 `user`.`blocked` AS `blocked`,
2356 `contact`.`block_reason` AS `block_reason`,
2357 `contact`.`readonly` AS `readonly`,
2358 `contact`.`writable` AS `writable`,
2359 `contact`.`forum` AS `forum`,
2360 `contact`.`prv` AS `prv`,
2361 `contact`.`contact-type` AS `contact-type`,
2362 `contact`.`manually-approve` AS `manually-approve`,
2363 `contact`.`hidden` AS `hidden`,
2364 `contact`.`archive` AS `archive`,
2365 `contact`.`pending` AS `pending`,
2366 `contact`.`deleted` AS `deleted`,
2367 `contact`.`unsearchable` AS `unsearchable`,
2368 `contact`.`sensitive` AS `sensitive`,
2369 `contact`.`baseurl` AS `baseurl`,
2370 `contact`.`reason` AS `reason`,
2371 `contact`.`info` AS `info`,
2372 `contact`.`bdyear` AS `bdyear`,
2373 `contact`.`bd` AS `bd`,
2374 `contact`.`notify_new_posts` AS `notify_new_posts`,
2375 `contact`.`fetch_further_information` AS `fetch_further_information`,
2376 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2377 `user`.`parent-uid` AS `parent-uid`,
2378 `user`.`guid` AS `guid`,
2379 `user`.`nickname` AS `nickname`,
2380 `user`.`email` AS `email`,
2381 `user`.`openid` AS `openid`,
2382 `user`.`timezone` AS `timezone`,
2383 `user`.`language` AS `language`,
2384 `user`.`register_date` AS `register_date`,
2385 `user`.`login_date` AS `login_date`,
2386 `user`.`default-location` AS `default-location`,
2387 `user`.`allow_location` AS `allow_location`,
2388 `user`.`theme` AS `theme`,
2389 `user`.`pubkey` AS `upubkey`,
2390 `user`.`prvkey` AS `uprvkey`,
2391 `user`.`sprvkey` AS `sprvkey`,
2392 `user`.`spubkey` AS `spubkey`,
2393 `user`.`verified` AS `verified`,
2394 `user`.`blockwall` AS `blockwall`,
2395 `user`.`hidewall` AS `hidewall`,
2396 `user`.`blocktags` AS `blocktags`,
2397 `user`.`unkmail` AS `unkmail`,
2398 `user`.`cntunkmail` AS `cntunkmail`,
2399 `user`.`notify-flags` AS `notify-flags`,
2400 `user`.`page-flags` AS `page-flags`,
2401 `user`.`account-type` AS `account-type`,
2402 `user`.`prvnets` AS `prvnets`,
2403 `user`.`maxreq` AS `maxreq`,
2404 `user`.`expire` AS `expire`,
2405 `user`.`account_removed` AS `account_removed`,
2406 `user`.`account_expired` AS `account_expired`,
2407 `user`.`account_expires_on` AS `account_expires_on`,
2408 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2409 `user`.`def_gid` AS `def_gid`,
2410 `user`.`allow_cid` AS `allow_cid`,
2411 `user`.`allow_gid` AS `allow_gid`,
2412 `user`.`deny_cid` AS `deny_cid`,
2413 `user`.`deny_gid` AS `deny_gid`,
2414 `user`.`openidserver` AS `openidserver`,
2415 `profile`.`publish` AS `publish`,
2416 `profile`.`net-publish` AS `net-publish`,
2417 `profile`.`hide-friends` AS `hide-friends`,
2418 `profile`.`prv_keywords` AS `prv_keywords`,
2419 `profile`.`pub_keywords` AS `pub_keywords`,
2420 `profile`.`address` AS `address`,
2421 `profile`.`locality` AS `locality`,
2422 `profile`.`region` AS `region`,
2423 `profile`.`postal-code` AS `postal-code`,
2424 `profile`.`country-name` AS `country-name`,
2425 `profile`.`homepage` AS `homepage`,
2426 `profile`.`dob` AS `dob`
2428 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2429 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2432 -- VIEW account-view
2434 DROP VIEW IF EXISTS `account-view`;
2435 CREATE VIEW `account-view` AS SELECT
2436 `contact`.`id` AS `id`,
2437 `contact`.`url` AS `url`,
2438 `contact`.`nurl` AS `nurl`,
2439 `contact`.`uri-id` AS `uri-id`,
2440 `item-uri`.`guid` AS `guid`,
2441 `contact`.`addr` AS `addr`,
2442 `contact`.`alias` AS `alias`,
2443 `contact`.`name` AS `name`,
2444 `contact`.`nick` AS `nick`,
2445 `contact`.`about` AS `about`,
2446 `contact`.`keywords` AS `keywords`,
2447 `contact`.`xmpp` AS `xmpp`,
2448 `contact`.`matrix` AS `matrix`,
2449 `contact`.`avatar` AS `avatar`,
2450 `contact`.`photo` AS `photo`,
2451 `contact`.`thumb` AS `thumb`,
2452 `contact`.`micro` AS `micro`,
2453 `contact`.`header` AS `header`,
2454 `contact`.`created` AS `created`,
2455 `contact`.`updated` AS `updated`,
2456 `contact`.`network` AS `network`,
2457 `contact`.`protocol` AS `protocol`,
2458 `contact`.`location` AS `location`,
2459 `contact`.`attag` AS `attag`,
2460 `contact`.`pubkey` AS `pubkey`,
2461 `contact`.`prvkey` AS `prvkey`,
2462 `contact`.`subscribe` AS `subscribe`,
2463 `contact`.`last-update` AS `last-update`,
2464 `contact`.`success_update` AS `success_update`,
2465 `contact`.`failure_update` AS `failure_update`,
2466 `contact`.`failed` AS `failed`,
2467 `contact`.`last-item` AS `last-item`,
2468 `contact`.`last-discovery` AS `last-discovery`,
2469 `contact`.`contact-type` AS `contact-type`,
2470 `contact`.`manually-approve` AS `manually-approve`,
2471 `contact`.`unsearchable` AS `unsearchable`,
2472 `contact`.`sensitive` AS `sensitive`,
2473 `contact`.`baseurl` AS `baseurl`,
2474 `contact`.`gsid` AS `gsid`,
2475 `contact`.`info` AS `info`,
2476 `contact`.`bdyear` AS `bdyear`,
2477 `contact`.`bd` AS `bd`,
2478 `contact`.`poco` AS `poco`,
2479 `contact`.`name-date` AS `name-date`,
2480 `contact`.`uri-date` AS `uri-date`,
2481 `contact`.`avatar-date` AS `avatar-date`,
2482 `contact`.`term-date` AS `term-date`,
2483 `contact`.`hidden` AS `global-ignored`,
2484 `contact`.`blocked` AS `global-blocked`,
2485 `contact`.`hidden` AS `hidden`,
2486 `contact`.`archive` AS `archive`,
2487 `contact`.`deleted` AS `deleted`,
2488 `contact`.`blocked` AS `blocked`,
2489 `contact`.`notify` AS `dfrn-notify`,
2490 `contact`.`poll` AS `dfrn-poll`,
2491 `fcontact`.`guid` AS `diaspora-guid`,
2492 `fcontact`.`batch` AS `diaspora-batch`,
2493 `fcontact`.`notify` AS `diaspora-notify`,
2494 `fcontact`.`poll` AS `diaspora-poll`,
2495 `fcontact`.`alias` AS `diaspora-alias`,
2496 `apcontact`.`uuid` AS `ap-uuid`,
2497 `apcontact`.`type` AS `ap-type`,
2498 `apcontact`.`following` AS `ap-following`,
2499 `apcontact`.`followers` AS `ap-followers`,
2500 `apcontact`.`inbox` AS `ap-inbox`,
2501 `apcontact`.`outbox` AS `ap-outbox`,
2502 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2503 `apcontact`.`generator` AS `ap-generator`,
2504 `apcontact`.`following_count` AS `ap-following_count`,
2505 `apcontact`.`followers_count` AS `ap-followers_count`,
2506 `apcontact`.`statuses_count` AS `ap-statuses_count`,
2507 `gserver`.`site_name` AS `site_name`,
2508 `gserver`.`platform` AS `platform`,
2509 `gserver`.`version` AS `version`
2511 LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id`
2512 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
2513 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = contact.`uri-id`
2514 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`
2515 WHERE `contact`.`uid` = 0;
2518 -- VIEW account-user-view
2520 DROP VIEW IF EXISTS `account-user-view`;
2521 CREATE VIEW `account-user-view` AS SELECT
2522 `ucontact`.`id` AS `id`,
2523 `contact`.`id` AS `pid`,
2524 `ucontact`.`uid` AS `uid`,
2525 `contact`.`url` AS `url`,
2526 `contact`.`nurl` AS `nurl`,
2527 `contact`.`uri-id` AS `uri-id`,
2528 `item-uri`.`guid` AS `guid`,
2529 `contact`.`addr` AS `addr`,
2530 `contact`.`alias` AS `alias`,
2531 `contact`.`name` AS `name`,
2532 `contact`.`nick` AS `nick`,
2533 `contact`.`about` AS `about`,
2534 `contact`.`keywords` AS `keywords`,
2535 `contact`.`xmpp` AS `xmpp`,
2536 `contact`.`matrix` AS `matrix`,
2537 `contact`.`avatar` AS `avatar`,
2538 `contact`.`photo` AS `photo`,
2539 `contact`.`thumb` AS `thumb`,
2540 `contact`.`micro` AS `micro`,
2541 `contact`.`header` AS `header`,
2542 `contact`.`created` AS `created`,
2543 `contact`.`updated` AS `updated`,
2544 `ucontact`.`self` AS `self`,
2545 `ucontact`.`remote_self` AS `remote_self`,
2546 `ucontact`.`rel` AS `rel`,
2547 `contact`.`network` AS `network`,
2548 `ucontact`.`protocol` AS `protocol`,
2549 `contact`.`location` AS `location`,
2550 `ucontact`.`attag` AS `attag`,
2551 `contact`.`pubkey` AS `pubkey`,
2552 `contact`.`prvkey` AS `prvkey`,
2553 `contact`.`subscribe` AS `subscribe`,
2554 `contact`.`last-update` AS `last-update`,
2555 `contact`.`success_update` AS `success_update`,
2556 `contact`.`failure_update` AS `failure_update`,
2557 `contact`.`failed` AS `failed`,
2558 `contact`.`last-item` AS `last-item`,
2559 `contact`.`last-discovery` AS `last-discovery`,
2560 `contact`.`contact-type` AS `contact-type`,
2561 `contact`.`manually-approve` AS `manually-approve`,
2562 `contact`.`unsearchable` AS `unsearchable`,
2563 `contact`.`sensitive` AS `sensitive`,
2564 `contact`.`baseurl` AS `baseurl`,
2565 `contact`.`gsid` AS `gsid`,
2566 `ucontact`.`info` AS `info`,
2567 `contact`.`bdyear` AS `bdyear`,
2568 `contact`.`bd` AS `bd`,
2569 `contact`.`poco` AS `poco`,
2570 `contact`.`name-date` AS `name-date`,
2571 `contact`.`uri-date` AS `uri-date`,
2572 `contact`.`avatar-date` AS `avatar-date`,
2573 `contact`.`term-date` AS `term-date`,
2574 `contact`.`hidden` AS `global-ignored`,
2575 `contact`.`blocked` AS `global-blocked`,
2576 `ucontact`.`hidden` AS `hidden`,
2577 `ucontact`.`archive` AS `archive`,
2578 `ucontact`.`pending` AS `pending`,
2579 `ucontact`.`deleted` AS `deleted`,
2580 `ucontact`.`notify_new_posts` AS `notify_new_posts`,
2581 `ucontact`.`fetch_further_information` AS `fetch_further_information`,
2582 `ucontact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2583 `ucontact`.`rating` AS `rating`,
2584 `ucontact`.`readonly` AS `readonly`,
2585 `ucontact`.`blocked` AS `blocked`,
2586 `ucontact`.`block_reason` AS `block_reason`,
2587 `ucontact`.`subhub` AS `subhub`,
2588 `ucontact`.`hub-verify` AS `hub-verify`,
2589 `ucontact`.`reason` AS `reason`,
2590 `contact`.`notify` AS `dfrn-notify`,
2591 `contact`.`poll` AS `dfrn-poll`,
2592 `fcontact`.`guid` AS `diaspora-guid`,
2593 `fcontact`.`batch` AS `diaspora-batch`,
2594 `fcontact`.`notify` AS `diaspora-notify`,
2595 `fcontact`.`poll` AS `diaspora-poll`,
2596 `fcontact`.`alias` AS `diaspora-alias`,
2597 `apcontact`.`uuid` AS `ap-uuid`,
2598 `apcontact`.`type` AS `ap-type`,
2599 `apcontact`.`following` AS `ap-following`,
2600 `apcontact`.`followers` AS `ap-followers`,
2601 `apcontact`.`inbox` AS `ap-inbox`,
2602 `apcontact`.`outbox` AS `ap-outbox`,
2603 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2604 `apcontact`.`generator` AS `ap-generator`,
2605 `apcontact`.`following_count` AS `ap-following_count`,
2606 `apcontact`.`followers_count` AS `ap-followers_count`,
2607 `apcontact`.`statuses_count` AS `ap-statuses_count`,
2608 `gserver`.`site_name` AS `site_name`,
2609 `gserver`.`platform` AS `platform`,
2610 `gserver`.`version` AS `version`
2611 FROM `contact` AS `ucontact`
2612 INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
2613 LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id`
2614 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
2615 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = `ucontact`.`uri-id` AND `fcontact`.`network` = 'dspr'
2616 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`;
2619 -- VIEW pending-view
2621 DROP VIEW IF EXISTS `pending-view`;
2622 CREATE VIEW `pending-view` AS SELECT
2623 `register`.`id` AS `id`,
2624 `register`.`hash` AS `hash`,
2625 `register`.`created` AS `created`,
2626 `register`.`uid` AS `uid`,
2627 `register`.`password` AS `password`,
2628 `register`.`language` AS `language`,
2629 `register`.`note` AS `note`,
2630 `contact`.`self` AS `self`,
2631 `contact`.`name` AS `name`,
2632 `contact`.`url` AS `url`,
2633 `contact`.`micro` AS `micro`,
2634 `user`.`email` AS `email`,
2635 `contact`.`nick` AS `nick`
2637 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2638 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2641 -- VIEW tag-search-view
2643 DROP VIEW IF EXISTS `tag-search-view`;
2644 CREATE VIEW `tag-search-view` AS SELECT
2645 `post-tag`.`uri-id` AS `uri-id`,
2646 `post-user`.`uid` AS `uid`,
2647 `post-user`.`id` AS `iid`,
2648 `post-user`.`private` AS `private`,
2649 `post-user`.`wall` AS `wall`,
2650 `post-user`.`origin` AS `origin`,
2651 `post-user`.`global` AS `global`,
2652 `post-user`.`gravity` AS `gravity`,
2653 `post-user`.`received` AS `received`,
2654 `post-user`.`network` AS `network`,
2655 `post-user`.`author-id` AS `author-id`,
2656 `tag`.`name` AS `name`
2658 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
2659 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
2660 WHERE `post-tag`.`type` = 1;
2663 -- VIEW workerqueue-view
2665 DROP VIEW IF EXISTS `workerqueue-view`;
2666 CREATE VIEW `workerqueue-view` AS SELECT
2667 `process`.`pid` AS `pid`,
2668 `workerqueue`.`priority` AS `priority`
2670 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
2671 WHERE NOT `workerqueue`.`done`;
2674 -- VIEW profile_field-view
2676 DROP VIEW IF EXISTS `profile_field-view`;
2677 CREATE VIEW `profile_field-view` AS SELECT
2678 `profile_field`.`id` AS `id`,
2679 `profile_field`.`uid` AS `uid`,
2680 `profile_field`.`label` AS `label`,
2681 `profile_field`.`value` AS `value`,
2682 `profile_field`.`order` AS `order`,
2683 `profile_field`.`psid` AS `psid`,
2684 `permissionset`.`allow_cid` AS `allow_cid`,
2685 `permissionset`.`allow_gid` AS `allow_gid`,
2686 `permissionset`.`deny_cid` AS `deny_cid`,
2687 `permissionset`.`deny_gid` AS `deny_gid`,
2688 `profile_field`.`created` AS `created`,
2689 `profile_field`.`edited` AS `edited`
2690 FROM `profile_field`
2691 INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`;