1 -- ------------------------------------------
2 -- Friendica 2022.05-dev (Siberian Iris)
3 -- DB_UPDATE_VERSION 1452
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 `manually-approve` boolean COMMENT '',
336 `discoverable` boolean COMMENT 'Mastodon extension: true if profile is published in their directory',
337 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
338 `name` varchar(255) COMMENT '',
339 `about` text COMMENT '',
340 `xmpp` varchar(255) COMMENT 'XMPP address',
341 `matrix` varchar(255) COMMENT 'Matrix address',
342 `photo` varchar(255) COMMENT '',
343 `header` varchar(255) COMMENT 'Header picture',
344 `addr` varchar(255) COMMENT '',
345 `alias` varchar(255) COMMENT '',
346 `pubkey` text COMMENT '',
347 `subscribe` varchar(255) COMMENT '',
348 `baseurl` varchar(255) COMMENT 'baseurl of the ap contact',
349 `gsid` int unsigned COMMENT 'Global Server ID',
350 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
351 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
352 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
353 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
354 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
356 INDEX `addr` (`addr`(32)),
357 INDEX `alias` (`alias`(190)),
358 INDEX `followers` (`followers`(190)),
359 INDEX `baseurl` (`baseurl`(190)),
360 INDEX `sharedinbox` (`sharedinbox`(190)),
361 INDEX `gsid` (`gsid`),
362 UNIQUE INDEX `uri-id` (`uri-id`),
363 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
364 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
365 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
370 CREATE TABLE IF NOT EXISTS `application` (
371 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
372 `client_id` varchar(64) NOT NULL COMMENT '',
373 `client_secret` varchar(64) NOT NULL COMMENT '',
374 `name` varchar(255) NOT NULL COMMENT '',
375 `redirect_uri` varchar(255) NOT NULL COMMENT '',
376 `website` varchar(255) COMMENT '',
377 `scopes` varchar(255) COMMENT '',
378 `read` boolean COMMENT 'Read scope',
379 `write` boolean COMMENT 'Write scope',
380 `follow` boolean COMMENT 'Follow scope',
381 `push` boolean COMMENT 'Push scope',
383 UNIQUE INDEX `client_id` (`client_id`)
384 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth application';
387 -- TABLE application-token
389 CREATE TABLE IF NOT EXISTS `application-token` (
390 `application-id` int unsigned NOT NULL COMMENT '',
391 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
392 `code` varchar(64) NOT NULL COMMENT '',
393 `access_token` varchar(64) NOT NULL COMMENT '',
394 `created_at` datetime NOT NULL COMMENT 'creation time',
395 `scopes` varchar(255) COMMENT '',
396 `read` boolean COMMENT 'Read scope',
397 `write` boolean COMMENT 'Write scope',
398 `follow` boolean COMMENT 'Follow scope',
399 `push` boolean COMMENT 'Push scope',
400 PRIMARY KEY(`application-id`,`uid`),
401 INDEX `uid_id` (`uid`,`application-id`),
402 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
403 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
404 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth user token';
409 CREATE TABLE IF NOT EXISTS `attach` (
410 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
411 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
412 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
413 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
414 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
415 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
416 `data` longblob NOT NULL COMMENT 'file data',
417 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
418 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
419 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
420 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
421 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
422 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
423 `backend-class` tinytext COMMENT 'Storage backend class',
424 `backend-ref` text COMMENT 'Storage backend data reference',
427 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
428 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
433 CREATE TABLE IF NOT EXISTS `cache` (
434 `k` varbinary(255) NOT NULL COMMENT 'cache key',
435 `v` mediumtext COMMENT 'cached serialized value',
436 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
437 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
439 INDEX `k_expires` (`k`,`expires`)
440 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
445 CREATE TABLE IF NOT EXISTS `config` (
446 `id` int unsigned NOT NULL auto_increment COMMENT '',
447 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
448 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
449 `v` mediumtext COMMENT '',
451 UNIQUE INDEX `cat_k` (`cat`,`k`)
452 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
455 -- TABLE contact-relation
457 CREATE TABLE IF NOT EXISTS `contact-relation` (
458 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
459 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
460 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
461 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
462 `follows` boolean NOT NULL DEFAULT '0' COMMENT '',
463 PRIMARY KEY(`cid`,`relation-cid`),
464 INDEX `relation-cid` (`relation-cid`),
465 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
466 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
467 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
472 CREATE TABLE IF NOT EXISTS `conv` (
473 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
474 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
475 `recips` text COMMENT 'sender_handle;recipient_handle',
476 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
477 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
478 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
479 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
480 `subject` text COMMENT 'subject of initial message',
483 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
484 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
487 -- TABLE conversation
489 CREATE TABLE IF NOT EXISTS `conversation` (
490 `item-uri` varbinary(255) NOT NULL COMMENT 'Original URI of the item - unrelated to the table with the same name',
491 `reply-to-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'URI to which this item is a reply',
492 `conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI',
493 `conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link',
494 `protocol` tinyint unsigned NOT NULL DEFAULT 255 COMMENT 'The protocol of the item',
495 `direction` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'How the message arrived here: 1=push, 2=pull',
496 `source` mediumtext COMMENT 'Original source',
497 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Receiving date',
498 PRIMARY KEY(`item-uri`),
499 INDEX `conversation-uri` (`conversation-uri`),
500 INDEX `received` (`received`)
501 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Raw data and structure information for messages';
506 CREATE TABLE IF NOT EXISTS `workerqueue` (
507 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
508 `command` varchar(100) COMMENT 'Task command',
509 `parameter` mediumtext COMMENT 'Task parameter',
510 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
511 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
512 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
513 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
514 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
515 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
516 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
518 INDEX `command` (`command`),
519 INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
520 INDEX `done_executed` (`done`,`executed`),
521 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
522 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
523 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
524 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
525 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
526 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
529 -- TABLE delayed-post
531 CREATE TABLE IF NOT EXISTS `delayed-post` (
532 `id` int unsigned NOT NULL auto_increment,
533 `uri` varchar(255) COMMENT 'URI of the post that will be distributed later',
534 `uid` mediumint unsigned COMMENT 'Owner User id',
535 `delayed` datetime COMMENT 'delay time',
536 `wid` int unsigned COMMENT 'Workerqueue id',
538 UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
540 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
541 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
542 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
545 -- TABLE diaspora-interaction
547 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
548 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
549 `interaction` mediumtext COMMENT 'The Diaspora interaction',
550 PRIMARY KEY(`uri-id`),
551 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
552 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
557 CREATE TABLE IF NOT EXISTS `event` (
558 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
559 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
560 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
561 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
562 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
563 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the event uri',
564 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
565 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
566 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
567 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
568 `summary` text COMMENT 'short description or title of the event',
569 `desc` text COMMENT 'event description',
570 `location` text COMMENT 'event location',
571 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
572 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
573 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
574 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
575 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
576 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
577 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
579 INDEX `uid_start` (`uid`,`start`),
581 INDEX `uri-id` (`uri-id`),
582 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
583 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
584 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
585 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
590 CREATE TABLE IF NOT EXISTS `fcontact` (
591 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
592 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
593 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
594 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the fcontact url',
595 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
596 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
597 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
598 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
599 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
600 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
601 `notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
602 `poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
603 `confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
604 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
605 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
606 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
607 `pubkey` text COMMENT '',
608 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
609 `interacting_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts this contact interactes with',
610 `interacted_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts that interacted with this contact',
611 `post_count` int unsigned DEFAULT 0 COMMENT 'Number of posts and comments',
613 INDEX `addr` (`addr`(32)),
614 UNIQUE INDEX `url` (`url`(190)),
615 UNIQUE INDEX `uri-id` (`uri-id`),
616 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
617 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
622 CREATE TABLE IF NOT EXISTS `fsuggest` (
623 `id` int unsigned NOT NULL auto_increment COMMENT '',
624 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
625 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
626 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
627 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
628 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
629 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
630 `note` text COMMENT '',
631 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
635 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
636 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
637 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
642 CREATE TABLE IF NOT EXISTS `group` (
643 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
644 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
645 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
646 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
647 `cid` int unsigned COMMENT 'Contact id of forum. When this field is filled then the members are synced automatically.',
648 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
652 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
653 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
654 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
657 -- TABLE group_member
659 CREATE TABLE IF NOT EXISTS `group_member` (
660 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
661 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
662 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
664 INDEX `contactid` (`contact-id`),
665 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
666 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
667 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
668 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
673 CREATE TABLE IF NOT EXISTS `gserver-tag` (
674 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
675 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
676 PRIMARY KEY(`gserver-id`,`tag`),
678 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
679 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
684 CREATE TABLE IF NOT EXISTS `hook` (
685 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
686 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
687 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
688 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
689 `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',
691 INDEX `priority` (`priority`),
692 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
693 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
696 -- TABLE inbox-status
698 CREATE TABLE IF NOT EXISTS `inbox-status` (
699 `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
700 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
701 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
702 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
703 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
704 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
705 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
707 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
712 CREATE TABLE IF NOT EXISTS `intro` (
713 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
714 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
715 `fid` int unsigned COMMENT 'deprecated',
716 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
717 `suggest-cid` int unsigned COMMENT 'Suggested contact',
718 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
719 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
720 `note` text COMMENT '',
721 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
722 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
723 `blocked` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
724 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
726 INDEX `contact-id` (`contact-id`),
727 INDEX `suggest-cid` (`suggest-cid`),
729 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
730 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
731 FOREIGN KEY (`suggest-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
732 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
737 CREATE TABLE IF NOT EXISTS `locks` (
738 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
739 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
740 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
741 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
742 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
744 INDEX `name_expires` (`name`,`expires`)
745 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
750 CREATE TABLE IF NOT EXISTS `mail` (
751 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
752 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
753 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
754 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
755 `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
756 `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
757 `contact-id` varchar(255) COMMENT 'contact.id',
758 `author-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the author of the mail',
759 `convid` int unsigned COMMENT 'conv.id',
760 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
761 `body` mediumtext COMMENT '',
762 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
763 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
764 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
765 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
766 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
767 `uri-id` int unsigned COMMENT 'Item-uri id of the related mail',
768 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
769 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related mail',
770 `thr-parent` varchar(255) COMMENT '',
771 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
772 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
774 INDEX `uid_seen` (`uid`,`seen`),
775 INDEX `convid` (`convid`),
776 INDEX `uri` (`uri`(64)),
777 INDEX `parent-uri` (`parent-uri`(64)),
778 INDEX `contactid` (`contact-id`(32)),
779 INDEX `author-id` (`author-id`),
780 INDEX `uri-id` (`uri-id`),
781 INDEX `parent-uri-id` (`parent-uri-id`),
782 INDEX `thr-parent-id` (`thr-parent-id`),
783 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
784 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
785 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
786 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
787 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
788 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
793 CREATE TABLE IF NOT EXISTS `mailacct` (
794 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
795 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
796 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
797 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
798 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
799 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
800 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
801 `pass` text COMMENT '',
802 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
803 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
804 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
805 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
806 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
809 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
810 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
815 CREATE TABLE IF NOT EXISTS `manage` (
816 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
817 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
818 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
820 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
822 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
823 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
824 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
827 -- TABLE notification
829 CREATE TABLE IF NOT EXISTS `notification` (
830 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
831 `uid` mediumint unsigned COMMENT 'Owner User id',
832 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
833 `type` tinyint unsigned COMMENT '',
834 `actor-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the actor that caused the notification',
835 `target-uri-id` int unsigned COMMENT 'Item-uri id of the related post',
836 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
837 `created` datetime COMMENT '',
838 `seen` boolean DEFAULT '0' COMMENT 'Seen on the desktop',
839 `dismissed` boolean DEFAULT '0' COMMENT 'Dismissed via the API',
841 UNIQUE INDEX `uid_vid_type_actor-id_target-uri-id` (`uid`,`vid`,`type`,`actor-id`,`target-uri-id`),
843 INDEX `actor-id` (`actor-id`),
844 INDEX `target-uri-id` (`target-uri-id`),
845 INDEX `parent-uri-id` (`parent-uri-id`),
846 INDEX `seen_uid` (`seen`,`uid`),
847 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
848 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
849 FOREIGN KEY (`actor-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
850 FOREIGN KEY (`target-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
851 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
852 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
857 CREATE TABLE IF NOT EXISTS `notify` (
858 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
859 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
860 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
861 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
862 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
863 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
864 `msg` mediumtext COMMENT '',
865 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
866 `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
867 `iid` int unsigned COMMENT '',
868 `parent` int unsigned COMMENT '',
869 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
870 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
871 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
872 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
873 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
874 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
875 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
877 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
878 INDEX `uid_date` (`uid`,`date`),
879 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
880 INDEX `uri-id` (`uri-id`),
881 INDEX `parent-uri-id` (`parent-uri-id`),
882 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
883 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
884 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
885 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
888 -- TABLE notify-threads
890 CREATE TABLE IF NOT EXISTS `notify-threads` (
891 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
892 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
893 `master-parent-item` int unsigned COMMENT 'Deprecated',
894 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
895 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
896 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
898 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
899 INDEX `receiver-uid` (`receiver-uid`),
900 INDEX `notify-id` (`notify-id`),
901 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
902 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
903 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
904 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
909 CREATE TABLE IF NOT EXISTS `oembed` (
910 `url` varbinary(255) NOT NULL COMMENT 'page url',
911 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
912 `content` mediumtext COMMENT 'OEmbed data of the page',
913 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
914 PRIMARY KEY(`url`,`maxwidth`),
915 INDEX `created` (`created`)
916 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
919 -- TABLE openwebauth-token
921 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
922 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
923 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
924 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
925 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
926 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
927 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
930 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
931 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
936 CREATE TABLE IF NOT EXISTS `parsed_url` (
937 `url_hash` binary(64) NOT NULL COMMENT 'page url hash',
938 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
939 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
940 `url` text NOT NULL COMMENT 'page url',
941 `content` mediumtext COMMENT 'page data',
942 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
943 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration',
944 PRIMARY KEY(`url_hash`,`guessing`,`oembed`),
945 INDEX `created` (`created`),
946 INDEX `expires` (`expires`)
947 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
952 CREATE TABLE IF NOT EXISTS `pconfig` (
953 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
954 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
955 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
956 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
957 `v` mediumtext COMMENT 'Value',
959 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
960 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
961 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
966 CREATE TABLE IF NOT EXISTS `photo` (
967 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
968 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
969 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
970 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
971 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
972 `hash` char(32) COMMENT 'hash value of the photo',
973 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
974 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
975 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
976 `desc` text COMMENT '',
977 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
978 `photo-type` tinyint unsigned COMMENT 'User avatar, user banner, contact avatar, contact banner or default',
979 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
980 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
981 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
982 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
983 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
984 `data` mediumblob NOT NULL COMMENT '',
985 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
986 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
987 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
988 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
989 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
990 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
991 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
992 `backend-class` tinytext COMMENT 'Storage backend class',
993 `backend-ref` text COMMENT 'Storage backend data reference',
994 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
996 INDEX `contactid` (`contact-id`),
997 INDEX `uid_contactid` (`uid`,`contact-id`),
998 INDEX `uid_profile` (`uid`,`profile`),
999 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
1000 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
1001 INDEX `resource-id` (`resource-id`),
1002 INDEX `uid_photo-type` (`uid`,`photo-type`),
1003 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1004 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1005 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1010 CREATE TABLE IF NOT EXISTS `post` (
1011 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1012 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1013 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1014 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1015 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1016 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1017 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1018 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1019 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1020 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1021 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1022 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1023 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1024 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1025 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1026 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1027 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1028 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1029 PRIMARY KEY(`uri-id`),
1030 INDEX `parent-uri-id` (`parent-uri-id`),
1031 INDEX `thr-parent-id` (`thr-parent-id`),
1032 INDEX `external-id` (`external-id`),
1033 INDEX `owner-id` (`owner-id`),
1034 INDEX `author-id` (`author-id`),
1035 INDEX `causer-id` (`causer-id`),
1036 INDEX `vid` (`vid`),
1037 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1038 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1039 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1040 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1041 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1042 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1043 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1044 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1045 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
1048 -- TABLE post-category
1050 CREATE TABLE IF NOT EXISTS `post-category` (
1051 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1052 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1053 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1054 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1055 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1056 INDEX `uri-id` (`tid`),
1057 INDEX `uid` (`uid`),
1058 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1059 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1060 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1061 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1064 -- TABLE post-content
1066 CREATE TABLE IF NOT EXISTS `post-content` (
1067 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1068 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1069 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1070 `body` mediumtext COMMENT 'item body content',
1071 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1072 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1073 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1074 `language` text COMMENT 'Language information about this post',
1075 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1076 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1077 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1078 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1079 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1080 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1081 `target` text COMMENT 'JSON encoded target structure if used',
1082 `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',
1083 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1084 PRIMARY KEY(`uri-id`),
1085 INDEX `plink` (`plink`(191)),
1086 INDEX `resource-id` (`resource-id`),
1087 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
1088 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1089 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1092 -- TABLE post-delivery-data
1094 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1095 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1096 `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',
1097 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1098 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1099 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1100 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1101 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1102 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1103 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1104 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1105 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1106 PRIMARY KEY(`uri-id`),
1107 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1108 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1113 CREATE TABLE IF NOT EXISTS `post-link` (
1114 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1115 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1116 `url` varbinary(511) NOT NULL COMMENT 'External URL',
1117 `mimetype` varchar(60) COMMENT '',
1119 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1120 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1121 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post related external links';
1126 CREATE TABLE IF NOT EXISTS `post-media` (
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 'Media URL',
1130 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1131 `mimetype` varchar(60) COMMENT '',
1132 `height` smallint unsigned COMMENT 'Height of the media',
1133 `width` smallint unsigned COMMENT 'Width of the media',
1134 `size` int unsigned COMMENT 'Media size',
1135 `preview` varbinary(255) COMMENT 'Preview URL',
1136 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1137 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1138 `description` text COMMENT '',
1139 `name` varchar(255) COMMENT 'Name of the media',
1140 `author-url` varbinary(255) COMMENT 'URL of the author of the media',
1141 `author-name` varchar(255) COMMENT 'Name of the author of the media',
1142 `author-image` varbinary(255) COMMENT 'Image of the author of the media',
1143 `publisher-url` varbinary(255) COMMENT 'URL of the publisher of the media',
1144 `publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
1145 `publisher-image` varbinary(255) COMMENT 'Image of the publisher of the media',
1147 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1148 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1149 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1154 CREATE TABLE IF NOT EXISTS `post-tag` (
1155 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1156 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1157 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1158 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1159 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1160 INDEX `tid` (`tid`),
1161 INDEX `cid` (`cid`),
1162 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1163 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1164 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1165 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1168 -- TABLE post-thread
1170 CREATE TABLE IF NOT EXISTS `post-thread` (
1171 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1172 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1173 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1174 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1175 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1176 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1177 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1178 `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',
1179 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1180 PRIMARY KEY(`uri-id`),
1181 INDEX `owner-id` (`owner-id`),
1182 INDEX `author-id` (`author-id`),
1183 INDEX `causer-id` (`causer-id`),
1184 INDEX `received` (`received`),
1185 INDEX `commented` (`commented`),
1186 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1187 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1188 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1189 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1190 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1195 CREATE TABLE IF NOT EXISTS `post-user` (
1196 `id` int unsigned NOT NULL auto_increment,
1197 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1198 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1199 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1200 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1201 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1202 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1203 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1204 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1205 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1206 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1207 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1208 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1209 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1210 `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
1211 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1212 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1213 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1214 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1215 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1216 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1217 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1218 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1219 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1220 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1221 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1222 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1223 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1224 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1225 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1227 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1228 INDEX `uri-id` (`uri-id`),
1229 INDEX `parent-uri-id` (`parent-uri-id`),
1230 INDEX `thr-parent-id` (`thr-parent-id`),
1231 INDEX `external-id` (`external-id`),
1232 INDEX `owner-id` (`owner-id`),
1233 INDEX `author-id` (`author-id`),
1234 INDEX `causer-id` (`causer-id`),
1235 INDEX `vid` (`vid`),
1236 INDEX `contact-id` (`contact-id`),
1237 INDEX `event-id` (`event-id`),
1238 INDEX `psid` (`psid`),
1239 INDEX `author-id_uid` (`author-id`,`uid`),
1240 INDEX `author-id_received` (`author-id`,`received`),
1241 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1242 INDEX `uid_contactid` (`uid`,`contact-id`),
1243 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1244 INDEX `uid_unseen` (`uid`,`unseen`),
1245 INDEX `uid_hidden_uri-id` (`uid`,`hidden`,`uri-id`),
1246 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1247 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1248 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1249 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1250 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1251 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1252 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1253 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1254 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1255 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1256 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1257 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1258 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1261 -- TABLE post-thread-user
1263 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1264 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1265 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1266 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1267 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1268 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1269 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1270 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1271 `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',
1272 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1273 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1274 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'The thread is pinned on the profile page',
1275 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1276 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1277 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1278 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1279 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1280 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Deprecated',
1281 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1282 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1283 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1284 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1285 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1286 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1287 PRIMARY KEY(`uid`,`uri-id`),
1288 INDEX `uri-id` (`uri-id`),
1289 INDEX `owner-id` (`owner-id`),
1290 INDEX `author-id` (`author-id`),
1291 INDEX `causer-id` (`causer-id`),
1292 INDEX `uid` (`uid`),
1293 INDEX `contact-id` (`contact-id`),
1294 INDEX `psid` (`psid`),
1295 INDEX `post-user-id` (`post-user-id`),
1296 INDEX `commented` (`commented`),
1297 INDEX `uid_received` (`uid`,`received`),
1298 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1299 INDEX `uid_pinned` (`uid`,`pinned`),
1300 INDEX `uid_commented` (`uid`,`commented`),
1301 INDEX `uid_starred` (`uid`,`starred`),
1302 INDEX `uid_mention` (`uid`,`mention`),
1303 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1304 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1305 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1306 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1307 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1308 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1309 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1310 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1311 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1314 -- TABLE post-user-notification
1316 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1317 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1318 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1319 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1320 PRIMARY KEY(`uid`,`uri-id`),
1321 INDEX `uri-id` (`uri-id`),
1322 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1323 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1324 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1329 CREATE TABLE IF NOT EXISTS `process` (
1330 `pid` int unsigned NOT NULL COMMENT 'The ID of the process',
1331 `hostname` varchar(32) NOT NULL COMMENT 'The name of the host the process is ran on',
1332 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1333 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1334 PRIMARY KEY(`pid`,`hostname`),
1335 INDEX `command` (`command`)
1336 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1341 CREATE TABLE IF NOT EXISTS `profile` (
1342 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1343 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1344 `profile-name` varchar(255) COMMENT 'Deprecated',
1345 `is-default` boolean COMMENT 'Deprecated',
1346 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1347 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1348 `pdesc` varchar(255) COMMENT 'Deprecated',
1349 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1350 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1351 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1352 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1353 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1354 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1355 `hometown` varchar(255) COMMENT 'Deprecated',
1356 `gender` varchar(32) COMMENT 'Deprecated',
1357 `marital` varchar(255) COMMENT 'Deprecated',
1358 `with` text COMMENT 'Deprecated',
1359 `howlong` datetime COMMENT 'Deprecated',
1360 `sexual` varchar(255) COMMENT 'Deprecated',
1361 `politic` varchar(255) COMMENT 'Deprecated',
1362 `religion` varchar(255) COMMENT 'Deprecated',
1363 `pub_keywords` text COMMENT '',
1364 `prv_keywords` text COMMENT '',
1365 `likes` text COMMENT 'Deprecated',
1366 `dislikes` text COMMENT 'Deprecated',
1367 `about` text COMMENT 'Profile description',
1368 `summary` varchar(255) COMMENT 'Deprecated',
1369 `music` text COMMENT 'Deprecated',
1370 `book` text COMMENT 'Deprecated',
1371 `tv` text COMMENT 'Deprecated',
1372 `film` text COMMENT 'Deprecated',
1373 `interest` text COMMENT 'Deprecated',
1374 `romance` text COMMENT 'Deprecated',
1375 `work` text COMMENT 'Deprecated',
1376 `education` text COMMENT 'Deprecated',
1377 `contact` text COMMENT 'Deprecated',
1378 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1379 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
1380 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
1381 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1382 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1383 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1384 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1386 INDEX `uid_is-default` (`uid`,`is-default`),
1387 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1388 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1389 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1392 -- TABLE profile_field
1394 CREATE TABLE IF NOT EXISTS `profile_field` (
1395 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1396 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1397 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1398 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1399 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1400 `value` text COMMENT 'Value of the field',
1401 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1402 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1404 INDEX `uid` (`uid`),
1405 INDEX `order` (`order`),
1406 INDEX `psid` (`psid`),
1407 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1408 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1409 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1412 -- TABLE push_subscriber
1414 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1415 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1416 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1417 `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1418 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1419 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1420 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1421 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1422 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1423 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1424 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1426 INDEX `next_try` (`next_try`),
1427 INDEX `uid` (`uid`),
1428 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1429 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1434 CREATE TABLE IF NOT EXISTS `register` (
1435 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1436 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1437 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1438 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1439 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1440 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1441 `note` text COMMENT '',
1443 INDEX `uid` (`uid`),
1444 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1445 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1450 CREATE TABLE IF NOT EXISTS `search` (
1451 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1452 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1453 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1455 INDEX `uid_term` (`uid`,`term`(64)),
1456 INDEX `term` (`term`(64)),
1457 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1458 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1463 CREATE TABLE IF NOT EXISTS `session` (
1464 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1465 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1466 `data` text COMMENT '',
1467 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1469 INDEX `sid` (`sid`(64)),
1470 INDEX `expire` (`expire`)
1471 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1476 CREATE TABLE IF NOT EXISTS `storage` (
1477 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1478 `data` longblob NOT NULL COMMENT 'file data',
1480 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1483 -- TABLE subscription
1485 CREATE TABLE IF NOT EXISTS `subscription` (
1486 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1487 `application-id` int unsigned NOT NULL COMMENT '',
1488 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
1489 `endpoint` varchar(511) COMMENT 'Endpoint URL',
1490 `pubkey` varchar(127) COMMENT 'User agent public key',
1491 `secret` varchar(32) COMMENT 'Auth secret',
1492 `follow` boolean COMMENT '',
1493 `favourite` boolean COMMENT '',
1494 `reblog` boolean COMMENT '',
1495 `mention` boolean COMMENT '',
1496 `poll` boolean COMMENT '',
1497 `follow_request` boolean COMMENT '',
1498 `status` boolean COMMENT '',
1500 UNIQUE INDEX `application-id_uid` (`application-id`,`uid`),
1501 INDEX `uid_application-id` (`uid`,`application-id`),
1502 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1503 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1504 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Push Subscription for the API';
1509 CREATE TABLE IF NOT EXISTS `userd` (
1510 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1511 `username` varchar(255) NOT NULL COMMENT '',
1513 INDEX `username` (`username`(32))
1514 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1517 -- TABLE user-contact
1519 CREATE TABLE IF NOT EXISTS `user-contact` (
1520 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1521 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1522 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
1523 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1524 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1525 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1526 `hidden` boolean COMMENT 'This contact is hidden from the others',
1527 `pending` boolean COMMENT '',
1528 `rel` tinyint unsigned COMMENT 'The kind of the relation between the user and the contact',
1529 `info` mediumtext COMMENT '',
1530 `notify_new_posts` boolean COMMENT '',
1531 `remote_self` boolean COMMENT '',
1532 `fetch_further_information` tinyint unsigned COMMENT '',
1533 `ffi_keyword_denylist` text COMMENT '',
1534 `subhub` boolean COMMENT '',
1535 `hub-verify` varchar(255) COMMENT '',
1536 `protocol` char(4) COMMENT 'Protocol of the contact',
1537 `rating` tinyint COMMENT 'Automatically detected feed poll frequency',
1538 `priority` tinyint unsigned COMMENT 'Feed poll priority',
1539 PRIMARY KEY(`uid`,`cid`),
1540 INDEX `cid` (`cid`),
1541 UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
1542 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1543 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1544 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1545 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1550 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1551 `key` int NOT NULL COMMENT '',
1552 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1554 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1557 -- VIEW application-view
1559 DROP VIEW IF EXISTS `application-view`;
1560 CREATE VIEW `application-view` AS SELECT
1561 `application`.`id` AS `id`,
1562 `application-token`.`uid` AS `uid`,
1563 `application`.`name` AS `name`,
1564 `application`.`redirect_uri` AS `redirect_uri`,
1565 `application`.`website` AS `website`,
1566 `application`.`client_id` AS `client_id`,
1567 `application`.`client_secret` AS `client_secret`,
1568 `application-token`.`code` AS `code`,
1569 `application-token`.`access_token` AS `access_token`,
1570 `application-token`.`created_at` AS `created_at`,
1571 `application-token`.`scopes` AS `scopes`,
1572 `application-token`.`read` AS `read`,
1573 `application-token`.`write` AS `write`,
1574 `application-token`.`follow` AS `follow`,
1575 `application-token`.`push` AS `push`
1576 FROM `application-token`
1577 INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`;
1580 -- VIEW post-user-view
1582 DROP VIEW IF EXISTS `post-user-view`;
1583 CREATE VIEW `post-user-view` AS SELECT
1584 `post-user`.`id` AS `id`,
1585 `post-user`.`id` AS `post-user-id`,
1586 `post-user`.`uid` AS `uid`,
1587 `parent-post`.`id` AS `parent`,
1588 `item-uri`.`uri` AS `uri`,
1589 `post-user`.`uri-id` AS `uri-id`,
1590 `parent-item-uri`.`uri` AS `parent-uri`,
1591 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1592 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1593 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1594 `item-uri`.`guid` AS `guid`,
1595 `post-user`.`wall` AS `wall`,
1596 `post-user`.`gravity` AS `gravity`,
1597 `external-item-uri`.`uri` AS `extid`,
1598 `post-user`.`external-id` AS `external-id`,
1599 `post-user`.`created` AS `created`,
1600 `post-user`.`edited` AS `edited`,
1601 `post-thread-user`.`commented` AS `commented`,
1602 `post-user`.`received` AS `received`,
1603 `post-thread-user`.`changed` AS `changed`,
1604 `post-user`.`post-type` AS `post-type`,
1605 `post-user`.`post-reason` AS `post-reason`,
1606 `post-user`.`private` AS `private`,
1607 `post-thread-user`.`pubmail` AS `pubmail`,
1608 `post-user`.`visible` AS `visible`,
1609 `post-thread-user`.`starred` AS `starred`,
1610 `post-thread-user`.`pinned` AS `pinned`,
1611 `post-user`.`unseen` AS `unseen`,
1612 `post-user`.`deleted` AS `deleted`,
1613 `post-user`.`origin` AS `origin`,
1614 `post-thread-user`.`origin` AS `parent-origin`,
1615 `post-thread-user`.`mention` AS `mention`,
1616 `post-user`.`global` AS `global`,
1617 `post-user`.`network` AS `network`,
1618 `post-user`.`vid` AS `vid`,
1619 `post-user`.`psid` AS `psid`,
1620 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1621 `post-content`.`title` AS `title`,
1622 `post-content`.`content-warning` AS `content-warning`,
1623 `post-content`.`raw-body` AS `raw-body`,
1624 IFNULL (`post-content`.`body`, '') AS `body`,
1625 `post-content`.`rendered-hash` AS `rendered-hash`,
1626 `post-content`.`rendered-html` AS `rendered-html`,
1627 `post-content`.`language` AS `language`,
1628 `post-content`.`plink` AS `plink`,
1629 `post-content`.`location` AS `location`,
1630 `post-content`.`coord` AS `coord`,
1631 `post-content`.`app` AS `app`,
1632 `post-content`.`object-type` AS `object-type`,
1633 `post-content`.`object` AS `object`,
1634 `post-content`.`target-type` AS `target-type`,
1635 `post-content`.`target` AS `target`,
1636 `post-content`.`resource-id` AS `resource-id`,
1637 `post-user`.`contact-id` AS `contact-id`,
1638 `contact`.`url` AS `contact-link`,
1639 `contact`.`addr` AS `contact-addr`,
1640 `contact`.`name` AS `contact-name`,
1641 `contact`.`nick` AS `contact-nick`,
1642 `contact`.`thumb` AS `contact-avatar`,
1643 `contact`.`network` AS `contact-network`,
1644 `contact`.`blocked` AS `contact-blocked`,
1645 `contact`.`hidden` AS `contact-hidden`,
1646 `contact`.`readonly` AS `contact-readonly`,
1647 `contact`.`archive` AS `contact-archive`,
1648 `contact`.`pending` AS `contact-pending`,
1649 `contact`.`rel` AS `contact-rel`,
1650 `contact`.`uid` AS `contact-uid`,
1651 `contact`.`contact-type` AS `contact-contact-type`,
1652 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1653 `contact`.`self` AS `self`,
1654 `contact`.`id` AS `cid`,
1655 `contact`.`alias` AS `alias`,
1656 `contact`.`photo` AS `photo`,
1657 `contact`.`name-date` AS `name-date`,
1658 `contact`.`uri-date` AS `uri-date`,
1659 `contact`.`avatar-date` AS `avatar-date`,
1660 `contact`.`thumb` AS `thumb`,
1661 `post-user`.`author-id` AS `author-id`,
1662 `author`.`url` AS `author-link`,
1663 `author`.`addr` AS `author-addr`,
1664 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1665 `author`.`nick` AS `author-nick`,
1666 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1667 `author`.`network` AS `author-network`,
1668 `author`.`blocked` AS `author-blocked`,
1669 `author`.`hidden` AS `author-hidden`,
1670 `post-user`.`owner-id` AS `owner-id`,
1671 `owner`.`url` AS `owner-link`,
1672 `owner`.`addr` AS `owner-addr`,
1673 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1674 `owner`.`nick` AS `owner-nick`,
1675 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1676 `owner`.`network` AS `owner-network`,
1677 `owner`.`blocked` AS `owner-blocked`,
1678 `owner`.`hidden` AS `owner-hidden`,
1679 `owner`.`contact-type` AS `owner-contact-type`,
1680 `post-user`.`causer-id` AS `causer-id`,
1681 `causer`.`url` AS `causer-link`,
1682 `causer`.`addr` AS `causer-addr`,
1683 `causer`.`name` AS `causer-name`,
1684 `causer`.`nick` AS `causer-nick`,
1685 `causer`.`thumb` AS `causer-avatar`,
1686 `causer`.`network` AS `causer-network`,
1687 `causer`.`blocked` AS `causer-blocked`,
1688 `causer`.`hidden` AS `causer-hidden`,
1689 `causer`.`contact-type` AS `causer-contact-type`,
1690 `post-delivery-data`.`postopts` AS `postopts`,
1691 `post-delivery-data`.`inform` AS `inform`,
1692 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1693 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1694 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1695 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1696 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1697 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1698 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1699 `post-user`.`event-id` AS `event-id`,
1700 `event`.`created` AS `event-created`,
1701 `event`.`edited` AS `event-edited`,
1702 `event`.`start` AS `event-start`,
1703 `event`.`finish` AS `event-finish`,
1704 `event`.`summary` AS `event-summary`,
1705 `event`.`desc` AS `event-desc`,
1706 `event`.`location` AS `event-location`,
1707 `event`.`type` AS `event-type`,
1708 `event`.`nofinish` AS `event-nofinish`,
1709 `event`.`ignore` AS `event-ignore`,
1710 `diaspora-interaction`.`interaction` AS `signed_text`,
1711 `parent-item-uri`.`guid` AS `parent-guid`,
1712 `parent-post`.`network` AS `parent-network`,
1713 `parent-post`.`author-id` AS `parent-author-id`,
1714 `parent-post-author`.`url` AS `parent-author-link`,
1715 `parent-post-author`.`name` AS `parent-author-name`,
1716 `parent-post-author`.`nick` AS `parent-author-nick`,
1717 `parent-post-author`.`network` AS `parent-author-network`,
1718 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1719 `parent-post-author`.`hidden` AS `parent-author-hidden`
1721 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
1722 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
1723 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
1724 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
1725 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
1726 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
1727 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1728 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1729 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1730 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1731 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1732 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
1733 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
1734 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
1735 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
1736 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
1737 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1740 -- VIEW post-thread-user-view
1742 DROP VIEW IF EXISTS `post-thread-user-view`;
1743 CREATE VIEW `post-thread-user-view` AS SELECT
1744 `post-user`.`id` AS `id`,
1745 `post-user`.`id` AS `post-user-id`,
1746 `post-thread-user`.`uid` AS `uid`,
1747 `parent-post`.`id` AS `parent`,
1748 `item-uri`.`uri` AS `uri`,
1749 `post-thread-user`.`uri-id` AS `uri-id`,
1750 `parent-item-uri`.`uri` AS `parent-uri`,
1751 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1752 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1753 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1754 `item-uri`.`guid` AS `guid`,
1755 `post-thread-user`.`wall` AS `wall`,
1756 `post-user`.`gravity` AS `gravity`,
1757 `external-item-uri`.`uri` AS `extid`,
1758 `post-user`.`external-id` AS `external-id`,
1759 `post-thread-user`.`created` AS `created`,
1760 `post-user`.`edited` AS `edited`,
1761 `post-thread-user`.`commented` AS `commented`,
1762 `post-thread-user`.`received` AS `received`,
1763 `post-thread-user`.`changed` AS `changed`,
1764 `post-user`.`post-type` AS `post-type`,
1765 `post-user`.`post-reason` AS `post-reason`,
1766 `post-user`.`private` AS `private`,
1767 `post-thread-user`.`pubmail` AS `pubmail`,
1768 `post-thread-user`.`ignored` AS `ignored`,
1769 `post-user`.`visible` AS `visible`,
1770 `post-thread-user`.`starred` AS `starred`,
1771 `post-thread-user`.`pinned` AS `pinned`,
1772 `post-thread-user`.`unseen` AS `unseen`,
1773 `post-user`.`deleted` AS `deleted`,
1774 `post-thread-user`.`origin` AS `origin`,
1775 `post-thread-user`.`mention` AS `mention`,
1776 `post-user`.`global` AS `global`,
1777 `post-thread-user`.`network` AS `network`,
1778 `post-user`.`vid` AS `vid`,
1779 `post-thread-user`.`psid` AS `psid`,
1780 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1781 `post-content`.`title` AS `title`,
1782 `post-content`.`content-warning` AS `content-warning`,
1783 `post-content`.`raw-body` AS `raw-body`,
1784 `post-content`.`body` AS `body`,
1785 `post-content`.`rendered-hash` AS `rendered-hash`,
1786 `post-content`.`rendered-html` AS `rendered-html`,
1787 `post-content`.`language` AS `language`,
1788 `post-content`.`plink` AS `plink`,
1789 `post-content`.`location` AS `location`,
1790 `post-content`.`coord` AS `coord`,
1791 `post-content`.`app` AS `app`,
1792 `post-content`.`object-type` AS `object-type`,
1793 `post-content`.`object` AS `object`,
1794 `post-content`.`target-type` AS `target-type`,
1795 `post-content`.`target` AS `target`,
1796 `post-content`.`resource-id` AS `resource-id`,
1797 `post-thread-user`.`contact-id` AS `contact-id`,
1798 `contact`.`url` AS `contact-link`,
1799 `contact`.`addr` AS `contact-addr`,
1800 `contact`.`name` AS `contact-name`,
1801 `contact`.`nick` AS `contact-nick`,
1802 `contact`.`thumb` AS `contact-avatar`,
1803 `contact`.`network` AS `contact-network`,
1804 `contact`.`blocked` AS `contact-blocked`,
1805 `contact`.`hidden` AS `contact-hidden`,
1806 `contact`.`readonly` AS `contact-readonly`,
1807 `contact`.`archive` AS `contact-archive`,
1808 `contact`.`pending` AS `contact-pending`,
1809 `contact`.`rel` AS `contact-rel`,
1810 `contact`.`uid` AS `contact-uid`,
1811 `contact`.`contact-type` AS `contact-contact-type`,
1812 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1813 `contact`.`self` AS `self`,
1814 `contact`.`id` AS `cid`,
1815 `contact`.`alias` AS `alias`,
1816 `contact`.`photo` AS `photo`,
1817 `contact`.`name-date` AS `name-date`,
1818 `contact`.`uri-date` AS `uri-date`,
1819 `contact`.`avatar-date` AS `avatar-date`,
1820 `contact`.`thumb` AS `thumb`,
1821 `post-thread-user`.`author-id` AS `author-id`,
1822 `author`.`url` AS `author-link`,
1823 `author`.`addr` AS `author-addr`,
1824 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1825 `author`.`nick` AS `author-nick`,
1826 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1827 `author`.`network` AS `author-network`,
1828 `author`.`blocked` AS `author-blocked`,
1829 `author`.`hidden` AS `author-hidden`,
1830 `post-thread-user`.`owner-id` AS `owner-id`,
1831 `owner`.`url` AS `owner-link`,
1832 `owner`.`addr` AS `owner-addr`,
1833 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1834 `owner`.`nick` AS `owner-nick`,
1835 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1836 `owner`.`network` AS `owner-network`,
1837 `owner`.`blocked` AS `owner-blocked`,
1838 `owner`.`hidden` AS `owner-hidden`,
1839 `owner`.`contact-type` AS `owner-contact-type`,
1840 `post-thread-user`.`causer-id` AS `causer-id`,
1841 `causer`.`url` AS `causer-link`,
1842 `causer`.`addr` AS `causer-addr`,
1843 `causer`.`name` AS `causer-name`,
1844 `causer`.`nick` AS `causer-nick`,
1845 `causer`.`thumb` AS `causer-avatar`,
1846 `causer`.`network` AS `causer-network`,
1847 `causer`.`blocked` AS `causer-blocked`,
1848 `causer`.`hidden` AS `causer-hidden`,
1849 `causer`.`contact-type` AS `causer-contact-type`,
1850 `post-delivery-data`.`postopts` AS `postopts`,
1851 `post-delivery-data`.`inform` AS `inform`,
1852 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1853 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1854 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1855 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1856 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1857 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1858 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1859 `post-user`.`event-id` AS `event-id`,
1860 `event`.`created` AS `event-created`,
1861 `event`.`edited` AS `event-edited`,
1862 `event`.`start` AS `event-start`,
1863 `event`.`finish` AS `event-finish`,
1864 `event`.`summary` AS `event-summary`,
1865 `event`.`desc` AS `event-desc`,
1866 `event`.`location` AS `event-location`,
1867 `event`.`type` AS `event-type`,
1868 `event`.`nofinish` AS `event-nofinish`,
1869 `event`.`ignore` AS `event-ignore`,
1870 `diaspora-interaction`.`interaction` AS `signed_text`,
1871 `parent-item-uri`.`guid` AS `parent-guid`,
1872 `parent-post`.`network` AS `parent-network`,
1873 `parent-post`.`author-id` AS `parent-author-id`,
1874 `parent-post-author`.`url` AS `parent-author-link`,
1875 `parent-post-author`.`name` AS `parent-author-name`,
1876 `parent-post-author`.`network` AS `parent-author-network`,
1877 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1878 `parent-post-author`.`hidden` AS `parent-author-hidden`
1879 FROM `post-thread-user`
1880 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
1881 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
1882 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
1883 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
1884 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
1885 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
1886 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1887 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1888 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1889 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1890 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1891 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
1892 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
1893 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
1894 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
1895 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`
1896 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1901 DROP VIEW IF EXISTS `post-view`;
1902 CREATE VIEW `post-view` AS SELECT
1903 `item-uri`.`uri` AS `uri`,
1904 `post`.`uri-id` AS `uri-id`,
1905 `parent-item-uri`.`uri` AS `parent-uri`,
1906 `post`.`parent-uri-id` AS `parent-uri-id`,
1907 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1908 `post`.`thr-parent-id` AS `thr-parent-id`,
1909 `item-uri`.`guid` AS `guid`,
1910 `post`.`gravity` AS `gravity`,
1911 `external-item-uri`.`uri` AS `extid`,
1912 `post`.`external-id` AS `external-id`,
1913 `post`.`created` AS `created`,
1914 `post`.`edited` AS `edited`,
1915 `post-thread`.`commented` AS `commented`,
1916 `post`.`received` AS `received`,
1917 `post-thread`.`changed` AS `changed`,
1918 `post`.`post-type` AS `post-type`,
1919 `post`.`private` AS `private`,
1920 `post`.`visible` AS `visible`,
1921 `post`.`deleted` AS `deleted`,
1922 `post`.`global` AS `global`,
1923 `post`.`network` AS `network`,
1924 `post`.`vid` AS `vid`,
1925 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1926 `post-content`.`title` AS `title`,
1927 `post-content`.`content-warning` AS `content-warning`,
1928 `post-content`.`raw-body` AS `raw-body`,
1929 `post-content`.`body` AS `body`,
1930 `post-content`.`rendered-hash` AS `rendered-hash`,
1931 `post-content`.`rendered-html` AS `rendered-html`,
1932 `post-content`.`language` AS `language`,
1933 `post-content`.`plink` AS `plink`,
1934 `post-content`.`location` AS `location`,
1935 `post-content`.`coord` AS `coord`,
1936 `post-content`.`app` AS `app`,
1937 `post-content`.`object-type` AS `object-type`,
1938 `post-content`.`object` AS `object`,
1939 `post-content`.`target-type` AS `target-type`,
1940 `post-content`.`target` AS `target`,
1941 `post-content`.`resource-id` AS `resource-id`,
1942 `post`.`author-id` AS `contact-id`,
1943 `author`.`url` AS `contact-link`,
1944 `author`.`addr` AS `contact-addr`,
1945 `author`.`name` AS `contact-name`,
1946 `author`.`nick` AS `contact-nick`,
1947 `author`.`thumb` AS `contact-avatar`,
1948 `author`.`network` AS `contact-network`,
1949 `author`.`blocked` AS `contact-blocked`,
1950 `author`.`hidden` AS `contact-hidden`,
1951 `author`.`readonly` AS `contact-readonly`,
1952 `author`.`archive` AS `contact-archive`,
1953 `author`.`pending` AS `contact-pending`,
1954 `author`.`rel` AS `contact-rel`,
1955 `author`.`uid` AS `contact-uid`,
1956 `author`.`contact-type` AS `contact-contact-type`,
1957 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
1959 `author`.`id` AS `cid`,
1960 `author`.`alias` AS `alias`,
1961 `author`.`photo` AS `photo`,
1962 `author`.`name-date` AS `name-date`,
1963 `author`.`uri-date` AS `uri-date`,
1964 `author`.`avatar-date` AS `avatar-date`,
1965 `author`.`thumb` AS `thumb`,
1966 `post`.`author-id` AS `author-id`,
1967 `author`.`url` AS `author-link`,
1968 `author`.`addr` AS `author-addr`,
1969 `author`.`name` AS `author-name`,
1970 `author`.`nick` AS `author-nick`,
1971 `author`.`thumb` AS `author-avatar`,
1972 `author`.`network` AS `author-network`,
1973 `author`.`blocked` AS `author-blocked`,
1974 `author`.`hidden` AS `author-hidden`,
1975 `post`.`owner-id` AS `owner-id`,
1976 `owner`.`url` AS `owner-link`,
1977 `owner`.`addr` AS `owner-addr`,
1978 `owner`.`name` AS `owner-name`,
1979 `owner`.`nick` AS `owner-nick`,
1980 `owner`.`thumb` AS `owner-avatar`,
1981 `owner`.`network` AS `owner-network`,
1982 `owner`.`blocked` AS `owner-blocked`,
1983 `owner`.`hidden` AS `owner-hidden`,
1984 `owner`.`contact-type` AS `owner-contact-type`,
1985 `post`.`causer-id` AS `causer-id`,
1986 `causer`.`url` AS `causer-link`,
1987 `causer`.`addr` AS `causer-addr`,
1988 `causer`.`name` AS `causer-name`,
1989 `causer`.`nick` AS `causer-nick`,
1990 `causer`.`thumb` AS `causer-avatar`,
1991 `causer`.`network` AS `causer-network`,
1992 `causer`.`blocked` AS `causer-blocked`,
1993 `causer`.`hidden` AS `causer-hidden`,
1994 `causer`.`contact-type` AS `causer-contact-type`,
1995 `diaspora-interaction`.`interaction` AS `signed_text`,
1996 `parent-item-uri`.`guid` AS `parent-guid`,
1997 `parent-post`.`network` AS `parent-network`,
1998 `parent-post`.`author-id` AS `parent-author-id`,
1999 `parent-post-author`.`url` AS `parent-author-link`,
2000 `parent-post-author`.`name` AS `parent-author-name`,
2001 `parent-post-author`.`network` AS `parent-author-network`,
2002 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2003 `parent-post-author`.`hidden` AS `parent-author-hidden`
2005 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
2006 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
2007 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
2008 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
2009 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
2010 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2011 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2012 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2013 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2014 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
2015 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
2016 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2017 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2020 -- VIEW post-thread-view
2022 DROP VIEW IF EXISTS `post-thread-view`;
2023 CREATE VIEW `post-thread-view` AS SELECT
2024 `item-uri`.`uri` AS `uri`,
2025 `post-thread`.`uri-id` AS `uri-id`,
2026 `parent-item-uri`.`uri` AS `parent-uri`,
2027 `post`.`parent-uri-id` AS `parent-uri-id`,
2028 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2029 `post`.`thr-parent-id` AS `thr-parent-id`,
2030 `item-uri`.`guid` AS `guid`,
2031 `post`.`gravity` AS `gravity`,
2032 `external-item-uri`.`uri` AS `extid`,
2033 `post`.`external-id` AS `external-id`,
2034 `post-thread`.`created` AS `created`,
2035 `post`.`edited` AS `edited`,
2036 `post-thread`.`commented` AS `commented`,
2037 `post-thread`.`received` AS `received`,
2038 `post-thread`.`changed` AS `changed`,
2039 `post`.`post-type` AS `post-type`,
2040 `post`.`private` AS `private`,
2041 `post`.`visible` AS `visible`,
2042 `post`.`deleted` AS `deleted`,
2043 `post`.`global` AS `global`,
2044 `post-thread`.`network` AS `network`,
2045 `post`.`vid` AS `vid`,
2046 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2047 `post-content`.`title` AS `title`,
2048 `post-content`.`content-warning` AS `content-warning`,
2049 `post-content`.`raw-body` AS `raw-body`,
2050 `post-content`.`body` AS `body`,
2051 `post-content`.`rendered-hash` AS `rendered-hash`,
2052 `post-content`.`rendered-html` AS `rendered-html`,
2053 `post-content`.`language` AS `language`,
2054 `post-content`.`plink` AS `plink`,
2055 `post-content`.`location` AS `location`,
2056 `post-content`.`coord` AS `coord`,
2057 `post-content`.`app` AS `app`,
2058 `post-content`.`object-type` AS `object-type`,
2059 `post-content`.`object` AS `object`,
2060 `post-content`.`target-type` AS `target-type`,
2061 `post-content`.`target` AS `target`,
2062 `post-content`.`resource-id` AS `resource-id`,
2063 `post-thread`.`author-id` AS `contact-id`,
2064 `author`.`url` AS `contact-link`,
2065 `author`.`addr` AS `contact-addr`,
2066 `author`.`name` AS `contact-name`,
2067 `author`.`nick` AS `contact-nick`,
2068 `author`.`thumb` AS `contact-avatar`,
2069 `author`.`network` AS `contact-network`,
2070 `author`.`blocked` AS `contact-blocked`,
2071 `author`.`hidden` AS `contact-hidden`,
2072 `author`.`readonly` AS `contact-readonly`,
2073 `author`.`archive` AS `contact-archive`,
2074 `author`.`pending` AS `contact-pending`,
2075 `author`.`rel` AS `contact-rel`,
2076 `author`.`uid` AS `contact-uid`,
2077 `author`.`contact-type` AS `contact-contact-type`,
2078 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2080 `author`.`id` AS `cid`,
2081 `author`.`alias` AS `alias`,
2082 `author`.`photo` AS `photo`,
2083 `author`.`name-date` AS `name-date`,
2084 `author`.`uri-date` AS `uri-date`,
2085 `author`.`avatar-date` AS `avatar-date`,
2086 `author`.`thumb` AS `thumb`,
2087 `post-thread`.`author-id` AS `author-id`,
2088 `author`.`url` AS `author-link`,
2089 `author`.`addr` AS `author-addr`,
2090 `author`.`name` AS `author-name`,
2091 `author`.`nick` AS `author-nick`,
2092 `author`.`thumb` AS `author-avatar`,
2093 `author`.`network` AS `author-network`,
2094 `author`.`blocked` AS `author-blocked`,
2095 `author`.`hidden` AS `author-hidden`,
2096 `post-thread`.`owner-id` AS `owner-id`,
2097 `owner`.`url` AS `owner-link`,
2098 `owner`.`addr` AS `owner-addr`,
2099 `owner`.`name` AS `owner-name`,
2100 `owner`.`nick` AS `owner-nick`,
2101 `owner`.`thumb` AS `owner-avatar`,
2102 `owner`.`network` AS `owner-network`,
2103 `owner`.`blocked` AS `owner-blocked`,
2104 `owner`.`hidden` AS `owner-hidden`,
2105 `owner`.`contact-type` AS `owner-contact-type`,
2106 `post-thread`.`causer-id` AS `causer-id`,
2107 `causer`.`url` AS `causer-link`,
2108 `causer`.`addr` AS `causer-addr`,
2109 `causer`.`name` AS `causer-name`,
2110 `causer`.`nick` AS `causer-nick`,
2111 `causer`.`thumb` AS `causer-avatar`,
2112 `causer`.`network` AS `causer-network`,
2113 `causer`.`blocked` AS `causer-blocked`,
2114 `causer`.`hidden` AS `causer-hidden`,
2115 `causer`.`contact-type` AS `causer-contact-type`,
2116 `diaspora-interaction`.`interaction` AS `signed_text`,
2117 `parent-item-uri`.`guid` AS `parent-guid`,
2118 `parent-post`.`network` AS `parent-network`,
2119 `parent-post`.`author-id` AS `parent-author-id`,
2120 `parent-post-author`.`url` AS `parent-author-link`,
2121 `parent-post-author`.`name` AS `parent-author-name`,
2122 `parent-post-author`.`network` AS `parent-author-network`,
2123 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2124 `parent-post-author`.`hidden` AS `parent-author-hidden`
2126 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
2127 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
2128 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
2129 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
2130 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
2131 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2132 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2133 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2134 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2135 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
2136 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
2137 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2138 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2141 -- VIEW category-view
2143 DROP VIEW IF EXISTS `category-view`;
2144 CREATE VIEW `category-view` AS SELECT
2145 `post-category`.`uri-id` AS `uri-id`,
2146 `post-category`.`uid` AS `uid`,
2147 `post-category`.`type` AS `type`,
2148 `post-category`.`tid` AS `tid`,
2149 `tag`.`name` AS `name`,
2150 `tag`.`url` AS `url`
2151 FROM `post-category`
2152 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2157 DROP VIEW IF EXISTS `tag-view`;
2158 CREATE VIEW `tag-view` AS SELECT
2159 `post-tag`.`uri-id` AS `uri-id`,
2160 `post-tag`.`type` AS `type`,
2161 `post-tag`.`tid` AS `tid`,
2162 `post-tag`.`cid` AS `cid`,
2163 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2164 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
2166 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2167 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2170 -- VIEW network-item-view
2172 DROP VIEW IF EXISTS `network-item-view`;
2173 CREATE VIEW `network-item-view` AS SELECT
2174 `post-user`.`uri-id` AS `uri-id`,
2175 `parent-post`.`id` AS `parent`,
2176 `post-user`.`received` AS `received`,
2177 `post-thread-user`.`commented` AS `commented`,
2178 `post-user`.`created` AS `created`,
2179 `post-user`.`uid` AS `uid`,
2180 `post-thread-user`.`starred` AS `starred`,
2181 `post-thread-user`.`mention` AS `mention`,
2182 `post-user`.`network` AS `network`,
2183 `post-user`.`unseen` AS `unseen`,
2184 `post-user`.`gravity` AS `gravity`,
2185 `post-user`.`contact-id` AS `contact-id`,
2186 `ownercontact`.`contact-type` AS `contact-type`
2188 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2189 INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2190 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2191 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2192 INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2193 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2194 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2195 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2196 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
2197 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2198 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2201 -- VIEW network-thread-view
2203 DROP VIEW IF EXISTS `network-thread-view`;
2204 CREATE VIEW `network-thread-view` AS SELECT
2205 `post-thread-user`.`uri-id` AS `uri-id`,
2206 `parent-post`.`id` AS `parent`,
2207 `post-thread-user`.`received` AS `received`,
2208 `post-thread-user`.`commented` AS `commented`,
2209 `post-thread-user`.`created` AS `created`,
2210 `post-thread-user`.`uid` AS `uid`,
2211 `post-thread-user`.`starred` AS `starred`,
2212 `post-thread-user`.`mention` AS `mention`,
2213 `post-thread-user`.`network` AS `network`,
2214 `post-thread-user`.`contact-id` AS `contact-id`,
2215 `ownercontact`.`contact-type` AS `contact-type`
2216 FROM `post-thread-user`
2217 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2218 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2219 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2220 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2221 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2222 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2223 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2224 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2225 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2226 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2227 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2232 DROP VIEW IF EXISTS `owner-view`;
2233 CREATE VIEW `owner-view` AS SELECT
2234 `contact`.`id` AS `id`,
2235 `contact`.`uid` AS `uid`,
2236 `contact`.`created` AS `created`,
2237 `contact`.`updated` AS `updated`,
2238 `contact`.`self` AS `self`,
2239 `contact`.`remote_self` AS `remote_self`,
2240 `contact`.`rel` AS `rel`,
2241 `contact`.`network` AS `network`,
2242 `contact`.`protocol` AS `protocol`,
2243 `contact`.`name` AS `name`,
2244 `contact`.`nick` AS `nick`,
2245 `contact`.`location` AS `location`,
2246 `contact`.`about` AS `about`,
2247 `contact`.`keywords` AS `keywords`,
2248 `contact`.`xmpp` AS `xmpp`,
2249 `contact`.`matrix` AS `matrix`,
2250 `contact`.`attag` AS `attag`,
2251 `contact`.`avatar` AS `avatar`,
2252 `contact`.`photo` AS `photo`,
2253 `contact`.`thumb` AS `thumb`,
2254 `contact`.`micro` AS `micro`,
2255 `contact`.`header` AS `header`,
2256 `contact`.`url` AS `url`,
2257 `contact`.`nurl` AS `nurl`,
2258 `contact`.`uri-id` AS `uri-id`,
2259 `contact`.`addr` AS `addr`,
2260 `contact`.`alias` AS `alias`,
2261 `contact`.`pubkey` AS `pubkey`,
2262 `contact`.`prvkey` AS `prvkey`,
2263 `contact`.`batch` AS `batch`,
2264 `contact`.`request` AS `request`,
2265 `contact`.`notify` AS `notify`,
2266 `contact`.`poll` AS `poll`,
2267 `contact`.`confirm` AS `confirm`,
2268 `contact`.`poco` AS `poco`,
2269 `contact`.`subhub` AS `subhub`,
2270 `contact`.`hub-verify` AS `hub-verify`,
2271 `contact`.`last-update` AS `last-update`,
2272 `contact`.`success_update` AS `success_update`,
2273 `contact`.`failure_update` AS `failure_update`,
2274 `contact`.`name-date` AS `name-date`,
2275 `contact`.`uri-date` AS `uri-date`,
2276 `contact`.`avatar-date` AS `avatar-date`,
2277 `contact`.`avatar-date` AS `picdate`,
2278 `contact`.`term-date` AS `term-date`,
2279 `contact`.`last-item` AS `last-item`,
2280 `contact`.`priority` AS `priority`,
2281 `user`.`blocked` AS `blocked`,
2282 `contact`.`block_reason` AS `block_reason`,
2283 `contact`.`readonly` AS `readonly`,
2284 `contact`.`writable` AS `writable`,
2285 `contact`.`forum` AS `forum`,
2286 `contact`.`prv` AS `prv`,
2287 `contact`.`contact-type` AS `contact-type`,
2288 `contact`.`manually-approve` AS `manually-approve`,
2289 `contact`.`hidden` AS `hidden`,
2290 `contact`.`archive` AS `archive`,
2291 `contact`.`pending` AS `pending`,
2292 `contact`.`deleted` AS `deleted`,
2293 `contact`.`unsearchable` AS `unsearchable`,
2294 `contact`.`sensitive` AS `sensitive`,
2295 `contact`.`baseurl` AS `baseurl`,
2296 `contact`.`reason` AS `reason`,
2297 `contact`.`info` AS `info`,
2298 `contact`.`bdyear` AS `bdyear`,
2299 `contact`.`bd` AS `bd`,
2300 `contact`.`notify_new_posts` AS `notify_new_posts`,
2301 `contact`.`fetch_further_information` AS `fetch_further_information`,
2302 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2303 `user`.`parent-uid` AS `parent-uid`,
2304 `user`.`guid` AS `guid`,
2305 `user`.`nickname` AS `nickname`,
2306 `user`.`email` AS `email`,
2307 `user`.`openid` AS `openid`,
2308 `user`.`timezone` AS `timezone`,
2309 `user`.`language` AS `language`,
2310 `user`.`register_date` AS `register_date`,
2311 `user`.`login_date` AS `login_date`,
2312 `user`.`default-location` AS `default-location`,
2313 `user`.`allow_location` AS `allow_location`,
2314 `user`.`theme` AS `theme`,
2315 `user`.`pubkey` AS `upubkey`,
2316 `user`.`prvkey` AS `uprvkey`,
2317 `user`.`sprvkey` AS `sprvkey`,
2318 `user`.`spubkey` AS `spubkey`,
2319 `user`.`verified` AS `verified`,
2320 `user`.`blockwall` AS `blockwall`,
2321 `user`.`hidewall` AS `hidewall`,
2322 `user`.`blocktags` AS `blocktags`,
2323 `user`.`unkmail` AS `unkmail`,
2324 `user`.`cntunkmail` AS `cntunkmail`,
2325 `user`.`notify-flags` AS `notify-flags`,
2326 `user`.`page-flags` AS `page-flags`,
2327 `user`.`account-type` AS `account-type`,
2328 `user`.`prvnets` AS `prvnets`,
2329 `user`.`maxreq` AS `maxreq`,
2330 `user`.`expire` AS `expire`,
2331 `user`.`account_removed` AS `account_removed`,
2332 `user`.`account_expired` AS `account_expired`,
2333 `user`.`account_expires_on` AS `account_expires_on`,
2334 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2335 `user`.`def_gid` AS `def_gid`,
2336 `user`.`allow_cid` AS `allow_cid`,
2337 `user`.`allow_gid` AS `allow_gid`,
2338 `user`.`deny_cid` AS `deny_cid`,
2339 `user`.`deny_gid` AS `deny_gid`,
2340 `user`.`openidserver` AS `openidserver`,
2341 `profile`.`publish` AS `publish`,
2342 `profile`.`net-publish` AS `net-publish`,
2343 `profile`.`hide-friends` AS `hide-friends`,
2344 `profile`.`prv_keywords` AS `prv_keywords`,
2345 `profile`.`pub_keywords` AS `pub_keywords`,
2346 `profile`.`address` AS `address`,
2347 `profile`.`locality` AS `locality`,
2348 `profile`.`region` AS `region`,
2349 `profile`.`postal-code` AS `postal-code`,
2350 `profile`.`country-name` AS `country-name`,
2351 `profile`.`homepage` AS `homepage`,
2352 `profile`.`dob` AS `dob`
2354 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2355 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2358 -- VIEW account-view
2360 DROP VIEW IF EXISTS `account-view`;
2361 CREATE VIEW `account-view` AS SELECT
2362 `contact`.`id` AS `id`,
2363 `contact`.`url` AS `url`,
2364 `contact`.`nurl` AS `nurl`,
2365 `contact`.`uri-id` AS `uri-id`,
2366 `item-uri`.`guid` AS `guid`,
2367 `contact`.`addr` AS `addr`,
2368 `contact`.`alias` AS `alias`,
2369 `contact`.`name` AS `name`,
2370 `contact`.`nick` AS `nick`,
2371 `contact`.`about` AS `about`,
2372 `contact`.`keywords` AS `keywords`,
2373 `contact`.`xmpp` AS `xmpp`,
2374 `contact`.`matrix` AS `matrix`,
2375 `contact`.`avatar` AS `avatar`,
2376 `contact`.`photo` AS `photo`,
2377 `contact`.`thumb` AS `thumb`,
2378 `contact`.`micro` AS `micro`,
2379 `contact`.`header` AS `header`,
2380 `contact`.`created` AS `created`,
2381 `contact`.`updated` AS `updated`,
2382 `contact`.`network` AS `network`,
2383 `contact`.`protocol` AS `protocol`,
2384 `contact`.`location` AS `location`,
2385 `contact`.`attag` AS `attag`,
2386 `contact`.`pubkey` AS `pubkey`,
2387 `contact`.`prvkey` AS `prvkey`,
2388 `contact`.`subscribe` AS `subscribe`,
2389 `contact`.`last-update` AS `last-update`,
2390 `contact`.`success_update` AS `success_update`,
2391 `contact`.`failure_update` AS `failure_update`,
2392 `contact`.`failed` AS `failed`,
2393 `contact`.`last-item` AS `last-item`,
2394 `contact`.`last-discovery` AS `last-discovery`,
2395 `contact`.`contact-type` AS `contact-type`,
2396 `contact`.`manually-approve` AS `manually-approve`,
2397 `contact`.`unsearchable` AS `unsearchable`,
2398 `contact`.`sensitive` AS `sensitive`,
2399 `contact`.`baseurl` AS `baseurl`,
2400 `contact`.`gsid` AS `gsid`,
2401 `contact`.`info` AS `info`,
2402 `contact`.`bdyear` AS `bdyear`,
2403 `contact`.`bd` AS `bd`,
2404 `contact`.`poco` AS `poco`,
2405 `contact`.`name-date` AS `name-date`,
2406 `contact`.`uri-date` AS `uri-date`,
2407 `contact`.`avatar-date` AS `avatar-date`,
2408 `contact`.`term-date` AS `term-date`,
2409 `contact`.`hidden` AS `global-ignored`,
2410 `contact`.`blocked` AS `global-blocked`,
2411 `contact`.`hidden` AS `hidden`,
2412 `contact`.`archive` AS `archive`,
2413 `contact`.`deleted` AS `deleted`,
2414 `contact`.`blocked` AS `blocked`,
2415 `contact`.`request` AS `dfrn-request`,
2416 `contact`.`notify` AS `dfrn-notify`,
2417 `contact`.`poll` AS `dfrn-poll`,
2418 `contact`.`confirm` AS `dfrn-confirm`,
2419 `fcontact`.`guid` AS `diaspora-guid`,
2420 `fcontact`.`batch` AS `diaspora-batch`,
2421 `fcontact`.`notify` AS `diaspora-notify`,
2422 `fcontact`.`poll` AS `diaspora-poll`,
2423 `fcontact`.`alias` AS `diaspora-alias`,
2424 `apcontact`.`uuid` AS `ap-uuid`,
2425 `apcontact`.`type` AS `ap-type`,
2426 `apcontact`.`following` AS `ap-following`,
2427 `apcontact`.`followers` AS `ap-followers`,
2428 `apcontact`.`inbox` AS `ap-inbox`,
2429 `apcontact`.`outbox` AS `ap-outbox`,
2430 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2431 `apcontact`.`generator` AS `ap-generator`,
2432 `apcontact`.`following_count` AS `ap-following_count`,
2433 `apcontact`.`followers_count` AS `ap-followers_count`,
2434 `apcontact`.`statuses_count` AS `ap-statuses_count`
2436 LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id`
2437 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
2438 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = contact.`uri-id`
2439 WHERE `contact`.`uid` = 0;
2442 -- VIEW account-user-view
2444 DROP VIEW IF EXISTS `account-user-view`;
2445 CREATE VIEW `account-user-view` AS SELECT
2446 `ucontact`.`id` AS `id`,
2447 `contact`.`id` AS `pid`,
2448 `ucontact`.`uid` AS `uid`,
2449 `contact`.`url` AS `url`,
2450 `contact`.`nurl` AS `nurl`,
2451 `contact`.`uri-id` AS `uri-id`,
2452 `item-uri`.`guid` AS `guid`,
2453 `contact`.`addr` AS `addr`,
2454 `contact`.`alias` AS `alias`,
2455 `contact`.`name` AS `name`,
2456 `contact`.`nick` AS `nick`,
2457 `contact`.`about` AS `about`,
2458 `contact`.`keywords` AS `keywords`,
2459 `contact`.`xmpp` AS `xmpp`,
2460 `contact`.`matrix` AS `matrix`,
2461 `contact`.`avatar` AS `avatar`,
2462 `contact`.`photo` AS `photo`,
2463 `contact`.`thumb` AS `thumb`,
2464 `contact`.`micro` AS `micro`,
2465 `contact`.`header` AS `header`,
2466 `contact`.`created` AS `created`,
2467 `contact`.`updated` AS `updated`,
2468 `ucontact`.`self` AS `self`,
2469 `ucontact`.`remote_self` AS `remote_self`,
2470 `ucontact`.`rel` AS `rel`,
2471 `contact`.`network` AS `network`,
2472 `ucontact`.`protocol` AS `protocol`,
2473 `contact`.`location` AS `location`,
2474 `ucontact`.`attag` AS `attag`,
2475 `contact`.`pubkey` AS `pubkey`,
2476 `contact`.`prvkey` AS `prvkey`,
2477 `contact`.`subscribe` AS `subscribe`,
2478 `contact`.`last-update` AS `last-update`,
2479 `contact`.`success_update` AS `success_update`,
2480 `contact`.`failure_update` AS `failure_update`,
2481 `contact`.`failed` AS `failed`,
2482 `contact`.`last-item` AS `last-item`,
2483 `contact`.`last-discovery` AS `last-discovery`,
2484 `contact`.`contact-type` AS `contact-type`,
2485 `contact`.`manually-approve` AS `manually-approve`,
2486 `contact`.`unsearchable` AS `unsearchable`,
2487 `contact`.`sensitive` AS `sensitive`,
2488 `contact`.`baseurl` AS `baseurl`,
2489 `contact`.`gsid` AS `gsid`,
2490 `ucontact`.`info` AS `info`,
2491 `contact`.`bdyear` AS `bdyear`,
2492 `contact`.`bd` AS `bd`,
2493 `contact`.`poco` AS `poco`,
2494 `contact`.`name-date` AS `name-date`,
2495 `contact`.`uri-date` AS `uri-date`,
2496 `contact`.`avatar-date` AS `avatar-date`,
2497 `contact`.`term-date` AS `term-date`,
2498 `contact`.`hidden` AS `global-ignored`,
2499 `contact`.`blocked` AS `global-blocked`,
2500 `ucontact`.`hidden` AS `hidden`,
2501 `ucontact`.`archive` AS `archive`,
2502 `ucontact`.`pending` AS `pending`,
2503 `ucontact`.`deleted` AS `deleted`,
2504 `ucontact`.`notify_new_posts` AS `notify_new_posts`,
2505 `ucontact`.`fetch_further_information` AS `fetch_further_information`,
2506 `ucontact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2507 `ucontact`.`rating` AS `rating`,
2508 `ucontact`.`readonly` AS `readonly`,
2509 `ucontact`.`blocked` AS `blocked`,
2510 `ucontact`.`block_reason` AS `block_reason`,
2511 `ucontact`.`subhub` AS `subhub`,
2512 `ucontact`.`hub-verify` AS `hub-verify`,
2513 `ucontact`.`reason` AS `reason`,
2514 `contact`.`request` AS `dfrn-request`,
2515 `contact`.`notify` AS `dfrn-notify`,
2516 `contact`.`poll` AS `dfrn-poll`,
2517 `contact`.`confirm` AS `dfrn-confirm`,
2518 `fcontact`.`guid` AS `diaspora-guid`,
2519 `fcontact`.`batch` AS `diaspora-batch`,
2520 `fcontact`.`notify` AS `diaspora-notify`,
2521 `fcontact`.`poll` AS `diaspora-poll`,
2522 `fcontact`.`alias` AS `diaspora-alias`,
2523 `apcontact`.`uuid` AS `ap-uuid`,
2524 `apcontact`.`type` AS `ap-type`,
2525 `apcontact`.`following` AS `ap-following`,
2526 `apcontact`.`followers` AS `ap-followers`,
2527 `apcontact`.`inbox` AS `ap-inbox`,
2528 `apcontact`.`outbox` AS `ap-outbox`,
2529 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2530 `apcontact`.`generator` AS `ap-generator`,
2531 `apcontact`.`following_count` AS `ap-following_count`,
2532 `apcontact`.`followers_count` AS `ap-followers_count`,
2533 `apcontact`.`statuses_count` AS `ap-statuses_count`
2534 FROM `contact` AS `ucontact`
2535 INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
2536 LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id`
2537 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
2538 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = `ucontact`.`uri-id` AND `fcontact`.`network` = 'dspr';
2541 -- VIEW pending-view
2543 DROP VIEW IF EXISTS `pending-view`;
2544 CREATE VIEW `pending-view` AS SELECT
2545 `register`.`id` AS `id`,
2546 `register`.`hash` AS `hash`,
2547 `register`.`created` AS `created`,
2548 `register`.`uid` AS `uid`,
2549 `register`.`password` AS `password`,
2550 `register`.`language` AS `language`,
2551 `register`.`note` AS `note`,
2552 `contact`.`self` AS `self`,
2553 `contact`.`name` AS `name`,
2554 `contact`.`url` AS `url`,
2555 `contact`.`micro` AS `micro`,
2556 `user`.`email` AS `email`,
2557 `contact`.`nick` AS `nick`
2559 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2560 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2563 -- VIEW tag-search-view
2565 DROP VIEW IF EXISTS `tag-search-view`;
2566 CREATE VIEW `tag-search-view` AS SELECT
2567 `post-tag`.`uri-id` AS `uri-id`,
2568 `post-user`.`uid` AS `uid`,
2569 `post-user`.`id` AS `iid`,
2570 `post-user`.`private` AS `private`,
2571 `post-user`.`wall` AS `wall`,
2572 `post-user`.`origin` AS `origin`,
2573 `post-user`.`global` AS `global`,
2574 `post-user`.`gravity` AS `gravity`,
2575 `post-user`.`received` AS `received`,
2576 `post-user`.`network` AS `network`,
2577 `post-user`.`author-id` AS `author-id`,
2578 `tag`.`name` AS `name`
2580 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
2581 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
2582 WHERE `post-tag`.`type` = 1;
2585 -- VIEW workerqueue-view
2587 DROP VIEW IF EXISTS `workerqueue-view`;
2588 CREATE VIEW `workerqueue-view` AS SELECT
2589 `process`.`pid` AS `pid`,
2590 `workerqueue`.`priority` AS `priority`
2592 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
2593 WHERE NOT `workerqueue`.`done`;
2596 -- VIEW profile_field-view
2598 DROP VIEW IF EXISTS `profile_field-view`;
2599 CREATE VIEW `profile_field-view` AS SELECT
2600 `profile_field`.`id` AS `id`,
2601 `profile_field`.`uid` AS `uid`,
2602 `profile_field`.`label` AS `label`,
2603 `profile_field`.`value` AS `value`,
2604 `profile_field`.`order` AS `order`,
2605 `profile_field`.`psid` AS `psid`,
2606 `permissionset`.`allow_cid` AS `allow_cid`,
2607 `permissionset`.`allow_gid` AS `allow_gid`,
2608 `permissionset`.`deny_cid` AS `deny_cid`,
2609 `permissionset`.`deny_gid` AS `deny_gid`,
2610 `profile_field`.`created` AS `created`,
2611 `profile_field`.`edited` AS `edited`
2612 FROM `profile_field`
2613 INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`;