1 -- ------------------------------------------
2 -- Friendica 2022.05-dev (Siberian Iris)
3 -- DB_UPDATE_VERSION 1451
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 '',
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`.`forum_mode` AS `forum_mode`,
1616 `post-thread-user`.`mention` AS `mention`,
1617 `post-user`.`global` AS `global`,
1618 `post-user`.`network` AS `network`,
1619 `post-user`.`vid` AS `vid`,
1620 `post-user`.`psid` AS `psid`,
1621 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1622 `post-content`.`title` AS `title`,
1623 `post-content`.`content-warning` AS `content-warning`,
1624 `post-content`.`raw-body` AS `raw-body`,
1625 IFNULL (`post-content`.`body`, '') AS `body`,
1626 `post-content`.`rendered-hash` AS `rendered-hash`,
1627 `post-content`.`rendered-html` AS `rendered-html`,
1628 `post-content`.`language` AS `language`,
1629 `post-content`.`plink` AS `plink`,
1630 `post-content`.`location` AS `location`,
1631 `post-content`.`coord` AS `coord`,
1632 `post-content`.`app` AS `app`,
1633 `post-content`.`object-type` AS `object-type`,
1634 `post-content`.`object` AS `object`,
1635 `post-content`.`target-type` AS `target-type`,
1636 `post-content`.`target` AS `target`,
1637 `post-content`.`resource-id` AS `resource-id`,
1638 `post-user`.`contact-id` AS `contact-id`,
1639 `contact`.`url` AS `contact-link`,
1640 `contact`.`addr` AS `contact-addr`,
1641 `contact`.`name` AS `contact-name`,
1642 `contact`.`nick` AS `contact-nick`,
1643 `contact`.`thumb` AS `contact-avatar`,
1644 `contact`.`network` AS `contact-network`,
1645 `contact`.`blocked` AS `contact-blocked`,
1646 `contact`.`hidden` AS `contact-hidden`,
1647 `contact`.`readonly` AS `contact-readonly`,
1648 `contact`.`archive` AS `contact-archive`,
1649 `contact`.`pending` AS `contact-pending`,
1650 `contact`.`rel` AS `contact-rel`,
1651 `contact`.`uid` AS `contact-uid`,
1652 `contact`.`contact-type` AS `contact-contact-type`,
1653 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1654 `contact`.`self` AS `self`,
1655 `contact`.`id` AS `cid`,
1656 `contact`.`alias` AS `alias`,
1657 `contact`.`photo` AS `photo`,
1658 `contact`.`name-date` AS `name-date`,
1659 `contact`.`uri-date` AS `uri-date`,
1660 `contact`.`avatar-date` AS `avatar-date`,
1661 `contact`.`thumb` AS `thumb`,
1662 `post-user`.`author-id` AS `author-id`,
1663 `author`.`url` AS `author-link`,
1664 `author`.`addr` AS `author-addr`,
1665 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1666 `author`.`nick` AS `author-nick`,
1667 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1668 `author`.`network` AS `author-network`,
1669 `author`.`blocked` AS `author-blocked`,
1670 `author`.`hidden` AS `author-hidden`,
1671 `post-user`.`owner-id` AS `owner-id`,
1672 `owner`.`url` AS `owner-link`,
1673 `owner`.`addr` AS `owner-addr`,
1674 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1675 `owner`.`nick` AS `owner-nick`,
1676 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1677 `owner`.`network` AS `owner-network`,
1678 `owner`.`blocked` AS `owner-blocked`,
1679 `owner`.`hidden` AS `owner-hidden`,
1680 `owner`.`contact-type` AS `owner-contact-type`,
1681 `post-user`.`causer-id` AS `causer-id`,
1682 `causer`.`url` AS `causer-link`,
1683 `causer`.`addr` AS `causer-addr`,
1684 `causer`.`name` AS `causer-name`,
1685 `causer`.`nick` AS `causer-nick`,
1686 `causer`.`thumb` AS `causer-avatar`,
1687 `causer`.`network` AS `causer-network`,
1688 `causer`.`blocked` AS `causer-blocked`,
1689 `causer`.`hidden` AS `causer-hidden`,
1690 `causer`.`contact-type` AS `causer-contact-type`,
1691 `post-delivery-data`.`postopts` AS `postopts`,
1692 `post-delivery-data`.`inform` AS `inform`,
1693 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1694 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1695 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1696 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1697 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1698 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1699 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1700 `post-user`.`event-id` AS `event-id`,
1701 `event`.`created` AS `event-created`,
1702 `event`.`edited` AS `event-edited`,
1703 `event`.`start` AS `event-start`,
1704 `event`.`finish` AS `event-finish`,
1705 `event`.`summary` AS `event-summary`,
1706 `event`.`desc` AS `event-desc`,
1707 `event`.`location` AS `event-location`,
1708 `event`.`type` AS `event-type`,
1709 `event`.`nofinish` AS `event-nofinish`,
1710 `event`.`ignore` AS `event-ignore`,
1711 `diaspora-interaction`.`interaction` AS `signed_text`,
1712 `parent-item-uri`.`guid` AS `parent-guid`,
1713 `parent-post`.`network` AS `parent-network`,
1714 `parent-post`.`author-id` AS `parent-author-id`,
1715 `parent-post-author`.`url` AS `parent-author-link`,
1716 `parent-post-author`.`name` AS `parent-author-name`,
1717 `parent-post-author`.`nick` AS `parent-author-nick`,
1718 `parent-post-author`.`network` AS `parent-author-network`,
1719 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1720 `parent-post-author`.`hidden` AS `parent-author-hidden`
1722 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
1723 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
1724 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
1725 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
1726 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
1727 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
1728 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1729 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1730 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1731 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1732 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1733 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
1734 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
1735 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
1736 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
1737 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
1738 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1741 -- VIEW post-thread-user-view
1743 DROP VIEW IF EXISTS `post-thread-user-view`;
1744 CREATE VIEW `post-thread-user-view` AS SELECT
1745 `post-user`.`id` AS `id`,
1746 `post-user`.`id` AS `post-user-id`,
1747 `post-thread-user`.`uid` AS `uid`,
1748 `parent-post`.`id` AS `parent`,
1749 `item-uri`.`uri` AS `uri`,
1750 `post-thread-user`.`uri-id` AS `uri-id`,
1751 `parent-item-uri`.`uri` AS `parent-uri`,
1752 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1753 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1754 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1755 `item-uri`.`guid` AS `guid`,
1756 `post-thread-user`.`wall` AS `wall`,
1757 `post-user`.`gravity` AS `gravity`,
1758 `external-item-uri`.`uri` AS `extid`,
1759 `post-user`.`external-id` AS `external-id`,
1760 `post-thread-user`.`created` AS `created`,
1761 `post-user`.`edited` AS `edited`,
1762 `post-thread-user`.`commented` AS `commented`,
1763 `post-thread-user`.`received` AS `received`,
1764 `post-thread-user`.`changed` AS `changed`,
1765 `post-user`.`post-type` AS `post-type`,
1766 `post-user`.`post-reason` AS `post-reason`,
1767 `post-user`.`private` AS `private`,
1768 `post-thread-user`.`pubmail` AS `pubmail`,
1769 `post-thread-user`.`ignored` AS `ignored`,
1770 `post-user`.`visible` AS `visible`,
1771 `post-thread-user`.`starred` AS `starred`,
1772 `post-thread-user`.`pinned` AS `pinned`,
1773 `post-thread-user`.`unseen` AS `unseen`,
1774 `post-user`.`deleted` AS `deleted`,
1775 `post-thread-user`.`origin` AS `origin`,
1776 `post-thread-user`.`forum_mode` AS `forum_mode`,
1777 `post-thread-user`.`mention` AS `mention`,
1778 `post-user`.`global` AS `global`,
1779 `post-thread-user`.`network` AS `network`,
1780 `post-user`.`vid` AS `vid`,
1781 `post-thread-user`.`psid` AS `psid`,
1782 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1783 `post-content`.`title` AS `title`,
1784 `post-content`.`content-warning` AS `content-warning`,
1785 `post-content`.`raw-body` AS `raw-body`,
1786 `post-content`.`body` AS `body`,
1787 `post-content`.`rendered-hash` AS `rendered-hash`,
1788 `post-content`.`rendered-html` AS `rendered-html`,
1789 `post-content`.`language` AS `language`,
1790 `post-content`.`plink` AS `plink`,
1791 `post-content`.`location` AS `location`,
1792 `post-content`.`coord` AS `coord`,
1793 `post-content`.`app` AS `app`,
1794 `post-content`.`object-type` AS `object-type`,
1795 `post-content`.`object` AS `object`,
1796 `post-content`.`target-type` AS `target-type`,
1797 `post-content`.`target` AS `target`,
1798 `post-content`.`resource-id` AS `resource-id`,
1799 `post-thread-user`.`contact-id` AS `contact-id`,
1800 `contact`.`url` AS `contact-link`,
1801 `contact`.`addr` AS `contact-addr`,
1802 `contact`.`name` AS `contact-name`,
1803 `contact`.`nick` AS `contact-nick`,
1804 `contact`.`thumb` AS `contact-avatar`,
1805 `contact`.`network` AS `contact-network`,
1806 `contact`.`blocked` AS `contact-blocked`,
1807 `contact`.`hidden` AS `contact-hidden`,
1808 `contact`.`readonly` AS `contact-readonly`,
1809 `contact`.`archive` AS `contact-archive`,
1810 `contact`.`pending` AS `contact-pending`,
1811 `contact`.`rel` AS `contact-rel`,
1812 `contact`.`uid` AS `contact-uid`,
1813 `contact`.`contact-type` AS `contact-contact-type`,
1814 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1815 `contact`.`self` AS `self`,
1816 `contact`.`id` AS `cid`,
1817 `contact`.`alias` AS `alias`,
1818 `contact`.`photo` AS `photo`,
1819 `contact`.`name-date` AS `name-date`,
1820 `contact`.`uri-date` AS `uri-date`,
1821 `contact`.`avatar-date` AS `avatar-date`,
1822 `contact`.`thumb` AS `thumb`,
1823 `post-thread-user`.`author-id` AS `author-id`,
1824 `author`.`url` AS `author-link`,
1825 `author`.`addr` AS `author-addr`,
1826 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1827 `author`.`nick` AS `author-nick`,
1828 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1829 `author`.`network` AS `author-network`,
1830 `author`.`blocked` AS `author-blocked`,
1831 `author`.`hidden` AS `author-hidden`,
1832 `post-thread-user`.`owner-id` AS `owner-id`,
1833 `owner`.`url` AS `owner-link`,
1834 `owner`.`addr` AS `owner-addr`,
1835 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1836 `owner`.`nick` AS `owner-nick`,
1837 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1838 `owner`.`network` AS `owner-network`,
1839 `owner`.`blocked` AS `owner-blocked`,
1840 `owner`.`hidden` AS `owner-hidden`,
1841 `owner`.`contact-type` AS `owner-contact-type`,
1842 `post-thread-user`.`causer-id` AS `causer-id`,
1843 `causer`.`url` AS `causer-link`,
1844 `causer`.`addr` AS `causer-addr`,
1845 `causer`.`name` AS `causer-name`,
1846 `causer`.`nick` AS `causer-nick`,
1847 `causer`.`thumb` AS `causer-avatar`,
1848 `causer`.`network` AS `causer-network`,
1849 `causer`.`blocked` AS `causer-blocked`,
1850 `causer`.`hidden` AS `causer-hidden`,
1851 `causer`.`contact-type` AS `causer-contact-type`,
1852 `post-delivery-data`.`postopts` AS `postopts`,
1853 `post-delivery-data`.`inform` AS `inform`,
1854 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1855 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1856 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1857 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1858 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1859 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1860 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1861 `post-user`.`event-id` AS `event-id`,
1862 `event`.`created` AS `event-created`,
1863 `event`.`edited` AS `event-edited`,
1864 `event`.`start` AS `event-start`,
1865 `event`.`finish` AS `event-finish`,
1866 `event`.`summary` AS `event-summary`,
1867 `event`.`desc` AS `event-desc`,
1868 `event`.`location` AS `event-location`,
1869 `event`.`type` AS `event-type`,
1870 `event`.`nofinish` AS `event-nofinish`,
1871 `event`.`ignore` AS `event-ignore`,
1872 `diaspora-interaction`.`interaction` AS `signed_text`,
1873 `parent-item-uri`.`guid` AS `parent-guid`,
1874 `parent-post`.`network` AS `parent-network`,
1875 `parent-post`.`author-id` AS `parent-author-id`,
1876 `parent-post-author`.`url` AS `parent-author-link`,
1877 `parent-post-author`.`name` AS `parent-author-name`,
1878 `parent-post-author`.`network` AS `parent-author-network`,
1879 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1880 `parent-post-author`.`hidden` AS `parent-author-hidden`
1881 FROM `post-thread-user`
1882 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
1883 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
1884 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
1885 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
1886 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
1887 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
1888 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1889 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1890 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1891 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1892 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1893 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
1894 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
1895 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
1896 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
1897 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`
1898 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1903 DROP VIEW IF EXISTS `post-view`;
1904 CREATE VIEW `post-view` AS SELECT
1905 `item-uri`.`uri` AS `uri`,
1906 `post`.`uri-id` AS `uri-id`,
1907 `parent-item-uri`.`uri` AS `parent-uri`,
1908 `post`.`parent-uri-id` AS `parent-uri-id`,
1909 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1910 `post`.`thr-parent-id` AS `thr-parent-id`,
1911 `item-uri`.`guid` AS `guid`,
1912 `post`.`gravity` AS `gravity`,
1913 `external-item-uri`.`uri` AS `extid`,
1914 `post`.`external-id` AS `external-id`,
1915 `post`.`created` AS `created`,
1916 `post`.`edited` AS `edited`,
1917 `post-thread`.`commented` AS `commented`,
1918 `post`.`received` AS `received`,
1919 `post-thread`.`changed` AS `changed`,
1920 `post`.`post-type` AS `post-type`,
1921 `post`.`private` AS `private`,
1922 `post`.`visible` AS `visible`,
1923 `post`.`deleted` AS `deleted`,
1924 `post`.`global` AS `global`,
1925 `post`.`network` AS `network`,
1926 `post`.`vid` AS `vid`,
1927 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1928 `post-content`.`title` AS `title`,
1929 `post-content`.`content-warning` AS `content-warning`,
1930 `post-content`.`raw-body` AS `raw-body`,
1931 `post-content`.`body` AS `body`,
1932 `post-content`.`rendered-hash` AS `rendered-hash`,
1933 `post-content`.`rendered-html` AS `rendered-html`,
1934 `post-content`.`language` AS `language`,
1935 `post-content`.`plink` AS `plink`,
1936 `post-content`.`location` AS `location`,
1937 `post-content`.`coord` AS `coord`,
1938 `post-content`.`app` AS `app`,
1939 `post-content`.`object-type` AS `object-type`,
1940 `post-content`.`object` AS `object`,
1941 `post-content`.`target-type` AS `target-type`,
1942 `post-content`.`target` AS `target`,
1943 `post-content`.`resource-id` AS `resource-id`,
1944 `post`.`author-id` AS `contact-id`,
1945 `author`.`url` AS `contact-link`,
1946 `author`.`addr` AS `contact-addr`,
1947 `author`.`name` AS `contact-name`,
1948 `author`.`nick` AS `contact-nick`,
1949 `author`.`thumb` AS `contact-avatar`,
1950 `author`.`network` AS `contact-network`,
1951 `author`.`blocked` AS `contact-blocked`,
1952 `author`.`hidden` AS `contact-hidden`,
1953 `author`.`readonly` AS `contact-readonly`,
1954 `author`.`archive` AS `contact-archive`,
1955 `author`.`pending` AS `contact-pending`,
1956 `author`.`rel` AS `contact-rel`,
1957 `author`.`uid` AS `contact-uid`,
1958 `author`.`contact-type` AS `contact-contact-type`,
1959 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
1961 `author`.`id` AS `cid`,
1962 `author`.`alias` AS `alias`,
1963 `author`.`photo` AS `photo`,
1964 `author`.`name-date` AS `name-date`,
1965 `author`.`uri-date` AS `uri-date`,
1966 `author`.`avatar-date` AS `avatar-date`,
1967 `author`.`thumb` AS `thumb`,
1968 `post`.`author-id` AS `author-id`,
1969 `author`.`url` AS `author-link`,
1970 `author`.`addr` AS `author-addr`,
1971 `author`.`name` AS `author-name`,
1972 `author`.`nick` AS `author-nick`,
1973 `author`.`thumb` AS `author-avatar`,
1974 `author`.`network` AS `author-network`,
1975 `author`.`blocked` AS `author-blocked`,
1976 `author`.`hidden` AS `author-hidden`,
1977 `post`.`owner-id` AS `owner-id`,
1978 `owner`.`url` AS `owner-link`,
1979 `owner`.`addr` AS `owner-addr`,
1980 `owner`.`name` AS `owner-name`,
1981 `owner`.`nick` AS `owner-nick`,
1982 `owner`.`thumb` AS `owner-avatar`,
1983 `owner`.`network` AS `owner-network`,
1984 `owner`.`blocked` AS `owner-blocked`,
1985 `owner`.`hidden` AS `owner-hidden`,
1986 `owner`.`contact-type` AS `owner-contact-type`,
1987 `post`.`causer-id` AS `causer-id`,
1988 `causer`.`url` AS `causer-link`,
1989 `causer`.`addr` AS `causer-addr`,
1990 `causer`.`name` AS `causer-name`,
1991 `causer`.`nick` AS `causer-nick`,
1992 `causer`.`thumb` AS `causer-avatar`,
1993 `causer`.`network` AS `causer-network`,
1994 `causer`.`blocked` AS `causer-blocked`,
1995 `causer`.`hidden` AS `causer-hidden`,
1996 `causer`.`contact-type` AS `causer-contact-type`,
1997 `diaspora-interaction`.`interaction` AS `signed_text`,
1998 `parent-item-uri`.`guid` AS `parent-guid`,
1999 `parent-post`.`network` AS `parent-network`,
2000 `parent-post`.`author-id` AS `parent-author-id`,
2001 `parent-post-author`.`url` AS `parent-author-link`,
2002 `parent-post-author`.`name` AS `parent-author-name`,
2003 `parent-post-author`.`network` AS `parent-author-network`,
2004 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2005 `parent-post-author`.`hidden` AS `parent-author-hidden`
2007 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
2008 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
2009 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
2010 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
2011 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
2012 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2013 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2014 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2015 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2016 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
2017 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
2018 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2019 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2022 -- VIEW post-thread-view
2024 DROP VIEW IF EXISTS `post-thread-view`;
2025 CREATE VIEW `post-thread-view` AS SELECT
2026 `item-uri`.`uri` AS `uri`,
2027 `post-thread`.`uri-id` AS `uri-id`,
2028 `parent-item-uri`.`uri` AS `parent-uri`,
2029 `post`.`parent-uri-id` AS `parent-uri-id`,
2030 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2031 `post`.`thr-parent-id` AS `thr-parent-id`,
2032 `item-uri`.`guid` AS `guid`,
2033 `post`.`gravity` AS `gravity`,
2034 `external-item-uri`.`uri` AS `extid`,
2035 `post`.`external-id` AS `external-id`,
2036 `post-thread`.`created` AS `created`,
2037 `post`.`edited` AS `edited`,
2038 `post-thread`.`commented` AS `commented`,
2039 `post-thread`.`received` AS `received`,
2040 `post-thread`.`changed` AS `changed`,
2041 `post`.`post-type` AS `post-type`,
2042 `post`.`private` AS `private`,
2043 `post`.`visible` AS `visible`,
2044 `post`.`deleted` AS `deleted`,
2045 `post`.`global` AS `global`,
2046 `post-thread`.`network` AS `network`,
2047 `post`.`vid` AS `vid`,
2048 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2049 `post-content`.`title` AS `title`,
2050 `post-content`.`content-warning` AS `content-warning`,
2051 `post-content`.`raw-body` AS `raw-body`,
2052 `post-content`.`body` AS `body`,
2053 `post-content`.`rendered-hash` AS `rendered-hash`,
2054 `post-content`.`rendered-html` AS `rendered-html`,
2055 `post-content`.`language` AS `language`,
2056 `post-content`.`plink` AS `plink`,
2057 `post-content`.`location` AS `location`,
2058 `post-content`.`coord` AS `coord`,
2059 `post-content`.`app` AS `app`,
2060 `post-content`.`object-type` AS `object-type`,
2061 `post-content`.`object` AS `object`,
2062 `post-content`.`target-type` AS `target-type`,
2063 `post-content`.`target` AS `target`,
2064 `post-content`.`resource-id` AS `resource-id`,
2065 `post-thread`.`author-id` AS `contact-id`,
2066 `author`.`url` AS `contact-link`,
2067 `author`.`addr` AS `contact-addr`,
2068 `author`.`name` AS `contact-name`,
2069 `author`.`nick` AS `contact-nick`,
2070 `author`.`thumb` AS `contact-avatar`,
2071 `author`.`network` AS `contact-network`,
2072 `author`.`blocked` AS `contact-blocked`,
2073 `author`.`hidden` AS `contact-hidden`,
2074 `author`.`readonly` AS `contact-readonly`,
2075 `author`.`archive` AS `contact-archive`,
2076 `author`.`pending` AS `contact-pending`,
2077 `author`.`rel` AS `contact-rel`,
2078 `author`.`uid` AS `contact-uid`,
2079 `author`.`contact-type` AS `contact-contact-type`,
2080 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2082 `author`.`id` AS `cid`,
2083 `author`.`alias` AS `alias`,
2084 `author`.`photo` AS `photo`,
2085 `author`.`name-date` AS `name-date`,
2086 `author`.`uri-date` AS `uri-date`,
2087 `author`.`avatar-date` AS `avatar-date`,
2088 `author`.`thumb` AS `thumb`,
2089 `post-thread`.`author-id` AS `author-id`,
2090 `author`.`url` AS `author-link`,
2091 `author`.`addr` AS `author-addr`,
2092 `author`.`name` AS `author-name`,
2093 `author`.`nick` AS `author-nick`,
2094 `author`.`thumb` AS `author-avatar`,
2095 `author`.`network` AS `author-network`,
2096 `author`.`blocked` AS `author-blocked`,
2097 `author`.`hidden` AS `author-hidden`,
2098 `post-thread`.`owner-id` AS `owner-id`,
2099 `owner`.`url` AS `owner-link`,
2100 `owner`.`addr` AS `owner-addr`,
2101 `owner`.`name` AS `owner-name`,
2102 `owner`.`nick` AS `owner-nick`,
2103 `owner`.`thumb` AS `owner-avatar`,
2104 `owner`.`network` AS `owner-network`,
2105 `owner`.`blocked` AS `owner-blocked`,
2106 `owner`.`hidden` AS `owner-hidden`,
2107 `owner`.`contact-type` AS `owner-contact-type`,
2108 `post-thread`.`causer-id` AS `causer-id`,
2109 `causer`.`url` AS `causer-link`,
2110 `causer`.`addr` AS `causer-addr`,
2111 `causer`.`name` AS `causer-name`,
2112 `causer`.`nick` AS `causer-nick`,
2113 `causer`.`thumb` AS `causer-avatar`,
2114 `causer`.`network` AS `causer-network`,
2115 `causer`.`blocked` AS `causer-blocked`,
2116 `causer`.`hidden` AS `causer-hidden`,
2117 `causer`.`contact-type` AS `causer-contact-type`,
2118 `diaspora-interaction`.`interaction` AS `signed_text`,
2119 `parent-item-uri`.`guid` AS `parent-guid`,
2120 `parent-post`.`network` AS `parent-network`,
2121 `parent-post`.`author-id` AS `parent-author-id`,
2122 `parent-post-author`.`url` AS `parent-author-link`,
2123 `parent-post-author`.`name` AS `parent-author-name`,
2124 `parent-post-author`.`network` AS `parent-author-network`,
2125 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2126 `parent-post-author`.`hidden` AS `parent-author-hidden`
2128 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
2129 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
2130 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
2131 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
2132 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
2133 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2134 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2135 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2136 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2137 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
2138 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
2139 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2140 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2143 -- VIEW category-view
2145 DROP VIEW IF EXISTS `category-view`;
2146 CREATE VIEW `category-view` AS SELECT
2147 `post-category`.`uri-id` AS `uri-id`,
2148 `post-category`.`uid` AS `uid`,
2149 `post-category`.`type` AS `type`,
2150 `post-category`.`tid` AS `tid`,
2151 `tag`.`name` AS `name`,
2152 `tag`.`url` AS `url`
2153 FROM `post-category`
2154 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2159 DROP VIEW IF EXISTS `tag-view`;
2160 CREATE VIEW `tag-view` AS SELECT
2161 `post-tag`.`uri-id` AS `uri-id`,
2162 `post-tag`.`type` AS `type`,
2163 `post-tag`.`tid` AS `tid`,
2164 `post-tag`.`cid` AS `cid`,
2165 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2166 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
2168 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2169 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2172 -- VIEW network-item-view
2174 DROP VIEW IF EXISTS `network-item-view`;
2175 CREATE VIEW `network-item-view` AS SELECT
2176 `post-user`.`uri-id` AS `uri-id`,
2177 `parent-post`.`id` AS `parent`,
2178 `post-user`.`received` AS `received`,
2179 `post-thread-user`.`commented` AS `commented`,
2180 `post-user`.`created` AS `created`,
2181 `post-user`.`uid` AS `uid`,
2182 `post-thread-user`.`starred` AS `starred`,
2183 `post-thread-user`.`mention` AS `mention`,
2184 `post-user`.`network` AS `network`,
2185 `post-user`.`unseen` AS `unseen`,
2186 `post-user`.`gravity` AS `gravity`,
2187 `post-user`.`contact-id` AS `contact-id`,
2188 `ownercontact`.`contact-type` AS `contact-type`
2190 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2191 INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2192 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2193 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2194 INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2195 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2196 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2197 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2198 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
2199 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2200 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2203 -- VIEW network-thread-view
2205 DROP VIEW IF EXISTS `network-thread-view`;
2206 CREATE VIEW `network-thread-view` AS SELECT
2207 `post-thread-user`.`uri-id` AS `uri-id`,
2208 `parent-post`.`id` AS `parent`,
2209 `post-thread-user`.`received` AS `received`,
2210 `post-thread-user`.`commented` AS `commented`,
2211 `post-thread-user`.`created` AS `created`,
2212 `post-thread-user`.`uid` AS `uid`,
2213 `post-thread-user`.`starred` AS `starred`,
2214 `post-thread-user`.`mention` AS `mention`,
2215 `post-thread-user`.`network` AS `network`,
2216 `post-thread-user`.`contact-id` AS `contact-id`,
2217 `ownercontact`.`contact-type` AS `contact-type`
2218 FROM `post-thread-user`
2219 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2220 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2221 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2222 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2223 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2224 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2225 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2226 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2227 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2228 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2229 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2234 DROP VIEW IF EXISTS `owner-view`;
2235 CREATE VIEW `owner-view` AS SELECT
2236 `contact`.`id` AS `id`,
2237 `contact`.`uid` AS `uid`,
2238 `contact`.`created` AS `created`,
2239 `contact`.`updated` AS `updated`,
2240 `contact`.`self` AS `self`,
2241 `contact`.`remote_self` AS `remote_self`,
2242 `contact`.`rel` AS `rel`,
2243 `contact`.`network` AS `network`,
2244 `contact`.`protocol` AS `protocol`,
2245 `contact`.`name` AS `name`,
2246 `contact`.`nick` AS `nick`,
2247 `contact`.`location` AS `location`,
2248 `contact`.`about` AS `about`,
2249 `contact`.`keywords` AS `keywords`,
2250 `contact`.`xmpp` AS `xmpp`,
2251 `contact`.`matrix` AS `matrix`,
2252 `contact`.`attag` AS `attag`,
2253 `contact`.`avatar` AS `avatar`,
2254 `contact`.`photo` AS `photo`,
2255 `contact`.`thumb` AS `thumb`,
2256 `contact`.`micro` AS `micro`,
2257 `contact`.`header` AS `header`,
2258 `contact`.`url` AS `url`,
2259 `contact`.`nurl` AS `nurl`,
2260 `contact`.`uri-id` AS `uri-id`,
2261 `contact`.`addr` AS `addr`,
2262 `contact`.`alias` AS `alias`,
2263 `contact`.`pubkey` AS `pubkey`,
2264 `contact`.`prvkey` AS `prvkey`,
2265 `contact`.`batch` AS `batch`,
2266 `contact`.`request` AS `request`,
2267 `contact`.`notify` AS `notify`,
2268 `contact`.`poll` AS `poll`,
2269 `contact`.`confirm` AS `confirm`,
2270 `contact`.`poco` AS `poco`,
2271 `contact`.`subhub` AS `subhub`,
2272 `contact`.`hub-verify` AS `hub-verify`,
2273 `contact`.`last-update` AS `last-update`,
2274 `contact`.`success_update` AS `success_update`,
2275 `contact`.`failure_update` AS `failure_update`,
2276 `contact`.`name-date` AS `name-date`,
2277 `contact`.`uri-date` AS `uri-date`,
2278 `contact`.`avatar-date` AS `avatar-date`,
2279 `contact`.`avatar-date` AS `picdate`,
2280 `contact`.`term-date` AS `term-date`,
2281 `contact`.`last-item` AS `last-item`,
2282 `contact`.`priority` AS `priority`,
2283 `user`.`blocked` AS `blocked`,
2284 `contact`.`block_reason` AS `block_reason`,
2285 `contact`.`readonly` AS `readonly`,
2286 `contact`.`writable` AS `writable`,
2287 `contact`.`forum` AS `forum`,
2288 `contact`.`prv` AS `prv`,
2289 `contact`.`contact-type` AS `contact-type`,
2290 `contact`.`manually-approve` AS `manually-approve`,
2291 `contact`.`hidden` AS `hidden`,
2292 `contact`.`archive` AS `archive`,
2293 `contact`.`pending` AS `pending`,
2294 `contact`.`deleted` AS `deleted`,
2295 `contact`.`unsearchable` AS `unsearchable`,
2296 `contact`.`sensitive` AS `sensitive`,
2297 `contact`.`baseurl` AS `baseurl`,
2298 `contact`.`reason` AS `reason`,
2299 `contact`.`info` AS `info`,
2300 `contact`.`bdyear` AS `bdyear`,
2301 `contact`.`bd` AS `bd`,
2302 `contact`.`notify_new_posts` AS `notify_new_posts`,
2303 `contact`.`fetch_further_information` AS `fetch_further_information`,
2304 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2305 `user`.`parent-uid` AS `parent-uid`,
2306 `user`.`guid` AS `guid`,
2307 `user`.`nickname` AS `nickname`,
2308 `user`.`email` AS `email`,
2309 `user`.`openid` AS `openid`,
2310 `user`.`timezone` AS `timezone`,
2311 `user`.`language` AS `language`,
2312 `user`.`register_date` AS `register_date`,
2313 `user`.`login_date` AS `login_date`,
2314 `user`.`default-location` AS `default-location`,
2315 `user`.`allow_location` AS `allow_location`,
2316 `user`.`theme` AS `theme`,
2317 `user`.`pubkey` AS `upubkey`,
2318 `user`.`prvkey` AS `uprvkey`,
2319 `user`.`sprvkey` AS `sprvkey`,
2320 `user`.`spubkey` AS `spubkey`,
2321 `user`.`verified` AS `verified`,
2322 `user`.`blockwall` AS `blockwall`,
2323 `user`.`hidewall` AS `hidewall`,
2324 `user`.`blocktags` AS `blocktags`,
2325 `user`.`unkmail` AS `unkmail`,
2326 `user`.`cntunkmail` AS `cntunkmail`,
2327 `user`.`notify-flags` AS `notify-flags`,
2328 `user`.`page-flags` AS `page-flags`,
2329 `user`.`account-type` AS `account-type`,
2330 `user`.`prvnets` AS `prvnets`,
2331 `user`.`maxreq` AS `maxreq`,
2332 `user`.`expire` AS `expire`,
2333 `user`.`account_removed` AS `account_removed`,
2334 `user`.`account_expired` AS `account_expired`,
2335 `user`.`account_expires_on` AS `account_expires_on`,
2336 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2337 `user`.`def_gid` AS `def_gid`,
2338 `user`.`allow_cid` AS `allow_cid`,
2339 `user`.`allow_gid` AS `allow_gid`,
2340 `user`.`deny_cid` AS `deny_cid`,
2341 `user`.`deny_gid` AS `deny_gid`,
2342 `user`.`openidserver` AS `openidserver`,
2343 `profile`.`publish` AS `publish`,
2344 `profile`.`net-publish` AS `net-publish`,
2345 `profile`.`hide-friends` AS `hide-friends`,
2346 `profile`.`prv_keywords` AS `prv_keywords`,
2347 `profile`.`pub_keywords` AS `pub_keywords`,
2348 `profile`.`address` AS `address`,
2349 `profile`.`locality` AS `locality`,
2350 `profile`.`region` AS `region`,
2351 `profile`.`postal-code` AS `postal-code`,
2352 `profile`.`country-name` AS `country-name`,
2353 `profile`.`homepage` AS `homepage`,
2354 `profile`.`dob` AS `dob`
2356 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2357 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2360 -- VIEW account-view
2362 DROP VIEW IF EXISTS `account-view`;
2363 CREATE VIEW `account-view` AS SELECT
2364 `contact`.`id` AS `id`,
2365 `contact`.`url` AS `url`,
2366 `contact`.`nurl` AS `nurl`,
2367 `contact`.`uri-id` AS `uri-id`,
2368 `item-uri`.`guid` AS `guid`,
2369 `contact`.`addr` AS `addr`,
2370 `contact`.`alias` AS `alias`,
2371 `contact`.`name` AS `name`,
2372 `contact`.`nick` AS `nick`,
2373 `contact`.`about` AS `about`,
2374 `contact`.`keywords` AS `keywords`,
2375 `contact`.`xmpp` AS `xmpp`,
2376 `contact`.`matrix` AS `matrix`,
2377 `contact`.`avatar` AS `avatar`,
2378 `contact`.`photo` AS `photo`,
2379 `contact`.`thumb` AS `thumb`,
2380 `contact`.`micro` AS `micro`,
2381 `contact`.`header` AS `header`,
2382 `contact`.`created` AS `created`,
2383 `contact`.`updated` AS `updated`,
2384 `contact`.`network` AS `network`,
2385 `contact`.`protocol` AS `protocol`,
2386 `contact`.`location` AS `location`,
2387 `contact`.`attag` AS `attag`,
2388 `contact`.`pubkey` AS `pubkey`,
2389 `contact`.`prvkey` AS `prvkey`,
2390 `contact`.`subscribe` AS `subscribe`,
2391 `contact`.`last-update` AS `last-update`,
2392 `contact`.`success_update` AS `success_update`,
2393 `contact`.`failure_update` AS `failure_update`,
2394 `contact`.`failed` AS `failed`,
2395 `contact`.`last-item` AS `last-item`,
2396 `contact`.`last-discovery` AS `last-discovery`,
2397 `contact`.`contact-type` AS `contact-type`,
2398 `contact`.`manually-approve` AS `manually-approve`,
2399 `contact`.`unsearchable` AS `unsearchable`,
2400 `contact`.`sensitive` AS `sensitive`,
2401 `contact`.`baseurl` AS `baseurl`,
2402 `contact`.`gsid` AS `gsid`,
2403 `contact`.`info` AS `info`,
2404 `contact`.`bdyear` AS `bdyear`,
2405 `contact`.`bd` AS `bd`,
2406 `contact`.`poco` AS `poco`,
2407 `contact`.`name-date` AS `name-date`,
2408 `contact`.`uri-date` AS `uri-date`,
2409 `contact`.`avatar-date` AS `avatar-date`,
2410 `contact`.`term-date` AS `term-date`,
2411 `contact`.`hidden` AS `global-ignored`,
2412 `contact`.`blocked` AS `global-blocked`,
2413 `contact`.`hidden` AS `hidden`,
2414 `contact`.`archive` AS `archive`,
2415 `contact`.`deleted` AS `deleted`,
2416 `contact`.`blocked` AS `blocked`,
2417 `contact`.`request` AS `dfrn-request`,
2418 `contact`.`notify` AS `dfrn-notify`,
2419 `contact`.`poll` AS `dfrn-poll`,
2420 `contact`.`confirm` AS `dfrn-confirm`,
2421 `fcontact`.`guid` AS `diaspora-guid`,
2422 `fcontact`.`batch` AS `diaspora-batch`,
2423 `fcontact`.`notify` AS `diaspora-notify`,
2424 `fcontact`.`poll` AS `diaspora-poll`,
2425 `fcontact`.`alias` AS `diaspora-alias`,
2426 `apcontact`.`uuid` AS `ap-uuid`,
2427 `apcontact`.`type` AS `ap-type`,
2428 `apcontact`.`following` AS `ap-following`,
2429 `apcontact`.`followers` AS `ap-followers`,
2430 `apcontact`.`inbox` AS `ap-inbox`,
2431 `apcontact`.`outbox` AS `ap-outbox`,
2432 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2433 `apcontact`.`generator` AS `ap-generator`,
2434 `apcontact`.`following_count` AS `ap-following_count`,
2435 `apcontact`.`followers_count` AS `ap-followers_count`,
2436 `apcontact`.`statuses_count` AS `ap-statuses_count`
2438 LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id`
2439 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
2440 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = contact.`uri-id`
2441 WHERE `contact`.`uid` = 0;
2444 -- VIEW account-user-view
2446 DROP VIEW IF EXISTS `account-user-view`;
2447 CREATE VIEW `account-user-view` AS SELECT
2448 `ucontact`.`id` AS `id`,
2449 `contact`.`id` AS `pid`,
2450 `ucontact`.`uid` AS `uid`,
2451 `contact`.`url` AS `url`,
2452 `contact`.`nurl` AS `nurl`,
2453 `contact`.`uri-id` AS `uri-id`,
2454 `item-uri`.`guid` AS `guid`,
2455 `contact`.`addr` AS `addr`,
2456 `contact`.`alias` AS `alias`,
2457 `contact`.`name` AS `name`,
2458 `contact`.`nick` AS `nick`,
2459 `contact`.`about` AS `about`,
2460 `contact`.`keywords` AS `keywords`,
2461 `contact`.`xmpp` AS `xmpp`,
2462 `contact`.`matrix` AS `matrix`,
2463 `contact`.`avatar` AS `avatar`,
2464 `contact`.`photo` AS `photo`,
2465 `contact`.`thumb` AS `thumb`,
2466 `contact`.`micro` AS `micro`,
2467 `contact`.`header` AS `header`,
2468 `contact`.`created` AS `created`,
2469 `contact`.`updated` AS `updated`,
2470 `ucontact`.`self` AS `self`,
2471 `ucontact`.`remote_self` AS `remote_self`,
2472 `ucontact`.`rel` AS `rel`,
2473 `contact`.`network` AS `network`,
2474 `ucontact`.`protocol` AS `protocol`,
2475 `contact`.`location` AS `location`,
2476 `ucontact`.`attag` AS `attag`,
2477 `contact`.`pubkey` AS `pubkey`,
2478 `contact`.`prvkey` AS `prvkey`,
2479 `contact`.`subscribe` AS `subscribe`,
2480 `contact`.`last-update` AS `last-update`,
2481 `contact`.`success_update` AS `success_update`,
2482 `contact`.`failure_update` AS `failure_update`,
2483 `contact`.`failed` AS `failed`,
2484 `contact`.`last-item` AS `last-item`,
2485 `contact`.`last-discovery` AS `last-discovery`,
2486 `contact`.`contact-type` AS `contact-type`,
2487 `contact`.`manually-approve` AS `manually-approve`,
2488 `contact`.`unsearchable` AS `unsearchable`,
2489 `contact`.`sensitive` AS `sensitive`,
2490 `contact`.`baseurl` AS `baseurl`,
2491 `contact`.`gsid` AS `gsid`,
2492 `ucontact`.`info` AS `info`,
2493 `contact`.`bdyear` AS `bdyear`,
2494 `contact`.`bd` AS `bd`,
2495 `contact`.`poco` AS `poco`,
2496 `contact`.`name-date` AS `name-date`,
2497 `contact`.`uri-date` AS `uri-date`,
2498 `contact`.`avatar-date` AS `avatar-date`,
2499 `contact`.`term-date` AS `term-date`,
2500 `contact`.`hidden` AS `global-ignored`,
2501 `contact`.`blocked` AS `global-blocked`,
2502 `ucontact`.`hidden` AS `hidden`,
2503 `ucontact`.`archive` AS `archive`,
2504 `ucontact`.`pending` AS `pending`,
2505 `ucontact`.`deleted` AS `deleted`,
2506 `ucontact`.`notify_new_posts` AS `notify_new_posts`,
2507 `ucontact`.`fetch_further_information` AS `fetch_further_information`,
2508 `ucontact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2509 `ucontact`.`rating` AS `rating`,
2510 `ucontact`.`readonly` AS `readonly`,
2511 `ucontact`.`blocked` AS `blocked`,
2512 `ucontact`.`block_reason` AS `block_reason`,
2513 `ucontact`.`subhub` AS `subhub`,
2514 `ucontact`.`hub-verify` AS `hub-verify`,
2515 `ucontact`.`reason` AS `reason`,
2516 `contact`.`request` AS `dfrn-request`,
2517 `contact`.`notify` AS `dfrn-notify`,
2518 `contact`.`poll` AS `dfrn-poll`,
2519 `contact`.`confirm` AS `dfrn-confirm`,
2520 `fcontact`.`guid` AS `diaspora-guid`,
2521 `fcontact`.`batch` AS `diaspora-batch`,
2522 `fcontact`.`notify` AS `diaspora-notify`,
2523 `fcontact`.`poll` AS `diaspora-poll`,
2524 `fcontact`.`alias` AS `diaspora-alias`,
2525 `apcontact`.`uuid` AS `ap-uuid`,
2526 `apcontact`.`type` AS `ap-type`,
2527 `apcontact`.`following` AS `ap-following`,
2528 `apcontact`.`followers` AS `ap-followers`,
2529 `apcontact`.`inbox` AS `ap-inbox`,
2530 `apcontact`.`outbox` AS `ap-outbox`,
2531 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2532 `apcontact`.`generator` AS `ap-generator`,
2533 `apcontact`.`following_count` AS `ap-following_count`,
2534 `apcontact`.`followers_count` AS `ap-followers_count`,
2535 `apcontact`.`statuses_count` AS `ap-statuses_count`
2536 FROM `contact` AS `ucontact`
2537 INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
2538 LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id`
2539 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
2540 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = `ucontact`.`uri-id` AND `fcontact`.`network` = 'dspr';
2543 -- VIEW pending-view
2545 DROP VIEW IF EXISTS `pending-view`;
2546 CREATE VIEW `pending-view` AS SELECT
2547 `register`.`id` AS `id`,
2548 `register`.`hash` AS `hash`,
2549 `register`.`created` AS `created`,
2550 `register`.`uid` AS `uid`,
2551 `register`.`password` AS `password`,
2552 `register`.`language` AS `language`,
2553 `register`.`note` AS `note`,
2554 `contact`.`self` AS `self`,
2555 `contact`.`name` AS `name`,
2556 `contact`.`url` AS `url`,
2557 `contact`.`micro` AS `micro`,
2558 `user`.`email` AS `email`,
2559 `contact`.`nick` AS `nick`
2561 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2562 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2565 -- VIEW tag-search-view
2567 DROP VIEW IF EXISTS `tag-search-view`;
2568 CREATE VIEW `tag-search-view` AS SELECT
2569 `post-tag`.`uri-id` AS `uri-id`,
2570 `post-user`.`uid` AS `uid`,
2571 `post-user`.`id` AS `iid`,
2572 `post-user`.`private` AS `private`,
2573 `post-user`.`wall` AS `wall`,
2574 `post-user`.`origin` AS `origin`,
2575 `post-user`.`global` AS `global`,
2576 `post-user`.`gravity` AS `gravity`,
2577 `post-user`.`received` AS `received`,
2578 `post-user`.`network` AS `network`,
2579 `post-user`.`author-id` AS `author-id`,
2580 `tag`.`name` AS `name`
2582 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
2583 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
2584 WHERE `post-tag`.`type` = 1;
2587 -- VIEW workerqueue-view
2589 DROP VIEW IF EXISTS `workerqueue-view`;
2590 CREATE VIEW `workerqueue-view` AS SELECT
2591 `process`.`pid` AS `pid`,
2592 `workerqueue`.`priority` AS `priority`
2594 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
2595 WHERE NOT `workerqueue`.`done`;
2598 -- VIEW profile_field-view
2600 DROP VIEW IF EXISTS `profile_field-view`;
2601 CREATE VIEW `profile_field-view` AS SELECT
2602 `profile_field`.`id` AS `id`,
2603 `profile_field`.`uid` AS `uid`,
2604 `profile_field`.`label` AS `label`,
2605 `profile_field`.`value` AS `value`,
2606 `profile_field`.`order` AS `order`,
2607 `profile_field`.`psid` AS `psid`,
2608 `permissionset`.`allow_cid` AS `allow_cid`,
2609 `permissionset`.`allow_gid` AS `allow_gid`,
2610 `permissionset`.`deny_cid` AS `deny_cid`,
2611 `permissionset`.`deny_gid` AS `deny_gid`,
2612 `profile_field`.`created` AS `created`,
2613 `profile_field`.`edited` AS `edited`
2614 FROM `profile_field`
2615 INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`;