1 -- ------------------------------------------
2 -- Friendica 2021.09-dev (Siberian Iris)
3 -- DB_UPDATE_VERSION 1426
4 -- ------------------------------------------
10 CREATE TABLE IF NOT EXISTS `gserver` (
11 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
12 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
13 `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
14 `version` varchar(255) NOT NULL DEFAULT '' COMMENT '',
15 `site_name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
16 `info` text COMMENT '',
17 `register_policy` tinyint NOT NULL DEFAULT 0 COMMENT '',
18 `registered-users` int unsigned NOT NULL DEFAULT 0 COMMENT 'Number of registered users',
19 `directory-type` tinyint DEFAULT 0 COMMENT 'Type of directory service (Poco, Mastodon)',
20 `poco` varchar(255) NOT NULL DEFAULT '' COMMENT '',
21 `noscrape` varchar(255) NOT NULL DEFAULT '' COMMENT '',
22 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
23 `protocol` tinyint unsigned COMMENT 'The protocol of the server',
24 `platform` varchar(255) NOT NULL DEFAULT '' COMMENT '',
25 `relay-subscribe` boolean NOT NULL DEFAULT '0' COMMENT 'Has the server subscribed to the relay system',
26 `relay-scope` varchar(10) NOT NULL DEFAULT '' COMMENT 'The scope of messages that the server wants to get',
27 `detection-method` tinyint unsigned COMMENT 'Method that had been used to detect that server',
28 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
29 `last_poco_query` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
30 `last_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Last successful connection request',
31 `last_failure` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Last failed connection request',
32 `failed` boolean COMMENT 'Connection failed',
33 `next_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Next connection request',
35 UNIQUE INDEX `nurl` (`nurl`(190)),
36 INDEX `next_contact` (`next_contact`),
37 INDEX `network` (`network`)
38 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Global servers';
43 CREATE TABLE IF NOT EXISTS `user` (
44 `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
45 `parent-uid` mediumint unsigned COMMENT 'The parent user that has full control about this user',
46 `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
47 `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
48 `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
49 `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
50 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
51 `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
52 `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
53 `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
54 `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
55 `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
56 `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
57 `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
58 `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
59 `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
60 `pubkey` text COMMENT 'RSA public key 4096 bit',
61 `prvkey` text COMMENT 'RSA private key 4096 bit',
62 `spubkey` text COMMENT '',
63 `sprvkey` text COMMENT '',
64 `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
65 `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
66 `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
67 `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unkown viewers',
68 `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
69 `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
70 `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
71 `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
72 `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
73 `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
74 `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
75 `pwdreset` varchar(255) COMMENT 'Password reset request token',
76 `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
77 `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
78 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
79 `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
80 `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
81 `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
82 `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
83 `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
84 `allow_cid` mediumtext COMMENT 'default permission for this user',
85 `allow_gid` mediumtext COMMENT 'default permission for this user',
86 `deny_cid` mediumtext COMMENT 'default permission for this user',
87 `deny_gid` mediumtext COMMENT 'default permission for this user',
88 `openidserver` text COMMENT '',
90 INDEX `nickname` (`nickname`(32)),
91 INDEX `parent-uid` (`parent-uid`),
92 INDEX `guid` (`guid`),
93 INDEX `email` (`email`(64)),
94 FOREIGN KEY (`parent-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
95 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
100 CREATE TABLE IF NOT EXISTS `item-uri` (
101 `id` int unsigned NOT NULL auto_increment,
102 `uri` varbinary(255) NOT NULL COMMENT 'URI of an item',
103 `guid` varbinary(255) COMMENT 'A unique identifier for an item',
105 UNIQUE INDEX `uri` (`uri`),
106 INDEX `guid` (`guid`)
107 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
112 CREATE TABLE IF NOT EXISTS `contact` (
113 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
114 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
115 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
116 `updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last contact update',
117 `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
118 `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
119 `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
120 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
121 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network of the contact',
122 `protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
123 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
124 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
125 `location` varchar(255) DEFAULT '' COMMENT '',
126 `about` text COMMENT '',
127 `keywords` text COMMENT 'public keywords (interests) of the contact',
128 `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
129 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
130 `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
131 `avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '',
132 `photo` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
133 `thumb` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
134 `micro` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
135 `header` varchar(255) COMMENT 'Header picture',
136 `site-pubkey` text COMMENT '',
137 `issued-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
138 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
139 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
140 `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
141 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
142 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
143 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
144 `pubkey` text COMMENT 'RSA public key 4096 bit',
145 `prvkey` text COMMENT 'RSA private key 4096 bit',
146 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
147 `request` varchar(255) COMMENT '',
148 `notify` varchar(255) COMMENT '',
149 `poll` varchar(255) COMMENT '',
150 `confirm` varchar(255) COMMENT '',
151 `subscribe` varchar(255) COMMENT '',
152 `poco` varchar(255) COMMENT '',
153 `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT '',
154 `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT '',
155 `usehub` boolean NOT NULL DEFAULT '0' COMMENT '',
156 `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
157 `hub-verify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
158 `last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
159 `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
160 `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
161 `failed` boolean COMMENT 'Connection failed',
162 `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
163 `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
164 `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
165 `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
166 `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
167 `last-discovery` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last follower discovery',
168 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
169 `blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
170 `block_reason` text COMMENT 'Node-wide block reason',
171 `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
172 `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
173 `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum',
174 `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group',
175 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT '',
176 `manually-approve` boolean COMMENT '',
177 `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
178 `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
179 `pending` boolean NOT NULL DEFAULT '1' COMMENT '',
180 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
181 `rating` tinyint NOT NULL DEFAULT 0 COMMENT '',
182 `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
183 `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
184 `baseurl` varchar(255) DEFAULT '' COMMENT 'baseurl of the contact',
185 `gsid` int unsigned COMMENT 'Global Server ID',
186 `reason` text COMMENT '',
187 `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT '',
188 `info` mediumtext COMMENT '',
189 `profile-id` int unsigned COMMENT 'Deprecated',
190 `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
191 `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
192 `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
193 `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
194 `ffi_keyword_denylist` text COMMENT '',
196 INDEX `uid_name` (`uid`,`name`(190)),
197 INDEX `self_uid` (`self`,`uid`),
198 INDEX `alias_uid` (`alias`(128),`uid`),
199 INDEX `pending_uid` (`pending`,`uid`),
200 INDEX `blocked_uid` (`blocked`,`uid`),
201 INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
202 INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
203 INDEX `batch_contact-type` (`batch`(64),`contact-type`),
204 INDEX `addr_uid` (`addr`(128),`uid`),
205 INDEX `nurl_uid` (`nurl`(128),`uid`),
206 INDEX `nick_uid` (`nick`(128),`uid`),
207 INDEX `attag_uid` (`attag`(96),`uid`),
208 INDEX `dfrn-id` (`dfrn-id`(64)),
209 INDEX `issued-id` (`issued-id`(64)),
210 INDEX `network_uid_lastupdate` (`network`,`uid`,`last-update`),
211 INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`),
212 INDEX `uid_lastitem` (`uid`,`last-item`),
213 INDEX `baseurl` (`baseurl`(64)),
214 INDEX `uid_contact-type` (`uid`,`contact-type`),
215 INDEX `uid_self_contact-type` (`uid`,`self`,`contact-type`),
216 INDEX `self_network_uid` (`self`,`network`,`uid`),
217 INDEX `gsid` (`gsid`),
218 INDEX `uri-id` (`uri-id`),
219 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
220 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
221 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
222 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
227 CREATE TABLE IF NOT EXISTS `tag` (
228 `id` int unsigned NOT NULL auto_increment COMMENT '',
229 `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
230 `url` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
232 UNIQUE INDEX `type_name_url` (`name`,`url`),
234 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
239 CREATE TABLE IF NOT EXISTS `clients` (
240 `client_id` varchar(20) NOT NULL COMMENT '',
241 `pw` varchar(20) NOT NULL DEFAULT '' COMMENT '',
242 `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
243 `name` text COMMENT '',
244 `icon` text COMMENT '',
245 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
246 PRIMARY KEY(`client_id`),
248 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
249 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
252 -- TABLE permissionset
254 CREATE TABLE IF NOT EXISTS `permissionset` (
255 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
256 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
257 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
258 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
259 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
260 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
262 INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`uid`,`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30)),
263 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
264 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
269 CREATE TABLE IF NOT EXISTS `verb` (
270 `id` smallint unsigned NOT NULL auto_increment,
271 `name` varchar(100) NOT NULL DEFAULT '' COMMENT '',
273 INDEX `name` (`name`)
274 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activity Verbs';
277 -- TABLE 2fa_app_specific_password
279 CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
280 `id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
281 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
282 `description` varchar(255) COMMENT 'Description of the usage of the password',
283 `hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
284 `generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
285 `last_used` datetime COMMENT 'Datetime the password was last used',
287 INDEX `uid_description` (`uid`,`description`(190)),
288 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
289 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
292 -- TABLE 2fa_recovery_codes
294 CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
295 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
296 `code` varchar(50) NOT NULL COMMENT 'Recovery code string',
297 `generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
298 `used` datetime COMMENT 'Datetime the code was used',
299 PRIMARY KEY(`uid`,`code`),
300 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
301 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
304 -- TABLE 2fa_trusted_browser
306 CREATE TABLE IF NOT EXISTS `2fa_trusted_browser` (
307 `cookie_hash` varchar(80) NOT NULL COMMENT 'Trusted cookie hash',
308 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
309 `user_agent` text COMMENT 'User agent string',
310 `created` datetime NOT NULL COMMENT 'Datetime the trusted browser was recorded',
311 `last_used` datetime COMMENT 'Datetime the trusted browser was last used',
312 PRIMARY KEY(`cookie_hash`),
314 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
315 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication trusted browsers';
320 CREATE TABLE IF NOT EXISTS `addon` (
321 `id` int unsigned NOT NULL auto_increment COMMENT '',
322 `name` varchar(50) NOT NULL DEFAULT '' COMMENT 'addon base (file)name',
323 `version` varchar(50) NOT NULL DEFAULT '' COMMENT 'currently unused',
324 `installed` boolean NOT NULL DEFAULT '0' COMMENT 'currently always 1',
325 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'currently unused',
326 `timestamp` int unsigned NOT NULL DEFAULT 0 COMMENT 'file timestamp to check for reloads',
327 `plugin_admin` boolean NOT NULL DEFAULT '0' COMMENT '1 = has admin config, 0 = has no admin config',
329 INDEX `installed_name` (`installed`,`name`),
330 UNIQUE INDEX `name` (`name`)
331 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registered addons';
336 CREATE TABLE IF NOT EXISTS `apcontact` (
337 `url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
338 `uuid` varchar(255) COMMENT '',
339 `type` varchar(20) NOT NULL COMMENT '',
340 `following` varchar(255) COMMENT '',
341 `followers` varchar(255) COMMENT '',
342 `inbox` varchar(255) NOT NULL COMMENT '',
343 `outbox` varchar(255) COMMENT '',
344 `sharedinbox` varchar(255) COMMENT '',
345 `manually-approve` boolean COMMENT '',
346 `discoverable` boolean COMMENT 'Mastodon extension: true if profile is published in their directory',
347 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
348 `name` varchar(255) COMMENT '',
349 `about` text COMMENT '',
350 `photo` varchar(255) COMMENT '',
351 `header` varchar(255) COMMENT 'Header picture',
352 `addr` varchar(255) COMMENT '',
353 `alias` varchar(255) COMMENT '',
354 `pubkey` text COMMENT '',
355 `subscribe` varchar(255) COMMENT '',
356 `baseurl` varchar(255) COMMENT 'baseurl of the ap contact',
357 `gsid` int unsigned COMMENT 'Global Server ID',
358 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
359 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
360 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
361 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
362 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
364 INDEX `addr` (`addr`(32)),
365 INDEX `alias` (`alias`(190)),
366 INDEX `followers` (`followers`(190)),
367 INDEX `baseurl` (`baseurl`(190)),
368 INDEX `sharedinbox` (`sharedinbox`(190)),
369 INDEX `gsid` (`gsid`),
370 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
371 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
376 CREATE TABLE IF NOT EXISTS `application` (
377 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
378 `client_id` varchar(64) NOT NULL COMMENT '',
379 `client_secret` varchar(64) NOT NULL COMMENT '',
380 `name` varchar(255) NOT NULL COMMENT '',
381 `redirect_uri` varchar(255) NOT NULL COMMENT '',
382 `website` varchar(255) COMMENT '',
383 `scopes` varchar(255) COMMENT '',
384 `read` boolean COMMENT 'Read scope',
385 `write` boolean COMMENT 'Write scope',
386 `follow` boolean COMMENT 'Follow scope',
387 `push` boolean COMMENT 'Push scope',
389 UNIQUE INDEX `client_id` (`client_id`)
390 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth application';
393 -- TABLE application-token
395 CREATE TABLE IF NOT EXISTS `application-token` (
396 `application-id` int unsigned NOT NULL COMMENT '',
397 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
398 `code` varchar(64) NOT NULL COMMENT '',
399 `access_token` varchar(64) NOT NULL COMMENT '',
400 `created_at` datetime NOT NULL COMMENT 'creation time',
401 `scopes` varchar(255) COMMENT '',
402 `read` boolean COMMENT 'Read scope',
403 `write` boolean COMMENT 'Write scope',
404 `follow` boolean COMMENT 'Follow scope',
405 `push` boolean COMMENT 'Push scope',
406 PRIMARY KEY(`application-id`,`uid`),
407 INDEX `uid_id` (`uid`,`application-id`),
408 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
409 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
410 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth user token';
415 CREATE TABLE IF NOT EXISTS `attach` (
416 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
417 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
418 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
419 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
420 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
421 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
422 `data` longblob NOT NULL COMMENT 'file data',
423 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
424 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
425 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
426 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
427 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
428 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
429 `backend-class` tinytext COMMENT 'Storage backend class',
430 `backend-ref` text COMMENT 'Storage backend data reference',
433 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
434 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
439 CREATE TABLE IF NOT EXISTS `auth_codes` (
440 `id` varchar(40) NOT NULL COMMENT '',
441 `client_id` varchar(20) NOT NULL DEFAULT '' COMMENT '',
442 `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
443 `expires` int NOT NULL DEFAULT 0 COMMENT '',
444 `scope` varchar(250) NOT NULL DEFAULT '' COMMENT '',
446 INDEX `client_id` (`client_id`),
447 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE
448 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
453 CREATE TABLE IF NOT EXISTS `cache` (
454 `k` varbinary(255) NOT NULL COMMENT 'cache key',
455 `v` mediumtext COMMENT 'cached serialized value',
456 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
457 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
459 INDEX `k_expires` (`k`,`expires`)
460 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
465 CREATE TABLE IF NOT EXISTS `challenge` (
466 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
467 `challenge` varchar(255) NOT NULL DEFAULT '' COMMENT '',
468 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
469 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
470 `type` varchar(255) NOT NULL DEFAULT '' COMMENT '',
471 `last_update` varchar(255) NOT NULL DEFAULT '' COMMENT '',
473 INDEX `expire` (`expire`)
474 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
479 CREATE TABLE IF NOT EXISTS `config` (
480 `id` int unsigned NOT NULL auto_increment COMMENT '',
481 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
482 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
483 `v` mediumtext COMMENT '',
485 UNIQUE INDEX `cat_k` (`cat`,`k`)
486 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
489 -- TABLE contact-relation
491 CREATE TABLE IF NOT EXISTS `contact-relation` (
492 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
493 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
494 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
495 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
496 `follows` boolean NOT NULL DEFAULT '0' COMMENT '',
497 PRIMARY KEY(`cid`,`relation-cid`),
498 INDEX `relation-cid` (`relation-cid`),
499 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
500 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
501 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
506 CREATE TABLE IF NOT EXISTS `conv` (
507 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
508 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
509 `recips` text COMMENT 'sender_handle;recipient_handle',
510 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
511 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
512 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
513 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
514 `subject` text COMMENT 'subject of initial message',
517 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
518 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
521 -- TABLE conversation
523 CREATE TABLE IF NOT EXISTS `conversation` (
524 `item-uri` varbinary(255) NOT NULL COMMENT 'Original URI of the item - unrelated to the table with the same name',
525 `reply-to-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'URI to which this item is a reply',
526 `conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI',
527 `conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link',
528 `protocol` tinyint unsigned NOT NULL DEFAULT 255 COMMENT 'The protocol of the item',
529 `direction` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'How the message arrived here: 1=push, 2=pull',
530 `source` mediumtext COMMENT 'Original source',
531 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Receiving date',
532 PRIMARY KEY(`item-uri`),
533 INDEX `conversation-uri` (`conversation-uri`),
534 INDEX `received` (`received`)
535 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Raw data and structure information for messages';
538 -- TABLE delayed-post
540 CREATE TABLE IF NOT EXISTS `delayed-post` (
541 `id` int unsigned NOT NULL auto_increment,
542 `uri` varchar(255) COMMENT 'URI of the post that will be distributed later',
543 `uid` mediumint unsigned COMMENT 'Owner User id',
544 `delayed` datetime COMMENT 'delay time',
546 UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
547 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
548 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
551 -- TABLE diaspora-interaction
553 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
554 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
555 `interaction` mediumtext COMMENT 'The Diaspora interaction',
556 PRIMARY KEY(`uri-id`),
557 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
558 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
563 CREATE TABLE IF NOT EXISTS `event` (
564 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
565 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
566 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
567 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
568 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
569 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the event uri',
570 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
571 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
572 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
573 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
574 `summary` text COMMENT 'short description or title of the event',
575 `desc` text COMMENT 'event description',
576 `location` text COMMENT 'event location',
577 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
578 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
579 `adjust` boolean NOT NULL DEFAULT '1' COMMENT 'adjust to timezone of the recipient (0 or 1)',
580 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
581 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
582 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
583 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
584 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
586 INDEX `uid_start` (`uid`,`start`),
588 INDEX `uri-id` (`uri-id`),
589 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
590 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
591 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
592 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
597 CREATE TABLE IF NOT EXISTS `fcontact` (
598 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
599 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
600 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
601 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
602 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
603 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
604 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
605 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
606 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
607 `notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
608 `poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
609 `confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
610 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
611 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
612 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
613 `pubkey` text COMMENT '',
614 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
616 INDEX `addr` (`addr`(32)),
617 UNIQUE INDEX `url` (`url`(190))
618 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
623 CREATE TABLE IF NOT EXISTS `fsuggest` (
624 `id` int unsigned NOT NULL auto_increment COMMENT '',
625 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
626 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
627 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
628 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
629 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
630 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
631 `note` text COMMENT '',
632 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
636 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
637 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
638 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
643 CREATE TABLE IF NOT EXISTS `group` (
644 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
645 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
646 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
647 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
648 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
651 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
652 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
655 -- TABLE group_member
657 CREATE TABLE IF NOT EXISTS `group_member` (
658 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
659 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
660 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
662 INDEX `contactid` (`contact-id`),
663 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
664 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
665 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
666 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
671 CREATE TABLE IF NOT EXISTS `gserver-tag` (
672 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
673 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
674 PRIMARY KEY(`gserver-id`,`tag`),
676 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
677 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
682 CREATE TABLE IF NOT EXISTS `hook` (
683 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
684 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
685 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
686 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
687 `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',
689 INDEX `priority` (`priority`),
690 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
691 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
696 CREATE TABLE IF NOT EXISTS `host` (
697 `id` tinyint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
698 `name` varchar(128) NOT NULL DEFAULT '' COMMENT 'The hostname',
700 UNIQUE INDEX `name` (`name`)
701 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Hostname';
704 -- TABLE inbox-status
706 CREATE TABLE IF NOT EXISTS `inbox-status` (
707 `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
708 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
709 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
710 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
711 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
712 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
713 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
715 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
720 CREATE TABLE IF NOT EXISTS `intro` (
721 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
722 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
723 `fid` int unsigned COMMENT '',
724 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
725 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
726 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
727 `note` text COMMENT '',
728 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
729 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
730 `blocked` boolean NOT NULL DEFAULT '1' COMMENT '',
731 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
733 INDEX `contact-id` (`contact-id`),
735 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
736 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
737 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
742 CREATE TABLE IF NOT EXISTS `locks` (
743 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
744 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
745 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
746 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
747 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
749 INDEX `name_expires` (`name`,`expires`)
750 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
755 CREATE TABLE IF NOT EXISTS `mail` (
756 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
757 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
758 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
759 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
760 `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
761 `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
762 `contact-id` varchar(255) COMMENT 'contact.id',
763 `author-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the author of the mail',
764 `convid` int unsigned COMMENT 'conv.id',
765 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
766 `body` mediumtext COMMENT '',
767 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
768 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
769 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
770 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
771 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
772 `uri-id` int unsigned COMMENT 'Item-uri id of the related mail',
773 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
774 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related mail',
775 `thr-parent` varchar(255) COMMENT '',
776 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
777 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
779 INDEX `uid_seen` (`uid`,`seen`),
780 INDEX `convid` (`convid`),
781 INDEX `uri` (`uri`(64)),
782 INDEX `parent-uri` (`parent-uri`(64)),
783 INDEX `contactid` (`contact-id`(32)),
784 INDEX `author-id` (`author-id`),
785 INDEX `uri-id` (`uri-id`),
786 INDEX `parent-uri-id` (`parent-uri-id`),
787 INDEX `thr-parent-id` (`thr-parent-id`),
788 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
789 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
790 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
791 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
792 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
793 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
798 CREATE TABLE IF NOT EXISTS `mailacct` (
799 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
800 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
801 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
802 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
803 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
804 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
805 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
806 `pass` text COMMENT '',
807 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
808 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
809 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
810 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
811 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
814 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
815 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
820 CREATE TABLE IF NOT EXISTS `manage` (
821 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
822 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
823 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
825 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
827 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
828 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
829 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
832 -- TABLE notification
834 CREATE TABLE IF NOT EXISTS `notification` (
835 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
836 `uid` mediumint unsigned COMMENT 'Owner User id',
837 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
838 `type` tinyint unsigned COMMENT '',
839 `actor-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the actor that caused the notification',
840 `target-uri-id` int unsigned COMMENT 'Item-uri id of the related post',
841 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
842 `created` datetime COMMENT '',
843 `seen` boolean DEFAULT '0' COMMENT '',
845 UNIQUE INDEX `uid_vid_type_actor-id_target-uri-id` (`uid`,`vid`,`type`,`actor-id`,`target-uri-id`),
847 INDEX `actor-id` (`actor-id`),
848 INDEX `target-uri-id` (`target-uri-id`),
849 INDEX `parent-uri-id` (`parent-uri-id`),
850 INDEX `seen_uid` (`seen`,`uid`),
851 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
852 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
853 FOREIGN KEY (`actor-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
854 FOREIGN KEY (`target-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
855 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
856 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
861 CREATE TABLE IF NOT EXISTS `notify` (
862 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
863 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
864 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
865 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
866 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
867 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
868 `msg` mediumtext COMMENT '',
869 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
870 `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
871 `iid` int unsigned COMMENT '',
872 `parent` int unsigned COMMENT '',
873 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
874 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
875 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
876 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
877 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
878 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
879 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
881 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
882 INDEX `uid_date` (`uid`,`date`),
883 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
884 INDEX `uri-id` (`uri-id`),
885 INDEX `parent-uri-id` (`parent-uri-id`),
886 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
887 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
888 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
889 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
892 -- TABLE notify-threads
894 CREATE TABLE IF NOT EXISTS `notify-threads` (
895 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
896 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
897 `master-parent-item` int unsigned COMMENT 'Deprecated',
898 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
899 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
900 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
902 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
903 INDEX `receiver-uid` (`receiver-uid`),
904 INDEX `notify-id` (`notify-id`),
905 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
906 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
907 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
908 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
913 CREATE TABLE IF NOT EXISTS `oembed` (
914 `url` varbinary(255) NOT NULL COMMENT 'page url',
915 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
916 `content` mediumtext COMMENT 'OEmbed data of the page',
917 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
918 PRIMARY KEY(`url`,`maxwidth`),
919 INDEX `created` (`created`)
920 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
923 -- TABLE openwebauth-token
925 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
926 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
927 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
928 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
929 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
930 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
931 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
934 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
935 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
940 CREATE TABLE IF NOT EXISTS `parsed_url` (
941 `url_hash` binary(64) NOT NULL COMMENT 'page url hash',
942 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
943 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
944 `url` text NOT NULL COMMENT 'page url',
945 `content` mediumtext COMMENT 'page data',
946 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
947 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration',
948 PRIMARY KEY(`url_hash`,`guessing`,`oembed`),
949 INDEX `created` (`created`),
950 INDEX `expires` (`expires`)
951 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
956 CREATE TABLE IF NOT EXISTS `pconfig` (
957 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
958 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
959 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
960 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
961 `v` mediumtext COMMENT 'Value',
963 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
964 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
965 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
970 CREATE TABLE IF NOT EXISTS `photo` (
971 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
972 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
973 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
974 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
975 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
976 `hash` char(32) COMMENT 'hash value of the photo',
977 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
978 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
979 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
980 `desc` text COMMENT '',
981 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
982 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
983 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
984 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
985 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
986 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
987 `data` mediumblob NOT NULL COMMENT '',
988 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
989 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
990 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
991 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
992 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
993 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
994 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
995 `backend-class` tinytext COMMENT 'Storage backend class',
996 `backend-ref` text COMMENT 'Storage backend data reference',
997 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
999 INDEX `contactid` (`contact-id`),
1000 INDEX `uid_contactid` (`uid`,`contact-id`),
1001 INDEX `uid_profile` (`uid`,`profile`),
1002 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
1003 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
1004 INDEX `resource-id` (`resource-id`),
1005 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1006 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1007 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1012 CREATE TABLE IF NOT EXISTS `post` (
1013 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1014 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1015 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1016 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1017 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1018 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1019 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1020 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1021 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1022 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1023 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1024 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1025 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1026 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1027 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1028 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1029 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1030 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1031 PRIMARY KEY(`uri-id`),
1032 INDEX `parent-uri-id` (`parent-uri-id`),
1033 INDEX `thr-parent-id` (`thr-parent-id`),
1034 INDEX `external-id` (`external-id`),
1035 INDEX `owner-id` (`owner-id`),
1036 INDEX `author-id` (`author-id`),
1037 INDEX `causer-id` (`causer-id`),
1038 INDEX `vid` (`vid`),
1039 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1040 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1041 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1042 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1043 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1044 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1045 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1046 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1047 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
1050 -- TABLE post-category
1052 CREATE TABLE IF NOT EXISTS `post-category` (
1053 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1054 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1055 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1056 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1057 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1058 INDEX `uri-id` (`tid`),
1059 INDEX `uid` (`uid`),
1060 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1061 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1062 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1063 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1066 -- TABLE post-content
1068 CREATE TABLE IF NOT EXISTS `post-content` (
1069 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1070 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1071 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1072 `body` mediumtext COMMENT 'item body content',
1073 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1074 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1075 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1076 `language` text COMMENT 'Language information about this post',
1077 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1078 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1079 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1080 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1081 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1082 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1083 `target` text COMMENT 'JSON encoded target structure if used',
1084 `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',
1085 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1086 PRIMARY KEY(`uri-id`),
1087 INDEX `plink` (`plink`(191)),
1088 INDEX `resource-id` (`resource-id`),
1089 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
1090 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1091 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1094 -- TABLE post-delivery-data
1096 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1097 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1098 `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',
1099 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1100 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1101 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1102 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1103 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1104 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1105 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1106 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1107 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1108 PRIMARY KEY(`uri-id`),
1109 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1110 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1115 CREATE TABLE IF NOT EXISTS `post-link` (
1116 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1117 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1118 `url` varbinary(511) NOT NULL COMMENT 'External URL',
1119 `mimetype` varchar(60) COMMENT '',
1121 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1122 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1123 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post related external links';
1128 CREATE TABLE IF NOT EXISTS `post-media` (
1129 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1130 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1131 `url` varbinary(511) NOT NULL COMMENT 'Media URL',
1132 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1133 `mimetype` varchar(60) COMMENT '',
1134 `height` smallint unsigned COMMENT 'Height of the media',
1135 `width` smallint unsigned COMMENT 'Width of the media',
1136 `size` int unsigned COMMENT 'Media size',
1137 `preview` varbinary(255) COMMENT 'Preview URL',
1138 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1139 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1140 `description` text COMMENT '',
1141 `name` varchar(255) COMMENT 'Name of the media',
1142 `author-url` varbinary(255) COMMENT 'URL of the author of the media',
1143 `author-name` varchar(255) COMMENT 'Name of the author of the media',
1144 `author-image` varbinary(255) COMMENT 'Image of the author of the media',
1145 `publisher-url` varbinary(255) COMMENT 'URL of the publisher of the media',
1146 `publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
1147 `publisher-image` varbinary(255) COMMENT 'Image of the publisher of the media',
1149 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1150 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1151 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1156 CREATE TABLE IF NOT EXISTS `post-tag` (
1157 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1158 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1159 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1160 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1161 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1162 INDEX `tid` (`tid`),
1163 INDEX `cid` (`cid`),
1164 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1165 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1166 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1167 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1170 -- TABLE post-thread
1172 CREATE TABLE IF NOT EXISTS `post-thread` (
1173 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1174 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1175 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1176 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1177 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1178 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1179 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1180 `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',
1181 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1182 PRIMARY KEY(`uri-id`),
1183 INDEX `owner-id` (`owner-id`),
1184 INDEX `author-id` (`author-id`),
1185 INDEX `causer-id` (`causer-id`),
1186 INDEX `received` (`received`),
1187 INDEX `commented` (`commented`),
1188 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1189 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1190 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1191 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1192 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1197 CREATE TABLE IF NOT EXISTS `post-user` (
1198 `id` int unsigned NOT NULL auto_increment,
1199 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1200 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1201 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1202 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1203 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1204 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1205 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1206 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1207 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1208 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1209 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1210 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1211 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1212 `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
1213 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1214 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1215 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1216 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1217 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1218 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1219 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1220 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1221 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1222 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1223 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1224 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1225 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1226 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1227 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1229 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1230 INDEX `uri-id` (`uri-id`),
1231 INDEX `parent-uri-id` (`parent-uri-id`),
1232 INDEX `thr-parent-id` (`thr-parent-id`),
1233 INDEX `external-id` (`external-id`),
1234 INDEX `owner-id` (`owner-id`),
1235 INDEX `author-id` (`author-id`),
1236 INDEX `causer-id` (`causer-id`),
1237 INDEX `vid` (`vid`),
1238 INDEX `contact-id` (`contact-id`),
1239 INDEX `event-id` (`event-id`),
1240 INDEX `psid` (`psid`),
1241 INDEX `author-id_uid` (`author-id`,`uid`),
1242 INDEX `author-id_received` (`author-id`,`received`),
1243 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1244 INDEX `uid_contactid` (`uid`,`contact-id`),
1245 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1246 INDEX `uid_unseen` (`uid`,`unseen`),
1247 INDEX `uid_hidden_uri-id` (`uid`,`hidden`,`uri-id`),
1248 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1249 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1250 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1251 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1252 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1253 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1254 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1255 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1256 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1257 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1258 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1259 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1260 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1263 -- TABLE post-thread-user
1265 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1266 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1267 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1268 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1269 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1270 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1271 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1272 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1273 `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',
1274 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1275 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1276 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'The thread is pinned on the profile page',
1277 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1278 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1279 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1280 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1281 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1282 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1283 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1284 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1285 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1286 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1287 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1288 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1289 PRIMARY KEY(`uid`,`uri-id`),
1290 INDEX `uri-id` (`uri-id`),
1291 INDEX `owner-id` (`owner-id`),
1292 INDEX `author-id` (`author-id`),
1293 INDEX `causer-id` (`causer-id`),
1294 INDEX `uid` (`uid`),
1295 INDEX `contact-id` (`contact-id`),
1296 INDEX `psid` (`psid`),
1297 INDEX `post-user-id` (`post-user-id`),
1298 INDEX `commented` (`commented`),
1299 INDEX `uid_received` (`uid`,`received`),
1300 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1301 INDEX `uid_pinned` (`uid`,`pinned`),
1302 INDEX `uid_commented` (`uid`,`commented`),
1303 INDEX `uid_starred` (`uid`,`starred`),
1304 INDEX `uid_mention` (`uid`,`mention`),
1305 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1306 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1307 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1308 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1309 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1310 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1311 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1312 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1313 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1316 -- TABLE post-user-notification
1318 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1319 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1320 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1321 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1322 PRIMARY KEY(`uid`,`uri-id`),
1323 INDEX `uri-id` (`uri-id`),
1324 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1325 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1326 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1331 CREATE TABLE IF NOT EXISTS `process` (
1332 `pid` int unsigned NOT NULL COMMENT '',
1333 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1334 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1336 INDEX `command` (`command`)
1337 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1342 CREATE TABLE IF NOT EXISTS `profile` (
1343 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1344 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1345 `profile-name` varchar(255) COMMENT 'Deprecated',
1346 `is-default` boolean COMMENT 'Deprecated',
1347 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1348 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1349 `pdesc` varchar(255) COMMENT 'Deprecated',
1350 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1351 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1352 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1353 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1354 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1355 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1356 `hometown` varchar(255) COMMENT 'Deprecated',
1357 `gender` varchar(32) COMMENT 'Deprecated',
1358 `marital` varchar(255) COMMENT 'Deprecated',
1359 `with` text COMMENT 'Deprecated',
1360 `howlong` datetime COMMENT 'Deprecated',
1361 `sexual` varchar(255) COMMENT 'Deprecated',
1362 `politic` varchar(255) COMMENT 'Deprecated',
1363 `religion` varchar(255) COMMENT 'Deprecated',
1364 `pub_keywords` text COMMENT '',
1365 `prv_keywords` text COMMENT '',
1366 `likes` text COMMENT 'Deprecated',
1367 `dislikes` text COMMENT 'Deprecated',
1368 `about` text COMMENT 'Profile description',
1369 `summary` varchar(255) COMMENT 'Deprecated',
1370 `music` text COMMENT 'Deprecated',
1371 `book` text COMMENT 'Deprecated',
1372 `tv` text COMMENT 'Deprecated',
1373 `film` text COMMENT 'Deprecated',
1374 `interest` text COMMENT 'Deprecated',
1375 `romance` text COMMENT 'Deprecated',
1376 `work` text COMMENT 'Deprecated',
1377 `education` text COMMENT 'Deprecated',
1378 `contact` text COMMENT 'Deprecated',
1379 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1380 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1381 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1382 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1383 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1384 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1386 INDEX `uid_is-default` (`uid`,`is-default`),
1387 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1388 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1389 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1392 -- TABLE profile_check
1394 CREATE TABLE IF NOT EXISTS `profile_check` (
1395 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1396 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1397 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1398 `dfrn_id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1399 `sec` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1400 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1402 INDEX `uid` (`uid`),
1403 INDEX `cid` (`cid`),
1404 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1405 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1406 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='DFRN remote auth use';
1409 -- TABLE profile_field
1411 CREATE TABLE IF NOT EXISTS `profile_field` (
1412 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1413 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1414 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1415 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1416 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1417 `value` text COMMENT 'Value of the field',
1418 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1419 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1421 INDEX `uid` (`uid`),
1422 INDEX `order` (`order`),
1423 INDEX `psid` (`psid`),
1424 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1425 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1426 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1429 -- TABLE push_subscriber
1431 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1432 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1433 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1434 `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1435 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1436 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1437 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1438 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1439 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1440 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1441 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1443 INDEX `next_try` (`next_try`),
1444 INDEX `uid` (`uid`),
1445 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1446 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1451 CREATE TABLE IF NOT EXISTS `register` (
1452 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1453 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1454 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1455 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1456 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1457 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1458 `note` text COMMENT '',
1460 INDEX `uid` (`uid`),
1461 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1462 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1467 CREATE TABLE IF NOT EXISTS `search` (
1468 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1469 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1470 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1472 INDEX `uid_term` (`uid`,`term`(64)),
1473 INDEX `term` (`term`(64)),
1474 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1475 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1480 CREATE TABLE IF NOT EXISTS `session` (
1481 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1482 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1483 `data` text COMMENT '',
1484 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1486 INDEX `sid` (`sid`(64)),
1487 INDEX `expire` (`expire`)
1488 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1493 CREATE TABLE IF NOT EXISTS `storage` (
1494 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1495 `data` longblob NOT NULL COMMENT 'file data',
1497 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1502 CREATE TABLE IF NOT EXISTS `tokens` (
1503 `id` varchar(40) NOT NULL COMMENT '',
1504 `secret` text COMMENT '',
1505 `client_id` varchar(20) NOT NULL DEFAULT '',
1506 `expires` int NOT NULL DEFAULT 0 COMMENT '',
1507 `scope` varchar(200) NOT NULL DEFAULT '' COMMENT '',
1508 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1510 INDEX `client_id` (`client_id`),
1511 INDEX `uid` (`uid`),
1512 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1513 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1514 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
1519 CREATE TABLE IF NOT EXISTS `userd` (
1520 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1521 `username` varchar(255) NOT NULL COMMENT '',
1523 INDEX `username` (`username`(32))
1524 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1527 -- TABLE user-contact
1529 CREATE TABLE IF NOT EXISTS `user-contact` (
1530 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1531 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1532 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1533 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1534 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1535 PRIMARY KEY(`uid`,`cid`),
1536 INDEX `cid` (`cid`),
1537 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1538 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1539 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1544 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1545 `key` int NOT NULL COMMENT '',
1546 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1548 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1551 -- TABLE workerqueue
1553 CREATE TABLE IF NOT EXISTS `workerqueue` (
1554 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
1555 `command` varchar(100) COMMENT 'Task command',
1556 `parameter` mediumtext COMMENT 'Task parameter',
1557 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
1558 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
1559 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
1560 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
1561 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1562 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1563 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
1565 INDEX `command` (`command`),
1566 INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
1567 INDEX `done_executed` (`done`,`executed`),
1568 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
1569 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
1570 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
1571 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
1572 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
1573 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
1576 -- VIEW application-view
1578 DROP VIEW IF EXISTS `application-view`;
1579 CREATE VIEW `application-view` AS SELECT
1580 `application`.`id` AS `id`,
1581 `application-token`.`uid` AS `uid`,
1582 `application`.`name` AS `name`,
1583 `application`.`redirect_uri` AS `redirect_uri`,
1584 `application`.`website` AS `website`,
1585 `application`.`client_id` AS `client_id`,
1586 `application`.`client_secret` AS `client_secret`,
1587 `application-token`.`code` AS `code`,
1588 `application-token`.`access_token` AS `access_token`,
1589 `application-token`.`created_at` AS `created_at`,
1590 `application-token`.`scopes` AS `scopes`,
1591 `application-token`.`read` AS `read`,
1592 `application-token`.`write` AS `write`,
1593 `application-token`.`follow` AS `follow`,
1594 `application-token`.`push` AS `push`
1595 FROM `application-token`
1596 INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`;
1599 -- VIEW post-user-view
1601 DROP VIEW IF EXISTS `post-user-view`;
1602 CREATE VIEW `post-user-view` AS SELECT
1603 `post-user`.`id` AS `id`,
1604 `post-user`.`id` AS `post-user-id`,
1605 `post-user`.`uid` AS `uid`,
1606 `parent-post`.`id` AS `parent`,
1607 `item-uri`.`uri` AS `uri`,
1608 `post-user`.`uri-id` AS `uri-id`,
1609 `parent-item-uri`.`uri` AS `parent-uri`,
1610 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1611 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1612 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1613 `item-uri`.`guid` AS `guid`,
1614 `post-user`.`wall` AS `wall`,
1615 `post-user`.`gravity` AS `gravity`,
1616 `external-item-uri`.`uri` AS `extid`,
1617 `post-user`.`external-id` AS `external-id`,
1618 `post-user`.`created` AS `created`,
1619 `post-user`.`edited` AS `edited`,
1620 `post-thread-user`.`commented` AS `commented`,
1621 `post-user`.`received` AS `received`,
1622 `post-thread-user`.`changed` AS `changed`,
1623 `post-user`.`post-type` AS `post-type`,
1624 `post-user`.`post-reason` AS `post-reason`,
1625 `post-user`.`private` AS `private`,
1626 `post-thread-user`.`pubmail` AS `pubmail`,
1627 `post-user`.`visible` AS `visible`,
1628 `post-thread-user`.`starred` AS `starred`,
1629 `post-thread-user`.`pinned` AS `pinned`,
1630 `post-user`.`unseen` AS `unseen`,
1631 `post-user`.`deleted` AS `deleted`,
1632 `post-user`.`origin` AS `origin`,
1633 `post-thread-user`.`origin` AS `parent-origin`,
1634 `post-thread-user`.`forum_mode` AS `forum_mode`,
1635 `post-thread-user`.`mention` AS `mention`,
1636 `post-user`.`global` AS `global`,
1637 `post-user`.`network` AS `network`,
1638 `post-user`.`vid` AS `vid`,
1639 `post-user`.`psid` AS `psid`,
1640 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1641 `post-content`.`title` AS `title`,
1642 `post-content`.`content-warning` AS `content-warning`,
1643 `post-content`.`raw-body` AS `raw-body`,
1644 `post-content`.`body` AS `body`,
1645 `post-content`.`rendered-hash` AS `rendered-hash`,
1646 `post-content`.`rendered-html` AS `rendered-html`,
1647 `post-content`.`language` AS `language`,
1648 `post-content`.`plink` AS `plink`,
1649 `post-content`.`location` AS `location`,
1650 `post-content`.`coord` AS `coord`,
1651 `post-content`.`app` AS `app`,
1652 `post-content`.`object-type` AS `object-type`,
1653 `post-content`.`object` AS `object`,
1654 `post-content`.`target-type` AS `target-type`,
1655 `post-content`.`target` AS `target`,
1656 `post-content`.`resource-id` AS `resource-id`,
1657 `post-user`.`contact-id` AS `contact-id`,
1658 `contact`.`url` AS `contact-link`,
1659 `contact`.`addr` AS `contact-addr`,
1660 `contact`.`name` AS `contact-name`,
1661 `contact`.`nick` AS `contact-nick`,
1662 `contact`.`thumb` AS `contact-avatar`,
1663 `contact`.`network` AS `contact-network`,
1664 `contact`.`blocked` AS `contact-blocked`,
1665 `contact`.`hidden` AS `contact-hidden`,
1666 `contact`.`readonly` AS `contact-readonly`,
1667 `contact`.`archive` AS `contact-archive`,
1668 `contact`.`pending` AS `contact-pending`,
1669 `contact`.`rel` AS `contact-rel`,
1670 `contact`.`uid` AS `contact-uid`,
1671 `contact`.`contact-type` AS `contact-contact-type`,
1672 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1673 `contact`.`self` AS `self`,
1674 `contact`.`id` AS `cid`,
1675 `contact`.`alias` AS `alias`,
1676 `contact`.`photo` AS `photo`,
1677 `contact`.`name-date` AS `name-date`,
1678 `contact`.`uri-date` AS `uri-date`,
1679 `contact`.`avatar-date` AS `avatar-date`,
1680 `contact`.`thumb` AS `thumb`,
1681 `contact`.`dfrn-id` AS `dfrn-id`,
1682 `post-user`.`author-id` AS `author-id`,
1683 `author`.`url` AS `author-link`,
1684 `author`.`addr` AS `author-addr`,
1685 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1686 `author`.`nick` AS `author-nick`,
1687 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1688 `author`.`network` AS `author-network`,
1689 `author`.`blocked` AS `author-blocked`,
1690 `author`.`hidden` AS `author-hidden`,
1691 `post-user`.`owner-id` AS `owner-id`,
1692 `owner`.`url` AS `owner-link`,
1693 `owner`.`addr` AS `owner-addr`,
1694 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1695 `owner`.`nick` AS `owner-nick`,
1696 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1697 `owner`.`network` AS `owner-network`,
1698 `owner`.`blocked` AS `owner-blocked`,
1699 `owner`.`hidden` AS `owner-hidden`,
1700 `owner`.`contact-type` AS `owner-contact-type`,
1701 `post-user`.`causer-id` AS `causer-id`,
1702 `causer`.`url` AS `causer-link`,
1703 `causer`.`addr` AS `causer-addr`,
1704 `causer`.`name` AS `causer-name`,
1705 `causer`.`nick` AS `causer-nick`,
1706 `causer`.`thumb` AS `causer-avatar`,
1707 `causer`.`network` AS `causer-network`,
1708 `causer`.`blocked` AS `causer-blocked`,
1709 `causer`.`hidden` AS `causer-hidden`,
1710 `causer`.`contact-type` AS `causer-contact-type`,
1711 `post-delivery-data`.`postopts` AS `postopts`,
1712 `post-delivery-data`.`inform` AS `inform`,
1713 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1714 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1715 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1716 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1717 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1718 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1719 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1720 `post-user`.`event-id` AS `event-id`,
1721 `event`.`created` AS `event-created`,
1722 `event`.`edited` AS `event-edited`,
1723 `event`.`start` AS `event-start`,
1724 `event`.`finish` AS `event-finish`,
1725 `event`.`summary` AS `event-summary`,
1726 `event`.`desc` AS `event-desc`,
1727 `event`.`location` AS `event-location`,
1728 `event`.`type` AS `event-type`,
1729 `event`.`nofinish` AS `event-nofinish`,
1730 `event`.`adjust` AS `event-adjust`,
1731 `event`.`ignore` AS `event-ignore`,
1732 `diaspora-interaction`.`interaction` AS `signed_text`,
1733 `parent-item-uri`.`guid` AS `parent-guid`,
1734 `parent-post`.`network` AS `parent-network`,
1735 `parent-post`.`author-id` AS `parent-author-id`,
1736 `parent-post-author`.`url` AS `parent-author-link`,
1737 `parent-post-author`.`name` AS `parent-author-name`,
1738 `parent-post-author`.`network` AS `parent-author-network`,
1739 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1740 `parent-post-author`.`hidden` AS `parent-author-hidden`
1742 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
1743 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
1744 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
1745 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
1746 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
1747 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
1748 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1749 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1750 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1751 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1752 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1753 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
1754 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
1755 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
1756 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
1757 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
1758 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1761 -- VIEW post-thread-user-view
1763 DROP VIEW IF EXISTS `post-thread-user-view`;
1764 CREATE VIEW `post-thread-user-view` AS SELECT
1765 `post-user`.`id` AS `id`,
1766 `post-user`.`id` AS `post-user-id`,
1767 `post-thread-user`.`uid` AS `uid`,
1768 `parent-post`.`id` AS `parent`,
1769 `item-uri`.`uri` AS `uri`,
1770 `post-thread-user`.`uri-id` AS `uri-id`,
1771 `parent-item-uri`.`uri` AS `parent-uri`,
1772 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1773 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1774 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1775 `item-uri`.`guid` AS `guid`,
1776 `post-thread-user`.`wall` AS `wall`,
1777 `post-user`.`gravity` AS `gravity`,
1778 `external-item-uri`.`uri` AS `extid`,
1779 `post-user`.`external-id` AS `external-id`,
1780 `post-thread-user`.`created` AS `created`,
1781 `post-user`.`edited` AS `edited`,
1782 `post-thread-user`.`commented` AS `commented`,
1783 `post-thread-user`.`received` AS `received`,
1784 `post-thread-user`.`changed` AS `changed`,
1785 `post-user`.`post-type` AS `post-type`,
1786 `post-user`.`post-reason` AS `post-reason`,
1787 `post-user`.`private` AS `private`,
1788 `post-thread-user`.`pubmail` AS `pubmail`,
1789 `post-thread-user`.`ignored` AS `ignored`,
1790 `post-user`.`visible` AS `visible`,
1791 `post-thread-user`.`starred` AS `starred`,
1792 `post-thread-user`.`pinned` AS `pinned`,
1793 `post-thread-user`.`unseen` AS `unseen`,
1794 `post-user`.`deleted` AS `deleted`,
1795 `post-thread-user`.`origin` AS `origin`,
1796 `post-thread-user`.`forum_mode` AS `forum_mode`,
1797 `post-thread-user`.`mention` AS `mention`,
1798 `post-user`.`global` AS `global`,
1799 `post-thread-user`.`network` AS `network`,
1800 `post-user`.`vid` AS `vid`,
1801 `post-thread-user`.`psid` AS `psid`,
1802 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1803 `post-content`.`title` AS `title`,
1804 `post-content`.`content-warning` AS `content-warning`,
1805 `post-content`.`raw-body` AS `raw-body`,
1806 `post-content`.`body` AS `body`,
1807 `post-content`.`rendered-hash` AS `rendered-hash`,
1808 `post-content`.`rendered-html` AS `rendered-html`,
1809 `post-content`.`language` AS `language`,
1810 `post-content`.`plink` AS `plink`,
1811 `post-content`.`location` AS `location`,
1812 `post-content`.`coord` AS `coord`,
1813 `post-content`.`app` AS `app`,
1814 `post-content`.`object-type` AS `object-type`,
1815 `post-content`.`object` AS `object`,
1816 `post-content`.`target-type` AS `target-type`,
1817 `post-content`.`target` AS `target`,
1818 `post-content`.`resource-id` AS `resource-id`,
1819 `post-thread-user`.`contact-id` AS `contact-id`,
1820 `contact`.`url` AS `contact-link`,
1821 `contact`.`addr` AS `contact-addr`,
1822 `contact`.`name` AS `contact-name`,
1823 `contact`.`nick` AS `contact-nick`,
1824 `contact`.`thumb` AS `contact-avatar`,
1825 `contact`.`network` AS `contact-network`,
1826 `contact`.`blocked` AS `contact-blocked`,
1827 `contact`.`hidden` AS `contact-hidden`,
1828 `contact`.`readonly` AS `contact-readonly`,
1829 `contact`.`archive` AS `contact-archive`,
1830 `contact`.`pending` AS `contact-pending`,
1831 `contact`.`rel` AS `contact-rel`,
1832 `contact`.`uid` AS `contact-uid`,
1833 `contact`.`contact-type` AS `contact-contact-type`,
1834 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1835 `contact`.`self` AS `self`,
1836 `contact`.`id` AS `cid`,
1837 `contact`.`alias` AS `alias`,
1838 `contact`.`photo` AS `photo`,
1839 `contact`.`name-date` AS `name-date`,
1840 `contact`.`uri-date` AS `uri-date`,
1841 `contact`.`avatar-date` AS `avatar-date`,
1842 `contact`.`thumb` AS `thumb`,
1843 `contact`.`dfrn-id` AS `dfrn-id`,
1844 `post-thread-user`.`author-id` AS `author-id`,
1845 `author`.`url` AS `author-link`,
1846 `author`.`addr` AS `author-addr`,
1847 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1848 `author`.`nick` AS `author-nick`,
1849 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1850 `author`.`network` AS `author-network`,
1851 `author`.`blocked` AS `author-blocked`,
1852 `author`.`hidden` AS `author-hidden`,
1853 `post-thread-user`.`owner-id` AS `owner-id`,
1854 `owner`.`url` AS `owner-link`,
1855 `owner`.`addr` AS `owner-addr`,
1856 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1857 `owner`.`nick` AS `owner-nick`,
1858 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1859 `owner`.`network` AS `owner-network`,
1860 `owner`.`blocked` AS `owner-blocked`,
1861 `owner`.`hidden` AS `owner-hidden`,
1862 `owner`.`contact-type` AS `owner-contact-type`,
1863 `post-thread-user`.`causer-id` AS `causer-id`,
1864 `causer`.`url` AS `causer-link`,
1865 `causer`.`addr` AS `causer-addr`,
1866 `causer`.`name` AS `causer-name`,
1867 `causer`.`nick` AS `causer-nick`,
1868 `causer`.`thumb` AS `causer-avatar`,
1869 `causer`.`network` AS `causer-network`,
1870 `causer`.`blocked` AS `causer-blocked`,
1871 `causer`.`hidden` AS `causer-hidden`,
1872 `causer`.`contact-type` AS `causer-contact-type`,
1873 `post-delivery-data`.`postopts` AS `postopts`,
1874 `post-delivery-data`.`inform` AS `inform`,
1875 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1876 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1877 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1878 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1879 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1880 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1881 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1882 `post-user`.`event-id` AS `event-id`,
1883 `event`.`created` AS `event-created`,
1884 `event`.`edited` AS `event-edited`,
1885 `event`.`start` AS `event-start`,
1886 `event`.`finish` AS `event-finish`,
1887 `event`.`summary` AS `event-summary`,
1888 `event`.`desc` AS `event-desc`,
1889 `event`.`location` AS `event-location`,
1890 `event`.`type` AS `event-type`,
1891 `event`.`nofinish` AS `event-nofinish`,
1892 `event`.`adjust` AS `event-adjust`,
1893 `event`.`ignore` AS `event-ignore`,
1894 `diaspora-interaction`.`interaction` AS `signed_text`,
1895 `parent-item-uri`.`guid` AS `parent-guid`,
1896 `parent-post`.`network` AS `parent-network`,
1897 `parent-post`.`author-id` AS `parent-author-id`,
1898 `parent-post-author`.`url` AS `parent-author-link`,
1899 `parent-post-author`.`name` AS `parent-author-name`,
1900 `parent-post-author`.`network` AS `parent-author-network`,
1901 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1902 `parent-post-author`.`hidden` AS `parent-author-hidden`
1903 FROM `post-thread-user`
1904 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
1905 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
1906 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
1907 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
1908 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
1909 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
1910 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1911 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1912 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1913 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1914 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1915 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
1916 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
1917 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
1918 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
1919 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`
1920 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1925 DROP VIEW IF EXISTS `post-view`;
1926 CREATE VIEW `post-view` AS SELECT
1927 `item-uri`.`uri` AS `uri`,
1928 `post`.`uri-id` AS `uri-id`,
1929 `parent-item-uri`.`uri` AS `parent-uri`,
1930 `post`.`parent-uri-id` AS `parent-uri-id`,
1931 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1932 `post`.`thr-parent-id` AS `thr-parent-id`,
1933 `item-uri`.`guid` AS `guid`,
1934 `post`.`gravity` AS `gravity`,
1935 `external-item-uri`.`uri` AS `extid`,
1936 `post`.`external-id` AS `external-id`,
1937 `post`.`created` AS `created`,
1938 `post`.`edited` AS `edited`,
1939 `post-thread`.`commented` AS `commented`,
1940 `post`.`received` AS `received`,
1941 `post-thread`.`changed` AS `changed`,
1942 `post`.`post-type` AS `post-type`,
1943 `post`.`private` AS `private`,
1944 `post`.`visible` AS `visible`,
1945 `post`.`deleted` AS `deleted`,
1946 `post`.`global` AS `global`,
1947 `post`.`network` AS `network`,
1948 `post`.`vid` AS `vid`,
1949 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1950 `post-content`.`title` AS `title`,
1951 `post-content`.`content-warning` AS `content-warning`,
1952 `post-content`.`raw-body` AS `raw-body`,
1953 `post-content`.`body` AS `body`,
1954 `post-content`.`rendered-hash` AS `rendered-hash`,
1955 `post-content`.`rendered-html` AS `rendered-html`,
1956 `post-content`.`language` AS `language`,
1957 `post-content`.`plink` AS `plink`,
1958 `post-content`.`location` AS `location`,
1959 `post-content`.`coord` AS `coord`,
1960 `post-content`.`app` AS `app`,
1961 `post-content`.`object-type` AS `object-type`,
1962 `post-content`.`object` AS `object`,
1963 `post-content`.`target-type` AS `target-type`,
1964 `post-content`.`target` AS `target`,
1965 `post-content`.`resource-id` AS `resource-id`,
1966 `post`.`author-id` AS `contact-id`,
1967 `author`.`url` AS `contact-link`,
1968 `author`.`addr` AS `contact-addr`,
1969 `author`.`name` AS `contact-name`,
1970 `author`.`nick` AS `contact-nick`,
1971 `author`.`thumb` AS `contact-avatar`,
1972 `author`.`network` AS `contact-network`,
1973 `author`.`blocked` AS `contact-blocked`,
1974 `author`.`hidden` AS `contact-hidden`,
1975 `author`.`readonly` AS `contact-readonly`,
1976 `author`.`archive` AS `contact-archive`,
1977 `author`.`pending` AS `contact-pending`,
1978 `author`.`rel` AS `contact-rel`,
1979 `author`.`uid` AS `contact-uid`,
1980 `author`.`contact-type` AS `contact-contact-type`,
1981 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
1983 `author`.`id` AS `cid`,
1984 `author`.`alias` AS `alias`,
1985 `author`.`photo` AS `photo`,
1986 `author`.`name-date` AS `name-date`,
1987 `author`.`uri-date` AS `uri-date`,
1988 `author`.`avatar-date` AS `avatar-date`,
1989 `author`.`thumb` AS `thumb`,
1990 `author`.`dfrn-id` AS `dfrn-id`,
1991 `post`.`author-id` AS `author-id`,
1992 `author`.`url` AS `author-link`,
1993 `author`.`addr` AS `author-addr`,
1994 `author`.`name` AS `author-name`,
1995 `author`.`nick` AS `author-nick`,
1996 `author`.`thumb` AS `author-avatar`,
1997 `author`.`network` AS `author-network`,
1998 `author`.`blocked` AS `author-blocked`,
1999 `author`.`hidden` AS `author-hidden`,
2000 `post`.`owner-id` AS `owner-id`,
2001 `owner`.`url` AS `owner-link`,
2002 `owner`.`addr` AS `owner-addr`,
2003 `owner`.`name` AS `owner-name`,
2004 `owner`.`nick` AS `owner-nick`,
2005 `owner`.`thumb` AS `owner-avatar`,
2006 `owner`.`network` AS `owner-network`,
2007 `owner`.`blocked` AS `owner-blocked`,
2008 `owner`.`hidden` AS `owner-hidden`,
2009 `owner`.`contact-type` AS `owner-contact-type`,
2010 `post`.`causer-id` AS `causer-id`,
2011 `causer`.`url` AS `causer-link`,
2012 `causer`.`addr` AS `causer-addr`,
2013 `causer`.`name` AS `causer-name`,
2014 `causer`.`nick` AS `causer-nick`,
2015 `causer`.`thumb` AS `causer-avatar`,
2016 `causer`.`network` AS `causer-network`,
2017 `causer`.`blocked` AS `causer-blocked`,
2018 `causer`.`hidden` AS `causer-hidden`,
2019 `causer`.`contact-type` AS `causer-contact-type`,
2020 `diaspora-interaction`.`interaction` AS `signed_text`,
2021 `parent-item-uri`.`guid` AS `parent-guid`,
2022 `parent-post`.`network` AS `parent-network`,
2023 `parent-post`.`author-id` AS `parent-author-id`,
2024 `parent-post-author`.`url` AS `parent-author-link`,
2025 `parent-post-author`.`name` AS `parent-author-name`,
2026 `parent-post-author`.`network` AS `parent-author-network`,
2027 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2028 `parent-post-author`.`hidden` AS `parent-author-hidden`
2030 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
2031 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
2032 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
2033 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
2034 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
2035 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2036 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2037 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2038 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2039 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
2040 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
2041 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2042 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2045 -- VIEW post-thread-view
2047 DROP VIEW IF EXISTS `post-thread-view`;
2048 CREATE VIEW `post-thread-view` AS SELECT
2049 `item-uri`.`uri` AS `uri`,
2050 `post-thread`.`uri-id` AS `uri-id`,
2051 `parent-item-uri`.`uri` AS `parent-uri`,
2052 `post`.`parent-uri-id` AS `parent-uri-id`,
2053 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2054 `post`.`thr-parent-id` AS `thr-parent-id`,
2055 `item-uri`.`guid` AS `guid`,
2056 `post`.`gravity` AS `gravity`,
2057 `external-item-uri`.`uri` AS `extid`,
2058 `post`.`external-id` AS `external-id`,
2059 `post-thread`.`created` AS `created`,
2060 `post`.`edited` AS `edited`,
2061 `post-thread`.`commented` AS `commented`,
2062 `post-thread`.`received` AS `received`,
2063 `post-thread`.`changed` AS `changed`,
2064 `post`.`post-type` AS `post-type`,
2065 `post`.`private` AS `private`,
2066 `post`.`visible` AS `visible`,
2067 `post`.`deleted` AS `deleted`,
2068 `post`.`global` AS `global`,
2069 `post-thread`.`network` AS `network`,
2070 `post`.`vid` AS `vid`,
2071 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2072 `post-content`.`title` AS `title`,
2073 `post-content`.`content-warning` AS `content-warning`,
2074 `post-content`.`raw-body` AS `raw-body`,
2075 `post-content`.`body` AS `body`,
2076 `post-content`.`rendered-hash` AS `rendered-hash`,
2077 `post-content`.`rendered-html` AS `rendered-html`,
2078 `post-content`.`language` AS `language`,
2079 `post-content`.`plink` AS `plink`,
2080 `post-content`.`location` AS `location`,
2081 `post-content`.`coord` AS `coord`,
2082 `post-content`.`app` AS `app`,
2083 `post-content`.`object-type` AS `object-type`,
2084 `post-content`.`object` AS `object`,
2085 `post-content`.`target-type` AS `target-type`,
2086 `post-content`.`target` AS `target`,
2087 `post-content`.`resource-id` AS `resource-id`,
2088 `post-thread`.`author-id` AS `contact-id`,
2089 `author`.`url` AS `contact-link`,
2090 `author`.`addr` AS `contact-addr`,
2091 `author`.`name` AS `contact-name`,
2092 `author`.`nick` AS `contact-nick`,
2093 `author`.`thumb` AS `contact-avatar`,
2094 `author`.`network` AS `contact-network`,
2095 `author`.`blocked` AS `contact-blocked`,
2096 `author`.`hidden` AS `contact-hidden`,
2097 `author`.`readonly` AS `contact-readonly`,
2098 `author`.`archive` AS `contact-archive`,
2099 `author`.`pending` AS `contact-pending`,
2100 `author`.`rel` AS `contact-rel`,
2101 `author`.`uid` AS `contact-uid`,
2102 `author`.`contact-type` AS `contact-contact-type`,
2103 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2105 `author`.`id` AS `cid`,
2106 `author`.`alias` AS `alias`,
2107 `author`.`photo` AS `photo`,
2108 `author`.`name-date` AS `name-date`,
2109 `author`.`uri-date` AS `uri-date`,
2110 `author`.`avatar-date` AS `avatar-date`,
2111 `author`.`thumb` AS `thumb`,
2112 `author`.`dfrn-id` AS `dfrn-id`,
2113 `post-thread`.`author-id` AS `author-id`,
2114 `author`.`url` AS `author-link`,
2115 `author`.`addr` AS `author-addr`,
2116 `author`.`name` AS `author-name`,
2117 `author`.`nick` AS `author-nick`,
2118 `author`.`thumb` AS `author-avatar`,
2119 `author`.`network` AS `author-network`,
2120 `author`.`blocked` AS `author-blocked`,
2121 `author`.`hidden` AS `author-hidden`,
2122 `post-thread`.`owner-id` AS `owner-id`,
2123 `owner`.`url` AS `owner-link`,
2124 `owner`.`addr` AS `owner-addr`,
2125 `owner`.`name` AS `owner-name`,
2126 `owner`.`nick` AS `owner-nick`,
2127 `owner`.`thumb` AS `owner-avatar`,
2128 `owner`.`network` AS `owner-network`,
2129 `owner`.`blocked` AS `owner-blocked`,
2130 `owner`.`hidden` AS `owner-hidden`,
2131 `owner`.`contact-type` AS `owner-contact-type`,
2132 `post-thread`.`causer-id` AS `causer-id`,
2133 `causer`.`url` AS `causer-link`,
2134 `causer`.`addr` AS `causer-addr`,
2135 `causer`.`name` AS `causer-name`,
2136 `causer`.`nick` AS `causer-nick`,
2137 `causer`.`thumb` AS `causer-avatar`,
2138 `causer`.`network` AS `causer-network`,
2139 `causer`.`blocked` AS `causer-blocked`,
2140 `causer`.`hidden` AS `causer-hidden`,
2141 `causer`.`contact-type` AS `causer-contact-type`,
2142 `diaspora-interaction`.`interaction` AS `signed_text`,
2143 `parent-item-uri`.`guid` AS `parent-guid`,
2144 `parent-post`.`network` AS `parent-network`,
2145 `parent-post`.`author-id` AS `parent-author-id`,
2146 `parent-post-author`.`url` AS `parent-author-link`,
2147 `parent-post-author`.`name` AS `parent-author-name`,
2148 `parent-post-author`.`network` AS `parent-author-network`,
2149 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2150 `parent-post-author`.`hidden` AS `parent-author-hidden`
2152 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
2153 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
2154 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
2155 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
2156 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
2157 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2158 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2159 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2160 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2161 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
2162 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
2163 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2164 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2167 -- VIEW category-view
2169 DROP VIEW IF EXISTS `category-view`;
2170 CREATE VIEW `category-view` AS SELECT
2171 `post-category`.`uri-id` AS `uri-id`,
2172 `post-category`.`uid` AS `uid`,
2173 `post-category`.`type` AS `type`,
2174 `post-category`.`tid` AS `tid`,
2175 `tag`.`name` AS `name`,
2176 `tag`.`url` AS `url`
2177 FROM `post-category`
2178 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2183 DROP VIEW IF EXISTS `tag-view`;
2184 CREATE VIEW `tag-view` AS SELECT
2185 `post-tag`.`uri-id` AS `uri-id`,
2186 `post-tag`.`type` AS `type`,
2187 `post-tag`.`tid` AS `tid`,
2188 `post-tag`.`cid` AS `cid`,
2189 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2190 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
2192 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2193 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2196 -- VIEW network-item-view
2198 DROP VIEW IF EXISTS `network-item-view`;
2199 CREATE VIEW `network-item-view` AS SELECT
2200 `post-user`.`uri-id` AS `uri-id`,
2201 `parent-post`.`id` AS `parent`,
2202 `post-user`.`received` AS `received`,
2203 `post-thread-user`.`commented` AS `commented`,
2204 `post-user`.`created` AS `created`,
2205 `post-user`.`uid` AS `uid`,
2206 `post-thread-user`.`starred` AS `starred`,
2207 `post-thread-user`.`mention` AS `mention`,
2208 `post-user`.`network` AS `network`,
2209 `post-user`.`unseen` AS `unseen`,
2210 `post-user`.`gravity` AS `gravity`,
2211 `post-user`.`contact-id` AS `contact-id`,
2212 `ownercontact`.`contact-type` AS `contact-type`
2214 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2215 INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2216 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2217 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2218 INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2219 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2220 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2221 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2222 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
2223 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2224 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2227 -- VIEW network-thread-view
2229 DROP VIEW IF EXISTS `network-thread-view`;
2230 CREATE VIEW `network-thread-view` AS SELECT
2231 `post-thread-user`.`uri-id` AS `uri-id`,
2232 `parent-post`.`id` AS `parent`,
2233 `post-thread-user`.`received` AS `received`,
2234 `post-thread-user`.`commented` AS `commented`,
2235 `post-thread-user`.`created` AS `created`,
2236 `post-thread-user`.`uid` AS `uid`,
2237 `post-thread-user`.`starred` AS `starred`,
2238 `post-thread-user`.`mention` AS `mention`,
2239 `post-thread-user`.`network` AS `network`,
2240 `post-thread-user`.`contact-id` AS `contact-id`,
2241 `ownercontact`.`contact-type` AS `contact-type`
2242 FROM `post-thread-user`
2243 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2244 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2245 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2246 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2247 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2248 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2249 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2250 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2251 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2252 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2253 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2258 DROP VIEW IF EXISTS `owner-view`;
2259 CREATE VIEW `owner-view` AS SELECT
2260 `contact`.`id` AS `id`,
2261 `contact`.`uid` AS `uid`,
2262 `contact`.`created` AS `created`,
2263 `contact`.`updated` AS `updated`,
2264 `contact`.`self` AS `self`,
2265 `contact`.`remote_self` AS `remote_self`,
2266 `contact`.`rel` AS `rel`,
2267 `contact`.`duplex` AS `duplex`,
2268 `contact`.`network` AS `network`,
2269 `contact`.`protocol` AS `protocol`,
2270 `contact`.`name` AS `name`,
2271 `contact`.`nick` AS `nick`,
2272 `contact`.`location` AS `location`,
2273 `contact`.`about` AS `about`,
2274 `contact`.`keywords` AS `keywords`,
2275 `contact`.`gender` AS `gender`,
2276 `contact`.`xmpp` AS `xmpp`,
2277 `contact`.`attag` AS `attag`,
2278 `contact`.`avatar` AS `avatar`,
2279 `contact`.`photo` AS `photo`,
2280 `contact`.`thumb` AS `thumb`,
2281 `contact`.`micro` AS `micro`,
2282 `contact`.`header` AS `header`,
2283 `contact`.`site-pubkey` AS `site-pubkey`,
2284 `contact`.`issued-id` AS `issued-id`,
2285 `contact`.`dfrn-id` AS `dfrn-id`,
2286 `contact`.`url` AS `url`,
2287 `contact`.`nurl` AS `nurl`,
2288 `contact`.`addr` AS `addr`,
2289 `contact`.`alias` AS `alias`,
2290 `contact`.`pubkey` AS `pubkey`,
2291 `contact`.`prvkey` AS `prvkey`,
2292 `contact`.`batch` AS `batch`,
2293 `contact`.`request` AS `request`,
2294 `contact`.`notify` AS `notify`,
2295 `contact`.`poll` AS `poll`,
2296 `contact`.`confirm` AS `confirm`,
2297 `contact`.`poco` AS `poco`,
2298 `contact`.`aes_allow` AS `aes_allow`,
2299 `contact`.`ret-aes` AS `ret-aes`,
2300 `contact`.`usehub` AS `usehub`,
2301 `contact`.`subhub` AS `subhub`,
2302 `contact`.`hub-verify` AS `hub-verify`,
2303 `contact`.`last-update` AS `last-update`,
2304 `contact`.`success_update` AS `success_update`,
2305 `contact`.`failure_update` AS `failure_update`,
2306 `contact`.`name-date` AS `name-date`,
2307 `contact`.`uri-date` AS `uri-date`,
2308 `contact`.`avatar-date` AS `avatar-date`,
2309 `contact`.`avatar-date` AS `picdate`,
2310 `contact`.`term-date` AS `term-date`,
2311 `contact`.`last-item` AS `last-item`,
2312 `contact`.`priority` AS `priority`,
2313 `user`.`blocked` AS `blocked`,
2314 `contact`.`block_reason` AS `block_reason`,
2315 `contact`.`readonly` AS `readonly`,
2316 `contact`.`writable` AS `writable`,
2317 `contact`.`forum` AS `forum`,
2318 `contact`.`prv` AS `prv`,
2319 `contact`.`contact-type` AS `contact-type`,
2320 `contact`.`manually-approve` AS `manually-approve`,
2321 `contact`.`hidden` AS `hidden`,
2322 `contact`.`archive` AS `archive`,
2323 `contact`.`pending` AS `pending`,
2324 `contact`.`deleted` AS `deleted`,
2325 `contact`.`unsearchable` AS `unsearchable`,
2326 `contact`.`sensitive` AS `sensitive`,
2327 `contact`.`baseurl` AS `baseurl`,
2328 `contact`.`reason` AS `reason`,
2329 `contact`.`closeness` AS `closeness`,
2330 `contact`.`info` AS `info`,
2331 `contact`.`profile-id` AS `profile-id`,
2332 `contact`.`bdyear` AS `bdyear`,
2333 `contact`.`bd` AS `bd`,
2334 `contact`.`notify_new_posts` AS `notify_new_posts`,
2335 `contact`.`fetch_further_information` AS `fetch_further_information`,
2336 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2337 `user`.`parent-uid` AS `parent-uid`,
2338 `user`.`guid` AS `guid`,
2339 `user`.`nickname` AS `nickname`,
2340 `user`.`email` AS `email`,
2341 `user`.`openid` AS `openid`,
2342 `user`.`timezone` AS `timezone`,
2343 `user`.`language` AS `language`,
2344 `user`.`register_date` AS `register_date`,
2345 `user`.`login_date` AS `login_date`,
2346 `user`.`default-location` AS `default-location`,
2347 `user`.`allow_location` AS `allow_location`,
2348 `user`.`theme` AS `theme`,
2349 `user`.`pubkey` AS `upubkey`,
2350 `user`.`prvkey` AS `uprvkey`,
2351 `user`.`sprvkey` AS `sprvkey`,
2352 `user`.`spubkey` AS `spubkey`,
2353 `user`.`verified` AS `verified`,
2354 `user`.`blockwall` AS `blockwall`,
2355 `user`.`hidewall` AS `hidewall`,
2356 `user`.`blocktags` AS `blocktags`,
2357 `user`.`unkmail` AS `unkmail`,
2358 `user`.`cntunkmail` AS `cntunkmail`,
2359 `user`.`notify-flags` AS `notify-flags`,
2360 `user`.`page-flags` AS `page-flags`,
2361 `user`.`account-type` AS `account-type`,
2362 `user`.`prvnets` AS `prvnets`,
2363 `user`.`maxreq` AS `maxreq`,
2364 `user`.`expire` AS `expire`,
2365 `user`.`account_removed` AS `account_removed`,
2366 `user`.`account_expired` AS `account_expired`,
2367 `user`.`account_expires_on` AS `account_expires_on`,
2368 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2369 `user`.`def_gid` AS `def_gid`,
2370 `user`.`allow_cid` AS `allow_cid`,
2371 `user`.`allow_gid` AS `allow_gid`,
2372 `user`.`deny_cid` AS `deny_cid`,
2373 `user`.`deny_gid` AS `deny_gid`,
2374 `user`.`openidserver` AS `openidserver`,
2375 `profile`.`publish` AS `publish`,
2376 `profile`.`net-publish` AS `net-publish`,
2377 `profile`.`hide-friends` AS `hide-friends`,
2378 `profile`.`prv_keywords` AS `prv_keywords`,
2379 `profile`.`pub_keywords` AS `pub_keywords`,
2380 `profile`.`address` AS `address`,
2381 `profile`.`locality` AS `locality`,
2382 `profile`.`region` AS `region`,
2383 `profile`.`postal-code` AS `postal-code`,
2384 `profile`.`country-name` AS `country-name`,
2385 `profile`.`homepage` AS `homepage`,
2386 `profile`.`dob` AS `dob`
2388 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2389 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2392 -- VIEW pending-view
2394 DROP VIEW IF EXISTS `pending-view`;
2395 CREATE VIEW `pending-view` AS SELECT
2396 `register`.`id` AS `id`,
2397 `register`.`hash` AS `hash`,
2398 `register`.`created` AS `created`,
2399 `register`.`uid` AS `uid`,
2400 `register`.`password` AS `password`,
2401 `register`.`language` AS `language`,
2402 `register`.`note` AS `note`,
2403 `contact`.`self` AS `self`,
2404 `contact`.`name` AS `name`,
2405 `contact`.`url` AS `url`,
2406 `contact`.`micro` AS `micro`,
2407 `user`.`email` AS `email`,
2408 `contact`.`nick` AS `nick`
2410 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2411 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2414 -- VIEW tag-search-view
2416 DROP VIEW IF EXISTS `tag-search-view`;
2417 CREATE VIEW `tag-search-view` AS SELECT
2418 `post-tag`.`uri-id` AS `uri-id`,
2419 `post-user`.`uid` AS `uid`,
2420 `post-user`.`id` AS `iid`,
2421 `post-user`.`private` AS `private`,
2422 `post-user`.`wall` AS `wall`,
2423 `post-user`.`origin` AS `origin`,
2424 `post-user`.`global` AS `global`,
2425 `post-user`.`gravity` AS `gravity`,
2426 `post-user`.`received` AS `received`,
2427 `post-user`.`network` AS `network`,
2428 `post-user`.`author-id` AS `author-id`,
2429 `tag`.`name` AS `name`
2431 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
2432 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
2433 WHERE `post-tag`.`type` = 1;
2436 -- VIEW workerqueue-view
2438 DROP VIEW IF EXISTS `workerqueue-view`;
2439 CREATE VIEW `workerqueue-view` AS SELECT
2440 `process`.`pid` AS `pid`,
2441 `workerqueue`.`priority` AS `priority`
2443 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
2444 WHERE NOT `workerqueue`.`done`;