1 -- ------------------------------------------
2 -- Friendica 2021.06-rc (Siberian Iris)
3 -- DB_UPDATE_VERSION 1423
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 `contact` (
101 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
102 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
103 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
104 `updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last contact update',
105 `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
106 `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
107 `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
108 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
109 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network of the contact',
110 `protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
111 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
112 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
113 `location` varchar(255) DEFAULT '' COMMENT '',
114 `about` text COMMENT '',
115 `keywords` text COMMENT 'public keywords (interests) of the contact',
116 `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
117 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
118 `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
119 `avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '',
120 `photo` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
121 `thumb` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
122 `micro` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
123 `header` varchar(255) COMMENT 'Header picture',
124 `site-pubkey` text COMMENT '',
125 `issued-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
126 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
127 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
128 `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
129 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
130 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
131 `pubkey` text COMMENT 'RSA public key 4096 bit',
132 `prvkey` text COMMENT 'RSA private key 4096 bit',
133 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
134 `request` varchar(255) COMMENT '',
135 `notify` varchar(255) COMMENT '',
136 `poll` varchar(255) COMMENT '',
137 `confirm` varchar(255) COMMENT '',
138 `subscribe` varchar(255) COMMENT '',
139 `poco` varchar(255) COMMENT '',
140 `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT '',
141 `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT '',
142 `usehub` boolean NOT NULL DEFAULT '0' COMMENT '',
143 `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
144 `hub-verify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
145 `last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
146 `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
147 `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
148 `failed` boolean COMMENT 'Connection failed',
149 `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
150 `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
151 `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
152 `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
153 `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
154 `last-discovery` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last follower discovery',
155 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
156 `blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
157 `block_reason` text COMMENT 'Node-wide block reason',
158 `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
159 `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
160 `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum',
161 `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group',
162 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT '',
163 `manually-approve` boolean COMMENT '',
164 `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
165 `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
166 `pending` boolean NOT NULL DEFAULT '1' COMMENT '',
167 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
168 `rating` tinyint NOT NULL DEFAULT 0 COMMENT '',
169 `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
170 `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
171 `baseurl` varchar(255) DEFAULT '' COMMENT 'baseurl of the contact',
172 `gsid` int unsigned COMMENT 'Global Server ID',
173 `reason` text COMMENT '',
174 `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT '',
175 `info` mediumtext COMMENT '',
176 `profile-id` int unsigned COMMENT 'Deprecated',
177 `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
178 `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
179 `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
180 `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
181 `ffi_keyword_denylist` text COMMENT '',
183 INDEX `uid_name` (`uid`,`name`(190)),
184 INDEX `self_uid` (`self`,`uid`),
185 INDEX `alias_uid` (`alias`(128),`uid`),
186 INDEX `pending_uid` (`pending`,`uid`),
187 INDEX `blocked_uid` (`blocked`,`uid`),
188 INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
189 INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
190 INDEX `batch_contact-type` (`batch`(64),`contact-type`),
191 INDEX `addr_uid` (`addr`(128),`uid`),
192 INDEX `nurl_uid` (`nurl`(128),`uid`),
193 INDEX `nick_uid` (`nick`(128),`uid`),
194 INDEX `attag_uid` (`attag`(96),`uid`),
195 INDEX `dfrn-id` (`dfrn-id`(64)),
196 INDEX `issued-id` (`issued-id`(64)),
197 INDEX `network_uid_lastupdate` (`network`,`uid`,`last-update`),
198 INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`),
199 INDEX `uid_lastitem` (`uid`,`last-item`),
200 INDEX `baseurl` (`baseurl`(64)),
201 INDEX `uid_contact-type` (`uid`,`contact-type`),
202 INDEX `uid_self_contact-type` (`uid`,`self`,`contact-type`),
203 INDEX `self_network_uid` (`self`,`network`,`uid`),
204 INDEX `gsid` (`gsid`),
205 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
206 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
207 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
212 CREATE TABLE IF NOT EXISTS `item-uri` (
213 `id` int unsigned NOT NULL auto_increment,
214 `uri` varbinary(255) NOT NULL COMMENT 'URI of an item',
215 `guid` varbinary(255) COMMENT 'A unique identifier for an item',
217 UNIQUE INDEX `uri` (`uri`),
218 INDEX `guid` (`guid`)
219 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
224 CREATE TABLE IF NOT EXISTS `tag` (
225 `id` int unsigned NOT NULL auto_increment COMMENT '',
226 `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
227 `url` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
229 UNIQUE INDEX `type_name_url` (`name`,`url`),
231 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
236 CREATE TABLE IF NOT EXISTS `clients` (
237 `client_id` varchar(20) NOT NULL COMMENT '',
238 `pw` varchar(20) NOT NULL DEFAULT '' COMMENT '',
239 `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
240 `name` text COMMENT '',
241 `icon` text COMMENT '',
242 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
243 PRIMARY KEY(`client_id`),
245 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
246 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
249 -- TABLE permissionset
251 CREATE TABLE IF NOT EXISTS `permissionset` (
252 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
253 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
254 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
255 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
256 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
257 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
259 INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`uid`,`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30)),
260 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
261 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
266 CREATE TABLE IF NOT EXISTS `verb` (
267 `id` smallint unsigned NOT NULL auto_increment,
268 `name` varchar(100) NOT NULL DEFAULT '' COMMENT '',
270 INDEX `name` (`name`)
271 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activity Verbs';
274 -- TABLE 2fa_app_specific_password
276 CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
277 `id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
278 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
279 `description` varchar(255) COMMENT 'Description of the usage of the password',
280 `hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
281 `generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
282 `last_used` datetime COMMENT 'Datetime the password was last used',
284 INDEX `uid_description` (`uid`,`description`(190)),
285 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
286 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
289 -- TABLE 2fa_recovery_codes
291 CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
292 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
293 `code` varchar(50) NOT NULL COMMENT 'Recovery code string',
294 `generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
295 `used` datetime COMMENT 'Datetime the code was used',
296 PRIMARY KEY(`uid`,`code`),
297 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
298 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
301 -- TABLE 2fa_trusted_browser
303 CREATE TABLE IF NOT EXISTS `2fa_trusted_browser` (
304 `cookie_hash` varchar(80) NOT NULL COMMENT 'Trusted cookie hash',
305 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
306 `user_agent` text COMMENT 'User agent string',
307 `created` datetime NOT NULL COMMENT 'Datetime the trusted browser was recorded',
308 `last_used` datetime COMMENT 'Datetime the trusted browser was last used',
309 PRIMARY KEY(`cookie_hash`),
311 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
312 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication trusted browsers';
317 CREATE TABLE IF NOT EXISTS `addon` (
318 `id` int unsigned NOT NULL auto_increment COMMENT '',
319 `name` varchar(50) NOT NULL DEFAULT '' COMMENT 'addon base (file)name',
320 `version` varchar(50) NOT NULL DEFAULT '' COMMENT 'currently unused',
321 `installed` boolean NOT NULL DEFAULT '0' COMMENT 'currently always 1',
322 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'currently unused',
323 `timestamp` int unsigned NOT NULL DEFAULT 0 COMMENT 'file timestamp to check for reloads',
324 `plugin_admin` boolean NOT NULL DEFAULT '0' COMMENT '1 = has admin config, 0 = has no admin config',
326 INDEX `installed_name` (`installed`,`name`),
327 UNIQUE INDEX `name` (`name`)
328 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registered addons';
333 CREATE TABLE IF NOT EXISTS `apcontact` (
334 `url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
335 `uuid` varchar(255) COMMENT '',
336 `type` varchar(20) NOT NULL COMMENT '',
337 `following` varchar(255) COMMENT '',
338 `followers` varchar(255) COMMENT '',
339 `inbox` varchar(255) NOT NULL COMMENT '',
340 `outbox` varchar(255) COMMENT '',
341 `sharedinbox` varchar(255) COMMENT '',
342 `manually-approve` boolean COMMENT '',
343 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
344 `name` varchar(255) COMMENT '',
345 `about` text COMMENT '',
346 `photo` varchar(255) COMMENT '',
347 `header` varchar(255) COMMENT 'Header picture',
348 `addr` varchar(255) COMMENT '',
349 `alias` varchar(255) COMMENT '',
350 `pubkey` text COMMENT '',
351 `subscribe` varchar(255) COMMENT '',
352 `baseurl` varchar(255) COMMENT 'baseurl of the ap contact',
353 `gsid` int unsigned COMMENT 'Global Server ID',
354 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
355 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
356 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
357 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
358 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
360 INDEX `addr` (`addr`(32)),
361 INDEX `alias` (`alias`(190)),
362 INDEX `followers` (`followers`(190)),
363 INDEX `baseurl` (`baseurl`(190)),
364 INDEX `sharedinbox` (`sharedinbox`(190)),
365 INDEX `gsid` (`gsid`),
366 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
367 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
372 CREATE TABLE IF NOT EXISTS `application` (
373 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
374 `client_id` varchar(64) NOT NULL COMMENT '',
375 `client_secret` varchar(64) NOT NULL COMMENT '',
376 `name` varchar(255) NOT NULL COMMENT '',
377 `redirect_uri` varchar(255) NOT NULL COMMENT '',
378 `website` varchar(255) COMMENT '',
379 `scopes` varchar(255) COMMENT '',
380 `read` boolean COMMENT 'Read scope',
381 `write` boolean COMMENT 'Write scope',
382 `follow` boolean COMMENT 'Follow scope',
383 `push` boolean COMMENT 'Push scope',
385 UNIQUE INDEX `client_id` (`client_id`)
386 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth application';
389 -- TABLE application-token
391 CREATE TABLE IF NOT EXISTS `application-token` (
392 `application-id` int unsigned NOT NULL COMMENT '',
393 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
394 `code` varchar(64) NOT NULL COMMENT '',
395 `access_token` varchar(64) NOT NULL COMMENT '',
396 `created_at` datetime NOT NULL COMMENT 'creation time',
397 `scopes` varchar(255) COMMENT '',
398 `read` boolean COMMENT 'Read scope',
399 `write` boolean COMMENT 'Write scope',
400 `follow` boolean COMMENT 'Follow scope',
401 `push` boolean COMMENT 'Push scope',
402 PRIMARY KEY(`application-id`,`uid`),
403 INDEX `uid_id` (`uid`,`application-id`),
404 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
405 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
406 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth user token';
411 CREATE TABLE IF NOT EXISTS `attach` (
412 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
413 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
414 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
415 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
416 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
417 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
418 `data` longblob NOT NULL COMMENT 'file data',
419 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
420 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
421 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
422 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
423 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
424 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
425 `backend-class` tinytext COMMENT 'Storage backend class',
426 `backend-ref` text COMMENT 'Storage backend data reference',
429 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
430 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
435 CREATE TABLE IF NOT EXISTS `auth_codes` (
436 `id` varchar(40) NOT NULL COMMENT '',
437 `client_id` varchar(20) NOT NULL DEFAULT '' COMMENT '',
438 `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
439 `expires` int NOT NULL DEFAULT 0 COMMENT '',
440 `scope` varchar(250) NOT NULL DEFAULT '' COMMENT '',
442 INDEX `client_id` (`client_id`),
443 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE
444 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
449 CREATE TABLE IF NOT EXISTS `cache` (
450 `k` varbinary(255) NOT NULL COMMENT 'cache key',
451 `v` mediumtext COMMENT 'cached serialized value',
452 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
453 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
455 INDEX `k_expires` (`k`,`expires`)
456 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
461 CREATE TABLE IF NOT EXISTS `challenge` (
462 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
463 `challenge` varchar(255) NOT NULL DEFAULT '' COMMENT '',
464 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
465 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
466 `type` varchar(255) NOT NULL DEFAULT '' COMMENT '',
467 `last_update` varchar(255) NOT NULL DEFAULT '' COMMENT '',
469 INDEX `expire` (`expire`)
470 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
475 CREATE TABLE IF NOT EXISTS `config` (
476 `id` int unsigned NOT NULL auto_increment COMMENT '',
477 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
478 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
479 `v` mediumtext COMMENT '',
481 UNIQUE INDEX `cat_k` (`cat`,`k`)
482 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
485 -- TABLE contact-relation
487 CREATE TABLE IF NOT EXISTS `contact-relation` (
488 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
489 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
490 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
491 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
492 `follows` boolean NOT NULL DEFAULT '0' COMMENT '',
493 PRIMARY KEY(`cid`,`relation-cid`),
494 INDEX `relation-cid` (`relation-cid`),
495 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
496 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
497 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
502 CREATE TABLE IF NOT EXISTS `conv` (
503 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
504 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
505 `recips` text COMMENT 'sender_handle;recipient_handle',
506 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
507 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
508 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
509 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
510 `subject` text COMMENT 'subject of initial message',
513 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
514 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
517 -- TABLE conversation
519 CREATE TABLE IF NOT EXISTS `conversation` (
520 `item-uri` varbinary(255) NOT NULL COMMENT 'Original URI of the item - unrelated to the table with the same name',
521 `reply-to-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'URI to which this item is a reply',
522 `conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI',
523 `conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link',
524 `protocol` tinyint unsigned NOT NULL DEFAULT 255 COMMENT 'The protocol of the item',
525 `direction` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'How the message arrived here: 1=push, 2=pull',
526 `source` mediumtext COMMENT 'Original source',
527 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Receiving date',
528 PRIMARY KEY(`item-uri`),
529 INDEX `conversation-uri` (`conversation-uri`),
530 INDEX `received` (`received`)
531 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Raw data and structure information for messages';
534 -- TABLE delayed-post
536 CREATE TABLE IF NOT EXISTS `delayed-post` (
537 `id` int unsigned NOT NULL auto_increment,
538 `uri` varchar(255) COMMENT 'URI of the post that will be distributed later',
539 `uid` mediumint unsigned COMMENT 'Owner User id',
540 `delayed` datetime COMMENT 'delay time',
542 UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
543 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
544 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
547 -- TABLE diaspora-interaction
549 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
550 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
551 `interaction` mediumtext COMMENT 'The Diaspora interaction',
552 PRIMARY KEY(`uri-id`),
553 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
554 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
559 CREATE TABLE IF NOT EXISTS `event` (
560 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
561 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
562 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
563 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
564 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
565 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
566 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
567 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
568 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
569 `summary` text COMMENT 'short description or title of the event',
570 `desc` text COMMENT 'event description',
571 `location` text COMMENT 'event location',
572 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
573 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
574 `adjust` boolean NOT NULL DEFAULT '1' COMMENT 'adjust to timezone of the recipient (0 or 1)',
575 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
576 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
577 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
578 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
579 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
581 INDEX `uid_start` (`uid`,`start`),
583 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
584 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
585 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
590 CREATE TABLE IF NOT EXISTS `fcontact` (
591 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
592 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
593 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
594 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
595 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
596 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
597 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
598 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
599 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
600 `notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
601 `poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
602 `confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
603 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
604 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
605 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
606 `pubkey` text COMMENT '',
607 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
609 INDEX `addr` (`addr`(32)),
610 UNIQUE INDEX `url` (`url`(190))
611 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
616 CREATE TABLE IF NOT EXISTS `fsuggest` (
617 `id` int unsigned NOT NULL auto_increment COMMENT '',
618 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
619 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
620 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
621 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
622 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
623 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
624 `note` text COMMENT '',
625 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
629 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
630 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
631 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
636 CREATE TABLE IF NOT EXISTS `group` (
637 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
638 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
639 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
640 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
641 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
644 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
645 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
648 -- TABLE group_member
650 CREATE TABLE IF NOT EXISTS `group_member` (
651 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
652 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
653 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
655 INDEX `contactid` (`contact-id`),
656 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
657 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
658 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
659 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
664 CREATE TABLE IF NOT EXISTS `gserver-tag` (
665 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
666 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
667 PRIMARY KEY(`gserver-id`,`tag`),
669 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
670 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
675 CREATE TABLE IF NOT EXISTS `hook` (
676 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
677 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
678 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
679 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
680 `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',
682 INDEX `priority` (`priority`),
683 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
684 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
689 CREATE TABLE IF NOT EXISTS `host` (
690 `id` tinyint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
691 `name` varchar(128) NOT NULL DEFAULT '' COMMENT 'The hostname',
693 UNIQUE INDEX `name` (`name`)
694 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Hostname';
697 -- TABLE inbox-status
699 CREATE TABLE IF NOT EXISTS `inbox-status` (
700 `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
701 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
702 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
703 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
704 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
705 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
706 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
708 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
713 CREATE TABLE IF NOT EXISTS `intro` (
714 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
715 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
716 `fid` int unsigned COMMENT '',
717 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
718 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
719 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
720 `note` text COMMENT '',
721 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
722 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
723 `blocked` boolean NOT NULL DEFAULT '1' COMMENT '',
724 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
726 INDEX `contact-id` (`contact-id`),
728 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
729 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
730 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
735 CREATE TABLE IF NOT EXISTS `locks` (
736 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
737 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
738 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
739 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
740 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
742 INDEX `name_expires` (`name`,`expires`)
743 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
748 CREATE TABLE IF NOT EXISTS `mail` (
749 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
750 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
751 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
752 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
753 `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
754 `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
755 `contact-id` varchar(255) COMMENT 'contact.id',
756 `author-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the author of the mail',
757 `convid` int unsigned COMMENT 'conv.id',
758 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
759 `body` mediumtext COMMENT '',
760 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
761 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
762 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
763 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
764 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
765 `uri-id` int unsigned COMMENT 'Item-uri id of the related mail',
766 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
767 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related mail',
768 `thr-parent` varchar(255) COMMENT '',
769 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
770 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
772 INDEX `uid_seen` (`uid`,`seen`),
773 INDEX `convid` (`convid`),
774 INDEX `uri` (`uri`(64)),
775 INDEX `parent-uri` (`parent-uri`(64)),
776 INDEX `contactid` (`contact-id`(32)),
777 INDEX `author-id` (`author-id`),
778 INDEX `uri-id` (`uri-id`),
779 INDEX `parent-uri-id` (`parent-uri-id`),
780 INDEX `thr-parent-id` (`thr-parent-id`),
781 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
782 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
783 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
784 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
785 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
786 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
791 CREATE TABLE IF NOT EXISTS `mailacct` (
792 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
793 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
794 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
795 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
796 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
797 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
798 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
799 `pass` text COMMENT '',
800 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
801 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
802 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
803 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
804 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
807 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
808 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
813 CREATE TABLE IF NOT EXISTS `manage` (
814 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
815 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
816 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
818 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
820 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
821 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
822 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
825 -- TABLE notification
827 CREATE TABLE IF NOT EXISTS `notification` (
828 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
829 `uid` mediumint unsigned COMMENT 'Owner User id',
830 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
831 `type` tinyint unsigned COMMENT '',
832 `actor-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the actor that caused the notification',
833 `target-uri-id` int unsigned COMMENT 'Item-uri id of the related post',
834 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
835 `created` datetime COMMENT '',
836 `seen` boolean DEFAULT '0' COMMENT '',
838 UNIQUE INDEX `uid_vid_type_actor-id_target-uri-id` (`uid`,`vid`,`type`,`actor-id`,`target-uri-id`),
840 INDEX `actor-id` (`actor-id`),
841 INDEX `target-uri-id` (`target-uri-id`),
842 INDEX `parent-uri-id` (`parent-uri-id`),
843 INDEX `seen_uid` (`seen`,`uid`),
844 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
845 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
846 FOREIGN KEY (`actor-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
847 FOREIGN KEY (`target-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
848 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
849 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
854 CREATE TABLE IF NOT EXISTS `notify` (
855 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
856 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
857 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
858 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
859 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
860 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
861 `msg` mediumtext COMMENT '',
862 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
863 `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
864 `iid` int unsigned COMMENT '',
865 `parent` int unsigned COMMENT '',
866 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
867 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
868 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
869 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
870 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
871 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
872 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
874 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
875 INDEX `uid_date` (`uid`,`date`),
876 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
877 INDEX `uri-id` (`uri-id`),
878 INDEX `parent-uri-id` (`parent-uri-id`),
879 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
880 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
881 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
882 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
885 -- TABLE notify-threads
887 CREATE TABLE IF NOT EXISTS `notify-threads` (
888 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
889 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
890 `master-parent-item` int unsigned COMMENT 'Deprecated',
891 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
892 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
893 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
895 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
896 INDEX `receiver-uid` (`receiver-uid`),
897 INDEX `notify-id` (`notify-id`),
898 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
899 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
900 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
901 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
906 CREATE TABLE IF NOT EXISTS `oembed` (
907 `url` varbinary(255) NOT NULL COMMENT 'page url',
908 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
909 `content` mediumtext COMMENT 'OEmbed data of the page',
910 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
911 PRIMARY KEY(`url`,`maxwidth`),
912 INDEX `created` (`created`)
913 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
916 -- TABLE openwebauth-token
918 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
919 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
920 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
921 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
922 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
923 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
924 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
927 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
928 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
933 CREATE TABLE IF NOT EXISTS `parsed_url` (
934 `url_hash` binary(64) NOT NULL COMMENT 'page url hash',
935 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
936 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
937 `url` text NOT NULL COMMENT 'page url',
938 `content` mediumtext COMMENT 'page data',
939 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
940 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration',
941 PRIMARY KEY(`url_hash`,`guessing`,`oembed`),
942 INDEX `created` (`created`),
943 INDEX `expires` (`expires`)
944 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
949 CREATE TABLE IF NOT EXISTS `pconfig` (
950 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
951 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
952 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
953 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
954 `v` mediumtext COMMENT 'Value',
956 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
957 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
958 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
963 CREATE TABLE IF NOT EXISTS `photo` (
964 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
965 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
966 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
967 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
968 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
969 `hash` char(32) COMMENT 'hash value of the photo',
970 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
971 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
972 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
973 `desc` text COMMENT '',
974 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
975 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
976 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
977 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
978 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
979 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
980 `data` mediumblob NOT NULL COMMENT '',
981 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
982 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
983 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
984 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
985 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
986 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
987 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
988 `backend-class` tinytext COMMENT 'Storage backend class',
989 `backend-ref` text COMMENT 'Storage backend data reference',
990 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
992 INDEX `contactid` (`contact-id`),
993 INDEX `uid_contactid` (`uid`,`contact-id`),
994 INDEX `uid_profile` (`uid`,`profile`),
995 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
996 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
997 INDEX `resource-id` (`resource-id`),
998 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
999 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1000 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1005 CREATE TABLE IF NOT EXISTS `post` (
1006 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1007 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1008 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1009 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1010 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1011 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1012 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1013 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1014 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1015 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1016 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1017 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1018 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1019 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1020 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1021 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1022 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1023 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1024 PRIMARY KEY(`uri-id`),
1025 INDEX `parent-uri-id` (`parent-uri-id`),
1026 INDEX `thr-parent-id` (`thr-parent-id`),
1027 INDEX `external-id` (`external-id`),
1028 INDEX `owner-id` (`owner-id`),
1029 INDEX `author-id` (`author-id`),
1030 INDEX `causer-id` (`causer-id`),
1031 INDEX `vid` (`vid`),
1032 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1033 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1034 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1035 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1036 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1037 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1038 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1039 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1040 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
1043 -- TABLE post-category
1045 CREATE TABLE IF NOT EXISTS `post-category` (
1046 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1047 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1048 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1049 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1050 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1051 INDEX `uri-id` (`tid`),
1052 INDEX `uid` (`uid`),
1053 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1054 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1055 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1056 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1059 -- TABLE post-content
1061 CREATE TABLE IF NOT EXISTS `post-content` (
1062 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1063 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1064 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1065 `body` mediumtext COMMENT 'item body content',
1066 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1067 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1068 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1069 `language` text COMMENT 'Language information about this post',
1070 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1071 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1072 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1073 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1074 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1075 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1076 `target` text COMMENT 'JSON encoded target structure if used',
1077 `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',
1078 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1079 PRIMARY KEY(`uri-id`),
1080 INDEX `plink` (`plink`(191)),
1081 INDEX `resource-id` (`resource-id`),
1082 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
1083 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1084 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1087 -- TABLE post-delivery-data
1089 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1090 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1091 `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',
1092 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1093 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1094 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1095 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1096 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1097 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1098 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1099 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1100 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1101 PRIMARY KEY(`uri-id`),
1102 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1103 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1108 CREATE TABLE IF NOT EXISTS `post-media` (
1109 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1110 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1111 `url` varbinary(511) NOT NULL COMMENT 'Media URL',
1112 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1113 `mimetype` varchar(60) COMMENT '',
1114 `height` smallint unsigned COMMENT 'Height of the media',
1115 `width` smallint unsigned COMMENT 'Width of the media',
1116 `size` int unsigned COMMENT 'Media size',
1117 `preview` varbinary(255) COMMENT 'Preview URL',
1118 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1119 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1120 `description` text COMMENT '',
1121 `name` varchar(255) COMMENT 'Name of the media',
1122 `author-url` varbinary(255) COMMENT 'URL of the author of the media',
1123 `author-name` varchar(255) COMMENT 'Name of the author of the media',
1124 `author-image` varbinary(255) COMMENT 'Image of the author of the media',
1125 `publisher-url` varbinary(255) COMMENT 'URL of the publisher of the media',
1126 `publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
1127 `publisher-image` varbinary(255) COMMENT 'Image of the publisher of the media',
1129 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1130 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1131 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1136 CREATE TABLE IF NOT EXISTS `post-tag` (
1137 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1138 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1139 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1140 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1141 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1142 INDEX `tid` (`tid`),
1143 INDEX `cid` (`cid`),
1144 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1145 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1146 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1147 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1150 -- TABLE post-thread
1152 CREATE TABLE IF NOT EXISTS `post-thread` (
1153 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1154 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1155 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1156 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1157 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1158 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1159 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1160 `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',
1161 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1162 PRIMARY KEY(`uri-id`),
1163 INDEX `owner-id` (`owner-id`),
1164 INDEX `author-id` (`author-id`),
1165 INDEX `causer-id` (`causer-id`),
1166 INDEX `received` (`received`),
1167 INDEX `commented` (`commented`),
1168 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1169 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1170 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1171 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1172 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1177 CREATE TABLE IF NOT EXISTS `post-user` (
1178 `id` int unsigned NOT NULL auto_increment,
1179 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1180 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1181 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1182 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1183 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1184 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1185 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1186 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1187 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1188 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1189 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1190 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1191 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1192 `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
1193 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1194 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1195 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1196 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1197 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1198 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1199 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1200 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1201 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1202 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1203 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1204 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1205 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1206 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1207 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1209 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1210 INDEX `uri-id` (`uri-id`),
1211 INDEX `parent-uri-id` (`parent-uri-id`),
1212 INDEX `thr-parent-id` (`thr-parent-id`),
1213 INDEX `external-id` (`external-id`),
1214 INDEX `owner-id` (`owner-id`),
1215 INDEX `author-id` (`author-id`),
1216 INDEX `causer-id` (`causer-id`),
1217 INDEX `vid` (`vid`),
1218 INDEX `contact-id` (`contact-id`),
1219 INDEX `event-id` (`event-id`),
1220 INDEX `psid` (`psid`),
1221 INDEX `author-id_uid` (`author-id`,`uid`),
1222 INDEX `author-id_received` (`author-id`,`received`),
1223 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1224 INDEX `uid_contactid` (`uid`,`contact-id`),
1225 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1226 INDEX `uid_unseen` (`uid`,`unseen`),
1227 INDEX `uid_hidden_uri-id` (`uid`,`hidden`,`uri-id`),
1228 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1229 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1230 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1231 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1232 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1233 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1234 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1235 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1236 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1237 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1238 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1239 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1240 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1243 -- TABLE post-thread-user
1245 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1246 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1247 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1248 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1249 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1250 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1251 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1252 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1253 `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',
1254 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1255 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1256 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'The thread is pinned on the profile page',
1257 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1258 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1259 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1260 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1261 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1262 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1263 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1264 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1265 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1266 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1267 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1268 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1269 PRIMARY KEY(`uid`,`uri-id`),
1270 INDEX `uri-id` (`uri-id`),
1271 INDEX `owner-id` (`owner-id`),
1272 INDEX `author-id` (`author-id`),
1273 INDEX `causer-id` (`causer-id`),
1274 INDEX `uid` (`uid`),
1275 INDEX `contact-id` (`contact-id`),
1276 INDEX `psid` (`psid`),
1277 INDEX `post-user-id` (`post-user-id`),
1278 INDEX `commented` (`commented`),
1279 INDEX `uid_received` (`uid`,`received`),
1280 INDEX `uid_pinned` (`uid`,`pinned`),
1281 INDEX `uid_commented` (`uid`,`commented`),
1282 INDEX `uid_starred` (`uid`,`starred`),
1283 INDEX `uid_mention` (`uid`,`mention`),
1284 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1285 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1286 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1287 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1288 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1289 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1290 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1291 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1292 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1295 -- TABLE post-user-notification
1297 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1298 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1299 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1300 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1301 PRIMARY KEY(`uid`,`uri-id`),
1302 INDEX `uri-id` (`uri-id`),
1303 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1304 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1305 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1310 CREATE TABLE IF NOT EXISTS `process` (
1311 `pid` int unsigned NOT NULL COMMENT '',
1312 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1313 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1315 INDEX `command` (`command`)
1316 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1321 CREATE TABLE IF NOT EXISTS `profile` (
1322 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1323 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1324 `profile-name` varchar(255) COMMENT 'Deprecated',
1325 `is-default` boolean COMMENT 'Deprecated',
1326 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1327 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1328 `pdesc` varchar(255) COMMENT 'Deprecated',
1329 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1330 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1331 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1332 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1333 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1334 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1335 `hometown` varchar(255) COMMENT 'Deprecated',
1336 `gender` varchar(32) COMMENT 'Deprecated',
1337 `marital` varchar(255) COMMENT 'Deprecated',
1338 `with` text COMMENT 'Deprecated',
1339 `howlong` datetime COMMENT 'Deprecated',
1340 `sexual` varchar(255) COMMENT 'Deprecated',
1341 `politic` varchar(255) COMMENT 'Deprecated',
1342 `religion` varchar(255) COMMENT 'Deprecated',
1343 `pub_keywords` text COMMENT '',
1344 `prv_keywords` text COMMENT '',
1345 `likes` text COMMENT 'Deprecated',
1346 `dislikes` text COMMENT 'Deprecated',
1347 `about` text COMMENT 'Profile description',
1348 `summary` varchar(255) COMMENT 'Deprecated',
1349 `music` text COMMENT 'Deprecated',
1350 `book` text COMMENT 'Deprecated',
1351 `tv` text COMMENT 'Deprecated',
1352 `film` text COMMENT 'Deprecated',
1353 `interest` text COMMENT 'Deprecated',
1354 `romance` text COMMENT 'Deprecated',
1355 `work` text COMMENT 'Deprecated',
1356 `education` text COMMENT 'Deprecated',
1357 `contact` text COMMENT 'Deprecated',
1358 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1359 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1360 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1361 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1362 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1363 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1365 INDEX `uid_is-default` (`uid`,`is-default`),
1366 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1367 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1368 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1371 -- TABLE profile_check
1373 CREATE TABLE IF NOT EXISTS `profile_check` (
1374 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1375 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1376 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1377 `dfrn_id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1378 `sec` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1379 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1381 INDEX `uid` (`uid`),
1382 INDEX `cid` (`cid`),
1383 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1384 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1385 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='DFRN remote auth use';
1388 -- TABLE profile_field
1390 CREATE TABLE IF NOT EXISTS `profile_field` (
1391 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1392 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1393 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1394 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1395 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1396 `value` text COMMENT 'Value of the field',
1397 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1398 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1400 INDEX `uid` (`uid`),
1401 INDEX `order` (`order`),
1402 INDEX `psid` (`psid`),
1403 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1404 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1405 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1408 -- TABLE push_subscriber
1410 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1411 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1412 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1413 `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1414 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1415 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1416 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1417 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1418 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1419 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1420 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1422 INDEX `next_try` (`next_try`),
1423 INDEX `uid` (`uid`),
1424 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1425 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1430 CREATE TABLE IF NOT EXISTS `register` (
1431 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1432 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1433 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1434 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1435 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1436 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1437 `note` text COMMENT '',
1439 INDEX `uid` (`uid`),
1440 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1441 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1446 CREATE TABLE IF NOT EXISTS `search` (
1447 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1448 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1449 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1451 INDEX `uid_term` (`uid`,`term`(64)),
1452 INDEX `term` (`term`(64)),
1453 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1454 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1459 CREATE TABLE IF NOT EXISTS `session` (
1460 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1461 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1462 `data` text COMMENT '',
1463 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1465 INDEX `sid` (`sid`(64)),
1466 INDEX `expire` (`expire`)
1467 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1472 CREATE TABLE IF NOT EXISTS `storage` (
1473 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1474 `data` longblob NOT NULL COMMENT 'file data',
1476 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1481 CREATE TABLE IF NOT EXISTS `tokens` (
1482 `id` varchar(40) NOT NULL COMMENT '',
1483 `secret` text COMMENT '',
1484 `client_id` varchar(20) NOT NULL DEFAULT '',
1485 `expires` int NOT NULL DEFAULT 0 COMMENT '',
1486 `scope` varchar(200) NOT NULL DEFAULT '' COMMENT '',
1487 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1489 INDEX `client_id` (`client_id`),
1490 INDEX `uid` (`uid`),
1491 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1492 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1493 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
1498 CREATE TABLE IF NOT EXISTS `userd` (
1499 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1500 `username` varchar(255) NOT NULL COMMENT '',
1502 INDEX `username` (`username`(32))
1503 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1506 -- TABLE user-contact
1508 CREATE TABLE IF NOT EXISTS `user-contact` (
1509 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1510 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1511 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1512 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1513 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1514 PRIMARY KEY(`uid`,`cid`),
1515 INDEX `cid` (`cid`),
1516 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1517 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1518 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1523 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1524 `key` int NOT NULL COMMENT '',
1525 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1527 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1530 -- TABLE workerqueue
1532 CREATE TABLE IF NOT EXISTS `workerqueue` (
1533 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
1534 `command` varchar(100) COMMENT 'Task command',
1535 `parameter` mediumtext COMMENT 'Task parameter',
1536 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
1537 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
1538 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
1539 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
1540 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1541 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1542 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
1544 INDEX `command` (`command`),
1545 INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
1546 INDEX `done_executed` (`done`,`executed`),
1547 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
1548 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
1549 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
1550 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
1551 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
1552 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
1555 -- VIEW application-view
1557 DROP VIEW IF EXISTS `application-view`;
1558 CREATE VIEW `application-view` AS SELECT
1559 `application`.`id` AS `id`,
1560 `application-token`.`uid` AS `uid`,
1561 `application`.`name` AS `name`,
1562 `application`.`redirect_uri` AS `redirect_uri`,
1563 `application`.`website` AS `website`,
1564 `application`.`client_id` AS `client_id`,
1565 `application`.`client_secret` AS `client_secret`,
1566 `application-token`.`code` AS `code`,
1567 `application-token`.`access_token` AS `access_token`,
1568 `application-token`.`created_at` AS `created_at`,
1569 `application-token`.`scopes` AS `scopes`,
1570 `application-token`.`read` AS `read`,
1571 `application-token`.`write` AS `write`,
1572 `application-token`.`follow` AS `follow`,
1573 `application-token`.`push` AS `push`
1574 FROM `application-token`
1575 INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`;
1578 -- VIEW post-user-view
1580 DROP VIEW IF EXISTS `post-user-view`;
1581 CREATE VIEW `post-user-view` AS SELECT
1582 `post-user`.`id` AS `id`,
1583 `post-user`.`id` AS `post-user-id`,
1584 `post-user`.`uid` AS `uid`,
1585 `parent-post`.`id` AS `parent`,
1586 `item-uri`.`uri` AS `uri`,
1587 `post-user`.`uri-id` AS `uri-id`,
1588 `parent-item-uri`.`uri` AS `parent-uri`,
1589 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1590 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1591 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1592 `item-uri`.`guid` AS `guid`,
1593 `post-user`.`wall` AS `wall`,
1594 `post-user`.`gravity` AS `gravity`,
1595 `external-item-uri`.`uri` AS `extid`,
1596 `post-user`.`external-id` AS `external-id`,
1597 `post-user`.`created` AS `created`,
1598 `post-user`.`edited` AS `edited`,
1599 `post-thread-user`.`commented` AS `commented`,
1600 `post-user`.`received` AS `received`,
1601 `post-thread-user`.`changed` AS `changed`,
1602 `post-user`.`post-type` AS `post-type`,
1603 `post-user`.`post-reason` AS `post-reason`,
1604 `post-user`.`private` AS `private`,
1605 `post-thread-user`.`pubmail` AS `pubmail`,
1606 `post-user`.`visible` AS `visible`,
1607 `post-thread-user`.`starred` AS `starred`,
1608 `post-thread-user`.`pinned` AS `pinned`,
1609 `post-user`.`unseen` AS `unseen`,
1610 `post-user`.`deleted` AS `deleted`,
1611 `post-user`.`origin` AS `origin`,
1612 `post-thread-user`.`origin` AS `parent-origin`,
1613 `post-thread-user`.`forum_mode` AS `forum_mode`,
1614 `post-thread-user`.`mention` AS `mention`,
1615 `post-user`.`global` AS `global`,
1616 `post-user`.`network` AS `network`,
1617 `post-user`.`vid` AS `vid`,
1618 `post-user`.`psid` AS `psid`,
1619 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1620 `post-content`.`title` AS `title`,
1621 `post-content`.`content-warning` AS `content-warning`,
1622 `post-content`.`raw-body` AS `raw-body`,
1623 `post-content`.`body` AS `body`,
1624 `post-content`.`rendered-hash` AS `rendered-hash`,
1625 `post-content`.`rendered-html` AS `rendered-html`,
1626 `post-content`.`language` AS `language`,
1627 `post-content`.`plink` AS `plink`,
1628 `post-content`.`location` AS `location`,
1629 `post-content`.`coord` AS `coord`,
1630 `post-content`.`app` AS `app`,
1631 `post-content`.`object-type` AS `object-type`,
1632 `post-content`.`object` AS `object`,
1633 `post-content`.`target-type` AS `target-type`,
1634 `post-content`.`target` AS `target`,
1635 `post-content`.`resource-id` AS `resource-id`,
1636 `post-user`.`contact-id` AS `contact-id`,
1637 `contact`.`url` AS `contact-link`,
1638 `contact`.`addr` AS `contact-addr`,
1639 `contact`.`name` AS `contact-name`,
1640 `contact`.`nick` AS `contact-nick`,
1641 `contact`.`thumb` AS `contact-avatar`,
1642 `contact`.`network` AS `contact-network`,
1643 `contact`.`blocked` AS `contact-blocked`,
1644 `contact`.`hidden` AS `contact-hidden`,
1645 `contact`.`readonly` AS `contact-readonly`,
1646 `contact`.`archive` AS `contact-archive`,
1647 `contact`.`pending` AS `contact-pending`,
1648 `contact`.`rel` AS `contact-rel`,
1649 `contact`.`uid` AS `contact-uid`,
1650 `contact`.`contact-type` AS `contact-contact-type`,
1651 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1652 `contact`.`self` AS `self`,
1653 `contact`.`id` AS `cid`,
1654 `contact`.`alias` AS `alias`,
1655 `contact`.`photo` AS `photo`,
1656 `contact`.`name-date` AS `name-date`,
1657 `contact`.`uri-date` AS `uri-date`,
1658 `contact`.`avatar-date` AS `avatar-date`,
1659 `contact`.`thumb` AS `thumb`,
1660 `contact`.`dfrn-id` AS `dfrn-id`,
1661 `post-user`.`author-id` AS `author-id`,
1662 `author`.`url` AS `author-link`,
1663 `author`.`addr` AS `author-addr`,
1664 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1665 `author`.`nick` AS `author-nick`,
1666 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1667 `author`.`network` AS `author-network`,
1668 `author`.`blocked` AS `author-blocked`,
1669 `author`.`hidden` AS `author-hidden`,
1670 `post-user`.`owner-id` AS `owner-id`,
1671 `owner`.`url` AS `owner-link`,
1672 `owner`.`addr` AS `owner-addr`,
1673 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1674 `owner`.`nick` AS `owner-nick`,
1675 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1676 `owner`.`network` AS `owner-network`,
1677 `owner`.`blocked` AS `owner-blocked`,
1678 `owner`.`hidden` AS `owner-hidden`,
1679 `owner`.`contact-type` AS `owner-contact-type`,
1680 `post-user`.`causer-id` AS `causer-id`,
1681 `causer`.`url` AS `causer-link`,
1682 `causer`.`addr` AS `causer-addr`,
1683 `causer`.`name` AS `causer-name`,
1684 `causer`.`nick` AS `causer-nick`,
1685 `causer`.`thumb` AS `causer-avatar`,
1686 `causer`.`network` AS `causer-network`,
1687 `causer`.`blocked` AS `causer-blocked`,
1688 `causer`.`hidden` AS `causer-hidden`,
1689 `causer`.`contact-type` AS `causer-contact-type`,
1690 `post-delivery-data`.`postopts` AS `postopts`,
1691 `post-delivery-data`.`inform` AS `inform`,
1692 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1693 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1694 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1695 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1696 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1697 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1698 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1699 `post-user`.`event-id` AS `event-id`,
1700 `event`.`created` AS `event-created`,
1701 `event`.`edited` AS `event-edited`,
1702 `event`.`start` AS `event-start`,
1703 `event`.`finish` AS `event-finish`,
1704 `event`.`summary` AS `event-summary`,
1705 `event`.`desc` AS `event-desc`,
1706 `event`.`location` AS `event-location`,
1707 `event`.`type` AS `event-type`,
1708 `event`.`nofinish` AS `event-nofinish`,
1709 `event`.`adjust` AS `event-adjust`,
1710 `event`.`ignore` AS `event-ignore`,
1711 `diaspora-interaction`.`interaction` AS `signed_text`,
1712 `parent-item-uri`.`guid` AS `parent-guid`,
1713 `parent-post`.`network` AS `parent-network`,
1714 `parent-post`.`author-id` AS `parent-author-id`,
1715 `parent-post-author`.`url` AS `parent-author-link`,
1716 `parent-post-author`.`name` AS `parent-author-name`,
1717 `parent-post-author`.`network` AS `parent-author-network`,
1718 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1719 `parent-post-author`.`hidden` AS `parent-author-hidden`
1721 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
1722 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
1723 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
1724 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
1725 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
1726 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
1727 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1728 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1729 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1730 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1731 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1732 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
1733 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
1734 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
1735 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
1736 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
1737 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1740 -- VIEW post-thread-user-view
1742 DROP VIEW IF EXISTS `post-thread-user-view`;
1743 CREATE VIEW `post-thread-user-view` AS SELECT
1744 `post-user`.`id` AS `id`,
1745 `post-user`.`id` AS `post-user-id`,
1746 `post-thread-user`.`uid` AS `uid`,
1747 `parent-post`.`id` AS `parent`,
1748 `item-uri`.`uri` AS `uri`,
1749 `post-thread-user`.`uri-id` AS `uri-id`,
1750 `parent-item-uri`.`uri` AS `parent-uri`,
1751 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1752 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1753 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1754 `item-uri`.`guid` AS `guid`,
1755 `post-thread-user`.`wall` AS `wall`,
1756 `post-user`.`gravity` AS `gravity`,
1757 `external-item-uri`.`uri` AS `extid`,
1758 `post-user`.`external-id` AS `external-id`,
1759 `post-thread-user`.`created` AS `created`,
1760 `post-user`.`edited` AS `edited`,
1761 `post-thread-user`.`commented` AS `commented`,
1762 `post-thread-user`.`received` AS `received`,
1763 `post-thread-user`.`changed` AS `changed`,
1764 `post-user`.`post-type` AS `post-type`,
1765 `post-user`.`post-reason` AS `post-reason`,
1766 `post-user`.`private` AS `private`,
1767 `post-thread-user`.`pubmail` AS `pubmail`,
1768 `post-thread-user`.`ignored` AS `ignored`,
1769 `post-user`.`visible` AS `visible`,
1770 `post-thread-user`.`starred` AS `starred`,
1771 `post-thread-user`.`pinned` AS `pinned`,
1772 `post-thread-user`.`unseen` AS `unseen`,
1773 `post-user`.`deleted` AS `deleted`,
1774 `post-thread-user`.`origin` AS `origin`,
1775 `post-thread-user`.`forum_mode` AS `forum_mode`,
1776 `post-thread-user`.`mention` AS `mention`,
1777 `post-user`.`global` AS `global`,
1778 `post-thread-user`.`network` AS `network`,
1779 `post-user`.`vid` AS `vid`,
1780 `post-thread-user`.`psid` AS `psid`,
1781 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1782 `post-content`.`title` AS `title`,
1783 `post-content`.`content-warning` AS `content-warning`,
1784 `post-content`.`raw-body` AS `raw-body`,
1785 `post-content`.`body` AS `body`,
1786 `post-content`.`rendered-hash` AS `rendered-hash`,
1787 `post-content`.`rendered-html` AS `rendered-html`,
1788 `post-content`.`language` AS `language`,
1789 `post-content`.`plink` AS `plink`,
1790 `post-content`.`location` AS `location`,
1791 `post-content`.`coord` AS `coord`,
1792 `post-content`.`app` AS `app`,
1793 `post-content`.`object-type` AS `object-type`,
1794 `post-content`.`object` AS `object`,
1795 `post-content`.`target-type` AS `target-type`,
1796 `post-content`.`target` AS `target`,
1797 `post-content`.`resource-id` AS `resource-id`,
1798 `post-thread-user`.`contact-id` AS `contact-id`,
1799 `contact`.`url` AS `contact-link`,
1800 `contact`.`addr` AS `contact-addr`,
1801 `contact`.`name` AS `contact-name`,
1802 `contact`.`nick` AS `contact-nick`,
1803 `contact`.`thumb` AS `contact-avatar`,
1804 `contact`.`network` AS `contact-network`,
1805 `contact`.`blocked` AS `contact-blocked`,
1806 `contact`.`hidden` AS `contact-hidden`,
1807 `contact`.`readonly` AS `contact-readonly`,
1808 `contact`.`archive` AS `contact-archive`,
1809 `contact`.`pending` AS `contact-pending`,
1810 `contact`.`rel` AS `contact-rel`,
1811 `contact`.`uid` AS `contact-uid`,
1812 `contact`.`contact-type` AS `contact-contact-type`,
1813 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1814 `contact`.`self` AS `self`,
1815 `contact`.`id` AS `cid`,
1816 `contact`.`alias` AS `alias`,
1817 `contact`.`photo` AS `photo`,
1818 `contact`.`name-date` AS `name-date`,
1819 `contact`.`uri-date` AS `uri-date`,
1820 `contact`.`avatar-date` AS `avatar-date`,
1821 `contact`.`thumb` AS `thumb`,
1822 `contact`.`dfrn-id` AS `dfrn-id`,
1823 `post-thread-user`.`author-id` AS `author-id`,
1824 `author`.`url` AS `author-link`,
1825 `author`.`addr` AS `author-addr`,
1826 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1827 `author`.`nick` AS `author-nick`,
1828 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1829 `author`.`network` AS `author-network`,
1830 `author`.`blocked` AS `author-blocked`,
1831 `author`.`hidden` AS `author-hidden`,
1832 `post-thread-user`.`owner-id` AS `owner-id`,
1833 `owner`.`url` AS `owner-link`,
1834 `owner`.`addr` AS `owner-addr`,
1835 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1836 `owner`.`nick` AS `owner-nick`,
1837 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1838 `owner`.`network` AS `owner-network`,
1839 `owner`.`blocked` AS `owner-blocked`,
1840 `owner`.`hidden` AS `owner-hidden`,
1841 `owner`.`contact-type` AS `owner-contact-type`,
1842 `post-thread-user`.`causer-id` AS `causer-id`,
1843 `causer`.`url` AS `causer-link`,
1844 `causer`.`addr` AS `causer-addr`,
1845 `causer`.`name` AS `causer-name`,
1846 `causer`.`nick` AS `causer-nick`,
1847 `causer`.`thumb` AS `causer-avatar`,
1848 `causer`.`network` AS `causer-network`,
1849 `causer`.`blocked` AS `causer-blocked`,
1850 `causer`.`hidden` AS `causer-hidden`,
1851 `causer`.`contact-type` AS `causer-contact-type`,
1852 `post-delivery-data`.`postopts` AS `postopts`,
1853 `post-delivery-data`.`inform` AS `inform`,
1854 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1855 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1856 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1857 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1858 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1859 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1860 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1861 `post-user`.`event-id` AS `event-id`,
1862 `event`.`created` AS `event-created`,
1863 `event`.`edited` AS `event-edited`,
1864 `event`.`start` AS `event-start`,
1865 `event`.`finish` AS `event-finish`,
1866 `event`.`summary` AS `event-summary`,
1867 `event`.`desc` AS `event-desc`,
1868 `event`.`location` AS `event-location`,
1869 `event`.`type` AS `event-type`,
1870 `event`.`nofinish` AS `event-nofinish`,
1871 `event`.`adjust` AS `event-adjust`,
1872 `event`.`ignore` AS `event-ignore`,
1873 `diaspora-interaction`.`interaction` AS `signed_text`,
1874 `parent-item-uri`.`guid` AS `parent-guid`,
1875 `parent-post`.`network` AS `parent-network`,
1876 `parent-post`.`author-id` AS `parent-author-id`,
1877 `parent-post-author`.`url` AS `parent-author-link`,
1878 `parent-post-author`.`name` AS `parent-author-name`,
1879 `parent-post-author`.`network` AS `parent-author-network`,
1880 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1881 `parent-post-author`.`hidden` AS `parent-author-hidden`
1882 FROM `post-thread-user`
1883 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
1884 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
1885 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
1886 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
1887 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
1888 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
1889 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1890 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1891 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1892 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1893 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1894 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
1895 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
1896 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
1897 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
1898 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`
1899 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1904 DROP VIEW IF EXISTS `post-view`;
1905 CREATE VIEW `post-view` AS SELECT
1906 `item-uri`.`uri` AS `uri`,
1907 `post`.`uri-id` AS `uri-id`,
1908 `parent-item-uri`.`uri` AS `parent-uri`,
1909 `post`.`parent-uri-id` AS `parent-uri-id`,
1910 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1911 `post`.`thr-parent-id` AS `thr-parent-id`,
1912 `item-uri`.`guid` AS `guid`,
1913 `post`.`gravity` AS `gravity`,
1914 `external-item-uri`.`uri` AS `extid`,
1915 `post`.`external-id` AS `external-id`,
1916 `post`.`created` AS `created`,
1917 `post`.`edited` AS `edited`,
1918 `post-thread`.`commented` AS `commented`,
1919 `post`.`received` AS `received`,
1920 `post-thread`.`changed` AS `changed`,
1921 `post`.`post-type` AS `post-type`,
1922 `post`.`private` AS `private`,
1923 `post`.`visible` AS `visible`,
1924 `post`.`deleted` AS `deleted`,
1925 `post`.`global` AS `global`,
1926 `post`.`network` AS `network`,
1927 `post`.`vid` AS `vid`,
1928 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1929 `post-content`.`title` AS `title`,
1930 `post-content`.`content-warning` AS `content-warning`,
1931 `post-content`.`raw-body` AS `raw-body`,
1932 `post-content`.`body` AS `body`,
1933 `post-content`.`rendered-hash` AS `rendered-hash`,
1934 `post-content`.`rendered-html` AS `rendered-html`,
1935 `post-content`.`language` AS `language`,
1936 `post-content`.`plink` AS `plink`,
1937 `post-content`.`location` AS `location`,
1938 `post-content`.`coord` AS `coord`,
1939 `post-content`.`app` AS `app`,
1940 `post-content`.`object-type` AS `object-type`,
1941 `post-content`.`object` AS `object`,
1942 `post-content`.`target-type` AS `target-type`,
1943 `post-content`.`target` AS `target`,
1944 `post-content`.`resource-id` AS `resource-id`,
1945 `post`.`author-id` AS `contact-id`,
1946 `author`.`url` AS `contact-link`,
1947 `author`.`addr` AS `contact-addr`,
1948 `author`.`name` AS `contact-name`,
1949 `author`.`nick` AS `contact-nick`,
1950 `author`.`thumb` AS `contact-avatar`,
1951 `author`.`network` AS `contact-network`,
1952 `author`.`blocked` AS `contact-blocked`,
1953 `author`.`hidden` AS `contact-hidden`,
1954 `author`.`readonly` AS `contact-readonly`,
1955 `author`.`archive` AS `contact-archive`,
1956 `author`.`pending` AS `contact-pending`,
1957 `author`.`rel` AS `contact-rel`,
1958 `author`.`uid` AS `contact-uid`,
1959 `author`.`contact-type` AS `contact-contact-type`,
1960 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
1962 `author`.`id` AS `cid`,
1963 `author`.`alias` AS `alias`,
1964 `author`.`photo` AS `photo`,
1965 `author`.`name-date` AS `name-date`,
1966 `author`.`uri-date` AS `uri-date`,
1967 `author`.`avatar-date` AS `avatar-date`,
1968 `author`.`thumb` AS `thumb`,
1969 `author`.`dfrn-id` AS `dfrn-id`,
1970 `post`.`author-id` AS `author-id`,
1971 `author`.`url` AS `author-link`,
1972 `author`.`addr` AS `author-addr`,
1973 `author`.`name` AS `author-name`,
1974 `author`.`nick` AS `author-nick`,
1975 `author`.`thumb` AS `author-avatar`,
1976 `author`.`network` AS `author-network`,
1977 `author`.`blocked` AS `author-blocked`,
1978 `author`.`hidden` AS `author-hidden`,
1979 `post`.`owner-id` AS `owner-id`,
1980 `owner`.`url` AS `owner-link`,
1981 `owner`.`addr` AS `owner-addr`,
1982 `owner`.`name` AS `owner-name`,
1983 `owner`.`nick` AS `owner-nick`,
1984 `owner`.`thumb` AS `owner-avatar`,
1985 `owner`.`network` AS `owner-network`,
1986 `owner`.`blocked` AS `owner-blocked`,
1987 `owner`.`hidden` AS `owner-hidden`,
1988 `owner`.`contact-type` AS `owner-contact-type`,
1989 `post`.`causer-id` AS `causer-id`,
1990 `causer`.`url` AS `causer-link`,
1991 `causer`.`addr` AS `causer-addr`,
1992 `causer`.`name` AS `causer-name`,
1993 `causer`.`nick` AS `causer-nick`,
1994 `causer`.`thumb` AS `causer-avatar`,
1995 `causer`.`network` AS `causer-network`,
1996 `causer`.`blocked` AS `causer-blocked`,
1997 `causer`.`hidden` AS `causer-hidden`,
1998 `causer`.`contact-type` AS `causer-contact-type`,
1999 `diaspora-interaction`.`interaction` AS `signed_text`,
2000 `parent-item-uri`.`guid` AS `parent-guid`,
2001 `parent-post`.`network` AS `parent-network`,
2002 `parent-post`.`author-id` AS `parent-author-id`,
2003 `parent-post-author`.`url` AS `parent-author-link`,
2004 `parent-post-author`.`name` AS `parent-author-name`,
2005 `parent-post-author`.`network` AS `parent-author-network`,
2006 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2007 `parent-post-author`.`hidden` AS `parent-author-hidden`
2009 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
2010 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
2011 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
2012 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
2013 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
2014 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2015 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2016 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2017 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2018 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
2019 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
2020 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2021 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2024 -- VIEW post-thread-view
2026 DROP VIEW IF EXISTS `post-thread-view`;
2027 CREATE VIEW `post-thread-view` AS SELECT
2028 `item-uri`.`uri` AS `uri`,
2029 `post-thread`.`uri-id` AS `uri-id`,
2030 `parent-item-uri`.`uri` AS `parent-uri`,
2031 `post`.`parent-uri-id` AS `parent-uri-id`,
2032 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2033 `post`.`thr-parent-id` AS `thr-parent-id`,
2034 `item-uri`.`guid` AS `guid`,
2035 `post`.`gravity` AS `gravity`,
2036 `external-item-uri`.`uri` AS `extid`,
2037 `post`.`external-id` AS `external-id`,
2038 `post-thread`.`created` AS `created`,
2039 `post`.`edited` AS `edited`,
2040 `post-thread`.`commented` AS `commented`,
2041 `post-thread`.`received` AS `received`,
2042 `post-thread`.`changed` AS `changed`,
2043 `post`.`post-type` AS `post-type`,
2044 `post`.`private` AS `private`,
2045 `post`.`visible` AS `visible`,
2046 `post`.`deleted` AS `deleted`,
2047 `post`.`global` AS `global`,
2048 `post-thread`.`network` AS `network`,
2049 `post`.`vid` AS `vid`,
2050 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2051 `post-content`.`title` AS `title`,
2052 `post-content`.`content-warning` AS `content-warning`,
2053 `post-content`.`raw-body` AS `raw-body`,
2054 `post-content`.`body` AS `body`,
2055 `post-content`.`rendered-hash` AS `rendered-hash`,
2056 `post-content`.`rendered-html` AS `rendered-html`,
2057 `post-content`.`language` AS `language`,
2058 `post-content`.`plink` AS `plink`,
2059 `post-content`.`location` AS `location`,
2060 `post-content`.`coord` AS `coord`,
2061 `post-content`.`app` AS `app`,
2062 `post-content`.`object-type` AS `object-type`,
2063 `post-content`.`object` AS `object`,
2064 `post-content`.`target-type` AS `target-type`,
2065 `post-content`.`target` AS `target`,
2066 `post-content`.`resource-id` AS `resource-id`,
2067 `post-thread`.`author-id` AS `contact-id`,
2068 `author`.`url` AS `contact-link`,
2069 `author`.`addr` AS `contact-addr`,
2070 `author`.`name` AS `contact-name`,
2071 `author`.`nick` AS `contact-nick`,
2072 `author`.`thumb` AS `contact-avatar`,
2073 `author`.`network` AS `contact-network`,
2074 `author`.`blocked` AS `contact-blocked`,
2075 `author`.`hidden` AS `contact-hidden`,
2076 `author`.`readonly` AS `contact-readonly`,
2077 `author`.`archive` AS `contact-archive`,
2078 `author`.`pending` AS `contact-pending`,
2079 `author`.`rel` AS `contact-rel`,
2080 `author`.`uid` AS `contact-uid`,
2081 `author`.`contact-type` AS `contact-contact-type`,
2082 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2084 `author`.`id` AS `cid`,
2085 `author`.`alias` AS `alias`,
2086 `author`.`photo` AS `photo`,
2087 `author`.`name-date` AS `name-date`,
2088 `author`.`uri-date` AS `uri-date`,
2089 `author`.`avatar-date` AS `avatar-date`,
2090 `author`.`thumb` AS `thumb`,
2091 `author`.`dfrn-id` AS `dfrn-id`,
2092 `post-thread`.`author-id` AS `author-id`,
2093 `author`.`url` AS `author-link`,
2094 `author`.`addr` AS `author-addr`,
2095 `author`.`name` AS `author-name`,
2096 `author`.`nick` AS `author-nick`,
2097 `author`.`thumb` AS `author-avatar`,
2098 `author`.`network` AS `author-network`,
2099 `author`.`blocked` AS `author-blocked`,
2100 `author`.`hidden` AS `author-hidden`,
2101 `post-thread`.`owner-id` AS `owner-id`,
2102 `owner`.`url` AS `owner-link`,
2103 `owner`.`addr` AS `owner-addr`,
2104 `owner`.`name` AS `owner-name`,
2105 `owner`.`nick` AS `owner-nick`,
2106 `owner`.`thumb` AS `owner-avatar`,
2107 `owner`.`network` AS `owner-network`,
2108 `owner`.`blocked` AS `owner-blocked`,
2109 `owner`.`hidden` AS `owner-hidden`,
2110 `owner`.`contact-type` AS `owner-contact-type`,
2111 `post-thread`.`causer-id` AS `causer-id`,
2112 `causer`.`url` AS `causer-link`,
2113 `causer`.`addr` AS `causer-addr`,
2114 `causer`.`name` AS `causer-name`,
2115 `causer`.`nick` AS `causer-nick`,
2116 `causer`.`thumb` AS `causer-avatar`,
2117 `causer`.`network` AS `causer-network`,
2118 `causer`.`blocked` AS `causer-blocked`,
2119 `causer`.`hidden` AS `causer-hidden`,
2120 `causer`.`contact-type` AS `causer-contact-type`,
2121 `diaspora-interaction`.`interaction` AS `signed_text`,
2122 `parent-item-uri`.`guid` AS `parent-guid`,
2123 `parent-post`.`network` AS `parent-network`,
2124 `parent-post`.`author-id` AS `parent-author-id`,
2125 `parent-post-author`.`url` AS `parent-author-link`,
2126 `parent-post-author`.`name` AS `parent-author-name`,
2127 `parent-post-author`.`network` AS `parent-author-network`,
2128 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2129 `parent-post-author`.`hidden` AS `parent-author-hidden`
2131 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
2132 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
2133 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
2134 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
2135 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
2136 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2137 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2138 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2139 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2140 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
2141 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
2142 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2143 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2146 -- VIEW category-view
2148 DROP VIEW IF EXISTS `category-view`;
2149 CREATE VIEW `category-view` AS SELECT
2150 `post-category`.`uri-id` AS `uri-id`,
2151 `post-category`.`uid` AS `uid`,
2152 `post-category`.`type` AS `type`,
2153 `post-category`.`tid` AS `tid`,
2154 `tag`.`name` AS `name`,
2155 `tag`.`url` AS `url`
2156 FROM `post-category`
2157 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2162 DROP VIEW IF EXISTS `tag-view`;
2163 CREATE VIEW `tag-view` AS SELECT
2164 `post-tag`.`uri-id` AS `uri-id`,
2165 `post-tag`.`type` AS `type`,
2166 `post-tag`.`tid` AS `tid`,
2167 `post-tag`.`cid` AS `cid`,
2168 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2169 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
2171 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2172 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2175 -- VIEW network-item-view
2177 DROP VIEW IF EXISTS `network-item-view`;
2178 CREATE VIEW `network-item-view` AS SELECT
2179 `post-user`.`uri-id` AS `uri-id`,
2180 `parent-post`.`id` AS `parent`,
2181 `post-user`.`received` AS `received`,
2182 `post-thread-user`.`commented` AS `commented`,
2183 `post-user`.`created` AS `created`,
2184 `post-user`.`uid` AS `uid`,
2185 `post-thread-user`.`starred` AS `starred`,
2186 `post-thread-user`.`mention` AS `mention`,
2187 `post-user`.`network` AS `network`,
2188 `post-user`.`unseen` AS `unseen`,
2189 `post-user`.`gravity` AS `gravity`,
2190 `post-user`.`contact-id` AS `contact-id`,
2191 `ownercontact`.`contact-type` AS `contact-type`
2193 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2194 INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2195 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2196 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2197 INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2198 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2199 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2200 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2201 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
2202 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2203 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2206 -- VIEW network-thread-view
2208 DROP VIEW IF EXISTS `network-thread-view`;
2209 CREATE VIEW `network-thread-view` AS SELECT
2210 `post-thread-user`.`uri-id` AS `uri-id`,
2211 `parent-post`.`id` AS `parent`,
2212 `post-thread-user`.`received` AS `received`,
2213 `post-thread-user`.`commented` AS `commented`,
2214 `post-thread-user`.`created` AS `created`,
2215 `post-thread-user`.`uid` AS `uid`,
2216 `post-thread-user`.`starred` AS `starred`,
2217 `post-thread-user`.`mention` AS `mention`,
2218 `post-thread-user`.`network` AS `network`,
2219 `post-thread-user`.`contact-id` AS `contact-id`,
2220 `ownercontact`.`contact-type` AS `contact-type`
2221 FROM `post-thread-user`
2222 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2223 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2224 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2225 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2226 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2227 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2228 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2229 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2230 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2231 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2232 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2237 DROP VIEW IF EXISTS `owner-view`;
2238 CREATE VIEW `owner-view` AS SELECT
2239 `contact`.`id` AS `id`,
2240 `contact`.`uid` AS `uid`,
2241 `contact`.`created` AS `created`,
2242 `contact`.`updated` AS `updated`,
2243 `contact`.`self` AS `self`,
2244 `contact`.`remote_self` AS `remote_self`,
2245 `contact`.`rel` AS `rel`,
2246 `contact`.`duplex` AS `duplex`,
2247 `contact`.`network` AS `network`,
2248 `contact`.`protocol` AS `protocol`,
2249 `contact`.`name` AS `name`,
2250 `contact`.`nick` AS `nick`,
2251 `contact`.`location` AS `location`,
2252 `contact`.`about` AS `about`,
2253 `contact`.`keywords` AS `keywords`,
2254 `contact`.`gender` AS `gender`,
2255 `contact`.`xmpp` AS `xmpp`,
2256 `contact`.`attag` AS `attag`,
2257 `contact`.`avatar` AS `avatar`,
2258 `contact`.`photo` AS `photo`,
2259 `contact`.`thumb` AS `thumb`,
2260 `contact`.`micro` AS `micro`,
2261 `contact`.`header` AS `header`,
2262 `contact`.`site-pubkey` AS `site-pubkey`,
2263 `contact`.`issued-id` AS `issued-id`,
2264 `contact`.`dfrn-id` AS `dfrn-id`,
2265 `contact`.`url` AS `url`,
2266 `contact`.`nurl` AS `nurl`,
2267 `contact`.`addr` AS `addr`,
2268 `contact`.`alias` AS `alias`,
2269 `contact`.`pubkey` AS `pubkey`,
2270 `contact`.`prvkey` AS `prvkey`,
2271 `contact`.`batch` AS `batch`,
2272 `contact`.`request` AS `request`,
2273 `contact`.`notify` AS `notify`,
2274 `contact`.`poll` AS `poll`,
2275 `contact`.`confirm` AS `confirm`,
2276 `contact`.`poco` AS `poco`,
2277 `contact`.`aes_allow` AS `aes_allow`,
2278 `contact`.`ret-aes` AS `ret-aes`,
2279 `contact`.`usehub` AS `usehub`,
2280 `contact`.`subhub` AS `subhub`,
2281 `contact`.`hub-verify` AS `hub-verify`,
2282 `contact`.`last-update` AS `last-update`,
2283 `contact`.`success_update` AS `success_update`,
2284 `contact`.`failure_update` AS `failure_update`,
2285 `contact`.`name-date` AS `name-date`,
2286 `contact`.`uri-date` AS `uri-date`,
2287 `contact`.`avatar-date` AS `avatar-date`,
2288 `contact`.`avatar-date` AS `picdate`,
2289 `contact`.`term-date` AS `term-date`,
2290 `contact`.`last-item` AS `last-item`,
2291 `contact`.`priority` AS `priority`,
2292 `user`.`blocked` AS `blocked`,
2293 `contact`.`block_reason` AS `block_reason`,
2294 `contact`.`readonly` AS `readonly`,
2295 `contact`.`writable` AS `writable`,
2296 `contact`.`forum` AS `forum`,
2297 `contact`.`prv` AS `prv`,
2298 `contact`.`contact-type` AS `contact-type`,
2299 `contact`.`manually-approve` AS `manually-approve`,
2300 `contact`.`hidden` AS `hidden`,
2301 `contact`.`archive` AS `archive`,
2302 `contact`.`pending` AS `pending`,
2303 `contact`.`deleted` AS `deleted`,
2304 `contact`.`unsearchable` AS `unsearchable`,
2305 `contact`.`sensitive` AS `sensitive`,
2306 `contact`.`baseurl` AS `baseurl`,
2307 `contact`.`reason` AS `reason`,
2308 `contact`.`closeness` AS `closeness`,
2309 `contact`.`info` AS `info`,
2310 `contact`.`profile-id` AS `profile-id`,
2311 `contact`.`bdyear` AS `bdyear`,
2312 `contact`.`bd` AS `bd`,
2313 `contact`.`notify_new_posts` AS `notify_new_posts`,
2314 `contact`.`fetch_further_information` AS `fetch_further_information`,
2315 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2316 `user`.`parent-uid` AS `parent-uid`,
2317 `user`.`guid` AS `guid`,
2318 `user`.`nickname` AS `nickname`,
2319 `user`.`email` AS `email`,
2320 `user`.`openid` AS `openid`,
2321 `user`.`timezone` AS `timezone`,
2322 `user`.`language` AS `language`,
2323 `user`.`register_date` AS `register_date`,
2324 `user`.`login_date` AS `login_date`,
2325 `user`.`default-location` AS `default-location`,
2326 `user`.`allow_location` AS `allow_location`,
2327 `user`.`theme` AS `theme`,
2328 `user`.`pubkey` AS `upubkey`,
2329 `user`.`prvkey` AS `uprvkey`,
2330 `user`.`sprvkey` AS `sprvkey`,
2331 `user`.`spubkey` AS `spubkey`,
2332 `user`.`verified` AS `verified`,
2333 `user`.`blockwall` AS `blockwall`,
2334 `user`.`hidewall` AS `hidewall`,
2335 `user`.`blocktags` AS `blocktags`,
2336 `user`.`unkmail` AS `unkmail`,
2337 `user`.`cntunkmail` AS `cntunkmail`,
2338 `user`.`notify-flags` AS `notify-flags`,
2339 `user`.`page-flags` AS `page-flags`,
2340 `user`.`account-type` AS `account-type`,
2341 `user`.`prvnets` AS `prvnets`,
2342 `user`.`maxreq` AS `maxreq`,
2343 `user`.`expire` AS `expire`,
2344 `user`.`account_removed` AS `account_removed`,
2345 `user`.`account_expired` AS `account_expired`,
2346 `user`.`account_expires_on` AS `account_expires_on`,
2347 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2348 `user`.`def_gid` AS `def_gid`,
2349 `user`.`allow_cid` AS `allow_cid`,
2350 `user`.`allow_gid` AS `allow_gid`,
2351 `user`.`deny_cid` AS `deny_cid`,
2352 `user`.`deny_gid` AS `deny_gid`,
2353 `user`.`openidserver` AS `openidserver`,
2354 `profile`.`publish` AS `publish`,
2355 `profile`.`net-publish` AS `net-publish`,
2356 `profile`.`hide-friends` AS `hide-friends`,
2357 `profile`.`prv_keywords` AS `prv_keywords`,
2358 `profile`.`pub_keywords` AS `pub_keywords`,
2359 `profile`.`address` AS `address`,
2360 `profile`.`locality` AS `locality`,
2361 `profile`.`region` AS `region`,
2362 `profile`.`postal-code` AS `postal-code`,
2363 `profile`.`country-name` AS `country-name`,
2364 `profile`.`homepage` AS `homepage`,
2365 `profile`.`dob` AS `dob`
2367 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2368 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2371 -- VIEW pending-view
2373 DROP VIEW IF EXISTS `pending-view`;
2374 CREATE VIEW `pending-view` AS SELECT
2375 `register`.`id` AS `id`,
2376 `register`.`hash` AS `hash`,
2377 `register`.`created` AS `created`,
2378 `register`.`uid` AS `uid`,
2379 `register`.`password` AS `password`,
2380 `register`.`language` AS `language`,
2381 `register`.`note` AS `note`,
2382 `contact`.`self` AS `self`,
2383 `contact`.`name` AS `name`,
2384 `contact`.`url` AS `url`,
2385 `contact`.`micro` AS `micro`,
2386 `user`.`email` AS `email`,
2387 `contact`.`nick` AS `nick`
2389 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2390 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2393 -- VIEW tag-search-view
2395 DROP VIEW IF EXISTS `tag-search-view`;
2396 CREATE VIEW `tag-search-view` AS SELECT
2397 `post-tag`.`uri-id` AS `uri-id`,
2398 `post-user`.`uid` AS `uid`,
2399 `post-user`.`id` AS `iid`,
2400 `post-user`.`private` AS `private`,
2401 `post-user`.`wall` AS `wall`,
2402 `post-user`.`origin` AS `origin`,
2403 `post-user`.`global` AS `global`,
2404 `post-user`.`gravity` AS `gravity`,
2405 `post-user`.`received` AS `received`,
2406 `post-user`.`network` AS `network`,
2407 `post-user`.`author-id` AS `author-id`,
2408 `tag`.`name` AS `name`
2410 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
2411 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
2412 WHERE `post-tag`.`type` = 1;
2415 -- VIEW workerqueue-view
2417 DROP VIEW IF EXISTS `workerqueue-view`;
2418 CREATE VIEW `workerqueue-view` AS SELECT
2419 `process`.`pid` AS `pid`,
2420 `workerqueue`.`priority` AS `priority`
2422 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
2423 WHERE NOT `workerqueue`.`done`;