1 -- ------------------------------------------
2 -- Friendica 2022.05-dev (Siberian Iris)
3 -- DB_UPDATE_VERSION 1457
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';
1167 CREATE TABLE IF NOT EXISTS `post-tag` (
1168 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1169 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1170 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1171 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1172 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1173 INDEX `tid` (`tid`),
1174 INDEX `cid` (`cid`),
1175 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1176 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1177 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1178 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1181 -- TABLE post-thread
1183 CREATE TABLE IF NOT EXISTS `post-thread` (
1184 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1185 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1186 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1187 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1188 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1189 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1190 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1191 `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',
1192 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1193 PRIMARY KEY(`uri-id`),
1194 INDEX `owner-id` (`owner-id`),
1195 INDEX `author-id` (`author-id`),
1196 INDEX `causer-id` (`causer-id`),
1197 INDEX `received` (`received`),
1198 INDEX `commented` (`commented`),
1199 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1200 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1201 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1202 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1203 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1208 CREATE TABLE IF NOT EXISTS `post-user` (
1209 `id` int unsigned NOT NULL auto_increment,
1210 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1211 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1212 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1213 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1214 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1215 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1216 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1217 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1218 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1219 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1220 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1221 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1222 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1223 `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
1224 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1225 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1226 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1227 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1228 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1229 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1230 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1231 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1232 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1233 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1234 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1235 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1236 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1237 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1238 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1240 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1241 INDEX `uri-id` (`uri-id`),
1242 INDEX `parent-uri-id` (`parent-uri-id`),
1243 INDEX `thr-parent-id` (`thr-parent-id`),
1244 INDEX `external-id` (`external-id`),
1245 INDEX `owner-id` (`owner-id`),
1246 INDEX `author-id` (`author-id`),
1247 INDEX `causer-id` (`causer-id`),
1248 INDEX `vid` (`vid`),
1249 INDEX `contact-id` (`contact-id`),
1250 INDEX `event-id` (`event-id`),
1251 INDEX `psid` (`psid`),
1252 INDEX `author-id_uid` (`author-id`,`uid`),
1253 INDEX `author-id_received` (`author-id`,`received`),
1254 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1255 INDEX `uid_contactid` (`uid`,`contact-id`),
1256 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1257 INDEX `uid_unseen` (`uid`,`unseen`),
1258 INDEX `uid_hidden_uri-id` (`uid`,`hidden`,`uri-id`),
1259 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1260 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1261 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1262 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1263 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1264 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1265 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1266 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1267 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1268 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1269 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1270 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1271 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1274 -- TABLE post-thread-user
1276 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1277 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1278 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1279 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1280 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1281 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1282 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1283 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1284 `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',
1285 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1286 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1287 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
1288 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1289 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1290 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1291 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1292 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1293 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Deprecated',
1294 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1295 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1296 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1297 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1298 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1299 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1300 PRIMARY KEY(`uid`,`uri-id`),
1301 INDEX `uri-id` (`uri-id`),
1302 INDEX `owner-id` (`owner-id`),
1303 INDEX `author-id` (`author-id`),
1304 INDEX `causer-id` (`causer-id`),
1305 INDEX `uid` (`uid`),
1306 INDEX `contact-id` (`contact-id`),
1307 INDEX `psid` (`psid`),
1308 INDEX `post-user-id` (`post-user-id`),
1309 INDEX `commented` (`commented`),
1310 INDEX `uid_received` (`uid`,`received`),
1311 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1312 INDEX `uid_commented` (`uid`,`commented`),
1313 INDEX `uid_starred` (`uid`,`starred`),
1314 INDEX `uid_mention` (`uid`,`mention`),
1315 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1316 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1317 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1318 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1319 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1320 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1321 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1322 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1323 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1326 -- TABLE post-user-notification
1328 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1329 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1330 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1331 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1332 PRIMARY KEY(`uid`,`uri-id`),
1333 INDEX `uri-id` (`uri-id`),
1334 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1335 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1336 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1341 CREATE TABLE IF NOT EXISTS `process` (
1342 `pid` int unsigned NOT NULL COMMENT 'The ID of the process',
1343 `hostname` varchar(32) NOT NULL COMMENT 'The name of the host the process is ran on',
1344 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1345 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1346 PRIMARY KEY(`pid`,`hostname`),
1347 INDEX `command` (`command`)
1348 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1353 CREATE TABLE IF NOT EXISTS `profile` (
1354 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1355 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1356 `profile-name` varchar(255) COMMENT 'Deprecated',
1357 `is-default` boolean COMMENT 'Deprecated',
1358 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1359 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1360 `pdesc` varchar(255) COMMENT 'Deprecated',
1361 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1362 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1363 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1364 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1365 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1366 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1367 `hometown` varchar(255) COMMENT 'Deprecated',
1368 `gender` varchar(32) COMMENT 'Deprecated',
1369 `marital` varchar(255) COMMENT 'Deprecated',
1370 `with` text COMMENT 'Deprecated',
1371 `howlong` datetime COMMENT 'Deprecated',
1372 `sexual` varchar(255) COMMENT 'Deprecated',
1373 `politic` varchar(255) COMMENT 'Deprecated',
1374 `religion` varchar(255) COMMENT 'Deprecated',
1375 `pub_keywords` text COMMENT '',
1376 `prv_keywords` text COMMENT '',
1377 `likes` text COMMENT 'Deprecated',
1378 `dislikes` text COMMENT 'Deprecated',
1379 `about` text COMMENT 'Profile description',
1380 `summary` varchar(255) COMMENT 'Deprecated',
1381 `music` text COMMENT 'Deprecated',
1382 `book` text COMMENT 'Deprecated',
1383 `tv` text COMMENT 'Deprecated',
1384 `film` text COMMENT 'Deprecated',
1385 `interest` text COMMENT 'Deprecated',
1386 `romance` text COMMENT 'Deprecated',
1387 `work` text COMMENT 'Deprecated',
1388 `education` text COMMENT 'Deprecated',
1389 `contact` text COMMENT 'Deprecated',
1390 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1391 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
1392 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
1393 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1394 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1395 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1396 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1398 INDEX `uid_is-default` (`uid`,`is-default`),
1399 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1400 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1401 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1404 -- TABLE profile_field
1406 CREATE TABLE IF NOT EXISTS `profile_field` (
1407 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1408 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1409 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1410 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1411 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1412 `value` text COMMENT 'Value of the field',
1413 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1414 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1416 INDEX `uid` (`uid`),
1417 INDEX `order` (`order`),
1418 INDEX `psid` (`psid`),
1419 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1420 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1421 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1424 -- TABLE push_subscriber
1426 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1427 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1428 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1429 `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1430 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1431 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1432 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1433 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1434 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1435 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1436 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1438 INDEX `next_try` (`next_try`),
1439 INDEX `uid` (`uid`),
1440 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1441 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1446 CREATE TABLE IF NOT EXISTS `register` (
1447 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1448 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1449 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1450 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1451 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1452 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1453 `note` text COMMENT '',
1455 INDEX `uid` (`uid`),
1456 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1457 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1462 CREATE TABLE IF NOT EXISTS `search` (
1463 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1464 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1465 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1467 INDEX `uid_term` (`uid`,`term`(64)),
1468 INDEX `term` (`term`(64)),
1469 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1470 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1475 CREATE TABLE IF NOT EXISTS `session` (
1476 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1477 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1478 `data` text COMMENT '',
1479 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1481 INDEX `sid` (`sid`(64)),
1482 INDEX `expire` (`expire`)
1483 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1488 CREATE TABLE IF NOT EXISTS `storage` (
1489 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1490 `data` longblob NOT NULL COMMENT 'file data',
1492 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1495 -- TABLE subscription
1497 CREATE TABLE IF NOT EXISTS `subscription` (
1498 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1499 `application-id` int unsigned NOT NULL COMMENT '',
1500 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
1501 `endpoint` varchar(511) COMMENT 'Endpoint URL',
1502 `pubkey` varchar(127) COMMENT 'User agent public key',
1503 `secret` varchar(32) COMMENT 'Auth secret',
1504 `follow` boolean COMMENT '',
1505 `favourite` boolean COMMENT '',
1506 `reblog` boolean COMMENT '',
1507 `mention` boolean COMMENT '',
1508 `poll` boolean COMMENT '',
1509 `follow_request` boolean COMMENT '',
1510 `status` boolean COMMENT '',
1512 UNIQUE INDEX `application-id_uid` (`application-id`,`uid`),
1513 INDEX `uid_application-id` (`uid`,`application-id`),
1514 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1515 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1516 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Push Subscription for the API';
1521 CREATE TABLE IF NOT EXISTS `userd` (
1522 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1523 `username` varchar(255) NOT NULL COMMENT '',
1525 INDEX `username` (`username`(32))
1526 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1529 -- TABLE user-contact
1531 CREATE TABLE IF NOT EXISTS `user-contact` (
1532 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1533 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1534 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
1535 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1536 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1537 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1538 `hidden` boolean COMMENT 'This contact is hidden from the others',
1539 `is-blocked` boolean COMMENT 'User is blocked by this contact',
1540 `pending` boolean COMMENT '',
1541 `rel` tinyint unsigned COMMENT 'The kind of the relation between the user and the contact',
1542 `info` mediumtext COMMENT '',
1543 `notify_new_posts` boolean COMMENT '',
1544 `remote_self` boolean COMMENT '',
1545 `fetch_further_information` tinyint unsigned COMMENT '',
1546 `ffi_keyword_denylist` text COMMENT '',
1547 `subhub` boolean COMMENT '',
1548 `hub-verify` varchar(255) COMMENT '',
1549 `protocol` char(4) COMMENT 'Protocol of the contact',
1550 `rating` tinyint COMMENT 'Automatically detected feed poll frequency',
1551 `priority` tinyint unsigned COMMENT 'Feed poll priority',
1552 PRIMARY KEY(`uid`,`cid`),
1553 INDEX `cid` (`cid`),
1554 UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
1555 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1556 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1557 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1558 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1563 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1564 `key` int NOT NULL COMMENT '',
1565 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1567 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1570 -- VIEW application-view
1572 DROP VIEW IF EXISTS `application-view`;
1573 CREATE VIEW `application-view` AS SELECT
1574 `application`.`id` AS `id`,
1575 `application-token`.`uid` AS `uid`,
1576 `application`.`name` AS `name`,
1577 `application`.`redirect_uri` AS `redirect_uri`,
1578 `application`.`website` AS `website`,
1579 `application`.`client_id` AS `client_id`,
1580 `application`.`client_secret` AS `client_secret`,
1581 `application-token`.`code` AS `code`,
1582 `application-token`.`access_token` AS `access_token`,
1583 `application-token`.`created_at` AS `created_at`,
1584 `application-token`.`scopes` AS `scopes`,
1585 `application-token`.`read` AS `read`,
1586 `application-token`.`write` AS `write`,
1587 `application-token`.`follow` AS `follow`,
1588 `application-token`.`push` AS `push`
1589 FROM `application-token`
1590 INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`;
1593 -- VIEW post-user-view
1595 DROP VIEW IF EXISTS `post-user-view`;
1596 CREATE VIEW `post-user-view` AS SELECT
1597 `post-user`.`id` AS `id`,
1598 `post-user`.`id` AS `post-user-id`,
1599 `post-user`.`uid` AS `uid`,
1600 `parent-post`.`id` AS `parent`,
1601 `item-uri`.`uri` AS `uri`,
1602 `post-user`.`uri-id` AS `uri-id`,
1603 `parent-item-uri`.`uri` AS `parent-uri`,
1604 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1605 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1606 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1607 `item-uri`.`guid` AS `guid`,
1608 `post-user`.`wall` AS `wall`,
1609 `post-user`.`gravity` AS `gravity`,
1610 `external-item-uri`.`uri` AS `extid`,
1611 `post-user`.`external-id` AS `external-id`,
1612 `post-user`.`created` AS `created`,
1613 `post-user`.`edited` AS `edited`,
1614 `post-thread-user`.`commented` AS `commented`,
1615 `post-user`.`received` AS `received`,
1616 `post-thread-user`.`changed` AS `changed`,
1617 `post-user`.`post-type` AS `post-type`,
1618 `post-user`.`post-reason` AS `post-reason`,
1619 `post-user`.`private` AS `private`,
1620 `post-thread-user`.`pubmail` AS `pubmail`,
1621 `post-user`.`visible` AS `visible`,
1622 `post-thread-user`.`starred` AS `starred`,
1623 `post-user`.`unseen` AS `unseen`,
1624 `post-user`.`deleted` AS `deleted`,
1625 `post-user`.`origin` AS `origin`,
1626 `post-thread-user`.`origin` AS `parent-origin`,
1627 `post-thread-user`.`mention` AS `mention`,
1628 `post-user`.`global` AS `global`,
1629 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-user`.`uri-id`) AS `featured`,
1630 `post-user`.`network` AS `network`,
1631 `post-user`.`vid` AS `vid`,
1632 `post-user`.`psid` AS `psid`,
1633 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1634 `post-content`.`title` AS `title`,
1635 `post-content`.`content-warning` AS `content-warning`,
1636 `post-content`.`raw-body` AS `raw-body`,
1637 IFNULL (`post-content`.`body`, '') AS `body`,
1638 `post-content`.`rendered-hash` AS `rendered-hash`,
1639 `post-content`.`rendered-html` AS `rendered-html`,
1640 `post-content`.`language` AS `language`,
1641 `post-content`.`plink` AS `plink`,
1642 `post-content`.`location` AS `location`,
1643 `post-content`.`coord` AS `coord`,
1644 `post-content`.`app` AS `app`,
1645 `post-content`.`object-type` AS `object-type`,
1646 `post-content`.`object` AS `object`,
1647 `post-content`.`target-type` AS `target-type`,
1648 `post-content`.`target` AS `target`,
1649 `post-content`.`resource-id` AS `resource-id`,
1650 `post-user`.`contact-id` AS `contact-id`,
1651 `contact`.`url` AS `contact-link`,
1652 `contact`.`addr` AS `contact-addr`,
1653 `contact`.`name` AS `contact-name`,
1654 `contact`.`nick` AS `contact-nick`,
1655 `contact`.`thumb` AS `contact-avatar`,
1656 `contact`.`network` AS `contact-network`,
1657 `contact`.`blocked` AS `contact-blocked`,
1658 `contact`.`hidden` AS `contact-hidden`,
1659 `contact`.`readonly` AS `contact-readonly`,
1660 `contact`.`archive` AS `contact-archive`,
1661 `contact`.`pending` AS `contact-pending`,
1662 `contact`.`rel` AS `contact-rel`,
1663 `contact`.`uid` AS `contact-uid`,
1664 `contact`.`contact-type` AS `contact-contact-type`,
1665 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1666 `contact`.`self` AS `self`,
1667 `contact`.`id` AS `cid`,
1668 `contact`.`alias` AS `alias`,
1669 `contact`.`photo` AS `photo`,
1670 `contact`.`name-date` AS `name-date`,
1671 `contact`.`uri-date` AS `uri-date`,
1672 `contact`.`avatar-date` AS `avatar-date`,
1673 `contact`.`thumb` AS `thumb`,
1674 `post-user`.`author-id` AS `author-id`,
1675 `author`.`url` AS `author-link`,
1676 `author`.`addr` AS `author-addr`,
1677 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1678 `author`.`nick` AS `author-nick`,
1679 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1680 `author`.`network` AS `author-network`,
1681 `author`.`blocked` AS `author-blocked`,
1682 `author`.`hidden` AS `author-hidden`,
1683 `post-user`.`owner-id` AS `owner-id`,
1684 `owner`.`url` AS `owner-link`,
1685 `owner`.`addr` AS `owner-addr`,
1686 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1687 `owner`.`nick` AS `owner-nick`,
1688 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1689 `owner`.`network` AS `owner-network`,
1690 `owner`.`blocked` AS `owner-blocked`,
1691 `owner`.`hidden` AS `owner-hidden`,
1692 `owner`.`contact-type` AS `owner-contact-type`,
1693 `post-user`.`causer-id` AS `causer-id`,
1694 `causer`.`url` AS `causer-link`,
1695 `causer`.`addr` AS `causer-addr`,
1696 `causer`.`name` AS `causer-name`,
1697 `causer`.`nick` AS `causer-nick`,
1698 `causer`.`thumb` AS `causer-avatar`,
1699 `causer`.`network` AS `causer-network`,
1700 `causer`.`blocked` AS `causer-blocked`,
1701 `causer`.`hidden` AS `causer-hidden`,
1702 `causer`.`contact-type` AS `causer-contact-type`,
1703 `post-delivery-data`.`postopts` AS `postopts`,
1704 `post-delivery-data`.`inform` AS `inform`,
1705 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1706 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1707 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1708 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1709 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1710 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1711 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1712 `post-user`.`event-id` AS `event-id`,
1713 `event`.`created` AS `event-created`,
1714 `event`.`edited` AS `event-edited`,
1715 `event`.`start` AS `event-start`,
1716 `event`.`finish` AS `event-finish`,
1717 `event`.`summary` AS `event-summary`,
1718 `event`.`desc` AS `event-desc`,
1719 `event`.`location` AS `event-location`,
1720 `event`.`type` AS `event-type`,
1721 `event`.`nofinish` AS `event-nofinish`,
1722 `event`.`ignore` AS `event-ignore`,
1723 `diaspora-interaction`.`interaction` AS `signed_text`,
1724 `parent-item-uri`.`guid` AS `parent-guid`,
1725 `parent-post`.`network` AS `parent-network`,
1726 `parent-post`.`author-id` AS `parent-author-id`,
1727 `parent-post-author`.`url` AS `parent-author-link`,
1728 `parent-post-author`.`name` AS `parent-author-name`,
1729 `parent-post-author`.`nick` AS `parent-author-nick`,
1730 `parent-post-author`.`network` AS `parent-author-network`,
1731 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1732 `parent-post-author`.`hidden` AS `parent-author-hidden`
1734 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
1735 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
1736 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
1737 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
1738 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
1739 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
1740 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1741 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1742 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1743 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1744 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1745 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
1746 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
1747 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
1748 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
1749 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
1750 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1753 -- VIEW post-thread-user-view
1755 DROP VIEW IF EXISTS `post-thread-user-view`;
1756 CREATE VIEW `post-thread-user-view` AS SELECT
1757 `post-user`.`id` AS `id`,
1758 `post-user`.`id` AS `post-user-id`,
1759 `post-thread-user`.`uid` AS `uid`,
1760 `parent-post`.`id` AS `parent`,
1761 `item-uri`.`uri` AS `uri`,
1762 `post-thread-user`.`uri-id` AS `uri-id`,
1763 `parent-item-uri`.`uri` AS `parent-uri`,
1764 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1765 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1766 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1767 `item-uri`.`guid` AS `guid`,
1768 `post-thread-user`.`wall` AS `wall`,
1769 `post-user`.`gravity` AS `gravity`,
1770 `external-item-uri`.`uri` AS `extid`,
1771 `post-user`.`external-id` AS `external-id`,
1772 `post-thread-user`.`created` AS `created`,
1773 `post-user`.`edited` AS `edited`,
1774 `post-thread-user`.`commented` AS `commented`,
1775 `post-thread-user`.`received` AS `received`,
1776 `post-thread-user`.`changed` AS `changed`,
1777 `post-user`.`post-type` AS `post-type`,
1778 `post-user`.`post-reason` AS `post-reason`,
1779 `post-user`.`private` AS `private`,
1780 `post-thread-user`.`pubmail` AS `pubmail`,
1781 `post-thread-user`.`ignored` AS `ignored`,
1782 `post-user`.`visible` AS `visible`,
1783 `post-thread-user`.`starred` AS `starred`,
1784 `post-thread-user`.`unseen` AS `unseen`,
1785 `post-user`.`deleted` AS `deleted`,
1786 `post-thread-user`.`origin` AS `origin`,
1787 `post-thread-user`.`mention` AS `mention`,
1788 `post-user`.`global` AS `global`,
1789 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread-user`.`uri-id`) AS `featured`,
1790 `post-thread-user`.`network` AS `network`,
1791 `post-user`.`vid` AS `vid`,
1792 `post-thread-user`.`psid` AS `psid`,
1793 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1794 `post-content`.`title` AS `title`,
1795 `post-content`.`content-warning` AS `content-warning`,
1796 `post-content`.`raw-body` AS `raw-body`,
1797 `post-content`.`body` AS `body`,
1798 `post-content`.`rendered-hash` AS `rendered-hash`,
1799 `post-content`.`rendered-html` AS `rendered-html`,
1800 `post-content`.`language` AS `language`,
1801 `post-content`.`plink` AS `plink`,
1802 `post-content`.`location` AS `location`,
1803 `post-content`.`coord` AS `coord`,
1804 `post-content`.`app` AS `app`,
1805 `post-content`.`object-type` AS `object-type`,
1806 `post-content`.`object` AS `object`,
1807 `post-content`.`target-type` AS `target-type`,
1808 `post-content`.`target` AS `target`,
1809 `post-content`.`resource-id` AS `resource-id`,
1810 `post-thread-user`.`contact-id` AS `contact-id`,
1811 `contact`.`url` AS `contact-link`,
1812 `contact`.`addr` AS `contact-addr`,
1813 `contact`.`name` AS `contact-name`,
1814 `contact`.`nick` AS `contact-nick`,
1815 `contact`.`thumb` AS `contact-avatar`,
1816 `contact`.`network` AS `contact-network`,
1817 `contact`.`blocked` AS `contact-blocked`,
1818 `contact`.`hidden` AS `contact-hidden`,
1819 `contact`.`readonly` AS `contact-readonly`,
1820 `contact`.`archive` AS `contact-archive`,
1821 `contact`.`pending` AS `contact-pending`,
1822 `contact`.`rel` AS `contact-rel`,
1823 `contact`.`uid` AS `contact-uid`,
1824 `contact`.`contact-type` AS `contact-contact-type`,
1825 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1826 `contact`.`self` AS `self`,
1827 `contact`.`id` AS `cid`,
1828 `contact`.`alias` AS `alias`,
1829 `contact`.`photo` AS `photo`,
1830 `contact`.`name-date` AS `name-date`,
1831 `contact`.`uri-date` AS `uri-date`,
1832 `contact`.`avatar-date` AS `avatar-date`,
1833 `contact`.`thumb` AS `thumb`,
1834 `post-thread-user`.`author-id` AS `author-id`,
1835 `author`.`url` AS `author-link`,
1836 `author`.`addr` AS `author-addr`,
1837 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1838 `author`.`nick` AS `author-nick`,
1839 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1840 `author`.`network` AS `author-network`,
1841 `author`.`blocked` AS `author-blocked`,
1842 `author`.`hidden` AS `author-hidden`,
1843 `post-thread-user`.`owner-id` AS `owner-id`,
1844 `owner`.`url` AS `owner-link`,
1845 `owner`.`addr` AS `owner-addr`,
1846 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1847 `owner`.`nick` AS `owner-nick`,
1848 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1849 `owner`.`network` AS `owner-network`,
1850 `owner`.`blocked` AS `owner-blocked`,
1851 `owner`.`hidden` AS `owner-hidden`,
1852 `owner`.`contact-type` AS `owner-contact-type`,
1853 `post-thread-user`.`causer-id` AS `causer-id`,
1854 `causer`.`url` AS `causer-link`,
1855 `causer`.`addr` AS `causer-addr`,
1856 `causer`.`name` AS `causer-name`,
1857 `causer`.`nick` AS `causer-nick`,
1858 `causer`.`thumb` AS `causer-avatar`,
1859 `causer`.`network` AS `causer-network`,
1860 `causer`.`blocked` AS `causer-blocked`,
1861 `causer`.`hidden` AS `causer-hidden`,
1862 `causer`.`contact-type` AS `causer-contact-type`,
1863 `post-delivery-data`.`postopts` AS `postopts`,
1864 `post-delivery-data`.`inform` AS `inform`,
1865 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1866 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1867 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1868 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1869 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1870 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1871 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1872 `post-user`.`event-id` AS `event-id`,
1873 `event`.`created` AS `event-created`,
1874 `event`.`edited` AS `event-edited`,
1875 `event`.`start` AS `event-start`,
1876 `event`.`finish` AS `event-finish`,
1877 `event`.`summary` AS `event-summary`,
1878 `event`.`desc` AS `event-desc`,
1879 `event`.`location` AS `event-location`,
1880 `event`.`type` AS `event-type`,
1881 `event`.`nofinish` AS `event-nofinish`,
1882 `event`.`ignore` AS `event-ignore`,
1883 `diaspora-interaction`.`interaction` AS `signed_text`,
1884 `parent-item-uri`.`guid` AS `parent-guid`,
1885 `parent-post`.`network` AS `parent-network`,
1886 `parent-post`.`author-id` AS `parent-author-id`,
1887 `parent-post-author`.`url` AS `parent-author-link`,
1888 `parent-post-author`.`name` AS `parent-author-name`,
1889 `parent-post-author`.`network` AS `parent-author-network`,
1890 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1891 `parent-post-author`.`hidden` AS `parent-author-hidden`
1892 FROM `post-thread-user`
1893 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
1894 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
1895 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
1896 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
1897 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
1898 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
1899 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1900 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1901 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1902 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1903 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1904 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
1905 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
1906 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
1907 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
1908 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`
1909 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1914 DROP VIEW IF EXISTS `post-view`;
1915 CREATE VIEW `post-view` AS SELECT
1916 `item-uri`.`uri` AS `uri`,
1917 `post`.`uri-id` AS `uri-id`,
1918 `parent-item-uri`.`uri` AS `parent-uri`,
1919 `post`.`parent-uri-id` AS `parent-uri-id`,
1920 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1921 `post`.`thr-parent-id` AS `thr-parent-id`,
1922 `item-uri`.`guid` AS `guid`,
1923 `post`.`gravity` AS `gravity`,
1924 `external-item-uri`.`uri` AS `extid`,
1925 `post`.`external-id` AS `external-id`,
1926 `post`.`created` AS `created`,
1927 `post`.`edited` AS `edited`,
1928 `post-thread`.`commented` AS `commented`,
1929 `post`.`received` AS `received`,
1930 `post-thread`.`changed` AS `changed`,
1931 `post`.`post-type` AS `post-type`,
1932 `post`.`private` AS `private`,
1933 `post`.`visible` AS `visible`,
1934 `post`.`deleted` AS `deleted`,
1935 `post`.`global` AS `global`,
1936 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post`.`uri-id`) AS `featured`,
1937 `post`.`network` AS `network`,
1938 `post`.`vid` AS `vid`,
1939 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1940 `post-content`.`title` AS `title`,
1941 `post-content`.`content-warning` AS `content-warning`,
1942 `post-content`.`raw-body` AS `raw-body`,
1943 `post-content`.`body` AS `body`,
1944 `post-content`.`rendered-hash` AS `rendered-hash`,
1945 `post-content`.`rendered-html` AS `rendered-html`,
1946 `post-content`.`language` AS `language`,
1947 `post-content`.`plink` AS `plink`,
1948 `post-content`.`location` AS `location`,
1949 `post-content`.`coord` AS `coord`,
1950 `post-content`.`app` AS `app`,
1951 `post-content`.`object-type` AS `object-type`,
1952 `post-content`.`object` AS `object`,
1953 `post-content`.`target-type` AS `target-type`,
1954 `post-content`.`target` AS `target`,
1955 `post-content`.`resource-id` AS `resource-id`,
1956 `post`.`author-id` AS `contact-id`,
1957 `author`.`url` AS `contact-link`,
1958 `author`.`addr` AS `contact-addr`,
1959 `author`.`name` AS `contact-name`,
1960 `author`.`nick` AS `contact-nick`,
1961 `author`.`thumb` AS `contact-avatar`,
1962 `author`.`network` AS `contact-network`,
1963 `author`.`blocked` AS `contact-blocked`,
1964 `author`.`hidden` AS `contact-hidden`,
1965 `author`.`readonly` AS `contact-readonly`,
1966 `author`.`archive` AS `contact-archive`,
1967 `author`.`pending` AS `contact-pending`,
1968 `author`.`rel` AS `contact-rel`,
1969 `author`.`uid` AS `contact-uid`,
1970 `author`.`contact-type` AS `contact-contact-type`,
1971 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
1973 `author`.`id` AS `cid`,
1974 `author`.`alias` AS `alias`,
1975 `author`.`photo` AS `photo`,
1976 `author`.`name-date` AS `name-date`,
1977 `author`.`uri-date` AS `uri-date`,
1978 `author`.`avatar-date` AS `avatar-date`,
1979 `author`.`thumb` AS `thumb`,
1980 `post`.`author-id` AS `author-id`,
1981 `author`.`url` AS `author-link`,
1982 `author`.`addr` AS `author-addr`,
1983 `author`.`name` AS `author-name`,
1984 `author`.`nick` AS `author-nick`,
1985 `author`.`thumb` AS `author-avatar`,
1986 `author`.`network` AS `author-network`,
1987 `author`.`blocked` AS `author-blocked`,
1988 `author`.`hidden` AS `author-hidden`,
1989 `post`.`owner-id` AS `owner-id`,
1990 `owner`.`url` AS `owner-link`,
1991 `owner`.`addr` AS `owner-addr`,
1992 `owner`.`name` AS `owner-name`,
1993 `owner`.`nick` AS `owner-nick`,
1994 `owner`.`thumb` AS `owner-avatar`,
1995 `owner`.`network` AS `owner-network`,
1996 `owner`.`blocked` AS `owner-blocked`,
1997 `owner`.`hidden` AS `owner-hidden`,
1998 `owner`.`contact-type` AS `owner-contact-type`,
1999 `post`.`causer-id` AS `causer-id`,
2000 `causer`.`url` AS `causer-link`,
2001 `causer`.`addr` AS `causer-addr`,
2002 `causer`.`name` AS `causer-name`,
2003 `causer`.`nick` AS `causer-nick`,
2004 `causer`.`thumb` AS `causer-avatar`,
2005 `causer`.`network` AS `causer-network`,
2006 `causer`.`blocked` AS `causer-blocked`,
2007 `causer`.`hidden` AS `causer-hidden`,
2008 `causer`.`contact-type` AS `causer-contact-type`,
2009 `diaspora-interaction`.`interaction` AS `signed_text`,
2010 `parent-item-uri`.`guid` AS `parent-guid`,
2011 `parent-post`.`network` AS `parent-network`,
2012 `parent-post`.`author-id` AS `parent-author-id`,
2013 `parent-post-author`.`url` AS `parent-author-link`,
2014 `parent-post-author`.`name` AS `parent-author-name`,
2015 `parent-post-author`.`network` AS `parent-author-network`,
2016 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2017 `parent-post-author`.`hidden` AS `parent-author-hidden`
2019 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
2020 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
2021 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
2022 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
2023 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
2024 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2025 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2026 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2027 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2028 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
2029 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
2030 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2031 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2034 -- VIEW post-thread-view
2036 DROP VIEW IF EXISTS `post-thread-view`;
2037 CREATE VIEW `post-thread-view` AS SELECT
2038 `item-uri`.`uri` AS `uri`,
2039 `post-thread`.`uri-id` AS `uri-id`,
2040 `parent-item-uri`.`uri` AS `parent-uri`,
2041 `post`.`parent-uri-id` AS `parent-uri-id`,
2042 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2043 `post`.`thr-parent-id` AS `thr-parent-id`,
2044 `item-uri`.`guid` AS `guid`,
2045 `post`.`gravity` AS `gravity`,
2046 `external-item-uri`.`uri` AS `extid`,
2047 `post`.`external-id` AS `external-id`,
2048 `post-thread`.`created` AS `created`,
2049 `post`.`edited` AS `edited`,
2050 `post-thread`.`commented` AS `commented`,
2051 `post-thread`.`received` AS `received`,
2052 `post-thread`.`changed` AS `changed`,
2053 `post`.`post-type` AS `post-type`,
2054 `post`.`private` AS `private`,
2055 `post`.`visible` AS `visible`,
2056 `post`.`deleted` AS `deleted`,
2057 `post`.`global` AS `global`,
2058 EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread`.`uri-id`) AS `featured`,
2059 `post-thread`.`network` AS `network`,
2060 `post`.`vid` AS `vid`,
2061 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2062 `post-content`.`title` AS `title`,
2063 `post-content`.`content-warning` AS `content-warning`,
2064 `post-content`.`raw-body` AS `raw-body`,
2065 `post-content`.`body` AS `body`,
2066 `post-content`.`rendered-hash` AS `rendered-hash`,
2067 `post-content`.`rendered-html` AS `rendered-html`,
2068 `post-content`.`language` AS `language`,
2069 `post-content`.`plink` AS `plink`,
2070 `post-content`.`location` AS `location`,
2071 `post-content`.`coord` AS `coord`,
2072 `post-content`.`app` AS `app`,
2073 `post-content`.`object-type` AS `object-type`,
2074 `post-content`.`object` AS `object`,
2075 `post-content`.`target-type` AS `target-type`,
2076 `post-content`.`target` AS `target`,
2077 `post-content`.`resource-id` AS `resource-id`,
2078 `post-thread`.`author-id` AS `contact-id`,
2079 `author`.`url` AS `contact-link`,
2080 `author`.`addr` AS `contact-addr`,
2081 `author`.`name` AS `contact-name`,
2082 `author`.`nick` AS `contact-nick`,
2083 `author`.`thumb` AS `contact-avatar`,
2084 `author`.`network` AS `contact-network`,
2085 `author`.`blocked` AS `contact-blocked`,
2086 `author`.`hidden` AS `contact-hidden`,
2087 `author`.`readonly` AS `contact-readonly`,
2088 `author`.`archive` AS `contact-archive`,
2089 `author`.`pending` AS `contact-pending`,
2090 `author`.`rel` AS `contact-rel`,
2091 `author`.`uid` AS `contact-uid`,
2092 `author`.`contact-type` AS `contact-contact-type`,
2093 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2095 `author`.`id` AS `cid`,
2096 `author`.`alias` AS `alias`,
2097 `author`.`photo` AS `photo`,
2098 `author`.`name-date` AS `name-date`,
2099 `author`.`uri-date` AS `uri-date`,
2100 `author`.`avatar-date` AS `avatar-date`,
2101 `author`.`thumb` AS `thumb`,
2102 `post-thread`.`author-id` AS `author-id`,
2103 `author`.`url` AS `author-link`,
2104 `author`.`addr` AS `author-addr`,
2105 `author`.`name` AS `author-name`,
2106 `author`.`nick` AS `author-nick`,
2107 `author`.`thumb` AS `author-avatar`,
2108 `author`.`network` AS `author-network`,
2109 `author`.`blocked` AS `author-blocked`,
2110 `author`.`hidden` AS `author-hidden`,
2111 `post-thread`.`owner-id` AS `owner-id`,
2112 `owner`.`url` AS `owner-link`,
2113 `owner`.`addr` AS `owner-addr`,
2114 `owner`.`name` AS `owner-name`,
2115 `owner`.`nick` AS `owner-nick`,
2116 `owner`.`thumb` AS `owner-avatar`,
2117 `owner`.`network` AS `owner-network`,
2118 `owner`.`blocked` AS `owner-blocked`,
2119 `owner`.`hidden` AS `owner-hidden`,
2120 `owner`.`contact-type` AS `owner-contact-type`,
2121 `post-thread`.`causer-id` AS `causer-id`,
2122 `causer`.`url` AS `causer-link`,
2123 `causer`.`addr` AS `causer-addr`,
2124 `causer`.`name` AS `causer-name`,
2125 `causer`.`nick` AS `causer-nick`,
2126 `causer`.`thumb` AS `causer-avatar`,
2127 `causer`.`network` AS `causer-network`,
2128 `causer`.`blocked` AS `causer-blocked`,
2129 `causer`.`hidden` AS `causer-hidden`,
2130 `causer`.`contact-type` AS `causer-contact-type`,
2131 `diaspora-interaction`.`interaction` AS `signed_text`,
2132 `parent-item-uri`.`guid` AS `parent-guid`,
2133 `parent-post`.`network` AS `parent-network`,
2134 `parent-post`.`author-id` AS `parent-author-id`,
2135 `parent-post-author`.`url` AS `parent-author-link`,
2136 `parent-post-author`.`name` AS `parent-author-name`,
2137 `parent-post-author`.`network` AS `parent-author-network`,
2138 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2139 `parent-post-author`.`hidden` AS `parent-author-hidden`
2141 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
2142 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
2143 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
2144 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
2145 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
2146 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2147 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2148 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2149 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2150 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
2151 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
2152 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2153 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2156 -- VIEW category-view
2158 DROP VIEW IF EXISTS `category-view`;
2159 CREATE VIEW `category-view` AS SELECT
2160 `post-category`.`uri-id` AS `uri-id`,
2161 `post-category`.`uid` AS `uid`,
2162 `post-category`.`type` AS `type`,
2163 `post-category`.`tid` AS `tid`,
2164 `tag`.`name` AS `name`,
2165 `tag`.`url` AS `url`
2166 FROM `post-category`
2167 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2170 -- VIEW collection-view
2172 DROP VIEW IF EXISTS `collection-view`;
2173 CREATE VIEW `collection-view` AS SELECT
2174 `post-collection`.`uri-id` AS `uri-id`,
2175 `post-collection`.`type` AS `type`,
2176 `post`.`author-id` AS `cid`,
2177 `post`.`received` AS `received`,
2178 `post`.`created` AS `created`
2179 FROM `post-collection`
2180 INNER JOIN `post` ON `post-collection`.`uri-id` = `post`.`uri-id`;
2185 DROP VIEW IF EXISTS `tag-view`;
2186 CREATE VIEW `tag-view` AS SELECT
2187 `post-tag`.`uri-id` AS `uri-id`,
2188 `post-tag`.`type` AS `type`,
2189 `post-tag`.`tid` AS `tid`,
2190 `post-tag`.`cid` AS `cid`,
2191 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2192 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
2194 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2195 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2198 -- VIEW network-item-view
2200 DROP VIEW IF EXISTS `network-item-view`;
2201 CREATE VIEW `network-item-view` AS SELECT
2202 `post-user`.`uri-id` AS `uri-id`,
2203 `parent-post`.`id` AS `parent`,
2204 `post-user`.`received` AS `received`,
2205 `post-thread-user`.`commented` AS `commented`,
2206 `post-user`.`created` AS `created`,
2207 `post-user`.`uid` AS `uid`,
2208 `post-thread-user`.`starred` AS `starred`,
2209 `post-thread-user`.`mention` AS `mention`,
2210 `post-user`.`network` AS `network`,
2211 `post-user`.`unseen` AS `unseen`,
2212 `post-user`.`gravity` AS `gravity`,
2213 `post-user`.`contact-id` AS `contact-id`,
2214 `ownercontact`.`contact-type` AS `contact-type`
2216 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2217 INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2218 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2219 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2220 INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2221 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2222 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2223 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2224 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
2225 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2226 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2229 -- VIEW network-thread-view
2231 DROP VIEW IF EXISTS `network-thread-view`;
2232 CREATE VIEW `network-thread-view` AS SELECT
2233 `post-thread-user`.`uri-id` AS `uri-id`,
2234 `parent-post`.`id` AS `parent`,
2235 `post-thread-user`.`received` AS `received`,
2236 `post-thread-user`.`commented` AS `commented`,
2237 `post-thread-user`.`created` AS `created`,
2238 `post-thread-user`.`uid` AS `uid`,
2239 `post-thread-user`.`starred` AS `starred`,
2240 `post-thread-user`.`mention` AS `mention`,
2241 `post-thread-user`.`network` AS `network`,
2242 `post-thread-user`.`contact-id` AS `contact-id`,
2243 `ownercontact`.`contact-type` AS `contact-type`
2244 FROM `post-thread-user`
2245 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2246 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2247 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2248 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2249 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2250 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2251 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2252 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2253 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2254 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2255 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2260 DROP VIEW IF EXISTS `owner-view`;
2261 CREATE VIEW `owner-view` AS SELECT
2262 `contact`.`id` AS `id`,
2263 `contact`.`uid` AS `uid`,
2264 `contact`.`created` AS `created`,
2265 `contact`.`updated` AS `updated`,
2266 `contact`.`self` AS `self`,
2267 `contact`.`remote_self` AS `remote_self`,
2268 `contact`.`rel` AS `rel`,
2269 `contact`.`network` AS `network`,
2270 `contact`.`protocol` AS `protocol`,
2271 `contact`.`name` AS `name`,
2272 `contact`.`nick` AS `nick`,
2273 `contact`.`location` AS `location`,
2274 `contact`.`about` AS `about`,
2275 `contact`.`keywords` AS `keywords`,
2276 `contact`.`xmpp` AS `xmpp`,
2277 `contact`.`matrix` AS `matrix`,
2278 `contact`.`attag` AS `attag`,
2279 `contact`.`avatar` AS `avatar`,
2280 `contact`.`photo` AS `photo`,
2281 `contact`.`thumb` AS `thumb`,
2282 `contact`.`micro` AS `micro`,
2283 `contact`.`header` AS `header`,
2284 `contact`.`url` AS `url`,
2285 `contact`.`nurl` AS `nurl`,
2286 `contact`.`uri-id` AS `uri-id`,
2287 `contact`.`addr` AS `addr`,
2288 `contact`.`alias` AS `alias`,
2289 `contact`.`pubkey` AS `pubkey`,
2290 `contact`.`prvkey` AS `prvkey`,
2291 `contact`.`batch` AS `batch`,
2292 `contact`.`request` AS `request`,
2293 `contact`.`notify` AS `notify`,
2294 `contact`.`poll` AS `poll`,
2295 `contact`.`confirm` AS `confirm`,
2296 `contact`.`poco` AS `poco`,
2297 `contact`.`subhub` AS `subhub`,
2298 `contact`.`hub-verify` AS `hub-verify`,
2299 `contact`.`last-update` AS `last-update`,
2300 `contact`.`success_update` AS `success_update`,
2301 `contact`.`failure_update` AS `failure_update`,
2302 `contact`.`name-date` AS `name-date`,
2303 `contact`.`uri-date` AS `uri-date`,
2304 `contact`.`avatar-date` AS `avatar-date`,
2305 `contact`.`avatar-date` AS `picdate`,
2306 `contact`.`term-date` AS `term-date`,
2307 `contact`.`last-item` AS `last-item`,
2308 `contact`.`priority` AS `priority`,
2309 `user`.`blocked` AS `blocked`,
2310 `contact`.`block_reason` AS `block_reason`,
2311 `contact`.`readonly` AS `readonly`,
2312 `contact`.`writable` AS `writable`,
2313 `contact`.`forum` AS `forum`,
2314 `contact`.`prv` AS `prv`,
2315 `contact`.`contact-type` AS `contact-type`,
2316 `contact`.`manually-approve` AS `manually-approve`,
2317 `contact`.`hidden` AS `hidden`,
2318 `contact`.`archive` AS `archive`,
2319 `contact`.`pending` AS `pending`,
2320 `contact`.`deleted` AS `deleted`,
2321 `contact`.`unsearchable` AS `unsearchable`,
2322 `contact`.`sensitive` AS `sensitive`,
2323 `contact`.`baseurl` AS `baseurl`,
2324 `contact`.`reason` AS `reason`,
2325 `contact`.`info` AS `info`,
2326 `contact`.`bdyear` AS `bdyear`,
2327 `contact`.`bd` AS `bd`,
2328 `contact`.`notify_new_posts` AS `notify_new_posts`,
2329 `contact`.`fetch_further_information` AS `fetch_further_information`,
2330 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2331 `user`.`parent-uid` AS `parent-uid`,
2332 `user`.`guid` AS `guid`,
2333 `user`.`nickname` AS `nickname`,
2334 `user`.`email` AS `email`,
2335 `user`.`openid` AS `openid`,
2336 `user`.`timezone` AS `timezone`,
2337 `user`.`language` AS `language`,
2338 `user`.`register_date` AS `register_date`,
2339 `user`.`login_date` AS `login_date`,
2340 `user`.`default-location` AS `default-location`,
2341 `user`.`allow_location` AS `allow_location`,
2342 `user`.`theme` AS `theme`,
2343 `user`.`pubkey` AS `upubkey`,
2344 `user`.`prvkey` AS `uprvkey`,
2345 `user`.`sprvkey` AS `sprvkey`,
2346 `user`.`spubkey` AS `spubkey`,
2347 `user`.`verified` AS `verified`,
2348 `user`.`blockwall` AS `blockwall`,
2349 `user`.`hidewall` AS `hidewall`,
2350 `user`.`blocktags` AS `blocktags`,
2351 `user`.`unkmail` AS `unkmail`,
2352 `user`.`cntunkmail` AS `cntunkmail`,
2353 `user`.`notify-flags` AS `notify-flags`,
2354 `user`.`page-flags` AS `page-flags`,
2355 `user`.`account-type` AS `account-type`,
2356 `user`.`prvnets` AS `prvnets`,
2357 `user`.`maxreq` AS `maxreq`,
2358 `user`.`expire` AS `expire`,
2359 `user`.`account_removed` AS `account_removed`,
2360 `user`.`account_expired` AS `account_expired`,
2361 `user`.`account_expires_on` AS `account_expires_on`,
2362 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2363 `user`.`def_gid` AS `def_gid`,
2364 `user`.`allow_cid` AS `allow_cid`,
2365 `user`.`allow_gid` AS `allow_gid`,
2366 `user`.`deny_cid` AS `deny_cid`,
2367 `user`.`deny_gid` AS `deny_gid`,
2368 `user`.`openidserver` AS `openidserver`,
2369 `profile`.`publish` AS `publish`,
2370 `profile`.`net-publish` AS `net-publish`,
2371 `profile`.`hide-friends` AS `hide-friends`,
2372 `profile`.`prv_keywords` AS `prv_keywords`,
2373 `profile`.`pub_keywords` AS `pub_keywords`,
2374 `profile`.`address` AS `address`,
2375 `profile`.`locality` AS `locality`,
2376 `profile`.`region` AS `region`,
2377 `profile`.`postal-code` AS `postal-code`,
2378 `profile`.`country-name` AS `country-name`,
2379 `profile`.`homepage` AS `homepage`,
2380 `profile`.`dob` AS `dob`
2382 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2383 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2386 -- VIEW account-view
2388 DROP VIEW IF EXISTS `account-view`;
2389 CREATE VIEW `account-view` AS SELECT
2390 `contact`.`id` AS `id`,
2391 `contact`.`url` AS `url`,
2392 `contact`.`nurl` AS `nurl`,
2393 `contact`.`uri-id` AS `uri-id`,
2394 `item-uri`.`guid` AS `guid`,
2395 `contact`.`addr` AS `addr`,
2396 `contact`.`alias` AS `alias`,
2397 `contact`.`name` AS `name`,
2398 `contact`.`nick` AS `nick`,
2399 `contact`.`about` AS `about`,
2400 `contact`.`keywords` AS `keywords`,
2401 `contact`.`xmpp` AS `xmpp`,
2402 `contact`.`matrix` AS `matrix`,
2403 `contact`.`avatar` AS `avatar`,
2404 `contact`.`photo` AS `photo`,
2405 `contact`.`thumb` AS `thumb`,
2406 `contact`.`micro` AS `micro`,
2407 `contact`.`header` AS `header`,
2408 `contact`.`created` AS `created`,
2409 `contact`.`updated` AS `updated`,
2410 `contact`.`network` AS `network`,
2411 `contact`.`protocol` AS `protocol`,
2412 `contact`.`location` AS `location`,
2413 `contact`.`attag` AS `attag`,
2414 `contact`.`pubkey` AS `pubkey`,
2415 `contact`.`prvkey` AS `prvkey`,
2416 `contact`.`subscribe` AS `subscribe`,
2417 `contact`.`last-update` AS `last-update`,
2418 `contact`.`success_update` AS `success_update`,
2419 `contact`.`failure_update` AS `failure_update`,
2420 `contact`.`failed` AS `failed`,
2421 `contact`.`last-item` AS `last-item`,
2422 `contact`.`last-discovery` AS `last-discovery`,
2423 `contact`.`contact-type` AS `contact-type`,
2424 `contact`.`manually-approve` AS `manually-approve`,
2425 `contact`.`unsearchable` AS `unsearchable`,
2426 `contact`.`sensitive` AS `sensitive`,
2427 `contact`.`baseurl` AS `baseurl`,
2428 `contact`.`gsid` AS `gsid`,
2429 `contact`.`info` AS `info`,
2430 `contact`.`bdyear` AS `bdyear`,
2431 `contact`.`bd` AS `bd`,
2432 `contact`.`poco` AS `poco`,
2433 `contact`.`name-date` AS `name-date`,
2434 `contact`.`uri-date` AS `uri-date`,
2435 `contact`.`avatar-date` AS `avatar-date`,
2436 `contact`.`term-date` AS `term-date`,
2437 `contact`.`hidden` AS `global-ignored`,
2438 `contact`.`blocked` AS `global-blocked`,
2439 `contact`.`hidden` AS `hidden`,
2440 `contact`.`archive` AS `archive`,
2441 `contact`.`deleted` AS `deleted`,
2442 `contact`.`blocked` AS `blocked`,
2443 `contact`.`notify` AS `dfrn-notify`,
2444 `contact`.`poll` AS `dfrn-poll`,
2445 `fcontact`.`guid` AS `diaspora-guid`,
2446 `fcontact`.`batch` AS `diaspora-batch`,
2447 `fcontact`.`notify` AS `diaspora-notify`,
2448 `fcontact`.`poll` AS `diaspora-poll`,
2449 `fcontact`.`alias` AS `diaspora-alias`,
2450 `apcontact`.`uuid` AS `ap-uuid`,
2451 `apcontact`.`type` AS `ap-type`,
2452 `apcontact`.`following` AS `ap-following`,
2453 `apcontact`.`followers` AS `ap-followers`,
2454 `apcontact`.`inbox` AS `ap-inbox`,
2455 `apcontact`.`outbox` AS `ap-outbox`,
2456 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2457 `apcontact`.`generator` AS `ap-generator`,
2458 `apcontact`.`following_count` AS `ap-following_count`,
2459 `apcontact`.`followers_count` AS `ap-followers_count`,
2460 `apcontact`.`statuses_count` AS `ap-statuses_count`,
2461 `gserver`.`site_name` AS `site_name`,
2462 `gserver`.`platform` AS `platform`,
2463 `gserver`.`version` AS `version`
2465 LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id`
2466 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
2467 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = contact.`uri-id`
2468 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`
2469 WHERE `contact`.`uid` = 0;
2472 -- VIEW account-user-view
2474 DROP VIEW IF EXISTS `account-user-view`;
2475 CREATE VIEW `account-user-view` AS SELECT
2476 `ucontact`.`id` AS `id`,
2477 `contact`.`id` AS `pid`,
2478 `ucontact`.`uid` AS `uid`,
2479 `contact`.`url` AS `url`,
2480 `contact`.`nurl` AS `nurl`,
2481 `contact`.`uri-id` AS `uri-id`,
2482 `item-uri`.`guid` AS `guid`,
2483 `contact`.`addr` AS `addr`,
2484 `contact`.`alias` AS `alias`,
2485 `contact`.`name` AS `name`,
2486 `contact`.`nick` AS `nick`,
2487 `contact`.`about` AS `about`,
2488 `contact`.`keywords` AS `keywords`,
2489 `contact`.`xmpp` AS `xmpp`,
2490 `contact`.`matrix` AS `matrix`,
2491 `contact`.`avatar` AS `avatar`,
2492 `contact`.`photo` AS `photo`,
2493 `contact`.`thumb` AS `thumb`,
2494 `contact`.`micro` AS `micro`,
2495 `contact`.`header` AS `header`,
2496 `contact`.`created` AS `created`,
2497 `contact`.`updated` AS `updated`,
2498 `ucontact`.`self` AS `self`,
2499 `ucontact`.`remote_self` AS `remote_self`,
2500 `ucontact`.`rel` AS `rel`,
2501 `contact`.`network` AS `network`,
2502 `ucontact`.`protocol` AS `protocol`,
2503 `contact`.`location` AS `location`,
2504 `ucontact`.`attag` AS `attag`,
2505 `contact`.`pubkey` AS `pubkey`,
2506 `contact`.`prvkey` AS `prvkey`,
2507 `contact`.`subscribe` AS `subscribe`,
2508 `contact`.`last-update` AS `last-update`,
2509 `contact`.`success_update` AS `success_update`,
2510 `contact`.`failure_update` AS `failure_update`,
2511 `contact`.`failed` AS `failed`,
2512 `contact`.`last-item` AS `last-item`,
2513 `contact`.`last-discovery` AS `last-discovery`,
2514 `contact`.`contact-type` AS `contact-type`,
2515 `contact`.`manually-approve` AS `manually-approve`,
2516 `contact`.`unsearchable` AS `unsearchable`,
2517 `contact`.`sensitive` AS `sensitive`,
2518 `contact`.`baseurl` AS `baseurl`,
2519 `contact`.`gsid` AS `gsid`,
2520 `ucontact`.`info` AS `info`,
2521 `contact`.`bdyear` AS `bdyear`,
2522 `contact`.`bd` AS `bd`,
2523 `contact`.`poco` AS `poco`,
2524 `contact`.`name-date` AS `name-date`,
2525 `contact`.`uri-date` AS `uri-date`,
2526 `contact`.`avatar-date` AS `avatar-date`,
2527 `contact`.`term-date` AS `term-date`,
2528 `contact`.`hidden` AS `global-ignored`,
2529 `contact`.`blocked` AS `global-blocked`,
2530 `ucontact`.`hidden` AS `hidden`,
2531 `ucontact`.`archive` AS `archive`,
2532 `ucontact`.`pending` AS `pending`,
2533 `ucontact`.`deleted` AS `deleted`,
2534 `ucontact`.`notify_new_posts` AS `notify_new_posts`,
2535 `ucontact`.`fetch_further_information` AS `fetch_further_information`,
2536 `ucontact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2537 `ucontact`.`rating` AS `rating`,
2538 `ucontact`.`readonly` AS `readonly`,
2539 `ucontact`.`blocked` AS `blocked`,
2540 `ucontact`.`block_reason` AS `block_reason`,
2541 `ucontact`.`subhub` AS `subhub`,
2542 `ucontact`.`hub-verify` AS `hub-verify`,
2543 `ucontact`.`reason` AS `reason`,
2544 `contact`.`notify` AS `dfrn-notify`,
2545 `contact`.`poll` AS `dfrn-poll`,
2546 `fcontact`.`guid` AS `diaspora-guid`,
2547 `fcontact`.`batch` AS `diaspora-batch`,
2548 `fcontact`.`notify` AS `diaspora-notify`,
2549 `fcontact`.`poll` AS `diaspora-poll`,
2550 `fcontact`.`alias` AS `diaspora-alias`,
2551 `apcontact`.`uuid` AS `ap-uuid`,
2552 `apcontact`.`type` AS `ap-type`,
2553 `apcontact`.`following` AS `ap-following`,
2554 `apcontact`.`followers` AS `ap-followers`,
2555 `apcontact`.`inbox` AS `ap-inbox`,
2556 `apcontact`.`outbox` AS `ap-outbox`,
2557 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2558 `apcontact`.`generator` AS `ap-generator`,
2559 `apcontact`.`following_count` AS `ap-following_count`,
2560 `apcontact`.`followers_count` AS `ap-followers_count`,
2561 `apcontact`.`statuses_count` AS `ap-statuses_count`,
2562 `gserver`.`site_name` AS `site_name`,
2563 `gserver`.`platform` AS `platform`,
2564 `gserver`.`version` AS `version`
2565 FROM `contact` AS `ucontact`
2566 INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
2567 LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id`
2568 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
2569 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = `ucontact`.`uri-id` AND `fcontact`.`network` = 'dspr'
2570 LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`;
2573 -- VIEW pending-view
2575 DROP VIEW IF EXISTS `pending-view`;
2576 CREATE VIEW `pending-view` AS SELECT
2577 `register`.`id` AS `id`,
2578 `register`.`hash` AS `hash`,
2579 `register`.`created` AS `created`,
2580 `register`.`uid` AS `uid`,
2581 `register`.`password` AS `password`,
2582 `register`.`language` AS `language`,
2583 `register`.`note` AS `note`,
2584 `contact`.`self` AS `self`,
2585 `contact`.`name` AS `name`,
2586 `contact`.`url` AS `url`,
2587 `contact`.`micro` AS `micro`,
2588 `user`.`email` AS `email`,
2589 `contact`.`nick` AS `nick`
2591 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2592 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2595 -- VIEW tag-search-view
2597 DROP VIEW IF EXISTS `tag-search-view`;
2598 CREATE VIEW `tag-search-view` AS SELECT
2599 `post-tag`.`uri-id` AS `uri-id`,
2600 `post-user`.`uid` AS `uid`,
2601 `post-user`.`id` AS `iid`,
2602 `post-user`.`private` AS `private`,
2603 `post-user`.`wall` AS `wall`,
2604 `post-user`.`origin` AS `origin`,
2605 `post-user`.`global` AS `global`,
2606 `post-user`.`gravity` AS `gravity`,
2607 `post-user`.`received` AS `received`,
2608 `post-user`.`network` AS `network`,
2609 `post-user`.`author-id` AS `author-id`,
2610 `tag`.`name` AS `name`
2612 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
2613 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
2614 WHERE `post-tag`.`type` = 1;
2617 -- VIEW workerqueue-view
2619 DROP VIEW IF EXISTS `workerqueue-view`;
2620 CREATE VIEW `workerqueue-view` AS SELECT
2621 `process`.`pid` AS `pid`,
2622 `workerqueue`.`priority` AS `priority`
2624 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
2625 WHERE NOT `workerqueue`.`done`;
2628 -- VIEW profile_field-view
2630 DROP VIEW IF EXISTS `profile_field-view`;
2631 CREATE VIEW `profile_field-view` AS SELECT
2632 `profile_field`.`id` AS `id`,
2633 `profile_field`.`uid` AS `uid`,
2634 `profile_field`.`label` AS `label`,
2635 `profile_field`.`value` AS `value`,
2636 `profile_field`.`order` AS `order`,
2637 `profile_field`.`psid` AS `psid`,
2638 `permissionset`.`allow_cid` AS `allow_cid`,
2639 `permissionset`.`allow_gid` AS `allow_gid`,
2640 `permissionset`.`deny_cid` AS `deny_cid`,
2641 `permissionset`.`deny_gid` AS `deny_gid`,
2642 `profile_field`.`created` AS `created`,
2643 `profile_field`.`edited` AS `edited`
2644 FROM `profile_field`
2645 INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`;