1 -- ------------------------------------------
2 -- Friendica 2021.09-dev (Siberian Iris)
3 -- DB_UPDATE_VERSION 1429
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 `directory-type` tinyint DEFAULT 0 COMMENT 'Type of directory service (Poco, Mastodon)',
20 `poco` varchar(255) NOT NULL DEFAULT '' COMMENT '',
21 `noscrape` varchar(255) NOT NULL DEFAULT '' COMMENT '',
22 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
23 `protocol` tinyint unsigned COMMENT 'The protocol of the server',
24 `platform` varchar(255) NOT NULL DEFAULT '' COMMENT '',
25 `relay-subscribe` boolean NOT NULL DEFAULT '0' COMMENT 'Has the server subscribed to the relay system',
26 `relay-scope` varchar(10) NOT NULL DEFAULT '' COMMENT 'The scope of messages that the server wants to get',
27 `detection-method` tinyint unsigned COMMENT 'Method that had been used to detect that server',
28 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
29 `last_poco_query` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
30 `last_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Last successful connection request',
31 `last_failure` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Last failed connection request',
32 `failed` boolean COMMENT 'Connection failed',
33 `next_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Next connection request',
35 UNIQUE INDEX `nurl` (`nurl`(190)),
36 INDEX `next_contact` (`next_contact`),
37 INDEX `network` (`network`)
38 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Global servers';
43 CREATE TABLE IF NOT EXISTS `user` (
44 `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
45 `parent-uid` mediumint unsigned COMMENT 'The parent user that has full control about this user',
46 `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
47 `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
48 `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
49 `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
50 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
51 `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
52 `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
53 `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
54 `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
55 `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
56 `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
57 `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
58 `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
59 `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
60 `pubkey` text COMMENT 'RSA public key 4096 bit',
61 `prvkey` text COMMENT 'RSA private key 4096 bit',
62 `spubkey` text COMMENT '',
63 `sprvkey` text COMMENT '',
64 `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
65 `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
66 `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
67 `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unkown viewers',
68 `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
69 `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
70 `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
71 `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
72 `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
73 `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
74 `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
75 `pwdreset` varchar(255) COMMENT 'Password reset request token',
76 `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
77 `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
78 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
79 `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
80 `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
81 `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
82 `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
83 `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
84 `allow_cid` mediumtext COMMENT 'default permission for this user',
85 `allow_gid` mediumtext COMMENT 'default permission for this user',
86 `deny_cid` mediumtext COMMENT 'default permission for this user',
87 `deny_gid` mediumtext COMMENT 'default permission for this user',
88 `openidserver` text COMMENT '',
90 INDEX `nickname` (`nickname`(32)),
91 INDEX `parent-uid` (`parent-uid`),
92 INDEX `guid` (`guid`),
93 INDEX `email` (`email`(64)),
94 FOREIGN KEY (`parent-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
95 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
100 CREATE TABLE IF NOT EXISTS `item-uri` (
101 `id` int unsigned NOT NULL auto_increment,
102 `uri` varbinary(255) NOT NULL COMMENT 'URI of an item',
103 `guid` varbinary(255) COMMENT 'A unique identifier for an item',
105 UNIQUE INDEX `uri` (`uri`),
106 INDEX `guid` (`guid`)
107 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
112 CREATE TABLE IF NOT EXISTS `contact` (
113 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
114 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
115 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
116 `updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last contact update',
117 `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
118 `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
119 `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
120 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
121 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network of the contact',
122 `protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol 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 `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
129 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
130 `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
131 `avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '',
132 `photo` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
133 `thumb` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
134 `micro` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
135 `header` varchar(255) COMMENT 'Header picture',
136 `site-pubkey` text COMMENT '',
137 `issued-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
138 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
139 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
140 `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
141 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
142 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
143 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
144 `pubkey` text COMMENT 'RSA public key 4096 bit',
145 `prvkey` text COMMENT 'RSA private key 4096 bit',
146 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
147 `request` varchar(255) COMMENT '',
148 `notify` varchar(255) COMMENT '',
149 `poll` varchar(255) COMMENT '',
150 `confirm` varchar(255) COMMENT '',
151 `subscribe` varchar(255) COMMENT '',
152 `poco` varchar(255) COMMENT '',
153 `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT '',
154 `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT '',
155 `usehub` boolean NOT NULL DEFAULT '0' COMMENT '',
156 `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
157 `hub-verify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
158 `last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
159 `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
160 `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
161 `failed` boolean COMMENT 'Connection failed',
162 `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
163 `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
164 `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
165 `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
166 `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
167 `last-discovery` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last follower discovery',
168 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
169 `blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
170 `block_reason` text COMMENT 'Node-wide block reason',
171 `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
172 `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
173 `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum',
174 `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group',
175 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT '',
176 `manually-approve` boolean COMMENT '',
177 `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
178 `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
179 `pending` boolean NOT NULL DEFAULT '1' COMMENT '',
180 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
181 `rating` tinyint NOT NULL DEFAULT 0 COMMENT '',
182 `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
183 `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
184 `baseurl` varchar(255) DEFAULT '' COMMENT 'baseurl of the contact',
185 `gsid` int unsigned COMMENT 'Global Server ID',
186 `reason` text COMMENT '',
187 `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT '',
188 `info` mediumtext COMMENT '',
189 `profile-id` int unsigned COMMENT 'Deprecated',
190 `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
191 `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
192 `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
193 `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
194 `ffi_keyword_denylist` text COMMENT '',
196 INDEX `uid_name` (`uid`,`name`(190)),
197 INDEX `self_uid` (`self`,`uid`),
198 INDEX `alias_uid` (`alias`(128),`uid`),
199 INDEX `pending_uid` (`pending`,`uid`),
200 INDEX `blocked_uid` (`blocked`,`uid`),
201 INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
202 INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
203 INDEX `batch_contact-type` (`batch`(64),`contact-type`),
204 INDEX `addr_uid` (`addr`(128),`uid`),
205 INDEX `nurl_uid` (`nurl`(128),`uid`),
206 INDEX `nick_uid` (`nick`(128),`uid`),
207 INDEX `attag_uid` (`attag`(96),`uid`),
208 INDEX `dfrn-id` (`dfrn-id`(64)),
209 INDEX `issued-id` (`issued-id`(64)),
210 INDEX `network_uid_lastupdate` (`network`,`uid`,`last-update`),
211 INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`),
212 INDEX `uid_lastitem` (`uid`,`last-item`),
213 INDEX `baseurl` (`baseurl`(64)),
214 INDEX `uid_contact-type` (`uid`,`contact-type`),
215 INDEX `uid_self_contact-type` (`uid`,`self`,`contact-type`),
216 INDEX `self_network_uid` (`self`,`network`,`uid`),
217 INDEX `gsid` (`gsid`),
218 INDEX `uri-id` (`uri-id`),
219 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
220 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
221 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
222 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
227 CREATE TABLE IF NOT EXISTS `tag` (
228 `id` int unsigned NOT NULL auto_increment COMMENT '',
229 `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
230 `url` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
232 UNIQUE INDEX `type_name_url` (`name`,`url`),
234 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
239 CREATE TABLE IF NOT EXISTS `clients` (
240 `client_id` varchar(20) NOT NULL COMMENT '',
241 `pw` varchar(20) NOT NULL DEFAULT '' COMMENT '',
242 `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
243 `name` text COMMENT '',
244 `icon` text COMMENT '',
245 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
246 PRIMARY KEY(`client_id`),
248 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
249 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
252 -- TABLE permissionset
254 CREATE TABLE IF NOT EXISTS `permissionset` (
255 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
256 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
257 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
258 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
259 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
260 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
262 INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`uid`,`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30)),
263 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
264 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
269 CREATE TABLE IF NOT EXISTS `verb` (
270 `id` smallint unsigned NOT NULL auto_increment,
271 `name` varchar(100) NOT NULL DEFAULT '' COMMENT '',
273 INDEX `name` (`name`)
274 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activity Verbs';
277 -- TABLE 2fa_app_specific_password
279 CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
280 `id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
281 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
282 `description` varchar(255) COMMENT 'Description of the usage of the password',
283 `hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
284 `generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
285 `last_used` datetime COMMENT 'Datetime the password was last used',
287 INDEX `uid_description` (`uid`,`description`(190)),
288 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
289 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
292 -- TABLE 2fa_recovery_codes
294 CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
295 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
296 `code` varchar(50) NOT NULL COMMENT 'Recovery code string',
297 `generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
298 `used` datetime COMMENT 'Datetime the code was used',
299 PRIMARY KEY(`uid`,`code`),
300 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
301 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
304 -- TABLE 2fa_trusted_browser
306 CREATE TABLE IF NOT EXISTS `2fa_trusted_browser` (
307 `cookie_hash` varchar(80) NOT NULL COMMENT 'Trusted cookie hash',
308 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
309 `user_agent` text COMMENT 'User agent string',
310 `created` datetime NOT NULL COMMENT 'Datetime the trusted browser was recorded',
311 `last_used` datetime COMMENT 'Datetime the trusted browser was last used',
312 PRIMARY KEY(`cookie_hash`),
314 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
315 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication trusted browsers';
320 CREATE TABLE IF NOT EXISTS `addon` (
321 `id` int unsigned NOT NULL auto_increment COMMENT '',
322 `name` varchar(50) NOT NULL DEFAULT '' COMMENT 'addon base (file)name',
323 `version` varchar(50) NOT NULL DEFAULT '' COMMENT 'currently unused',
324 `installed` boolean NOT NULL DEFAULT '0' COMMENT 'currently always 1',
325 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'currently unused',
326 `timestamp` int unsigned NOT NULL DEFAULT 0 COMMENT 'file timestamp to check for reloads',
327 `plugin_admin` boolean NOT NULL DEFAULT '0' COMMENT '1 = has admin config, 0 = has no admin config',
329 INDEX `installed_name` (`installed`,`name`),
330 UNIQUE INDEX `name` (`name`)
331 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registered addons';
336 CREATE TABLE IF NOT EXISTS `apcontact` (
337 `url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
338 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
339 `uuid` varchar(255) COMMENT '',
340 `type` varchar(20) NOT NULL COMMENT '',
341 `following` varchar(255) COMMENT '',
342 `followers` varchar(255) COMMENT '',
343 `inbox` varchar(255) NOT NULL COMMENT '',
344 `outbox` varchar(255) COMMENT '',
345 `sharedinbox` varchar(255) COMMENT '',
346 `manually-approve` boolean COMMENT '',
347 `discoverable` boolean COMMENT 'Mastodon extension: true if profile is published in their directory',
348 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
349 `name` varchar(255) COMMENT '',
350 `about` text COMMENT '',
351 `photo` varchar(255) COMMENT '',
352 `header` varchar(255) COMMENT 'Header picture',
353 `addr` varchar(255) COMMENT '',
354 `alias` varchar(255) COMMENT '',
355 `pubkey` text COMMENT '',
356 `subscribe` varchar(255) COMMENT '',
357 `baseurl` varchar(255) COMMENT 'baseurl of the ap contact',
358 `gsid` int unsigned COMMENT 'Global Server ID',
359 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
360 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
361 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
362 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
363 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
365 INDEX `addr` (`addr`(32)),
366 INDEX `alias` (`alias`(190)),
367 INDEX `followers` (`followers`(190)),
368 INDEX `baseurl` (`baseurl`(190)),
369 INDEX `sharedinbox` (`sharedinbox`(190)),
370 INDEX `gsid` (`gsid`),
371 UNIQUE INDEX `uri-id` (`uri-id`),
372 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
373 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
374 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
379 CREATE TABLE IF NOT EXISTS `application` (
380 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
381 `client_id` varchar(64) NOT NULL COMMENT '',
382 `client_secret` varchar(64) NOT NULL COMMENT '',
383 `name` varchar(255) NOT NULL COMMENT '',
384 `redirect_uri` varchar(255) NOT NULL COMMENT '',
385 `website` varchar(255) COMMENT '',
386 `scopes` varchar(255) COMMENT '',
387 `read` boolean COMMENT 'Read scope',
388 `write` boolean COMMENT 'Write scope',
389 `follow` boolean COMMENT 'Follow scope',
390 `push` boolean COMMENT 'Push scope',
392 UNIQUE INDEX `client_id` (`client_id`)
393 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth application';
396 -- TABLE application-token
398 CREATE TABLE IF NOT EXISTS `application-token` (
399 `application-id` int unsigned NOT NULL COMMENT '',
400 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
401 `code` varchar(64) NOT NULL COMMENT '',
402 `access_token` varchar(64) NOT NULL COMMENT '',
403 `created_at` datetime NOT NULL COMMENT 'creation time',
404 `scopes` varchar(255) COMMENT '',
405 `read` boolean COMMENT 'Read scope',
406 `write` boolean COMMENT 'Write scope',
407 `follow` boolean COMMENT 'Follow scope',
408 `push` boolean COMMENT 'Push scope',
409 PRIMARY KEY(`application-id`,`uid`),
410 INDEX `uid_id` (`uid`,`application-id`),
411 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
412 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
413 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth user token';
418 CREATE TABLE IF NOT EXISTS `attach` (
419 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
420 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
421 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
422 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
423 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
424 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
425 `data` longblob NOT NULL COMMENT 'file data',
426 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
427 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
428 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
429 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
430 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
431 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
432 `backend-class` tinytext COMMENT 'Storage backend class',
433 `backend-ref` text COMMENT 'Storage backend data reference',
436 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
437 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
442 CREATE TABLE IF NOT EXISTS `auth_codes` (
443 `id` varchar(40) NOT NULL COMMENT '',
444 `client_id` varchar(20) NOT NULL DEFAULT '' COMMENT '',
445 `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
446 `expires` int NOT NULL DEFAULT 0 COMMENT '',
447 `scope` varchar(250) NOT NULL DEFAULT '' COMMENT '',
449 INDEX `client_id` (`client_id`),
450 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE
451 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
456 CREATE TABLE IF NOT EXISTS `cache` (
457 `k` varbinary(255) NOT NULL COMMENT 'cache key',
458 `v` mediumtext COMMENT 'cached serialized value',
459 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
460 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
462 INDEX `k_expires` (`k`,`expires`)
463 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
468 CREATE TABLE IF NOT EXISTS `challenge` (
469 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
470 `challenge` varchar(255) NOT NULL DEFAULT '' COMMENT '',
471 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
472 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
473 `type` varchar(255) NOT NULL DEFAULT '' COMMENT '',
474 `last_update` varchar(255) NOT NULL DEFAULT '' COMMENT '',
476 INDEX `expire` (`expire`)
477 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
482 CREATE TABLE IF NOT EXISTS `config` (
483 `id` int unsigned NOT NULL auto_increment COMMENT '',
484 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
485 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
486 `v` mediumtext COMMENT '',
488 UNIQUE INDEX `cat_k` (`cat`,`k`)
489 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
492 -- TABLE contact-relation
494 CREATE TABLE IF NOT EXISTS `contact-relation` (
495 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
496 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
497 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
498 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
499 `follows` boolean NOT NULL DEFAULT '0' COMMENT '',
500 PRIMARY KEY(`cid`,`relation-cid`),
501 INDEX `relation-cid` (`relation-cid`),
502 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
503 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
504 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
509 CREATE TABLE IF NOT EXISTS `conv` (
510 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
511 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
512 `recips` text COMMENT 'sender_handle;recipient_handle',
513 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
514 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
515 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
516 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
517 `subject` text COMMENT 'subject of initial message',
520 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
521 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
524 -- TABLE conversation
526 CREATE TABLE IF NOT EXISTS `conversation` (
527 `item-uri` varbinary(255) NOT NULL COMMENT 'Original URI of the item - unrelated to the table with the same name',
528 `reply-to-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'URI to which this item is a reply',
529 `conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI',
530 `conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link',
531 `protocol` tinyint unsigned NOT NULL DEFAULT 255 COMMENT 'The protocol of the item',
532 `direction` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'How the message arrived here: 1=push, 2=pull',
533 `source` mediumtext COMMENT 'Original source',
534 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Receiving date',
535 PRIMARY KEY(`item-uri`),
536 INDEX `conversation-uri` (`conversation-uri`),
537 INDEX `received` (`received`)
538 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Raw data and structure information for messages';
541 -- TABLE delayed-post
543 CREATE TABLE IF NOT EXISTS `delayed-post` (
544 `id` int unsigned NOT NULL auto_increment,
545 `uri` varchar(255) COMMENT 'URI of the post that will be distributed later',
546 `uid` mediumint unsigned COMMENT 'Owner User id',
547 `delayed` datetime COMMENT 'delay time',
549 UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
550 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
551 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
554 -- TABLE diaspora-interaction
556 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
557 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
558 `interaction` mediumtext COMMENT 'The Diaspora interaction',
559 PRIMARY KEY(`uri-id`),
560 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
561 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
566 CREATE TABLE IF NOT EXISTS `event` (
567 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
568 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
569 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
570 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
571 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
572 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the event uri',
573 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
574 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
575 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
576 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
577 `summary` text COMMENT 'short description or title of the event',
578 `desc` text COMMENT 'event description',
579 `location` text COMMENT 'event location',
580 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
581 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
582 `adjust` boolean NOT NULL DEFAULT '1' COMMENT 'adjust to timezone of the recipient (0 or 1)',
583 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
584 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
585 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
586 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
587 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
589 INDEX `uid_start` (`uid`,`start`),
591 INDEX `uri-id` (`uri-id`),
592 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
593 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
594 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
595 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
600 CREATE TABLE IF NOT EXISTS `fcontact` (
601 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
602 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
603 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
604 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the fcontact url',
605 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
606 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
607 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
608 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
609 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
610 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
611 `notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
612 `poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
613 `confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
614 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
615 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
616 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
617 `pubkey` text COMMENT '',
618 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
620 INDEX `addr` (`addr`(32)),
621 UNIQUE INDEX `url` (`url`(190)),
622 UNIQUE INDEX `uri-id` (`uri-id`),
623 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
624 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
629 CREATE TABLE IF NOT EXISTS `fsuggest` (
630 `id` int unsigned NOT NULL auto_increment COMMENT '',
631 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
632 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
633 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
634 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
635 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
636 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
637 `note` text COMMENT '',
638 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
642 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
643 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
644 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
649 CREATE TABLE IF NOT EXISTS `group` (
650 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
651 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
652 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
653 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
654 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
657 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
658 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
661 -- TABLE group_member
663 CREATE TABLE IF NOT EXISTS `group_member` (
664 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
665 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
666 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
668 INDEX `contactid` (`contact-id`),
669 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
670 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
671 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
672 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
677 CREATE TABLE IF NOT EXISTS `gserver-tag` (
678 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
679 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
680 PRIMARY KEY(`gserver-id`,`tag`),
682 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
683 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
688 CREATE TABLE IF NOT EXISTS `hook` (
689 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
690 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
691 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
692 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
693 `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',
695 INDEX `priority` (`priority`),
696 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
697 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
702 CREATE TABLE IF NOT EXISTS `host` (
703 `id` tinyint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
704 `name` varchar(128) NOT NULL DEFAULT '' COMMENT 'The hostname',
706 UNIQUE INDEX `name` (`name`)
707 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Hostname';
710 -- TABLE inbox-status
712 CREATE TABLE IF NOT EXISTS `inbox-status` (
713 `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
714 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
715 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
716 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
717 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
718 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
719 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
721 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
726 CREATE TABLE IF NOT EXISTS `intro` (
727 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
728 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
729 `fid` int unsigned COMMENT '',
730 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
731 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
732 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
733 `note` text COMMENT '',
734 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
735 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
736 `blocked` boolean NOT NULL DEFAULT '1' COMMENT '',
737 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
739 INDEX `contact-id` (`contact-id`),
741 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
742 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
743 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
748 CREATE TABLE IF NOT EXISTS `locks` (
749 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
750 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
751 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
752 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
753 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
755 INDEX `name_expires` (`name`,`expires`)
756 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
761 CREATE TABLE IF NOT EXISTS `mail` (
762 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
763 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
764 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
765 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
766 `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
767 `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
768 `contact-id` varchar(255) COMMENT 'contact.id',
769 `author-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the author of the mail',
770 `convid` int unsigned COMMENT 'conv.id',
771 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
772 `body` mediumtext COMMENT '',
773 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
774 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
775 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
776 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
777 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
778 `uri-id` int unsigned COMMENT 'Item-uri id of the related mail',
779 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
780 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related mail',
781 `thr-parent` varchar(255) COMMENT '',
782 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
783 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
785 INDEX `uid_seen` (`uid`,`seen`),
786 INDEX `convid` (`convid`),
787 INDEX `uri` (`uri`(64)),
788 INDEX `parent-uri` (`parent-uri`(64)),
789 INDEX `contactid` (`contact-id`(32)),
790 INDEX `author-id` (`author-id`),
791 INDEX `uri-id` (`uri-id`),
792 INDEX `parent-uri-id` (`parent-uri-id`),
793 INDEX `thr-parent-id` (`thr-parent-id`),
794 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
795 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
796 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
797 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
798 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
799 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
804 CREATE TABLE IF NOT EXISTS `mailacct` (
805 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
806 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
807 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
808 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
809 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
810 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
811 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
812 `pass` text COMMENT '',
813 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
814 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
815 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
816 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
817 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
820 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
821 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
826 CREATE TABLE IF NOT EXISTS `manage` (
827 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
828 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
829 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
831 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
833 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
834 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
835 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
838 -- TABLE notification
840 CREATE TABLE IF NOT EXISTS `notification` (
841 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
842 `uid` mediumint unsigned COMMENT 'Owner User id',
843 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
844 `type` tinyint unsigned COMMENT '',
845 `actor-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the actor that caused the notification',
846 `target-uri-id` int unsigned COMMENT 'Item-uri id of the related post',
847 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
848 `created` datetime COMMENT '',
849 `seen` boolean DEFAULT '0' COMMENT '',
851 UNIQUE INDEX `uid_vid_type_actor-id_target-uri-id` (`uid`,`vid`,`type`,`actor-id`,`target-uri-id`),
853 INDEX `actor-id` (`actor-id`),
854 INDEX `target-uri-id` (`target-uri-id`),
855 INDEX `parent-uri-id` (`parent-uri-id`),
856 INDEX `seen_uid` (`seen`,`uid`),
857 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
858 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
859 FOREIGN KEY (`actor-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
860 FOREIGN KEY (`target-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
861 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
862 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
867 CREATE TABLE IF NOT EXISTS `notify` (
868 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
869 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
870 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
871 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
872 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
873 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
874 `msg` mediumtext COMMENT '',
875 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
876 `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
877 `iid` int unsigned COMMENT '',
878 `parent` int unsigned COMMENT '',
879 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
880 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
881 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
882 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
883 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
884 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
885 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
887 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
888 INDEX `uid_date` (`uid`,`date`),
889 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
890 INDEX `uri-id` (`uri-id`),
891 INDEX `parent-uri-id` (`parent-uri-id`),
892 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
893 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
894 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
895 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
898 -- TABLE notify-threads
900 CREATE TABLE IF NOT EXISTS `notify-threads` (
901 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
902 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
903 `master-parent-item` int unsigned COMMENT 'Deprecated',
904 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
905 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
906 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
908 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
909 INDEX `receiver-uid` (`receiver-uid`),
910 INDEX `notify-id` (`notify-id`),
911 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
912 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
913 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
914 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
919 CREATE TABLE IF NOT EXISTS `oembed` (
920 `url` varbinary(255) NOT NULL COMMENT 'page url',
921 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
922 `content` mediumtext COMMENT 'OEmbed data of the page',
923 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
924 PRIMARY KEY(`url`,`maxwidth`),
925 INDEX `created` (`created`)
926 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
929 -- TABLE openwebauth-token
931 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
932 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
933 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
934 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
935 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
936 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
937 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
940 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
941 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
946 CREATE TABLE IF NOT EXISTS `parsed_url` (
947 `url_hash` binary(64) NOT NULL COMMENT 'page url hash',
948 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
949 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
950 `url` text NOT NULL COMMENT 'page url',
951 `content` mediumtext COMMENT 'page data',
952 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
953 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration',
954 PRIMARY KEY(`url_hash`,`guessing`,`oembed`),
955 INDEX `created` (`created`),
956 INDEX `expires` (`expires`)
957 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
962 CREATE TABLE IF NOT EXISTS `pconfig` (
963 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
964 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
965 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
966 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
967 `v` mediumtext COMMENT 'Value',
969 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
970 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
971 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
976 CREATE TABLE IF NOT EXISTS `photo` (
977 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
978 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
979 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
980 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
981 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
982 `hash` char(32) COMMENT 'hash value of the photo',
983 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
984 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
985 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
986 `desc` text COMMENT '',
987 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
988 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
989 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
990 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
991 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
992 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
993 `data` mediumblob NOT NULL COMMENT '',
994 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
995 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
996 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
997 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
998 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
999 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
1000 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
1001 `backend-class` tinytext COMMENT 'Storage backend class',
1002 `backend-ref` text COMMENT 'Storage backend data reference',
1003 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1005 INDEX `contactid` (`contact-id`),
1006 INDEX `uid_contactid` (`uid`,`contact-id`),
1007 INDEX `uid_profile` (`uid`,`profile`),
1008 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
1009 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
1010 INDEX `resource-id` (`resource-id`),
1011 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1012 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1013 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1018 CREATE TABLE IF NOT EXISTS `post` (
1019 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1020 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1021 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1022 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1023 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1024 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1025 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1026 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1027 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1028 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1029 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1030 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1031 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1032 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1033 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1034 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1035 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1036 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1037 PRIMARY KEY(`uri-id`),
1038 INDEX `parent-uri-id` (`parent-uri-id`),
1039 INDEX `thr-parent-id` (`thr-parent-id`),
1040 INDEX `external-id` (`external-id`),
1041 INDEX `owner-id` (`owner-id`),
1042 INDEX `author-id` (`author-id`),
1043 INDEX `causer-id` (`causer-id`),
1044 INDEX `vid` (`vid`),
1045 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1046 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1047 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1048 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1049 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1050 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1051 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1052 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1053 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
1056 -- TABLE post-category
1058 CREATE TABLE IF NOT EXISTS `post-category` (
1059 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1060 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1061 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1062 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1063 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1064 INDEX `uri-id` (`tid`),
1065 INDEX `uid` (`uid`),
1066 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1067 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1068 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1069 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1072 -- TABLE post-content
1074 CREATE TABLE IF NOT EXISTS `post-content` (
1075 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1076 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1077 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1078 `body` mediumtext COMMENT 'item body content',
1079 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1080 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1081 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1082 `language` text COMMENT 'Language information about this post',
1083 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1084 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1085 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1086 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1087 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1088 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1089 `target` text COMMENT 'JSON encoded target structure if used',
1090 `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',
1091 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1092 PRIMARY KEY(`uri-id`),
1093 INDEX `plink` (`plink`(191)),
1094 INDEX `resource-id` (`resource-id`),
1095 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
1096 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1097 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1100 -- TABLE post-delivery-data
1102 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1103 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1104 `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',
1105 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1106 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1107 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1108 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1109 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1110 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1111 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1112 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1113 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1114 PRIMARY KEY(`uri-id`),
1115 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1116 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1121 CREATE TABLE IF NOT EXISTS `post-link` (
1122 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1123 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1124 `url` varbinary(511) NOT NULL COMMENT 'External URL',
1125 `mimetype` varchar(60) COMMENT '',
1127 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1128 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1129 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post related external links';
1134 CREATE TABLE IF NOT EXISTS `post-media` (
1135 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1136 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1137 `url` varbinary(511) NOT NULL COMMENT 'Media URL',
1138 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1139 `mimetype` varchar(60) COMMENT '',
1140 `height` smallint unsigned COMMENT 'Height of the media',
1141 `width` smallint unsigned COMMENT 'Width of the media',
1142 `size` int unsigned COMMENT 'Media size',
1143 `preview` varbinary(255) COMMENT 'Preview URL',
1144 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1145 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1146 `description` text COMMENT '',
1147 `name` varchar(255) COMMENT 'Name of the media',
1148 `author-url` varbinary(255) COMMENT 'URL of the author of the media',
1149 `author-name` varchar(255) COMMENT 'Name of the author of the media',
1150 `author-image` varbinary(255) COMMENT 'Image of the author of the media',
1151 `publisher-url` varbinary(255) COMMENT 'URL of the publisher of the media',
1152 `publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
1153 `publisher-image` varbinary(255) COMMENT 'Image of the publisher of the media',
1155 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1156 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1157 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1162 CREATE TABLE IF NOT EXISTS `post-tag` (
1163 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1164 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1165 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1166 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1167 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1168 INDEX `tid` (`tid`),
1169 INDEX `cid` (`cid`),
1170 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1171 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1172 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1173 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1176 -- TABLE post-thread
1178 CREATE TABLE IF NOT EXISTS `post-thread` (
1179 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1180 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1181 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1182 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1183 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1184 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1185 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1186 `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',
1187 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1188 PRIMARY KEY(`uri-id`),
1189 INDEX `owner-id` (`owner-id`),
1190 INDEX `author-id` (`author-id`),
1191 INDEX `causer-id` (`causer-id`),
1192 INDEX `received` (`received`),
1193 INDEX `commented` (`commented`),
1194 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1195 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1196 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1197 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1198 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1203 CREATE TABLE IF NOT EXISTS `post-user` (
1204 `id` int unsigned NOT NULL auto_increment,
1205 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1206 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1207 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1208 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1209 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1210 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1211 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1212 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1213 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1214 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1215 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1216 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1217 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1218 `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
1219 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1220 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1221 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1222 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1223 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1224 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1225 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1226 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1227 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1228 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1229 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1230 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1231 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1232 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1233 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1235 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1236 INDEX `uri-id` (`uri-id`),
1237 INDEX `parent-uri-id` (`parent-uri-id`),
1238 INDEX `thr-parent-id` (`thr-parent-id`),
1239 INDEX `external-id` (`external-id`),
1240 INDEX `owner-id` (`owner-id`),
1241 INDEX `author-id` (`author-id`),
1242 INDEX `causer-id` (`causer-id`),
1243 INDEX `vid` (`vid`),
1244 INDEX `contact-id` (`contact-id`),
1245 INDEX `event-id` (`event-id`),
1246 INDEX `psid` (`psid`),
1247 INDEX `author-id_uid` (`author-id`,`uid`),
1248 INDEX `author-id_received` (`author-id`,`received`),
1249 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1250 INDEX `uid_contactid` (`uid`,`contact-id`),
1251 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1252 INDEX `uid_unseen` (`uid`,`unseen`),
1253 INDEX `uid_hidden_uri-id` (`uid`,`hidden`,`uri-id`),
1254 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1255 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1256 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1257 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1258 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1259 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1260 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1261 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1262 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1263 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1264 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1265 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1266 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1269 -- TABLE post-thread-user
1271 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1272 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1273 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1274 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1275 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1276 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1277 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1278 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1279 `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',
1280 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1281 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1282 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'The thread is pinned on the profile page',
1283 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1284 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1285 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1286 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1287 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1288 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1289 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1290 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1291 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1292 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1293 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1294 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1295 PRIMARY KEY(`uid`,`uri-id`),
1296 INDEX `uri-id` (`uri-id`),
1297 INDEX `owner-id` (`owner-id`),
1298 INDEX `author-id` (`author-id`),
1299 INDEX `causer-id` (`causer-id`),
1300 INDEX `uid` (`uid`),
1301 INDEX `contact-id` (`contact-id`),
1302 INDEX `psid` (`psid`),
1303 INDEX `post-user-id` (`post-user-id`),
1304 INDEX `commented` (`commented`),
1305 INDEX `uid_received` (`uid`,`received`),
1306 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1307 INDEX `uid_pinned` (`uid`,`pinned`),
1308 INDEX `uid_commented` (`uid`,`commented`),
1309 INDEX `uid_starred` (`uid`,`starred`),
1310 INDEX `uid_mention` (`uid`,`mention`),
1311 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1312 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1313 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1314 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1315 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1316 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1317 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1318 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1319 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1322 -- TABLE post-user-notification
1324 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1325 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1326 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1327 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1328 PRIMARY KEY(`uid`,`uri-id`),
1329 INDEX `uri-id` (`uri-id`),
1330 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1331 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1332 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1337 CREATE TABLE IF NOT EXISTS `process` (
1338 `pid` int unsigned NOT NULL COMMENT '',
1339 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1340 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1342 INDEX `command` (`command`)
1343 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1348 CREATE TABLE IF NOT EXISTS `profile` (
1349 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1350 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1351 `profile-name` varchar(255) COMMENT 'Deprecated',
1352 `is-default` boolean COMMENT 'Deprecated',
1353 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1354 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1355 `pdesc` varchar(255) COMMENT 'Deprecated',
1356 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1357 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1358 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1359 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1360 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1361 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1362 `hometown` varchar(255) COMMENT 'Deprecated',
1363 `gender` varchar(32) COMMENT 'Deprecated',
1364 `marital` varchar(255) COMMENT 'Deprecated',
1365 `with` text COMMENT 'Deprecated',
1366 `howlong` datetime COMMENT 'Deprecated',
1367 `sexual` varchar(255) COMMENT 'Deprecated',
1368 `politic` varchar(255) COMMENT 'Deprecated',
1369 `religion` varchar(255) COMMENT 'Deprecated',
1370 `pub_keywords` text COMMENT '',
1371 `prv_keywords` text COMMENT '',
1372 `likes` text COMMENT 'Deprecated',
1373 `dislikes` text COMMENT 'Deprecated',
1374 `about` text COMMENT 'Profile description',
1375 `summary` varchar(255) COMMENT 'Deprecated',
1376 `music` text COMMENT 'Deprecated',
1377 `book` text COMMENT 'Deprecated',
1378 `tv` text COMMENT 'Deprecated',
1379 `film` text COMMENT 'Deprecated',
1380 `interest` text COMMENT 'Deprecated',
1381 `romance` text COMMENT 'Deprecated',
1382 `work` text COMMENT 'Deprecated',
1383 `education` text COMMENT 'Deprecated',
1384 `contact` text COMMENT 'Deprecated',
1385 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1386 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1387 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1388 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1389 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1390 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1392 INDEX `uid_is-default` (`uid`,`is-default`),
1393 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1394 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1395 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1398 -- TABLE profile_check
1400 CREATE TABLE IF NOT EXISTS `profile_check` (
1401 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1402 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1403 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1404 `dfrn_id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1405 `sec` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1406 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1408 INDEX `uid` (`uid`),
1409 INDEX `cid` (`cid`),
1410 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1411 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1412 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='DFRN remote auth use';
1415 -- TABLE profile_field
1417 CREATE TABLE IF NOT EXISTS `profile_field` (
1418 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1419 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1420 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1421 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1422 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1423 `value` text COMMENT 'Value of the field',
1424 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1425 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1427 INDEX `uid` (`uid`),
1428 INDEX `order` (`order`),
1429 INDEX `psid` (`psid`),
1430 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1431 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1432 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1435 -- TABLE push_subscriber
1437 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1438 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1439 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1440 `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1441 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1442 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1443 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1444 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1445 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1446 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1447 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1449 INDEX `next_try` (`next_try`),
1450 INDEX `uid` (`uid`),
1451 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1452 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1457 CREATE TABLE IF NOT EXISTS `register` (
1458 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1459 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1460 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1461 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1462 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1463 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1464 `note` text COMMENT '',
1466 INDEX `uid` (`uid`),
1467 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1468 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1473 CREATE TABLE IF NOT EXISTS `search` (
1474 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1475 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1476 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1478 INDEX `uid_term` (`uid`,`term`(64)),
1479 INDEX `term` (`term`(64)),
1480 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1481 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1486 CREATE TABLE IF NOT EXISTS `session` (
1487 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1488 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1489 `data` text COMMENT '',
1490 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1492 INDEX `sid` (`sid`(64)),
1493 INDEX `expire` (`expire`)
1494 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1499 CREATE TABLE IF NOT EXISTS `storage` (
1500 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1501 `data` longblob NOT NULL COMMENT 'file data',
1503 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1508 CREATE TABLE IF NOT EXISTS `tokens` (
1509 `id` varchar(40) NOT NULL COMMENT '',
1510 `secret` text COMMENT '',
1511 `client_id` varchar(20) NOT NULL DEFAULT '',
1512 `expires` int NOT NULL DEFAULT 0 COMMENT '',
1513 `scope` varchar(200) NOT NULL DEFAULT '' COMMENT '',
1514 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1516 INDEX `client_id` (`client_id`),
1517 INDEX `uid` (`uid`),
1518 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1519 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1520 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
1525 CREATE TABLE IF NOT EXISTS `userd` (
1526 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1527 `username` varchar(255) NOT NULL COMMENT '',
1529 INDEX `username` (`username`(32))
1530 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1533 -- TABLE user-contact
1535 CREATE TABLE IF NOT EXISTS `user-contact` (
1536 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1537 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1538 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1539 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1540 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1541 PRIMARY KEY(`uid`,`cid`),
1542 INDEX `cid` (`cid`),
1543 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1544 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) 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 -- TABLE workerqueue
1559 CREATE TABLE IF NOT EXISTS `workerqueue` (
1560 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
1561 `command` varchar(100) COMMENT 'Task command',
1562 `parameter` mediumtext COMMENT 'Task parameter',
1563 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
1564 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
1565 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
1566 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
1567 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1568 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1569 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
1571 INDEX `command` (`command`),
1572 INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
1573 INDEX `done_executed` (`done`,`executed`),
1574 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
1575 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
1576 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
1577 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
1578 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
1579 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
1582 -- VIEW application-view
1584 DROP VIEW IF EXISTS `application-view`;
1585 CREATE VIEW `application-view` AS SELECT
1586 `application`.`id` AS `id`,
1587 `application-token`.`uid` AS `uid`,
1588 `application`.`name` AS `name`,
1589 `application`.`redirect_uri` AS `redirect_uri`,
1590 `application`.`website` AS `website`,
1591 `application`.`client_id` AS `client_id`,
1592 `application`.`client_secret` AS `client_secret`,
1593 `application-token`.`code` AS `code`,
1594 `application-token`.`access_token` AS `access_token`,
1595 `application-token`.`created_at` AS `created_at`,
1596 `application-token`.`scopes` AS `scopes`,
1597 `application-token`.`read` AS `read`,
1598 `application-token`.`write` AS `write`,
1599 `application-token`.`follow` AS `follow`,
1600 `application-token`.`push` AS `push`
1601 FROM `application-token`
1602 INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`;
1605 -- VIEW post-user-view
1607 DROP VIEW IF EXISTS `post-user-view`;
1608 CREATE VIEW `post-user-view` AS SELECT
1609 `post-user`.`id` AS `id`,
1610 `post-user`.`id` AS `post-user-id`,
1611 `post-user`.`uid` AS `uid`,
1612 `parent-post`.`id` AS `parent`,
1613 `item-uri`.`uri` AS `uri`,
1614 `post-user`.`uri-id` AS `uri-id`,
1615 `parent-item-uri`.`uri` AS `parent-uri`,
1616 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1617 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1618 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1619 `item-uri`.`guid` AS `guid`,
1620 `post-user`.`wall` AS `wall`,
1621 `post-user`.`gravity` AS `gravity`,
1622 `external-item-uri`.`uri` AS `extid`,
1623 `post-user`.`external-id` AS `external-id`,
1624 `post-user`.`created` AS `created`,
1625 `post-user`.`edited` AS `edited`,
1626 `post-thread-user`.`commented` AS `commented`,
1627 `post-user`.`received` AS `received`,
1628 `post-thread-user`.`changed` AS `changed`,
1629 `post-user`.`post-type` AS `post-type`,
1630 `post-user`.`post-reason` AS `post-reason`,
1631 `post-user`.`private` AS `private`,
1632 `post-thread-user`.`pubmail` AS `pubmail`,
1633 `post-user`.`visible` AS `visible`,
1634 `post-thread-user`.`starred` AS `starred`,
1635 `post-thread-user`.`pinned` AS `pinned`,
1636 `post-user`.`unseen` AS `unseen`,
1637 `post-user`.`deleted` AS `deleted`,
1638 `post-user`.`origin` AS `origin`,
1639 `post-thread-user`.`origin` AS `parent-origin`,
1640 `post-thread-user`.`forum_mode` AS `forum_mode`,
1641 `post-thread-user`.`mention` AS `mention`,
1642 `post-user`.`global` AS `global`,
1643 `post-user`.`network` AS `network`,
1644 `post-user`.`vid` AS `vid`,
1645 `post-user`.`psid` AS `psid`,
1646 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1647 `post-content`.`title` AS `title`,
1648 `post-content`.`content-warning` AS `content-warning`,
1649 `post-content`.`raw-body` AS `raw-body`,
1650 `post-content`.`body` AS `body`,
1651 `post-content`.`rendered-hash` AS `rendered-hash`,
1652 `post-content`.`rendered-html` AS `rendered-html`,
1653 `post-content`.`language` AS `language`,
1654 `post-content`.`plink` AS `plink`,
1655 `post-content`.`location` AS `location`,
1656 `post-content`.`coord` AS `coord`,
1657 `post-content`.`app` AS `app`,
1658 `post-content`.`object-type` AS `object-type`,
1659 `post-content`.`object` AS `object`,
1660 `post-content`.`target-type` AS `target-type`,
1661 `post-content`.`target` AS `target`,
1662 `post-content`.`resource-id` AS `resource-id`,
1663 `post-user`.`contact-id` AS `contact-id`,
1664 `contact`.`url` AS `contact-link`,
1665 `contact`.`addr` AS `contact-addr`,
1666 `contact`.`name` AS `contact-name`,
1667 `contact`.`nick` AS `contact-nick`,
1668 `contact`.`thumb` AS `contact-avatar`,
1669 `contact`.`network` AS `contact-network`,
1670 `contact`.`blocked` AS `contact-blocked`,
1671 `contact`.`hidden` AS `contact-hidden`,
1672 `contact`.`readonly` AS `contact-readonly`,
1673 `contact`.`archive` AS `contact-archive`,
1674 `contact`.`pending` AS `contact-pending`,
1675 `contact`.`rel` AS `contact-rel`,
1676 `contact`.`uid` AS `contact-uid`,
1677 `contact`.`contact-type` AS `contact-contact-type`,
1678 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1679 `contact`.`self` AS `self`,
1680 `contact`.`id` AS `cid`,
1681 `contact`.`alias` AS `alias`,
1682 `contact`.`photo` AS `photo`,
1683 `contact`.`name-date` AS `name-date`,
1684 `contact`.`uri-date` AS `uri-date`,
1685 `contact`.`avatar-date` AS `avatar-date`,
1686 `contact`.`thumb` AS `thumb`,
1687 `contact`.`dfrn-id` AS `dfrn-id`,
1688 `post-user`.`author-id` AS `author-id`,
1689 `author`.`url` AS `author-link`,
1690 `author`.`addr` AS `author-addr`,
1691 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1692 `author`.`nick` AS `author-nick`,
1693 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1694 `author`.`network` AS `author-network`,
1695 `author`.`blocked` AS `author-blocked`,
1696 `author`.`hidden` AS `author-hidden`,
1697 `post-user`.`owner-id` AS `owner-id`,
1698 `owner`.`url` AS `owner-link`,
1699 `owner`.`addr` AS `owner-addr`,
1700 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1701 `owner`.`nick` AS `owner-nick`,
1702 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1703 `owner`.`network` AS `owner-network`,
1704 `owner`.`blocked` AS `owner-blocked`,
1705 `owner`.`hidden` AS `owner-hidden`,
1706 `owner`.`contact-type` AS `owner-contact-type`,
1707 `post-user`.`causer-id` AS `causer-id`,
1708 `causer`.`url` AS `causer-link`,
1709 `causer`.`addr` AS `causer-addr`,
1710 `causer`.`name` AS `causer-name`,
1711 `causer`.`nick` AS `causer-nick`,
1712 `causer`.`thumb` AS `causer-avatar`,
1713 `causer`.`network` AS `causer-network`,
1714 `causer`.`blocked` AS `causer-blocked`,
1715 `causer`.`hidden` AS `causer-hidden`,
1716 `causer`.`contact-type` AS `causer-contact-type`,
1717 `post-delivery-data`.`postopts` AS `postopts`,
1718 `post-delivery-data`.`inform` AS `inform`,
1719 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1720 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1721 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1722 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1723 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1724 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1725 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1726 `post-user`.`event-id` AS `event-id`,
1727 `event`.`created` AS `event-created`,
1728 `event`.`edited` AS `event-edited`,
1729 `event`.`start` AS `event-start`,
1730 `event`.`finish` AS `event-finish`,
1731 `event`.`summary` AS `event-summary`,
1732 `event`.`desc` AS `event-desc`,
1733 `event`.`location` AS `event-location`,
1734 `event`.`type` AS `event-type`,
1735 `event`.`nofinish` AS `event-nofinish`,
1736 `event`.`adjust` AS `event-adjust`,
1737 `event`.`ignore` AS `event-ignore`,
1738 `diaspora-interaction`.`interaction` AS `signed_text`,
1739 `parent-item-uri`.`guid` AS `parent-guid`,
1740 `parent-post`.`network` AS `parent-network`,
1741 `parent-post`.`author-id` AS `parent-author-id`,
1742 `parent-post-author`.`url` AS `parent-author-link`,
1743 `parent-post-author`.`name` AS `parent-author-name`,
1744 `parent-post-author`.`network` AS `parent-author-network`,
1745 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1746 `parent-post-author`.`hidden` AS `parent-author-hidden`
1748 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
1749 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
1750 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
1751 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
1752 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
1753 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
1754 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1755 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1756 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1757 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1758 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1759 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
1760 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
1761 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
1762 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
1763 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
1764 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1767 -- VIEW post-thread-user-view
1769 DROP VIEW IF EXISTS `post-thread-user-view`;
1770 CREATE VIEW `post-thread-user-view` AS SELECT
1771 `post-user`.`id` AS `id`,
1772 `post-user`.`id` AS `post-user-id`,
1773 `post-thread-user`.`uid` AS `uid`,
1774 `parent-post`.`id` AS `parent`,
1775 `item-uri`.`uri` AS `uri`,
1776 `post-thread-user`.`uri-id` AS `uri-id`,
1777 `parent-item-uri`.`uri` AS `parent-uri`,
1778 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1779 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1780 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1781 `item-uri`.`guid` AS `guid`,
1782 `post-thread-user`.`wall` AS `wall`,
1783 `post-user`.`gravity` AS `gravity`,
1784 `external-item-uri`.`uri` AS `extid`,
1785 `post-user`.`external-id` AS `external-id`,
1786 `post-thread-user`.`created` AS `created`,
1787 `post-user`.`edited` AS `edited`,
1788 `post-thread-user`.`commented` AS `commented`,
1789 `post-thread-user`.`received` AS `received`,
1790 `post-thread-user`.`changed` AS `changed`,
1791 `post-user`.`post-type` AS `post-type`,
1792 `post-user`.`post-reason` AS `post-reason`,
1793 `post-user`.`private` AS `private`,
1794 `post-thread-user`.`pubmail` AS `pubmail`,
1795 `post-thread-user`.`ignored` AS `ignored`,
1796 `post-user`.`visible` AS `visible`,
1797 `post-thread-user`.`starred` AS `starred`,
1798 `post-thread-user`.`pinned` AS `pinned`,
1799 `post-thread-user`.`unseen` AS `unseen`,
1800 `post-user`.`deleted` AS `deleted`,
1801 `post-thread-user`.`origin` AS `origin`,
1802 `post-thread-user`.`forum_mode` AS `forum_mode`,
1803 `post-thread-user`.`mention` AS `mention`,
1804 `post-user`.`global` AS `global`,
1805 `post-thread-user`.`network` AS `network`,
1806 `post-user`.`vid` AS `vid`,
1807 `post-thread-user`.`psid` AS `psid`,
1808 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1809 `post-content`.`title` AS `title`,
1810 `post-content`.`content-warning` AS `content-warning`,
1811 `post-content`.`raw-body` AS `raw-body`,
1812 `post-content`.`body` AS `body`,
1813 `post-content`.`rendered-hash` AS `rendered-hash`,
1814 `post-content`.`rendered-html` AS `rendered-html`,
1815 `post-content`.`language` AS `language`,
1816 `post-content`.`plink` AS `plink`,
1817 `post-content`.`location` AS `location`,
1818 `post-content`.`coord` AS `coord`,
1819 `post-content`.`app` AS `app`,
1820 `post-content`.`object-type` AS `object-type`,
1821 `post-content`.`object` AS `object`,
1822 `post-content`.`target-type` AS `target-type`,
1823 `post-content`.`target` AS `target`,
1824 `post-content`.`resource-id` AS `resource-id`,
1825 `post-thread-user`.`contact-id` AS `contact-id`,
1826 `contact`.`url` AS `contact-link`,
1827 `contact`.`addr` AS `contact-addr`,
1828 `contact`.`name` AS `contact-name`,
1829 `contact`.`nick` AS `contact-nick`,
1830 `contact`.`thumb` AS `contact-avatar`,
1831 `contact`.`network` AS `contact-network`,
1832 `contact`.`blocked` AS `contact-blocked`,
1833 `contact`.`hidden` AS `contact-hidden`,
1834 `contact`.`readonly` AS `contact-readonly`,
1835 `contact`.`archive` AS `contact-archive`,
1836 `contact`.`pending` AS `contact-pending`,
1837 `contact`.`rel` AS `contact-rel`,
1838 `contact`.`uid` AS `contact-uid`,
1839 `contact`.`contact-type` AS `contact-contact-type`,
1840 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1841 `contact`.`self` AS `self`,
1842 `contact`.`id` AS `cid`,
1843 `contact`.`alias` AS `alias`,
1844 `contact`.`photo` AS `photo`,
1845 `contact`.`name-date` AS `name-date`,
1846 `contact`.`uri-date` AS `uri-date`,
1847 `contact`.`avatar-date` AS `avatar-date`,
1848 `contact`.`thumb` AS `thumb`,
1849 `contact`.`dfrn-id` AS `dfrn-id`,
1850 `post-thread-user`.`author-id` AS `author-id`,
1851 `author`.`url` AS `author-link`,
1852 `author`.`addr` AS `author-addr`,
1853 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1854 `author`.`nick` AS `author-nick`,
1855 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1856 `author`.`network` AS `author-network`,
1857 `author`.`blocked` AS `author-blocked`,
1858 `author`.`hidden` AS `author-hidden`,
1859 `post-thread-user`.`owner-id` AS `owner-id`,
1860 `owner`.`url` AS `owner-link`,
1861 `owner`.`addr` AS `owner-addr`,
1862 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1863 `owner`.`nick` AS `owner-nick`,
1864 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1865 `owner`.`network` AS `owner-network`,
1866 `owner`.`blocked` AS `owner-blocked`,
1867 `owner`.`hidden` AS `owner-hidden`,
1868 `owner`.`contact-type` AS `owner-contact-type`,
1869 `post-thread-user`.`causer-id` AS `causer-id`,
1870 `causer`.`url` AS `causer-link`,
1871 `causer`.`addr` AS `causer-addr`,
1872 `causer`.`name` AS `causer-name`,
1873 `causer`.`nick` AS `causer-nick`,
1874 `causer`.`thumb` AS `causer-avatar`,
1875 `causer`.`network` AS `causer-network`,
1876 `causer`.`blocked` AS `causer-blocked`,
1877 `causer`.`hidden` AS `causer-hidden`,
1878 `causer`.`contact-type` AS `causer-contact-type`,
1879 `post-delivery-data`.`postopts` AS `postopts`,
1880 `post-delivery-data`.`inform` AS `inform`,
1881 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1882 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1883 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1884 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1885 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1886 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1887 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1888 `post-user`.`event-id` AS `event-id`,
1889 `event`.`created` AS `event-created`,
1890 `event`.`edited` AS `event-edited`,
1891 `event`.`start` AS `event-start`,
1892 `event`.`finish` AS `event-finish`,
1893 `event`.`summary` AS `event-summary`,
1894 `event`.`desc` AS `event-desc`,
1895 `event`.`location` AS `event-location`,
1896 `event`.`type` AS `event-type`,
1897 `event`.`nofinish` AS `event-nofinish`,
1898 `event`.`adjust` AS `event-adjust`,
1899 `event`.`ignore` AS `event-ignore`,
1900 `diaspora-interaction`.`interaction` AS `signed_text`,
1901 `parent-item-uri`.`guid` AS `parent-guid`,
1902 `parent-post`.`network` AS `parent-network`,
1903 `parent-post`.`author-id` AS `parent-author-id`,
1904 `parent-post-author`.`url` AS `parent-author-link`,
1905 `parent-post-author`.`name` AS `parent-author-name`,
1906 `parent-post-author`.`network` AS `parent-author-network`,
1907 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1908 `parent-post-author`.`hidden` AS `parent-author-hidden`
1909 FROM `post-thread-user`
1910 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
1911 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
1912 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
1913 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
1914 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
1915 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
1916 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1917 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1918 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1919 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1920 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1921 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
1922 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
1923 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
1924 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
1925 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`
1926 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1931 DROP VIEW IF EXISTS `post-view`;
1932 CREATE VIEW `post-view` AS SELECT
1933 `item-uri`.`uri` AS `uri`,
1934 `post`.`uri-id` AS `uri-id`,
1935 `parent-item-uri`.`uri` AS `parent-uri`,
1936 `post`.`parent-uri-id` AS `parent-uri-id`,
1937 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1938 `post`.`thr-parent-id` AS `thr-parent-id`,
1939 `item-uri`.`guid` AS `guid`,
1940 `post`.`gravity` AS `gravity`,
1941 `external-item-uri`.`uri` AS `extid`,
1942 `post`.`external-id` AS `external-id`,
1943 `post`.`created` AS `created`,
1944 `post`.`edited` AS `edited`,
1945 `post-thread`.`commented` AS `commented`,
1946 `post`.`received` AS `received`,
1947 `post-thread`.`changed` AS `changed`,
1948 `post`.`post-type` AS `post-type`,
1949 `post`.`private` AS `private`,
1950 `post`.`visible` AS `visible`,
1951 `post`.`deleted` AS `deleted`,
1952 `post`.`global` AS `global`,
1953 `post`.`network` AS `network`,
1954 `post`.`vid` AS `vid`,
1955 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1956 `post-content`.`title` AS `title`,
1957 `post-content`.`content-warning` AS `content-warning`,
1958 `post-content`.`raw-body` AS `raw-body`,
1959 `post-content`.`body` AS `body`,
1960 `post-content`.`rendered-hash` AS `rendered-hash`,
1961 `post-content`.`rendered-html` AS `rendered-html`,
1962 `post-content`.`language` AS `language`,
1963 `post-content`.`plink` AS `plink`,
1964 `post-content`.`location` AS `location`,
1965 `post-content`.`coord` AS `coord`,
1966 `post-content`.`app` AS `app`,
1967 `post-content`.`object-type` AS `object-type`,
1968 `post-content`.`object` AS `object`,
1969 `post-content`.`target-type` AS `target-type`,
1970 `post-content`.`target` AS `target`,
1971 `post-content`.`resource-id` AS `resource-id`,
1972 `post`.`author-id` AS `contact-id`,
1973 `author`.`url` AS `contact-link`,
1974 `author`.`addr` AS `contact-addr`,
1975 `author`.`name` AS `contact-name`,
1976 `author`.`nick` AS `contact-nick`,
1977 `author`.`thumb` AS `contact-avatar`,
1978 `author`.`network` AS `contact-network`,
1979 `author`.`blocked` AS `contact-blocked`,
1980 `author`.`hidden` AS `contact-hidden`,
1981 `author`.`readonly` AS `contact-readonly`,
1982 `author`.`archive` AS `contact-archive`,
1983 `author`.`pending` AS `contact-pending`,
1984 `author`.`rel` AS `contact-rel`,
1985 `author`.`uid` AS `contact-uid`,
1986 `author`.`contact-type` AS `contact-contact-type`,
1987 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
1989 `author`.`id` AS `cid`,
1990 `author`.`alias` AS `alias`,
1991 `author`.`photo` AS `photo`,
1992 `author`.`name-date` AS `name-date`,
1993 `author`.`uri-date` AS `uri-date`,
1994 `author`.`avatar-date` AS `avatar-date`,
1995 `author`.`thumb` AS `thumb`,
1996 `author`.`dfrn-id` AS `dfrn-id`,
1997 `post`.`author-id` AS `author-id`,
1998 `author`.`url` AS `author-link`,
1999 `author`.`addr` AS `author-addr`,
2000 `author`.`name` AS `author-name`,
2001 `author`.`nick` AS `author-nick`,
2002 `author`.`thumb` AS `author-avatar`,
2003 `author`.`network` AS `author-network`,
2004 `author`.`blocked` AS `author-blocked`,
2005 `author`.`hidden` AS `author-hidden`,
2006 `post`.`owner-id` AS `owner-id`,
2007 `owner`.`url` AS `owner-link`,
2008 `owner`.`addr` AS `owner-addr`,
2009 `owner`.`name` AS `owner-name`,
2010 `owner`.`nick` AS `owner-nick`,
2011 `owner`.`thumb` AS `owner-avatar`,
2012 `owner`.`network` AS `owner-network`,
2013 `owner`.`blocked` AS `owner-blocked`,
2014 `owner`.`hidden` AS `owner-hidden`,
2015 `owner`.`contact-type` AS `owner-contact-type`,
2016 `post`.`causer-id` AS `causer-id`,
2017 `causer`.`url` AS `causer-link`,
2018 `causer`.`addr` AS `causer-addr`,
2019 `causer`.`name` AS `causer-name`,
2020 `causer`.`nick` AS `causer-nick`,
2021 `causer`.`thumb` AS `causer-avatar`,
2022 `causer`.`network` AS `causer-network`,
2023 `causer`.`blocked` AS `causer-blocked`,
2024 `causer`.`hidden` AS `causer-hidden`,
2025 `causer`.`contact-type` AS `causer-contact-type`,
2026 `diaspora-interaction`.`interaction` AS `signed_text`,
2027 `parent-item-uri`.`guid` AS `parent-guid`,
2028 `parent-post`.`network` AS `parent-network`,
2029 `parent-post`.`author-id` AS `parent-author-id`,
2030 `parent-post-author`.`url` AS `parent-author-link`,
2031 `parent-post-author`.`name` AS `parent-author-name`,
2032 `parent-post-author`.`network` AS `parent-author-network`,
2033 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2034 `parent-post-author`.`hidden` AS `parent-author-hidden`
2036 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
2037 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
2038 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
2039 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
2040 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
2041 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2042 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2043 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2044 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2045 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
2046 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
2047 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2048 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2051 -- VIEW post-thread-view
2053 DROP VIEW IF EXISTS `post-thread-view`;
2054 CREATE VIEW `post-thread-view` AS SELECT
2055 `item-uri`.`uri` AS `uri`,
2056 `post-thread`.`uri-id` AS `uri-id`,
2057 `parent-item-uri`.`uri` AS `parent-uri`,
2058 `post`.`parent-uri-id` AS `parent-uri-id`,
2059 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2060 `post`.`thr-parent-id` AS `thr-parent-id`,
2061 `item-uri`.`guid` AS `guid`,
2062 `post`.`gravity` AS `gravity`,
2063 `external-item-uri`.`uri` AS `extid`,
2064 `post`.`external-id` AS `external-id`,
2065 `post-thread`.`created` AS `created`,
2066 `post`.`edited` AS `edited`,
2067 `post-thread`.`commented` AS `commented`,
2068 `post-thread`.`received` AS `received`,
2069 `post-thread`.`changed` AS `changed`,
2070 `post`.`post-type` AS `post-type`,
2071 `post`.`private` AS `private`,
2072 `post`.`visible` AS `visible`,
2073 `post`.`deleted` AS `deleted`,
2074 `post`.`global` AS `global`,
2075 `post-thread`.`network` AS `network`,
2076 `post`.`vid` AS `vid`,
2077 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2078 `post-content`.`title` AS `title`,
2079 `post-content`.`content-warning` AS `content-warning`,
2080 `post-content`.`raw-body` AS `raw-body`,
2081 `post-content`.`body` AS `body`,
2082 `post-content`.`rendered-hash` AS `rendered-hash`,
2083 `post-content`.`rendered-html` AS `rendered-html`,
2084 `post-content`.`language` AS `language`,
2085 `post-content`.`plink` AS `plink`,
2086 `post-content`.`location` AS `location`,
2087 `post-content`.`coord` AS `coord`,
2088 `post-content`.`app` AS `app`,
2089 `post-content`.`object-type` AS `object-type`,
2090 `post-content`.`object` AS `object`,
2091 `post-content`.`target-type` AS `target-type`,
2092 `post-content`.`target` AS `target`,
2093 `post-content`.`resource-id` AS `resource-id`,
2094 `post-thread`.`author-id` AS `contact-id`,
2095 `author`.`url` AS `contact-link`,
2096 `author`.`addr` AS `contact-addr`,
2097 `author`.`name` AS `contact-name`,
2098 `author`.`nick` AS `contact-nick`,
2099 `author`.`thumb` AS `contact-avatar`,
2100 `author`.`network` AS `contact-network`,
2101 `author`.`blocked` AS `contact-blocked`,
2102 `author`.`hidden` AS `contact-hidden`,
2103 `author`.`readonly` AS `contact-readonly`,
2104 `author`.`archive` AS `contact-archive`,
2105 `author`.`pending` AS `contact-pending`,
2106 `author`.`rel` AS `contact-rel`,
2107 `author`.`uid` AS `contact-uid`,
2108 `author`.`contact-type` AS `contact-contact-type`,
2109 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2111 `author`.`id` AS `cid`,
2112 `author`.`alias` AS `alias`,
2113 `author`.`photo` AS `photo`,
2114 `author`.`name-date` AS `name-date`,
2115 `author`.`uri-date` AS `uri-date`,
2116 `author`.`avatar-date` AS `avatar-date`,
2117 `author`.`thumb` AS `thumb`,
2118 `author`.`dfrn-id` AS `dfrn-id`,
2119 `post-thread`.`author-id` AS `author-id`,
2120 `author`.`url` AS `author-link`,
2121 `author`.`addr` AS `author-addr`,
2122 `author`.`name` AS `author-name`,
2123 `author`.`nick` AS `author-nick`,
2124 `author`.`thumb` AS `author-avatar`,
2125 `author`.`network` AS `author-network`,
2126 `author`.`blocked` AS `author-blocked`,
2127 `author`.`hidden` AS `author-hidden`,
2128 `post-thread`.`owner-id` AS `owner-id`,
2129 `owner`.`url` AS `owner-link`,
2130 `owner`.`addr` AS `owner-addr`,
2131 `owner`.`name` AS `owner-name`,
2132 `owner`.`nick` AS `owner-nick`,
2133 `owner`.`thumb` AS `owner-avatar`,
2134 `owner`.`network` AS `owner-network`,
2135 `owner`.`blocked` AS `owner-blocked`,
2136 `owner`.`hidden` AS `owner-hidden`,
2137 `owner`.`contact-type` AS `owner-contact-type`,
2138 `post-thread`.`causer-id` AS `causer-id`,
2139 `causer`.`url` AS `causer-link`,
2140 `causer`.`addr` AS `causer-addr`,
2141 `causer`.`name` AS `causer-name`,
2142 `causer`.`nick` AS `causer-nick`,
2143 `causer`.`thumb` AS `causer-avatar`,
2144 `causer`.`network` AS `causer-network`,
2145 `causer`.`blocked` AS `causer-blocked`,
2146 `causer`.`hidden` AS `causer-hidden`,
2147 `causer`.`contact-type` AS `causer-contact-type`,
2148 `diaspora-interaction`.`interaction` AS `signed_text`,
2149 `parent-item-uri`.`guid` AS `parent-guid`,
2150 `parent-post`.`network` AS `parent-network`,
2151 `parent-post`.`author-id` AS `parent-author-id`,
2152 `parent-post-author`.`url` AS `parent-author-link`,
2153 `parent-post-author`.`name` AS `parent-author-name`,
2154 `parent-post-author`.`network` AS `parent-author-network`,
2155 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2156 `parent-post-author`.`hidden` AS `parent-author-hidden`
2158 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
2159 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
2160 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
2161 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
2162 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
2163 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2164 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2165 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2166 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2167 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
2168 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
2169 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2170 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2173 -- VIEW category-view
2175 DROP VIEW IF EXISTS `category-view`;
2176 CREATE VIEW `category-view` AS SELECT
2177 `post-category`.`uri-id` AS `uri-id`,
2178 `post-category`.`uid` AS `uid`,
2179 `post-category`.`type` AS `type`,
2180 `post-category`.`tid` AS `tid`,
2181 `tag`.`name` AS `name`,
2182 `tag`.`url` AS `url`
2183 FROM `post-category`
2184 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2189 DROP VIEW IF EXISTS `tag-view`;
2190 CREATE VIEW `tag-view` AS SELECT
2191 `post-tag`.`uri-id` AS `uri-id`,
2192 `post-tag`.`type` AS `type`,
2193 `post-tag`.`tid` AS `tid`,
2194 `post-tag`.`cid` AS `cid`,
2195 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2196 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
2198 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2199 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2202 -- VIEW network-item-view
2204 DROP VIEW IF EXISTS `network-item-view`;
2205 CREATE VIEW `network-item-view` AS SELECT
2206 `post-user`.`uri-id` AS `uri-id`,
2207 `parent-post`.`id` AS `parent`,
2208 `post-user`.`received` AS `received`,
2209 `post-thread-user`.`commented` AS `commented`,
2210 `post-user`.`created` AS `created`,
2211 `post-user`.`uid` AS `uid`,
2212 `post-thread-user`.`starred` AS `starred`,
2213 `post-thread-user`.`mention` AS `mention`,
2214 `post-user`.`network` AS `network`,
2215 `post-user`.`unseen` AS `unseen`,
2216 `post-user`.`gravity` AS `gravity`,
2217 `post-user`.`contact-id` AS `contact-id`,
2218 `ownercontact`.`contact-type` AS `contact-type`
2220 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2221 INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2222 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2223 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2224 INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2225 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2226 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2227 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2228 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
2229 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2230 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2233 -- VIEW network-thread-view
2235 DROP VIEW IF EXISTS `network-thread-view`;
2236 CREATE VIEW `network-thread-view` AS SELECT
2237 `post-thread-user`.`uri-id` AS `uri-id`,
2238 `parent-post`.`id` AS `parent`,
2239 `post-thread-user`.`received` AS `received`,
2240 `post-thread-user`.`commented` AS `commented`,
2241 `post-thread-user`.`created` AS `created`,
2242 `post-thread-user`.`uid` AS `uid`,
2243 `post-thread-user`.`starred` AS `starred`,
2244 `post-thread-user`.`mention` AS `mention`,
2245 `post-thread-user`.`network` AS `network`,
2246 `post-thread-user`.`contact-id` AS `contact-id`,
2247 `ownercontact`.`contact-type` AS `contact-type`
2248 FROM `post-thread-user`
2249 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2250 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2251 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2252 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2253 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2254 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2255 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2256 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2257 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2258 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2259 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2264 DROP VIEW IF EXISTS `owner-view`;
2265 CREATE VIEW `owner-view` AS SELECT
2266 `contact`.`id` AS `id`,
2267 `contact`.`uid` AS `uid`,
2268 `contact`.`created` AS `created`,
2269 `contact`.`updated` AS `updated`,
2270 `contact`.`self` AS `self`,
2271 `contact`.`remote_self` AS `remote_self`,
2272 `contact`.`rel` AS `rel`,
2273 `contact`.`duplex` AS `duplex`,
2274 `contact`.`network` AS `network`,
2275 `contact`.`protocol` AS `protocol`,
2276 `contact`.`name` AS `name`,
2277 `contact`.`nick` AS `nick`,
2278 `contact`.`location` AS `location`,
2279 `contact`.`about` AS `about`,
2280 `contact`.`keywords` AS `keywords`,
2281 `contact`.`gender` AS `gender`,
2282 `contact`.`xmpp` AS `xmpp`,
2283 `contact`.`attag` AS `attag`,
2284 `contact`.`avatar` AS `avatar`,
2285 `contact`.`photo` AS `photo`,
2286 `contact`.`thumb` AS `thumb`,
2287 `contact`.`micro` AS `micro`,
2288 `contact`.`header` AS `header`,
2289 `contact`.`site-pubkey` AS `site-pubkey`,
2290 `contact`.`issued-id` AS `issued-id`,
2291 `contact`.`dfrn-id` AS `dfrn-id`,
2292 `contact`.`url` AS `url`,
2293 `contact`.`nurl` AS `nurl`,
2294 `contact`.`uri-id` AS `uri-id`,
2295 `contact`.`addr` AS `addr`,
2296 `contact`.`alias` AS `alias`,
2297 `contact`.`pubkey` AS `pubkey`,
2298 `contact`.`prvkey` AS `prvkey`,
2299 `contact`.`batch` AS `batch`,
2300 `contact`.`request` AS `request`,
2301 `contact`.`notify` AS `notify`,
2302 `contact`.`poll` AS `poll`,
2303 `contact`.`confirm` AS `confirm`,
2304 `contact`.`poco` AS `poco`,
2305 `contact`.`aes_allow` AS `aes_allow`,
2306 `contact`.`ret-aes` AS `ret-aes`,
2307 `contact`.`usehub` AS `usehub`,
2308 `contact`.`subhub` AS `subhub`,
2309 `contact`.`hub-verify` AS `hub-verify`,
2310 `contact`.`last-update` AS `last-update`,
2311 `contact`.`success_update` AS `success_update`,
2312 `contact`.`failure_update` AS `failure_update`,
2313 `contact`.`name-date` AS `name-date`,
2314 `contact`.`uri-date` AS `uri-date`,
2315 `contact`.`avatar-date` AS `avatar-date`,
2316 `contact`.`avatar-date` AS `picdate`,
2317 `contact`.`term-date` AS `term-date`,
2318 `contact`.`last-item` AS `last-item`,
2319 `contact`.`priority` AS `priority`,
2320 `user`.`blocked` AS `blocked`,
2321 `contact`.`block_reason` AS `block_reason`,
2322 `contact`.`readonly` AS `readonly`,
2323 `contact`.`writable` AS `writable`,
2324 `contact`.`forum` AS `forum`,
2325 `contact`.`prv` AS `prv`,
2326 `contact`.`contact-type` AS `contact-type`,
2327 `contact`.`manually-approve` AS `manually-approve`,
2328 `contact`.`hidden` AS `hidden`,
2329 `contact`.`archive` AS `archive`,
2330 `contact`.`pending` AS `pending`,
2331 `contact`.`deleted` AS `deleted`,
2332 `contact`.`unsearchable` AS `unsearchable`,
2333 `contact`.`sensitive` AS `sensitive`,
2334 `contact`.`baseurl` AS `baseurl`,
2335 `contact`.`reason` AS `reason`,
2336 `contact`.`closeness` AS `closeness`,
2337 `contact`.`info` AS `info`,
2338 `contact`.`profile-id` AS `profile-id`,
2339 `contact`.`bdyear` AS `bdyear`,
2340 `contact`.`bd` AS `bd`,
2341 `contact`.`notify_new_posts` AS `notify_new_posts`,
2342 `contact`.`fetch_further_information` AS `fetch_further_information`,
2343 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2344 `user`.`parent-uid` AS `parent-uid`,
2345 `user`.`guid` AS `guid`,
2346 `user`.`nickname` AS `nickname`,
2347 `user`.`email` AS `email`,
2348 `user`.`openid` AS `openid`,
2349 `user`.`timezone` AS `timezone`,
2350 `user`.`language` AS `language`,
2351 `user`.`register_date` AS `register_date`,
2352 `user`.`login_date` AS `login_date`,
2353 `user`.`default-location` AS `default-location`,
2354 `user`.`allow_location` AS `allow_location`,
2355 `user`.`theme` AS `theme`,
2356 `user`.`pubkey` AS `upubkey`,
2357 `user`.`prvkey` AS `uprvkey`,
2358 `user`.`sprvkey` AS `sprvkey`,
2359 `user`.`spubkey` AS `spubkey`,
2360 `user`.`verified` AS `verified`,
2361 `user`.`blockwall` AS `blockwall`,
2362 `user`.`hidewall` AS `hidewall`,
2363 `user`.`blocktags` AS `blocktags`,
2364 `user`.`unkmail` AS `unkmail`,
2365 `user`.`cntunkmail` AS `cntunkmail`,
2366 `user`.`notify-flags` AS `notify-flags`,
2367 `user`.`page-flags` AS `page-flags`,
2368 `user`.`account-type` AS `account-type`,
2369 `user`.`prvnets` AS `prvnets`,
2370 `user`.`maxreq` AS `maxreq`,
2371 `user`.`expire` AS `expire`,
2372 `user`.`account_removed` AS `account_removed`,
2373 `user`.`account_expired` AS `account_expired`,
2374 `user`.`account_expires_on` AS `account_expires_on`,
2375 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2376 `user`.`def_gid` AS `def_gid`,
2377 `user`.`allow_cid` AS `allow_cid`,
2378 `user`.`allow_gid` AS `allow_gid`,
2379 `user`.`deny_cid` AS `deny_cid`,
2380 `user`.`deny_gid` AS `deny_gid`,
2381 `user`.`openidserver` AS `openidserver`,
2382 `profile`.`publish` AS `publish`,
2383 `profile`.`net-publish` AS `net-publish`,
2384 `profile`.`hide-friends` AS `hide-friends`,
2385 `profile`.`prv_keywords` AS `prv_keywords`,
2386 `profile`.`pub_keywords` AS `pub_keywords`,
2387 `profile`.`address` AS `address`,
2388 `profile`.`locality` AS `locality`,
2389 `profile`.`region` AS `region`,
2390 `profile`.`postal-code` AS `postal-code`,
2391 `profile`.`country-name` AS `country-name`,
2392 `profile`.`homepage` AS `homepage`,
2393 `profile`.`dob` AS `dob`
2395 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2396 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2399 -- VIEW account-view
2401 DROP VIEW IF EXISTS `account-view`;
2402 CREATE VIEW `account-view` AS SELECT
2403 `contact`.`id` AS `id`,
2404 `contact`.`url` AS `url`,
2405 `contact`.`nurl` AS `nurl`,
2406 `contact`.`uri-id` AS `uri-id`,
2407 `contact`.`addr` AS `addr`,
2408 `contact`.`alias` AS `alias`,
2409 `contact`.`name` AS `name`,
2410 `contact`.`nick` AS `nick`,
2411 `contact`.`about` AS `about`,
2412 `contact`.`keywords` AS `keywords`,
2413 `contact`.`xmpp` AS `xmpp`,
2414 `contact`.`avatar` AS `avatar`,
2415 `contact`.`photo` AS `photo`,
2416 `contact`.`thumb` AS `thumb`,
2417 `contact`.`micro` AS `micro`,
2418 `contact`.`header` AS `header`,
2419 `contact`.`created` AS `created`,
2420 `contact`.`updated` AS `updated`,
2421 `contact`.`network` AS `network`,
2422 `contact`.`protocol` AS `protocol`,
2423 `contact`.`location` AS `location`,
2424 `contact`.`attag` AS `attag`,
2425 `contact`.`pubkey` AS `pubkey`,
2426 `contact`.`prvkey` AS `prvkey`,
2427 `contact`.`subscribe` AS `subscribe`,
2428 `contact`.`last-update` AS `last-update`,
2429 `contact`.`success_update` AS `success_update`,
2430 `contact`.`failure_update` AS `failure_update`,
2431 `contact`.`failed` AS `failed`,
2432 `contact`.`last-item` AS `last-item`,
2433 `contact`.`last-discovery` AS `last-discovery`,
2434 `contact`.`contact-type` AS `contact-type`,
2435 `contact`.`manually-approve` AS `manually-approve`,
2436 `contact`.`unsearchable` AS `unsearchable`,
2437 `contact`.`sensitive` AS `sensitive`,
2438 `contact`.`baseurl` AS `baseurl`,
2439 `contact`.`gsid` AS `gsid`,
2440 `contact`.`info` AS `info`,
2441 `contact`.`bdyear` AS `bdyear`,
2442 `contact`.`bd` AS `bd`,
2443 `contact`.`poco` AS `poco`,
2444 `contact`.`name-date` AS `name-date`,
2445 `contact`.`uri-date` AS `uri-date`,
2446 `contact`.`avatar-date` AS `avatar-date`,
2447 `contact`.`term-date` AS `term-date`,
2448 `contact`.`hidden` AS `global-ignored`,
2449 `contact`.`blocked` AS `global-blocked`,
2450 `contact`.`hidden` AS `hidden`,
2451 `contact`.`archive` AS `archive`,
2452 `contact`.`deleted` AS `deleted`,
2453 `contact`.`blocked` AS `blocked`,
2454 `contact`.`request` AS `dfrn-request`,
2455 `contact`.`notify` AS `dfrn-notify`,
2456 `contact`.`poll` AS `dfrn-poll`,
2457 `contact`.`confirm` AS `dfrn-confirm`,
2458 `fcontact`.`guid` AS `diaspora-guid`,
2459 `fcontact`.`batch` AS `diaspora-batch`,
2460 `fcontact`.`notify` AS `diaspora-notify`,
2461 `fcontact`.`poll` AS `diaspora-poll`,
2462 `fcontact`.`alias` AS `diaspora-alias`,
2463 `apcontact`.`uuid` AS `ap-uuid`,
2464 `apcontact`.`type` AS `ap-type`,
2465 `apcontact`.`following` AS `ap-following`,
2466 `apcontact`.`followers` AS `ap-followers`,
2467 `apcontact`.`inbox` AS `ap-inbox`,
2468 `apcontact`.`outbox` AS `ap-outbox`,
2469 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2470 `apcontact`.`generator` AS `ap-generator`,
2471 `apcontact`.`following_count` AS `ap-following_count`,
2472 `apcontact`.`followers_count` AS `ap-followers_count`,
2473 `apcontact`.`statuses_count` AS `ap-statuses_count`
2475 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
2476 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = contact.`uri-id`
2477 WHERE `contact`.`uid` = 0;
2480 -- VIEW account-user-view
2482 DROP VIEW IF EXISTS `account-user-view`;
2483 CREATE VIEW `account-user-view` AS SELECT
2484 `ucontact`.`id` AS `id`,
2485 `contact`.`id` AS `pid`,
2486 `ucontact`.`uid` AS `uid`,
2487 `contact`.`url` AS `url`,
2488 `contact`.`nurl` AS `nurl`,
2489 `contact`.`uri-id` AS `uri-id`,
2490 `contact`.`addr` AS `addr`,
2491 `contact`.`alias` AS `alias`,
2492 `contact`.`name` AS `name`,
2493 `contact`.`nick` AS `nick`,
2494 `contact`.`about` AS `about`,
2495 `contact`.`keywords` AS `keywords`,
2496 `contact`.`xmpp` AS `xmpp`,
2497 `contact`.`avatar` AS `avatar`,
2498 `contact`.`photo` AS `photo`,
2499 `contact`.`thumb` AS `thumb`,
2500 `contact`.`micro` AS `micro`,
2501 `contact`.`header` AS `header`,
2502 `contact`.`created` AS `created`,
2503 `contact`.`updated` AS `updated`,
2504 `ucontact`.`self` AS `self`,
2505 `ucontact`.`remote_self` AS `remote_self`,
2506 `ucontact`.`rel` AS `rel`,
2507 `contact`.`network` AS `network`,
2508 `ucontact`.`protocol` AS `protocol`,
2509 `contact`.`location` AS `location`,
2510 `contact`.`attag` AS `attag`,
2511 `contact`.`pubkey` AS `pubkey`,
2512 `contact`.`prvkey` AS `prvkey`,
2513 `contact`.`subscribe` AS `subscribe`,
2514 `contact`.`last-update` AS `last-update`,
2515 `contact`.`success_update` AS `success_update`,
2516 `contact`.`failure_update` AS `failure_update`,
2517 `contact`.`failed` AS `failed`,
2518 `contact`.`last-item` AS `last-item`,
2519 `contact`.`last-discovery` AS `last-discovery`,
2520 `contact`.`contact-type` AS `contact-type`,
2521 `contact`.`manually-approve` AS `manually-approve`,
2522 `contact`.`unsearchable` AS `unsearchable`,
2523 `contact`.`sensitive` AS `sensitive`,
2524 `contact`.`baseurl` AS `baseurl`,
2525 `contact`.`gsid` AS `gsid`,
2526 `contact`.`info` AS `info`,
2527 `contact`.`bdyear` AS `bdyear`,
2528 `contact`.`bd` AS `bd`,
2529 `contact`.`poco` AS `poco`,
2530 `contact`.`name-date` AS `name-date`,
2531 `contact`.`uri-date` AS `uri-date`,
2532 `contact`.`avatar-date` AS `avatar-date`,
2533 `contact`.`term-date` AS `term-date`,
2534 `contact`.`hidden` AS `global-ignored`,
2535 `contact`.`blocked` AS `global-blocked`,
2536 `ucontact`.`hidden` AS `hidden`,
2537 `ucontact`.`archive` AS `archive`,
2538 `ucontact`.`pending` AS `pending`,
2539 `ucontact`.`deleted` AS `deleted`,
2540 `ucontact`.`notify_new_posts` AS `notify_new_posts`,
2541 `ucontact`.`fetch_further_information` AS `fetch_further_information`,
2542 `ucontact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2543 `ucontact`.`rating` AS `rating`,
2544 `ucontact`.`readonly` AS `readonly`,
2545 `ucontact`.`blocked` AS `blocked`,
2546 `ucontact`.`block_reason` AS `block_reason`,
2547 `ucontact`.`subhub` AS `subhub`,
2548 `ucontact`.`hub-verify` AS `hub-verify`,
2549 `ucontact`.`reason` AS `reason`,
2550 `ucontact`.`duplex` AS `dfrn-duplex`,
2551 `ucontact`.`ret-aes` AS `dfrn-ret-aes`,
2552 `ucontact`.`site-pubkey` AS `dfrn-site-pubkey`,
2553 `ucontact`.`issued-id` AS `dfrn-issued-id`,
2554 `ucontact`.`dfrn-id` AS `dfrn-id`,
2555 `ucontact`.`aes_allow` AS `dfrn-aes_allow`,
2556 `contact`.`request` AS `dfrn-request`,
2557 `contact`.`notify` AS `dfrn-notify`,
2558 `contact`.`poll` AS `dfrn-poll`,
2559 `contact`.`confirm` AS `dfrn-confirm`,
2560 `fcontact`.`guid` AS `diaspora-guid`,
2561 `fcontact`.`batch` AS `diaspora-batch`,
2562 `fcontact`.`notify` AS `diaspora-notify`,
2563 `fcontact`.`poll` AS `diaspora-poll`,
2564 `fcontact`.`alias` AS `diaspora-alias`,
2565 `apcontact`.`uuid` AS `ap-uuid`,
2566 `apcontact`.`type` AS `ap-type`,
2567 `apcontact`.`following` AS `ap-following`,
2568 `apcontact`.`followers` AS `ap-followers`,
2569 `apcontact`.`inbox` AS `ap-inbox`,
2570 `apcontact`.`outbox` AS `ap-outbox`,
2571 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2572 `apcontact`.`generator` AS `ap-generator`,
2573 `apcontact`.`following_count` AS `ap-following_count`,
2574 `apcontact`.`followers_count` AS `ap-followers_count`,
2575 `apcontact`.`statuses_count` AS `ap-statuses_count`
2576 FROM `contact` AS `ucontact`
2577 INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
2578 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
2579 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = `ucontact`.`uri-id` AND `fcontact`.`network` = 'dspr';
2582 -- VIEW pending-view
2584 DROP VIEW IF EXISTS `pending-view`;
2585 CREATE VIEW `pending-view` AS SELECT
2586 `register`.`id` AS `id`,
2587 `register`.`hash` AS `hash`,
2588 `register`.`created` AS `created`,
2589 `register`.`uid` AS `uid`,
2590 `register`.`password` AS `password`,
2591 `register`.`language` AS `language`,
2592 `register`.`note` AS `note`,
2593 `contact`.`self` AS `self`,
2594 `contact`.`name` AS `name`,
2595 `contact`.`url` AS `url`,
2596 `contact`.`micro` AS `micro`,
2597 `user`.`email` AS `email`,
2598 `contact`.`nick` AS `nick`
2600 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2601 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2604 -- VIEW tag-search-view
2606 DROP VIEW IF EXISTS `tag-search-view`;
2607 CREATE VIEW `tag-search-view` AS SELECT
2608 `post-tag`.`uri-id` AS `uri-id`,
2609 `post-user`.`uid` AS `uid`,
2610 `post-user`.`id` AS `iid`,
2611 `post-user`.`private` AS `private`,
2612 `post-user`.`wall` AS `wall`,
2613 `post-user`.`origin` AS `origin`,
2614 `post-user`.`global` AS `global`,
2615 `post-user`.`gravity` AS `gravity`,
2616 `post-user`.`received` AS `received`,
2617 `post-user`.`network` AS `network`,
2618 `post-user`.`author-id` AS `author-id`,
2619 `tag`.`name` AS `name`
2621 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
2622 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
2623 WHERE `post-tag`.`type` = 1;
2626 -- VIEW workerqueue-view
2628 DROP VIEW IF EXISTS `workerqueue-view`;
2629 CREATE VIEW `workerqueue-view` AS SELECT
2630 `process`.`pid` AS `pid`,
2631 `workerqueue`.`priority` AS `priority`
2633 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
2634 WHERE NOT `workerqueue`.`done`;