1 -- ------------------------------------------
2 -- Friendica 2021.06-dev (Siberian Iris)
3 -- DB_UPDATE_VERSION 1415
4 -- ------------------------------------------
10 CREATE TABLE IF NOT EXISTS `gserver` (
11 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
12 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
13 `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
14 `version` varchar(255) NOT NULL DEFAULT '' COMMENT '',
15 `site_name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
16 `info` text COMMENT '',
17 `register_policy` tinyint NOT NULL DEFAULT 0 COMMENT '',
18 `registered-users` int unsigned NOT NULL DEFAULT 0 COMMENT 'Number of registered users',
19 `directory-type` tinyint DEFAULT 0 COMMENT 'Type of directory service (Poco, Mastodon)',
20 `poco` varchar(255) NOT NULL DEFAULT '' COMMENT '',
21 `noscrape` varchar(255) NOT NULL DEFAULT '' COMMENT '',
22 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
23 `protocol` tinyint unsigned COMMENT 'The protocol of the server',
24 `platform` varchar(255) NOT NULL DEFAULT '' COMMENT '',
25 `relay-subscribe` boolean NOT NULL DEFAULT '0' COMMENT 'Has the server subscribed to the relay system',
26 `relay-scope` varchar(10) NOT NULL DEFAULT '' COMMENT 'The scope of messages that the server wants to get',
27 `detection-method` tinyint unsigned COMMENT 'Method that had been used to detect that server',
28 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
29 `last_poco_query` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
30 `last_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Last successful connection request',
31 `last_failure` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Last failed connection request',
32 `failed` boolean COMMENT 'Connection failed',
33 `next_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Next connection request',
35 UNIQUE INDEX `nurl` (`nurl`(190)),
36 INDEX `next_contact` (`next_contact`),
37 INDEX `network` (`network`)
38 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Global servers';
43 CREATE TABLE IF NOT EXISTS `user` (
44 `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
45 `parent-uid` mediumint unsigned COMMENT 'The parent user that has full control about this user',
46 `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
47 `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
48 `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
49 `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
50 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
51 `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
52 `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
53 `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
54 `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
55 `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
56 `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
57 `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
58 `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
59 `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
60 `pubkey` text COMMENT 'RSA public key 4096 bit',
61 `prvkey` text COMMENT 'RSA private key 4096 bit',
62 `spubkey` text COMMENT '',
63 `sprvkey` text COMMENT '',
64 `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
65 `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
66 `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
67 `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unkown viewers',
68 `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
69 `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
70 `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
71 `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
72 `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
73 `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
74 `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
75 `pwdreset` varchar(255) COMMENT 'Password reset request token',
76 `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
77 `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
78 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
79 `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
80 `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
81 `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
82 `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
83 `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
84 `allow_cid` mediumtext COMMENT 'default permission for this user',
85 `allow_gid` mediumtext COMMENT 'default permission for this user',
86 `deny_cid` mediumtext COMMENT 'default permission for this user',
87 `deny_gid` mediumtext COMMENT 'default permission for this user',
88 `openidserver` text COMMENT '',
90 INDEX `nickname` (`nickname`(32)),
91 INDEX `parent-uid` (`parent-uid`),
92 INDEX `guid` (`guid`),
93 INDEX `email` (`email`(64)),
94 FOREIGN KEY (`parent-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
95 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
100 CREATE TABLE IF NOT EXISTS `contact` (
101 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
102 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
103 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
104 `updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last contact update',
105 `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
106 `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
107 `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
108 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
109 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network of the contact',
110 `protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
111 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
112 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
113 `location` varchar(255) DEFAULT '' COMMENT '',
114 `about` text COMMENT '',
115 `keywords` text COMMENT 'public keywords (interests) of the contact',
116 `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
117 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
118 `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
119 `avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '',
120 `photo` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
121 `thumb` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
122 `micro` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
123 `site-pubkey` text COMMENT '',
124 `issued-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
125 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
126 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
127 `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
128 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
129 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
130 `pubkey` text COMMENT 'RSA public key 4096 bit',
131 `prvkey` text COMMENT 'RSA private key 4096 bit',
132 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
133 `request` varchar(255) COMMENT '',
134 `notify` varchar(255) COMMENT '',
135 `poll` varchar(255) COMMENT '',
136 `confirm` varchar(255) COMMENT '',
137 `subscribe` varchar(255) COMMENT '',
138 `poco` varchar(255) COMMENT '',
139 `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT '',
140 `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT '',
141 `usehub` boolean NOT NULL DEFAULT '0' COMMENT '',
142 `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
143 `hub-verify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
144 `last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
145 `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
146 `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
147 `failed` boolean COMMENT 'Connection failed',
148 `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
149 `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
150 `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
151 `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
152 `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
153 `last-discovery` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last follower discovery',
154 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
155 `blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
156 `block_reason` text COMMENT 'Node-wide block reason',
157 `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
158 `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
159 `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum',
160 `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group',
161 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT '',
162 `manually-approve` boolean COMMENT '',
163 `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
164 `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
165 `pending` boolean NOT NULL DEFAULT '1' COMMENT '',
166 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
167 `rating` tinyint NOT NULL DEFAULT 0 COMMENT '',
168 `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
169 `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
170 `baseurl` varchar(255) DEFAULT '' COMMENT 'baseurl of the contact',
171 `gsid` int unsigned COMMENT 'Global Server ID',
172 `reason` text COMMENT '',
173 `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT '',
174 `info` mediumtext COMMENT '',
175 `profile-id` int unsigned COMMENT 'Deprecated',
176 `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
177 `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
178 `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
179 `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
180 `ffi_keyword_denylist` text COMMENT '',
182 INDEX `uid_name` (`uid`,`name`(190)),
183 INDEX `self_uid` (`self`,`uid`),
184 INDEX `alias_uid` (`alias`(128),`uid`),
185 INDEX `pending_uid` (`pending`,`uid`),
186 INDEX `blocked_uid` (`blocked`,`uid`),
187 INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
188 INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
189 INDEX `batch_contact-type` (`batch`(64),`contact-type`),
190 INDEX `addr_uid` (`addr`(128),`uid`),
191 INDEX `nurl_uid` (`nurl`(128),`uid`),
192 INDEX `nick_uid` (`nick`(128),`uid`),
193 INDEX `attag_uid` (`attag`(96),`uid`),
194 INDEX `dfrn-id` (`dfrn-id`(64)),
195 INDEX `issued-id` (`issued-id`(64)),
196 INDEX `network_uid_lastupdate` (`network`,`uid`,`last-update`),
197 INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`),
198 INDEX `uid_lastitem` (`uid`,`last-item`),
199 INDEX `baseurl` (`baseurl`(64)),
200 INDEX `uid_contact-type` (`uid`,`contact-type`),
201 INDEX `uid_self_contact-type` (`uid`,`self`,`contact-type`),
202 INDEX `self_network_uid` (`self`,`network`,`uid`),
203 INDEX `gsid` (`gsid`),
204 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
205 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
206 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
211 CREATE TABLE IF NOT EXISTS `item-uri` (
212 `id` int unsigned NOT NULL auto_increment,
213 `uri` varbinary(255) NOT NULL COMMENT 'URI of an item',
214 `guid` varbinary(255) COMMENT 'A unique identifier for an item',
216 UNIQUE INDEX `uri` (`uri`),
217 INDEX `guid` (`guid`)
218 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
223 CREATE TABLE IF NOT EXISTS `tag` (
224 `id` int unsigned NOT NULL auto_increment COMMENT '',
225 `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
226 `url` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
228 UNIQUE INDEX `type_name_url` (`name`,`url`),
230 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
235 CREATE TABLE IF NOT EXISTS `clients` (
236 `client_id` varchar(20) NOT NULL COMMENT '',
237 `pw` varchar(20) NOT NULL DEFAULT '' COMMENT '',
238 `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
239 `name` text COMMENT '',
240 `icon` text COMMENT '',
241 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
242 PRIMARY KEY(`client_id`),
244 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
245 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
248 -- TABLE permissionset
250 CREATE TABLE IF NOT EXISTS `permissionset` (
251 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
252 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
253 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
254 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
255 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
256 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
258 INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`uid`,`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30)),
259 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
260 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
265 CREATE TABLE IF NOT EXISTS `verb` (
266 `id` smallint unsigned NOT NULL auto_increment,
267 `name` varchar(100) NOT NULL DEFAULT '' COMMENT '',
269 INDEX `name` (`name`)
270 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activity Verbs';
273 -- TABLE 2fa_app_specific_password
275 CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
276 `id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
277 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
278 `description` varchar(255) COMMENT 'Description of the usage of the password',
279 `hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
280 `generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
281 `last_used` datetime COMMENT 'Datetime the password was last used',
283 INDEX `uid_description` (`uid`,`description`(190)),
284 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
285 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
288 -- TABLE 2fa_recovery_codes
290 CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
291 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
292 `code` varchar(50) NOT NULL COMMENT 'Recovery code string',
293 `generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
294 `used` datetime COMMENT 'Datetime the code was used',
295 PRIMARY KEY(`uid`,`code`),
296 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
297 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
300 -- TABLE 2fa_trusted_browser
302 CREATE TABLE IF NOT EXISTS `2fa_trusted_browser` (
303 `cookie_hash` varchar(80) NOT NULL COMMENT 'Trusted cookie hash',
304 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
305 `user_agent` text COMMENT 'User agent string',
306 `created` datetime NOT NULL COMMENT 'Datetime the trusted browser was recorded',
307 `last_used` datetime COMMENT 'Datetime the trusted browser was last used',
308 PRIMARY KEY(`cookie_hash`),
310 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
311 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication trusted browsers';
316 CREATE TABLE IF NOT EXISTS `addon` (
317 `id` int unsigned NOT NULL auto_increment COMMENT '',
318 `name` varchar(50) NOT NULL DEFAULT '' COMMENT 'addon base (file)name',
319 `version` varchar(50) NOT NULL DEFAULT '' COMMENT 'currently unused',
320 `installed` boolean NOT NULL DEFAULT '0' COMMENT 'currently always 1',
321 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'currently unused',
322 `timestamp` int unsigned NOT NULL DEFAULT 0 COMMENT 'file timestamp to check for reloads',
323 `plugin_admin` boolean NOT NULL DEFAULT '0' COMMENT '1 = has admin config, 0 = has no admin config',
325 INDEX `installed_name` (`installed`,`name`),
326 UNIQUE INDEX `name` (`name`)
327 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registered addons';
332 CREATE TABLE IF NOT EXISTS `apcontact` (
333 `url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
334 `uuid` varchar(255) COMMENT '',
335 `type` varchar(20) NOT NULL COMMENT '',
336 `following` varchar(255) COMMENT '',
337 `followers` varchar(255) COMMENT '',
338 `inbox` varchar(255) NOT NULL COMMENT '',
339 `outbox` varchar(255) COMMENT '',
340 `sharedinbox` varchar(255) COMMENT '',
341 `manually-approve` boolean COMMENT '',
342 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
343 `name` varchar(255) COMMENT '',
344 `about` text COMMENT '',
345 `photo` varchar(255) COMMENT '',
346 `addr` varchar(255) COMMENT '',
347 `alias` varchar(255) COMMENT '',
348 `pubkey` text COMMENT '',
349 `subscribe` varchar(255) COMMENT '',
350 `baseurl` varchar(255) COMMENT 'baseurl of the ap contact',
351 `gsid` int unsigned COMMENT 'Global Server ID',
352 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
353 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
354 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
355 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
356 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
358 INDEX `addr` (`addr`(32)),
359 INDEX `alias` (`alias`(190)),
360 INDEX `followers` (`followers`(190)),
361 INDEX `baseurl` (`baseurl`(190)),
362 INDEX `sharedinbox` (`sharedinbox`(190)),
363 INDEX `gsid` (`gsid`),
364 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
365 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
370 CREATE TABLE IF NOT EXISTS `application` (
371 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
372 `client_id` varchar(64) NOT NULL COMMENT '',
373 `client_secret` varchar(64) NOT NULL COMMENT '',
374 `name` varchar(255) NOT NULL COMMENT '',
375 `redirect_uri` varchar(255) NOT NULL COMMENT '',
376 `website` varchar(255) COMMENT '',
377 `scopes` varchar(255) COMMENT '',
379 UNIQUE INDEX `client_id` (`client_id`)
380 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth application';
385 CREATE TABLE IF NOT EXISTS `attach` (
386 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
387 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
388 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
389 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
390 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
391 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
392 `data` longblob NOT NULL COMMENT 'file data',
393 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
394 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
395 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
396 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
397 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
398 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
399 `backend-class` tinytext COMMENT 'Storage backend class',
400 `backend-ref` text COMMENT 'Storage backend data reference',
403 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
404 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
409 CREATE TABLE IF NOT EXISTS `auth_codes` (
410 `id` varchar(40) NOT NULL COMMENT '',
411 `client_id` varchar(20) NOT NULL DEFAULT '' COMMENT '',
412 `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
413 `expires` int NOT NULL DEFAULT 0 COMMENT '',
414 `scope` varchar(250) NOT NULL DEFAULT '' COMMENT '',
416 INDEX `client_id` (`client_id`),
417 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE
418 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
423 CREATE TABLE IF NOT EXISTS `cache` (
424 `k` varbinary(255) NOT NULL COMMENT 'cache key',
425 `v` mediumtext COMMENT 'cached serialized value',
426 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
427 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
429 INDEX `k_expires` (`k`,`expires`)
430 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
435 CREATE TABLE IF NOT EXISTS `challenge` (
436 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
437 `challenge` varchar(255) NOT NULL DEFAULT '' COMMENT '',
438 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
439 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
440 `type` varchar(255) NOT NULL DEFAULT '' COMMENT '',
441 `last_update` varchar(255) NOT NULL DEFAULT '' COMMENT '',
443 INDEX `expire` (`expire`)
444 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
449 CREATE TABLE IF NOT EXISTS `config` (
450 `id` int unsigned NOT NULL auto_increment COMMENT '',
451 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
452 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
453 `v` mediumtext COMMENT '',
455 UNIQUE INDEX `cat_k` (`cat`,`k`)
456 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
459 -- TABLE contact-relation
461 CREATE TABLE IF NOT EXISTS `contact-relation` (
462 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
463 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
464 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
465 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
466 `follows` boolean NOT NULL DEFAULT '0' COMMENT '',
467 PRIMARY KEY(`cid`,`relation-cid`),
468 INDEX `relation-cid` (`relation-cid`),
469 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
470 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
471 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
476 CREATE TABLE IF NOT EXISTS `conv` (
477 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
478 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
479 `recips` text COMMENT 'sender_handle;recipient_handle',
480 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
481 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
482 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
483 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
484 `subject` text COMMENT 'subject of initial message',
487 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
488 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
491 -- TABLE conversation
493 CREATE TABLE IF NOT EXISTS `conversation` (
494 `item-uri` varbinary(255) NOT NULL COMMENT 'Original URI of the item - unrelated to the table with the same name',
495 `reply-to-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'URI to which this item is a reply',
496 `conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI',
497 `conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link',
498 `protocol` tinyint unsigned NOT NULL DEFAULT 255 COMMENT 'The protocol of the item',
499 `direction` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'How the message arrived here: 1=push, 2=pull',
500 `source` mediumtext COMMENT 'Original source',
501 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Receiving date',
502 PRIMARY KEY(`item-uri`),
503 INDEX `conversation-uri` (`conversation-uri`),
504 INDEX `received` (`received`)
505 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Raw data and structure information for messages';
508 -- TABLE delayed-post
510 CREATE TABLE IF NOT EXISTS `delayed-post` (
511 `id` int unsigned NOT NULL auto_increment,
512 `uri` varchar(255) COMMENT 'URI of the post that will be distributed later',
513 `uid` mediumint unsigned COMMENT 'Owner User id',
514 `delayed` datetime COMMENT 'delay time',
516 UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
517 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
518 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
521 -- TABLE diaspora-interaction
523 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
524 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
525 `interaction` mediumtext COMMENT 'The Diaspora interaction',
526 PRIMARY KEY(`uri-id`),
527 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
528 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
533 CREATE TABLE IF NOT EXISTS `event` (
534 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
535 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
536 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
537 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
538 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
539 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
540 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
541 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
542 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
543 `summary` text COMMENT 'short description or title of the event',
544 `desc` text COMMENT 'event description',
545 `location` text COMMENT 'event location',
546 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
547 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
548 `adjust` boolean NOT NULL DEFAULT '1' COMMENT 'adjust to timezone of the recipient (0 or 1)',
549 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
550 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
551 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
552 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
553 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
555 INDEX `uid_start` (`uid`,`start`),
557 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
558 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
559 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
564 CREATE TABLE IF NOT EXISTS `fcontact` (
565 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
566 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
567 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
568 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
569 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
570 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
571 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
572 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
573 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
574 `notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
575 `poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
576 `confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
577 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
578 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
579 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
580 `pubkey` text COMMENT '',
581 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
583 INDEX `addr` (`addr`(32)),
584 UNIQUE INDEX `url` (`url`(190))
585 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
590 CREATE TABLE IF NOT EXISTS `fsuggest` (
591 `id` int unsigned NOT NULL auto_increment COMMENT '',
592 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
593 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
594 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
595 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
596 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
597 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
598 `note` text COMMENT '',
599 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
603 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
604 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
605 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
610 CREATE TABLE IF NOT EXISTS `group` (
611 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
612 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
613 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
614 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
615 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
618 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
619 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
622 -- TABLE group_member
624 CREATE TABLE IF NOT EXISTS `group_member` (
625 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
626 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
627 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
629 INDEX `contactid` (`contact-id`),
630 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
631 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
632 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
633 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
638 CREATE TABLE IF NOT EXISTS `gserver-tag` (
639 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
640 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
641 PRIMARY KEY(`gserver-id`,`tag`),
643 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
644 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
649 CREATE TABLE IF NOT EXISTS `hook` (
650 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
651 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
652 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
653 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
654 `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',
656 INDEX `priority` (`priority`),
657 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
658 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
663 CREATE TABLE IF NOT EXISTS `host` (
664 `id` tinyint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
665 `name` varchar(128) NOT NULL DEFAULT '' COMMENT 'The hostname',
667 UNIQUE INDEX `name` (`name`)
668 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Hostname';
671 -- TABLE inbox-status
673 CREATE TABLE IF NOT EXISTS `inbox-status` (
674 `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
675 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
676 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
677 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
678 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
679 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
680 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
682 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
687 CREATE TABLE IF NOT EXISTS `intro` (
688 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
689 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
690 `fid` int unsigned COMMENT '',
691 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
692 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
693 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
694 `note` text COMMENT '',
695 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
696 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
697 `blocked` boolean NOT NULL DEFAULT '1' COMMENT '',
698 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
700 INDEX `contact-id` (`contact-id`),
702 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
703 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
704 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
709 CREATE TABLE IF NOT EXISTS `locks` (
710 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
711 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
712 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
713 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
714 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
716 INDEX `name_expires` (`name`,`expires`)
717 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
722 CREATE TABLE IF NOT EXISTS `mail` (
723 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
724 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
725 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
726 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
727 `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
728 `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
729 `contact-id` varchar(255) COMMENT 'contact.id',
730 `convid` int unsigned COMMENT 'conv.id',
731 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
732 `body` mediumtext COMMENT '',
733 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
734 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
735 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
736 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
737 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
738 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
739 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
741 INDEX `uid_seen` (`uid`,`seen`),
742 INDEX `convid` (`convid`),
743 INDEX `uri` (`uri`(64)),
744 INDEX `parent-uri` (`parent-uri`(64)),
745 INDEX `contactid` (`contact-id`(32)),
746 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
747 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
752 CREATE TABLE IF NOT EXISTS `mailacct` (
753 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
754 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
755 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
756 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
757 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
758 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
759 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
760 `pass` text COMMENT '',
761 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
762 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
763 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
764 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
765 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
768 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
769 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
774 CREATE TABLE IF NOT EXISTS `manage` (
775 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
776 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
777 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
779 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
781 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
782 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
783 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
788 CREATE TABLE IF NOT EXISTS `notify` (
789 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
790 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
791 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
792 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
793 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
794 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
795 `msg` mediumtext COMMENT '',
796 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
797 `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
798 `iid` int unsigned COMMENT '',
799 `parent` int unsigned COMMENT '',
800 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
801 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
802 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
803 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
804 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
805 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
806 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
808 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
809 INDEX `uid_date` (`uid`,`date`),
810 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
811 INDEX `uri-id` (`uri-id`),
812 INDEX `parent-uri-id` (`parent-uri-id`),
813 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
814 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
815 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
816 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
819 -- TABLE notify-threads
821 CREATE TABLE IF NOT EXISTS `notify-threads` (
822 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
823 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
824 `master-parent-item` int unsigned COMMENT 'Deprecated',
825 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
826 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
827 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
829 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
830 INDEX `receiver-uid` (`receiver-uid`),
831 INDEX `notify-id` (`notify-id`),
832 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
833 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
834 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
835 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
840 CREATE TABLE IF NOT EXISTS `oembed` (
841 `url` varbinary(255) NOT NULL COMMENT 'page url',
842 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
843 `content` mediumtext COMMENT 'OEmbed data of the page',
844 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
845 PRIMARY KEY(`url`,`maxwidth`),
846 INDEX `created` (`created`)
847 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
850 -- TABLE openwebauth-token
852 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
853 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
854 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
855 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
856 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
857 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
858 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
861 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
862 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
867 CREATE TABLE IF NOT EXISTS `parsed_url` (
868 `url_hash` binary(64) NOT NULL COMMENT 'page url hash',
869 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
870 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
871 `url` text NOT NULL COMMENT 'page url',
872 `content` mediumtext COMMENT 'page data',
873 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
874 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration',
875 PRIMARY KEY(`url_hash`,`guessing`,`oembed`),
876 INDEX `created` (`created`),
877 INDEX `expires` (`expires`)
878 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
883 CREATE TABLE IF NOT EXISTS `pconfig` (
884 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
885 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
886 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
887 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
888 `v` mediumtext COMMENT 'Value',
890 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
891 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
892 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
897 CREATE TABLE IF NOT EXISTS `photo` (
898 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
899 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
900 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
901 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
902 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
903 `hash` char(32) COMMENT 'hash value of the photo',
904 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
905 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
906 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
907 `desc` text COMMENT '',
908 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
909 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
910 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
911 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
912 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
913 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
914 `data` mediumblob NOT NULL COMMENT '',
915 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
916 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
917 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
918 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
919 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
920 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
921 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
922 `backend-class` tinytext COMMENT 'Storage backend class',
923 `backend-ref` text COMMENT 'Storage backend data reference',
924 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
926 INDEX `contactid` (`contact-id`),
927 INDEX `uid_contactid` (`uid`,`contact-id`),
928 INDEX `uid_profile` (`uid`,`profile`),
929 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
930 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
931 INDEX `resource-id` (`resource-id`),
932 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
933 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
934 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
939 CREATE TABLE IF NOT EXISTS `post` (
940 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
941 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
942 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
943 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
944 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
945 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
946 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
947 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
948 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
949 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
950 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
951 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
952 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
953 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
954 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
955 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
956 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
957 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
958 PRIMARY KEY(`uri-id`),
959 INDEX `parent-uri-id` (`parent-uri-id`),
960 INDEX `thr-parent-id` (`thr-parent-id`),
961 INDEX `external-id` (`external-id`),
962 INDEX `owner-id` (`owner-id`),
963 INDEX `author-id` (`author-id`),
964 INDEX `causer-id` (`causer-id`),
966 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
967 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
968 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
969 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
970 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
971 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
972 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
973 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
974 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
977 -- TABLE post-category
979 CREATE TABLE IF NOT EXISTS `post-category` (
980 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
981 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
982 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
983 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
984 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
985 INDEX `uri-id` (`tid`),
987 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
988 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
989 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
990 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
993 -- TABLE post-content
995 CREATE TABLE IF NOT EXISTS `post-content` (
996 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
997 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
998 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
999 `body` mediumtext COMMENT 'item body content',
1000 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1001 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1002 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1003 `language` text COMMENT 'Language information about this post',
1004 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1005 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1006 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1007 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1008 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1009 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1010 `target` text COMMENT 'JSON encoded target structure if used',
1011 `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',
1012 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1013 PRIMARY KEY(`uri-id`),
1014 INDEX `plink` (`plink`(191)),
1015 INDEX `resource-id` (`resource-id`),
1016 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
1017 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1018 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1021 -- TABLE post-delivery-data
1023 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1024 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1025 `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',
1026 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1027 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1028 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1029 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1030 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1031 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1032 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1033 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1034 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1035 PRIMARY KEY(`uri-id`),
1036 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1037 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1042 CREATE TABLE IF NOT EXISTS `post-media` (
1043 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1044 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1045 `url` varbinary(511) NOT NULL COMMENT 'Media URL',
1046 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1047 `mimetype` varchar(60) COMMENT '',
1048 `height` smallint unsigned COMMENT 'Height of the media',
1049 `width` smallint unsigned COMMENT 'Width of the media',
1050 `size` int unsigned COMMENT 'Media size',
1051 `preview` varbinary(255) COMMENT 'Preview URL',
1052 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1053 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1054 `description` text COMMENT '',
1055 `name` varchar(255) COMMENT 'Name of the media',
1056 `author-url` varbinary(255) COMMENT 'URL of the author of the media',
1057 `author-name` varchar(255) COMMENT 'Name of the author of the media',
1058 `author-image` varbinary(255) COMMENT 'Image of the author of the media',
1059 `publisher-url` varbinary(255) COMMENT 'URL of the publisher of the media',
1060 `publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
1061 `publisher-image` varbinary(255) COMMENT 'Image of the publisher of the media',
1063 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1064 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1065 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1070 CREATE TABLE IF NOT EXISTS `post-tag` (
1071 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1072 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1073 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1074 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1075 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1076 INDEX `tid` (`tid`),
1077 INDEX `cid` (`cid`),
1078 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1079 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1080 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1081 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1084 -- TABLE post-thread
1086 CREATE TABLE IF NOT EXISTS `post-thread` (
1087 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1088 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1089 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1090 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1091 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1092 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1093 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1094 `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',
1095 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1096 PRIMARY KEY(`uri-id`),
1097 INDEX `owner-id` (`owner-id`),
1098 INDEX `author-id` (`author-id`),
1099 INDEX `causer-id` (`causer-id`),
1100 INDEX `received` (`received`),
1101 INDEX `commented` (`commented`),
1102 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1103 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1104 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1105 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1106 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1111 CREATE TABLE IF NOT EXISTS `post-user` (
1112 `id` int unsigned NOT NULL auto_increment,
1113 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1114 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1115 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1116 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1117 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1118 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1119 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1120 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1121 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1122 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1123 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1124 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1125 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1126 `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
1127 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1128 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1129 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1130 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1131 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1132 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1133 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1134 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1135 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1136 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1137 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1138 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1139 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1140 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1141 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1143 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1144 INDEX `uri-id` (`uri-id`),
1145 INDEX `parent-uri-id` (`parent-uri-id`),
1146 INDEX `thr-parent-id` (`thr-parent-id`),
1147 INDEX `external-id` (`external-id`),
1148 INDEX `owner-id` (`owner-id`),
1149 INDEX `author-id` (`author-id`),
1150 INDEX `causer-id` (`causer-id`),
1151 INDEX `vid` (`vid`),
1152 INDEX `contact-id` (`contact-id`),
1153 INDEX `event-id` (`event-id`),
1154 INDEX `psid` (`psid`),
1155 INDEX `author-id_uid` (`author-id`,`uid`),
1156 INDEX `author-id_received` (`author-id`,`received`),
1157 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1158 INDEX `uid_contactid` (`uid`,`contact-id`),
1159 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1160 INDEX `uid_unseen` (`uid`,`unseen`),
1161 INDEX `uid_hidden_uri-id` (`uid`,`hidden`,`uri-id`),
1162 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1163 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1164 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1165 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1166 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1167 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1168 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1169 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1170 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1171 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1172 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1173 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1174 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1177 -- TABLE post-thread-user
1179 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1180 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1181 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1182 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1183 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1184 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1185 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1186 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1187 `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',
1188 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1189 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1190 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'The thread is pinned on the profile page',
1191 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1192 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1193 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1194 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1195 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1196 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1197 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1198 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1199 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1200 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1201 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1202 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1203 PRIMARY KEY(`uid`,`uri-id`),
1204 INDEX `uri-id` (`uri-id`),
1205 INDEX `owner-id` (`owner-id`),
1206 INDEX `author-id` (`author-id`),
1207 INDEX `causer-id` (`causer-id`),
1208 INDEX `uid` (`uid`),
1209 INDEX `contact-id` (`contact-id`),
1210 INDEX `psid` (`psid`),
1211 INDEX `post-user-id` (`post-user-id`),
1212 INDEX `commented` (`commented`),
1213 INDEX `uid_received` (`uid`,`received`),
1214 INDEX `uid_pinned` (`uid`,`pinned`),
1215 INDEX `uid_commented` (`uid`,`commented`),
1216 INDEX `uid_starred` (`uid`,`starred`),
1217 INDEX `uid_mention` (`uid`,`mention`),
1218 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1219 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1220 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1221 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1222 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1223 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1224 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1225 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1226 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1229 -- TABLE post-user-notification
1231 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1232 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1233 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1234 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1235 PRIMARY KEY(`uid`,`uri-id`),
1236 INDEX `uri-id` (`uri-id`),
1237 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1238 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1239 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1244 CREATE TABLE IF NOT EXISTS `process` (
1245 `pid` int unsigned NOT NULL COMMENT '',
1246 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1247 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1249 INDEX `command` (`command`)
1250 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1255 CREATE TABLE IF NOT EXISTS `profile` (
1256 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1257 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1258 `profile-name` varchar(255) COMMENT 'Deprecated',
1259 `is-default` boolean COMMENT 'Deprecated',
1260 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1261 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1262 `pdesc` varchar(255) COMMENT 'Deprecated',
1263 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1264 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1265 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1266 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1267 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1268 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1269 `hometown` varchar(255) COMMENT 'Deprecated',
1270 `gender` varchar(32) COMMENT 'Deprecated',
1271 `marital` varchar(255) COMMENT 'Deprecated',
1272 `with` text COMMENT 'Deprecated',
1273 `howlong` datetime COMMENT 'Deprecated',
1274 `sexual` varchar(255) COMMENT 'Deprecated',
1275 `politic` varchar(255) COMMENT 'Deprecated',
1276 `religion` varchar(255) COMMENT 'Deprecated',
1277 `pub_keywords` text COMMENT '',
1278 `prv_keywords` text COMMENT '',
1279 `likes` text COMMENT 'Deprecated',
1280 `dislikes` text COMMENT 'Deprecated',
1281 `about` text COMMENT 'Profile description',
1282 `summary` varchar(255) COMMENT 'Deprecated',
1283 `music` text COMMENT 'Deprecated',
1284 `book` text COMMENT 'Deprecated',
1285 `tv` text COMMENT 'Deprecated',
1286 `film` text COMMENT 'Deprecated',
1287 `interest` text COMMENT 'Deprecated',
1288 `romance` text COMMENT 'Deprecated',
1289 `work` text COMMENT 'Deprecated',
1290 `education` text COMMENT 'Deprecated',
1291 `contact` text COMMENT 'Deprecated',
1292 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1293 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1294 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1295 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1296 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1297 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1299 INDEX `uid_is-default` (`uid`,`is-default`),
1300 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1301 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1302 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1305 -- TABLE profile_check
1307 CREATE TABLE IF NOT EXISTS `profile_check` (
1308 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1309 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1310 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1311 `dfrn_id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1312 `sec` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1313 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1315 INDEX `uid` (`uid`),
1316 INDEX `cid` (`cid`),
1317 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1318 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1319 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='DFRN remote auth use';
1322 -- TABLE profile_field
1324 CREATE TABLE IF NOT EXISTS `profile_field` (
1325 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1326 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1327 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1328 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1329 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1330 `value` text COMMENT 'Value of the field',
1331 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1332 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1334 INDEX `uid` (`uid`),
1335 INDEX `order` (`order`),
1336 INDEX `psid` (`psid`),
1337 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1338 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1339 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1342 -- TABLE push_subscriber
1344 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1345 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1346 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1347 `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1348 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1349 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1350 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1351 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1352 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1353 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1354 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1356 INDEX `next_try` (`next_try`),
1357 INDEX `uid` (`uid`),
1358 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1359 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1364 CREATE TABLE IF NOT EXISTS `register` (
1365 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1366 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1367 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1368 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1369 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1370 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1371 `note` text COMMENT '',
1373 INDEX `uid` (`uid`),
1374 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1375 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1380 CREATE TABLE IF NOT EXISTS `search` (
1381 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1382 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1383 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1385 INDEX `uid_term` (`uid`,`term`(64)),
1386 INDEX `term` (`term`(64)),
1387 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1388 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1393 CREATE TABLE IF NOT EXISTS `session` (
1394 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1395 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1396 `data` text COMMENT '',
1397 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1399 INDEX `sid` (`sid`(64)),
1400 INDEX `expire` (`expire`)
1401 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1406 CREATE TABLE IF NOT EXISTS `storage` (
1407 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1408 `data` longblob NOT NULL COMMENT 'file data',
1410 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1415 CREATE TABLE IF NOT EXISTS `tokens` (
1416 `id` varchar(40) NOT NULL COMMENT '',
1417 `secret` text COMMENT '',
1418 `client_id` varchar(20) NOT NULL DEFAULT '',
1419 `expires` int NOT NULL DEFAULT 0 COMMENT '',
1420 `scope` varchar(200) NOT NULL DEFAULT '' COMMENT '',
1421 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1423 INDEX `client_id` (`client_id`),
1424 INDEX `uid` (`uid`),
1425 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1426 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1427 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
1432 CREATE TABLE IF NOT EXISTS `userd` (
1433 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1434 `username` varchar(255) NOT NULL COMMENT '',
1436 INDEX `username` (`username`(32))
1437 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1440 -- TABLE user-contact
1442 CREATE TABLE IF NOT EXISTS `user-contact` (
1443 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1444 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1445 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1446 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1447 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1448 PRIMARY KEY(`uid`,`cid`),
1449 INDEX `cid` (`cid`),
1450 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1451 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1452 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1457 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1458 `key` int NOT NULL COMMENT '',
1459 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1461 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1464 -- TABLE workerqueue
1466 CREATE TABLE IF NOT EXISTS `workerqueue` (
1467 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
1468 `command` varchar(100) COMMENT 'Task command',
1469 `parameter` mediumtext COMMENT 'Task parameter',
1470 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
1471 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
1472 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
1473 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
1474 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1475 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1476 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
1478 INDEX `command` (`command`),
1479 INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
1480 INDEX `done_executed` (`done`,`executed`),
1481 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
1482 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
1483 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
1484 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
1485 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
1486 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
1489 -- VIEW post-user-view
1491 DROP VIEW IF EXISTS `post-user-view`;
1492 CREATE VIEW `post-user-view` AS SELECT
1493 `post-user`.`id` AS `id`,
1494 `post-user`.`id` AS `post-user-id`,
1495 `post-user`.`uid` AS `uid`,
1496 `parent-post`.`id` AS `parent`,
1497 `item-uri`.`uri` AS `uri`,
1498 `post-user`.`uri-id` AS `uri-id`,
1499 `parent-item-uri`.`uri` AS `parent-uri`,
1500 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1501 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1502 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1503 `item-uri`.`guid` AS `guid`,
1504 `post-user`.`wall` AS `wall`,
1505 `post-user`.`gravity` AS `gravity`,
1506 `external-item-uri`.`uri` AS `extid`,
1507 `post-user`.`external-id` AS `external-id`,
1508 `post-user`.`created` AS `created`,
1509 `post-user`.`edited` AS `edited`,
1510 `post-thread-user`.`commented` AS `commented`,
1511 `post-user`.`received` AS `received`,
1512 `post-thread-user`.`changed` AS `changed`,
1513 `post-user`.`post-type` AS `post-type`,
1514 `post-user`.`post-reason` AS `post-reason`,
1515 `post-user`.`private` AS `private`,
1516 `post-thread-user`.`pubmail` AS `pubmail`,
1517 `post-user`.`visible` AS `visible`,
1518 `post-thread-user`.`starred` AS `starred`,
1519 `post-thread-user`.`pinned` AS `pinned`,
1520 `post-user`.`unseen` AS `unseen`,
1521 `post-user`.`deleted` AS `deleted`,
1522 `post-user`.`origin` AS `origin`,
1523 `post-thread-user`.`origin` AS `parent-origin`,
1524 `post-thread-user`.`forum_mode` AS `forum_mode`,
1525 `post-thread-user`.`mention` AS `mention`,
1526 `post-user`.`global` AS `global`,
1527 `post-user`.`network` AS `network`,
1528 `post-user`.`vid` AS `vid`,
1529 `post-user`.`psid` AS `psid`,
1530 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1531 `post-content`.`title` AS `title`,
1532 `post-content`.`content-warning` AS `content-warning`,
1533 `post-content`.`raw-body` AS `raw-body`,
1534 `post-content`.`body` AS `body`,
1535 `post-content`.`rendered-hash` AS `rendered-hash`,
1536 `post-content`.`rendered-html` AS `rendered-html`,
1537 `post-content`.`language` AS `language`,
1538 `post-content`.`plink` AS `plink`,
1539 `post-content`.`location` AS `location`,
1540 `post-content`.`coord` AS `coord`,
1541 `post-content`.`app` AS `app`,
1542 `post-content`.`object-type` AS `object-type`,
1543 `post-content`.`object` AS `object`,
1544 `post-content`.`target-type` AS `target-type`,
1545 `post-content`.`target` AS `target`,
1546 `post-content`.`resource-id` AS `resource-id`,
1547 `post-user`.`contact-id` AS `contact-id`,
1548 `contact`.`url` AS `contact-link`,
1549 `contact`.`addr` AS `contact-addr`,
1550 `contact`.`name` AS `contact-name`,
1551 `contact`.`nick` AS `contact-nick`,
1552 `contact`.`thumb` AS `contact-avatar`,
1553 `contact`.`network` AS `contact-network`,
1554 `contact`.`blocked` AS `contact-blocked`,
1555 `contact`.`hidden` AS `contact-hidden`,
1556 `contact`.`readonly` AS `contact-readonly`,
1557 `contact`.`archive` AS `contact-archive`,
1558 `contact`.`pending` AS `contact-pending`,
1559 `contact`.`rel` AS `contact-rel`,
1560 `contact`.`uid` AS `contact-uid`,
1561 `contact`.`contact-type` AS `contact-contact-type`,
1562 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1563 `contact`.`self` AS `self`,
1564 `contact`.`id` AS `cid`,
1565 `contact`.`alias` AS `alias`,
1566 `contact`.`photo` AS `photo`,
1567 `contact`.`name-date` AS `name-date`,
1568 `contact`.`uri-date` AS `uri-date`,
1569 `contact`.`avatar-date` AS `avatar-date`,
1570 `contact`.`thumb` AS `thumb`,
1571 `contact`.`dfrn-id` AS `dfrn-id`,
1572 `post-user`.`author-id` AS `author-id`,
1573 `author`.`url` AS `author-link`,
1574 `author`.`addr` AS `author-addr`,
1575 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1576 `author`.`nick` AS `author-nick`,
1577 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1578 `author`.`network` AS `author-network`,
1579 `author`.`blocked` AS `author-blocked`,
1580 `author`.`hidden` AS `author-hidden`,
1581 `post-user`.`owner-id` AS `owner-id`,
1582 `owner`.`url` AS `owner-link`,
1583 `owner`.`addr` AS `owner-addr`,
1584 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1585 `owner`.`nick` AS `owner-nick`,
1586 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1587 `owner`.`network` AS `owner-network`,
1588 `owner`.`blocked` AS `owner-blocked`,
1589 `owner`.`hidden` AS `owner-hidden`,
1590 `owner`.`contact-type` AS `owner-contact-type`,
1591 `post-user`.`causer-id` AS `causer-id`,
1592 `causer`.`url` AS `causer-link`,
1593 `causer`.`addr` AS `causer-addr`,
1594 `causer`.`name` AS `causer-name`,
1595 `causer`.`nick` AS `causer-nick`,
1596 `causer`.`thumb` AS `causer-avatar`,
1597 `causer`.`network` AS `causer-network`,
1598 `causer`.`blocked` AS `causer-blocked`,
1599 `causer`.`hidden` AS `causer-hidden`,
1600 `causer`.`contact-type` AS `causer-contact-type`,
1601 `post-delivery-data`.`postopts` AS `postopts`,
1602 `post-delivery-data`.`inform` AS `inform`,
1603 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1604 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1605 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1606 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1607 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1608 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1609 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1610 `post-user`.`event-id` AS `event-id`,
1611 `event`.`created` AS `event-created`,
1612 `event`.`edited` AS `event-edited`,
1613 `event`.`start` AS `event-start`,
1614 `event`.`finish` AS `event-finish`,
1615 `event`.`summary` AS `event-summary`,
1616 `event`.`desc` AS `event-desc`,
1617 `event`.`location` AS `event-location`,
1618 `event`.`type` AS `event-type`,
1619 `event`.`nofinish` AS `event-nofinish`,
1620 `event`.`adjust` AS `event-adjust`,
1621 `event`.`ignore` AS `event-ignore`,
1622 `diaspora-interaction`.`interaction` AS `signed_text`,
1623 `parent-item-uri`.`guid` AS `parent-guid`,
1624 `parent-post`.`network` AS `parent-network`,
1625 `parent-post`.`author-id` AS `parent-author-id`,
1626 `parent-post-author`.`url` AS `parent-author-link`,
1627 `parent-post-author`.`name` AS `parent-author-name`,
1628 `parent-post-author`.`network` AS `parent-author-network`
1630 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
1631 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
1632 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
1633 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
1634 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
1635 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
1636 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1637 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1638 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1639 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1640 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1641 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
1642 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
1643 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
1644 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
1645 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
1646 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1649 -- VIEW post-thread-user-view
1651 DROP VIEW IF EXISTS `post-thread-user-view`;
1652 CREATE VIEW `post-thread-user-view` AS SELECT
1653 `post-user`.`id` AS `id`,
1654 `post-user`.`id` AS `post-user-id`,
1655 `post-thread-user`.`uid` AS `uid`,
1656 `parent-post`.`id` AS `parent`,
1657 `item-uri`.`uri` AS `uri`,
1658 `post-thread-user`.`uri-id` AS `uri-id`,
1659 `parent-item-uri`.`uri` AS `parent-uri`,
1660 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1661 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1662 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1663 `item-uri`.`guid` AS `guid`,
1664 `post-thread-user`.`wall` AS `wall`,
1665 `post-user`.`gravity` AS `gravity`,
1666 `external-item-uri`.`uri` AS `extid`,
1667 `post-user`.`external-id` AS `external-id`,
1668 `post-thread-user`.`created` AS `created`,
1669 `post-user`.`edited` AS `edited`,
1670 `post-thread-user`.`commented` AS `commented`,
1671 `post-thread-user`.`received` AS `received`,
1672 `post-thread-user`.`changed` AS `changed`,
1673 `post-user`.`post-type` AS `post-type`,
1674 `post-user`.`post-reason` AS `post-reason`,
1675 `post-user`.`private` AS `private`,
1676 `post-thread-user`.`pubmail` AS `pubmail`,
1677 `post-thread-user`.`ignored` AS `ignored`,
1678 `post-user`.`visible` AS `visible`,
1679 `post-thread-user`.`starred` AS `starred`,
1680 `post-thread-user`.`pinned` AS `pinned`,
1681 `post-thread-user`.`unseen` AS `unseen`,
1682 `post-user`.`deleted` AS `deleted`,
1683 `post-thread-user`.`origin` AS `origin`,
1684 `post-thread-user`.`forum_mode` AS `forum_mode`,
1685 `post-thread-user`.`mention` AS `mention`,
1686 `post-user`.`global` AS `global`,
1687 `post-thread-user`.`network` AS `network`,
1688 `post-user`.`vid` AS `vid`,
1689 `post-thread-user`.`psid` AS `psid`,
1690 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1691 `post-content`.`title` AS `title`,
1692 `post-content`.`content-warning` AS `content-warning`,
1693 `post-content`.`raw-body` AS `raw-body`,
1694 `post-content`.`body` AS `body`,
1695 `post-content`.`rendered-hash` AS `rendered-hash`,
1696 `post-content`.`rendered-html` AS `rendered-html`,
1697 `post-content`.`language` AS `language`,
1698 `post-content`.`plink` AS `plink`,
1699 `post-content`.`location` AS `location`,
1700 `post-content`.`coord` AS `coord`,
1701 `post-content`.`app` AS `app`,
1702 `post-content`.`object-type` AS `object-type`,
1703 `post-content`.`object` AS `object`,
1704 `post-content`.`target-type` AS `target-type`,
1705 `post-content`.`target` AS `target`,
1706 `post-content`.`resource-id` AS `resource-id`,
1707 `post-thread-user`.`contact-id` AS `contact-id`,
1708 `contact`.`url` AS `contact-link`,
1709 `contact`.`addr` AS `contact-addr`,
1710 `contact`.`name` AS `contact-name`,
1711 `contact`.`nick` AS `contact-nick`,
1712 `contact`.`thumb` AS `contact-avatar`,
1713 `contact`.`network` AS `contact-network`,
1714 `contact`.`blocked` AS `contact-blocked`,
1715 `contact`.`hidden` AS `contact-hidden`,
1716 `contact`.`readonly` AS `contact-readonly`,
1717 `contact`.`archive` AS `contact-archive`,
1718 `contact`.`pending` AS `contact-pending`,
1719 `contact`.`rel` AS `contact-rel`,
1720 `contact`.`uid` AS `contact-uid`,
1721 `contact`.`contact-type` AS `contact-contact-type`,
1722 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1723 `contact`.`self` AS `self`,
1724 `contact`.`id` AS `cid`,
1725 `contact`.`alias` AS `alias`,
1726 `contact`.`photo` AS `photo`,
1727 `contact`.`name-date` AS `name-date`,
1728 `contact`.`uri-date` AS `uri-date`,
1729 `contact`.`avatar-date` AS `avatar-date`,
1730 `contact`.`thumb` AS `thumb`,
1731 `contact`.`dfrn-id` AS `dfrn-id`,
1732 `post-thread-user`.`author-id` AS `author-id`,
1733 `author`.`url` AS `author-link`,
1734 `author`.`addr` AS `author-addr`,
1735 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1736 `author`.`nick` AS `author-nick`,
1737 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1738 `author`.`network` AS `author-network`,
1739 `author`.`blocked` AS `author-blocked`,
1740 `author`.`hidden` AS `author-hidden`,
1741 `post-thread-user`.`owner-id` AS `owner-id`,
1742 `owner`.`url` AS `owner-link`,
1743 `owner`.`addr` AS `owner-addr`,
1744 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1745 `owner`.`nick` AS `owner-nick`,
1746 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1747 `owner`.`network` AS `owner-network`,
1748 `owner`.`blocked` AS `owner-blocked`,
1749 `owner`.`hidden` AS `owner-hidden`,
1750 `owner`.`contact-type` AS `owner-contact-type`,
1751 `post-thread-user`.`causer-id` AS `causer-id`,
1752 `causer`.`url` AS `causer-link`,
1753 `causer`.`addr` AS `causer-addr`,
1754 `causer`.`name` AS `causer-name`,
1755 `causer`.`nick` AS `causer-nick`,
1756 `causer`.`thumb` AS `causer-avatar`,
1757 `causer`.`network` AS `causer-network`,
1758 `causer`.`blocked` AS `causer-blocked`,
1759 `causer`.`hidden` AS `causer-hidden`,
1760 `causer`.`contact-type` AS `causer-contact-type`,
1761 `post-delivery-data`.`postopts` AS `postopts`,
1762 `post-delivery-data`.`inform` AS `inform`,
1763 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1764 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1765 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1766 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1767 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1768 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1769 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1770 `post-user`.`event-id` AS `event-id`,
1771 `event`.`created` AS `event-created`,
1772 `event`.`edited` AS `event-edited`,
1773 `event`.`start` AS `event-start`,
1774 `event`.`finish` AS `event-finish`,
1775 `event`.`summary` AS `event-summary`,
1776 `event`.`desc` AS `event-desc`,
1777 `event`.`location` AS `event-location`,
1778 `event`.`type` AS `event-type`,
1779 `event`.`nofinish` AS `event-nofinish`,
1780 `event`.`adjust` AS `event-adjust`,
1781 `event`.`ignore` AS `event-ignore`,
1782 `diaspora-interaction`.`interaction` AS `signed_text`,
1783 `parent-item-uri`.`guid` AS `parent-guid`,
1784 `parent-post`.`network` AS `parent-network`,
1785 `parent-post`.`author-id` AS `parent-author-id`,
1786 `parent-post-author`.`url` AS `parent-author-link`,
1787 `parent-post-author`.`name` AS `parent-author-name`,
1788 `parent-post-author`.`network` AS `parent-author-network`
1789 FROM `post-thread-user`
1790 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
1791 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
1792 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
1793 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
1794 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
1795 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
1796 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1797 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1798 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1799 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1800 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1801 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
1802 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
1803 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
1804 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
1805 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`
1806 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1811 DROP VIEW IF EXISTS `post-view`;
1812 CREATE VIEW `post-view` AS SELECT
1813 `item-uri`.`uri` AS `uri`,
1814 `post`.`uri-id` AS `uri-id`,
1815 `parent-item-uri`.`uri` AS `parent-uri`,
1816 `post`.`parent-uri-id` AS `parent-uri-id`,
1817 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1818 `post`.`thr-parent-id` AS `thr-parent-id`,
1819 `item-uri`.`guid` AS `guid`,
1820 `post`.`gravity` AS `gravity`,
1821 `external-item-uri`.`uri` AS `extid`,
1822 `post`.`external-id` AS `external-id`,
1823 `post`.`created` AS `created`,
1824 `post`.`edited` AS `edited`,
1825 `post-thread`.`commented` AS `commented`,
1826 `post`.`received` AS `received`,
1827 `post-thread`.`changed` AS `changed`,
1828 `post`.`post-type` AS `post-type`,
1829 `post`.`private` AS `private`,
1830 `post`.`visible` AS `visible`,
1831 `post`.`deleted` AS `deleted`,
1832 `post`.`global` AS `global`,
1833 `post`.`network` AS `network`,
1834 `post`.`vid` AS `vid`,
1835 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1836 `post-content`.`title` AS `title`,
1837 `post-content`.`content-warning` AS `content-warning`,
1838 `post-content`.`raw-body` AS `raw-body`,
1839 `post-content`.`body` AS `body`,
1840 `post-content`.`rendered-hash` AS `rendered-hash`,
1841 `post-content`.`rendered-html` AS `rendered-html`,
1842 `post-content`.`language` AS `language`,
1843 `post-content`.`plink` AS `plink`,
1844 `post-content`.`location` AS `location`,
1845 `post-content`.`coord` AS `coord`,
1846 `post-content`.`app` AS `app`,
1847 `post-content`.`object-type` AS `object-type`,
1848 `post-content`.`object` AS `object`,
1849 `post-content`.`target-type` AS `target-type`,
1850 `post-content`.`target` AS `target`,
1851 `post-content`.`resource-id` AS `resource-id`,
1852 `post`.`author-id` AS `author-id`,
1853 `author`.`url` AS `author-link`,
1854 `author`.`addr` AS `author-addr`,
1855 `author`.`name` AS `author-name`,
1856 `author`.`nick` AS `author-nick`,
1857 `author`.`thumb` AS `author-avatar`,
1858 `author`.`network` AS `author-network`,
1859 `author`.`blocked` AS `author-blocked`,
1860 `author`.`hidden` AS `author-hidden`,
1861 `post`.`owner-id` AS `owner-id`,
1862 `owner`.`url` AS `owner-link`,
1863 `owner`.`addr` AS `owner-addr`,
1864 `owner`.`name` AS `owner-name`,
1865 `owner`.`nick` AS `owner-nick`,
1866 `owner`.`thumb` AS `owner-avatar`,
1867 `owner`.`network` AS `owner-network`,
1868 `owner`.`blocked` AS `owner-blocked`,
1869 `owner`.`hidden` AS `owner-hidden`,
1870 `owner`.`contact-type` AS `owner-contact-type`,
1871 `post`.`causer-id` AS `causer-id`,
1872 `causer`.`url` AS `causer-link`,
1873 `causer`.`addr` AS `causer-addr`,
1874 `causer`.`name` AS `causer-name`,
1875 `causer`.`nick` AS `causer-nick`,
1876 `causer`.`thumb` AS `causer-avatar`,
1877 `causer`.`network` AS `causer-network`,
1878 `causer`.`blocked` AS `causer-blocked`,
1879 `causer`.`hidden` AS `causer-hidden`,
1880 `causer`.`contact-type` AS `causer-contact-type`,
1881 `diaspora-interaction`.`interaction` AS `signed_text`,
1882 `parent-item-uri`.`guid` AS `parent-guid`,
1883 `parent-post`.`network` AS `parent-network`,
1884 `parent-post`.`author-id` AS `parent-author-id`,
1885 `parent-post-author`.`url` AS `parent-author-link`,
1886 `parent-post-author`.`name` AS `parent-author-name`,
1887 `parent-post-author`.`network` AS `parent-author-network`
1889 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
1890 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
1891 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
1892 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
1893 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
1894 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
1895 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
1896 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
1897 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
1898 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
1899 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
1900 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
1901 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1904 -- VIEW post-thread-view
1906 DROP VIEW IF EXISTS `post-thread-view`;
1907 CREATE VIEW `post-thread-view` AS SELECT
1908 `item-uri`.`uri` AS `uri`,
1909 `post-thread`.`uri-id` AS `uri-id`,
1910 `parent-item-uri`.`uri` AS `parent-uri`,
1911 `post`.`parent-uri-id` AS `parent-uri-id`,
1912 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1913 `post`.`thr-parent-id` AS `thr-parent-id`,
1914 `item-uri`.`guid` AS `guid`,
1915 `post`.`gravity` AS `gravity`,
1916 `external-item-uri`.`uri` AS `extid`,
1917 `post`.`external-id` AS `external-id`,
1918 `post-thread`.`created` AS `created`,
1919 `post`.`edited` AS `edited`,
1920 `post-thread`.`commented` AS `commented`,
1921 `post-thread`.`received` AS `received`,
1922 `post-thread`.`changed` AS `changed`,
1923 `post`.`post-type` AS `post-type`,
1924 `post`.`private` AS `private`,
1925 `post`.`visible` AS `visible`,
1926 `post`.`deleted` AS `deleted`,
1927 `post`.`global` AS `global`,
1928 `post-thread`.`network` AS `network`,
1929 `post`.`vid` AS `vid`,
1930 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1931 `post-content`.`title` AS `title`,
1932 `post-content`.`content-warning` AS `content-warning`,
1933 `post-content`.`raw-body` AS `raw-body`,
1934 `post-content`.`body` AS `body`,
1935 `post-content`.`rendered-hash` AS `rendered-hash`,
1936 `post-content`.`rendered-html` AS `rendered-html`,
1937 `post-content`.`language` AS `language`,
1938 `post-content`.`plink` AS `plink`,
1939 `post-content`.`location` AS `location`,
1940 `post-content`.`coord` AS `coord`,
1941 `post-content`.`app` AS `app`,
1942 `post-content`.`object-type` AS `object-type`,
1943 `post-content`.`object` AS `object`,
1944 `post-content`.`target-type` AS `target-type`,
1945 `post-content`.`target` AS `target`,
1946 `post-content`.`resource-id` AS `resource-id`,
1947 `post-thread`.`author-id` AS `author-id`,
1948 `author`.`url` AS `author-link`,
1949 `author`.`addr` AS `author-addr`,
1950 `author`.`name` AS `author-name`,
1951 `author`.`nick` AS `author-nick`,
1952 `author`.`thumb` AS `author-avatar`,
1953 `author`.`network` AS `author-network`,
1954 `author`.`blocked` AS `author-blocked`,
1955 `author`.`hidden` AS `author-hidden`,
1956 `post-thread`.`owner-id` AS `owner-id`,
1957 `owner`.`url` AS `owner-link`,
1958 `owner`.`addr` AS `owner-addr`,
1959 `owner`.`name` AS `owner-name`,
1960 `owner`.`nick` AS `owner-nick`,
1961 `owner`.`thumb` AS `owner-avatar`,
1962 `owner`.`network` AS `owner-network`,
1963 `owner`.`blocked` AS `owner-blocked`,
1964 `owner`.`hidden` AS `owner-hidden`,
1965 `owner`.`contact-type` AS `owner-contact-type`,
1966 `post-thread`.`causer-id` AS `causer-id`,
1967 `causer`.`url` AS `causer-link`,
1968 `causer`.`addr` AS `causer-addr`,
1969 `causer`.`name` AS `causer-name`,
1970 `causer`.`nick` AS `causer-nick`,
1971 `causer`.`thumb` AS `causer-avatar`,
1972 `causer`.`network` AS `causer-network`,
1973 `causer`.`blocked` AS `causer-blocked`,
1974 `causer`.`hidden` AS `causer-hidden`,
1975 `causer`.`contact-type` AS `causer-contact-type`,
1976 `diaspora-interaction`.`interaction` AS `signed_text`,
1977 `parent-item-uri`.`guid` AS `parent-guid`,
1978 `parent-post`.`network` AS `parent-network`,
1979 `parent-post`.`author-id` AS `parent-author-id`,
1980 `parent-post-author`.`url` AS `parent-author-link`,
1981 `parent-post-author`.`name` AS `parent-author-name`,
1982 `parent-post-author`.`network` AS `parent-author-network`
1984 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
1985 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
1986 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
1987 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
1988 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
1989 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
1990 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
1991 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
1992 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
1993 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
1994 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
1995 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
1996 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1999 -- VIEW category-view
2001 DROP VIEW IF EXISTS `category-view`;
2002 CREATE VIEW `category-view` AS SELECT
2003 `post-category`.`uri-id` AS `uri-id`,
2004 `post-category`.`uid` AS `uid`,
2005 `post-category`.`type` AS `type`,
2006 `post-category`.`tid` AS `tid`,
2007 `tag`.`name` AS `name`,
2008 `tag`.`url` AS `url`
2009 FROM `post-category`
2010 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2015 DROP VIEW IF EXISTS `tag-view`;
2016 CREATE VIEW `tag-view` AS SELECT
2017 `post-tag`.`uri-id` AS `uri-id`,
2018 `post-tag`.`type` AS `type`,
2019 `post-tag`.`tid` AS `tid`,
2020 `post-tag`.`cid` AS `cid`,
2021 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2022 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
2024 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2025 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2028 -- VIEW network-item-view
2030 DROP VIEW IF EXISTS `network-item-view`;
2031 CREATE VIEW `network-item-view` AS SELECT
2032 `post-user`.`uri-id` AS `uri-id`,
2033 `parent-post`.`id` AS `parent`,
2034 `post-user`.`received` AS `received`,
2035 `post-thread-user`.`commented` AS `commented`,
2036 `post-user`.`created` AS `created`,
2037 `post-user`.`uid` AS `uid`,
2038 `post-thread-user`.`starred` AS `starred`,
2039 `post-thread-user`.`mention` AS `mention`,
2040 `post-user`.`network` AS `network`,
2041 `post-user`.`unseen` AS `unseen`,
2042 `post-user`.`gravity` AS `gravity`,
2043 `post-user`.`contact-id` AS `contact-id`,
2044 `ownercontact`.`contact-type` AS `contact-type`
2046 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2047 INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2048 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2049 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2050 INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2051 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2052 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2053 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2054 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
2055 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2056 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2059 -- VIEW network-thread-view
2061 DROP VIEW IF EXISTS `network-thread-view`;
2062 CREATE VIEW `network-thread-view` AS SELECT
2063 `post-thread-user`.`uri-id` AS `uri-id`,
2064 `parent-post`.`id` AS `parent`,
2065 `post-thread-user`.`received` AS `received`,
2066 `post-thread-user`.`commented` AS `commented`,
2067 `post-thread-user`.`created` AS `created`,
2068 `post-thread-user`.`uid` AS `uid`,
2069 `post-thread-user`.`starred` AS `starred`,
2070 `post-thread-user`.`mention` AS `mention`,
2071 `post-thread-user`.`network` AS `network`,
2072 `post-thread-user`.`contact-id` AS `contact-id`,
2073 `ownercontact`.`contact-type` AS `contact-type`
2074 FROM `post-thread-user`
2075 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2076 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2077 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2078 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2079 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2080 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2081 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2082 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2083 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2084 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2085 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2090 DROP VIEW IF EXISTS `owner-view`;
2091 CREATE VIEW `owner-view` AS SELECT
2092 `contact`.`id` AS `id`,
2093 `contact`.`uid` AS `uid`,
2094 `contact`.`created` AS `created`,
2095 `contact`.`updated` AS `updated`,
2096 `contact`.`self` AS `self`,
2097 `contact`.`remote_self` AS `remote_self`,
2098 `contact`.`rel` AS `rel`,
2099 `contact`.`duplex` AS `duplex`,
2100 `contact`.`network` AS `network`,
2101 `contact`.`protocol` AS `protocol`,
2102 `contact`.`name` AS `name`,
2103 `contact`.`nick` AS `nick`,
2104 `contact`.`location` AS `location`,
2105 `contact`.`about` AS `about`,
2106 `contact`.`keywords` AS `keywords`,
2107 `contact`.`gender` AS `gender`,
2108 `contact`.`xmpp` AS `xmpp`,
2109 `contact`.`attag` AS `attag`,
2110 `contact`.`avatar` AS `avatar`,
2111 `contact`.`photo` AS `photo`,
2112 `contact`.`thumb` AS `thumb`,
2113 `contact`.`micro` AS `micro`,
2114 `contact`.`site-pubkey` AS `site-pubkey`,
2115 `contact`.`issued-id` AS `issued-id`,
2116 `contact`.`dfrn-id` AS `dfrn-id`,
2117 `contact`.`url` AS `url`,
2118 `contact`.`nurl` AS `nurl`,
2119 `contact`.`addr` AS `addr`,
2120 `contact`.`alias` AS `alias`,
2121 `contact`.`pubkey` AS `pubkey`,
2122 `contact`.`prvkey` AS `prvkey`,
2123 `contact`.`batch` AS `batch`,
2124 `contact`.`request` AS `request`,
2125 `contact`.`notify` AS `notify`,
2126 `contact`.`poll` AS `poll`,
2127 `contact`.`confirm` AS `confirm`,
2128 `contact`.`poco` AS `poco`,
2129 `contact`.`aes_allow` AS `aes_allow`,
2130 `contact`.`ret-aes` AS `ret-aes`,
2131 `contact`.`usehub` AS `usehub`,
2132 `contact`.`subhub` AS `subhub`,
2133 `contact`.`hub-verify` AS `hub-verify`,
2134 `contact`.`last-update` AS `last-update`,
2135 `contact`.`success_update` AS `success_update`,
2136 `contact`.`failure_update` AS `failure_update`,
2137 `contact`.`name-date` AS `name-date`,
2138 `contact`.`uri-date` AS `uri-date`,
2139 `contact`.`avatar-date` AS `avatar-date`,
2140 `contact`.`avatar-date` AS `picdate`,
2141 `contact`.`term-date` AS `term-date`,
2142 `contact`.`last-item` AS `last-item`,
2143 `contact`.`priority` AS `priority`,
2144 `user`.`blocked` AS `blocked`,
2145 `contact`.`block_reason` AS `block_reason`,
2146 `contact`.`readonly` AS `readonly`,
2147 `contact`.`writable` AS `writable`,
2148 `contact`.`forum` AS `forum`,
2149 `contact`.`prv` AS `prv`,
2150 `contact`.`contact-type` AS `contact-type`,
2151 `contact`.`manually-approve` AS `manually-approve`,
2152 `contact`.`hidden` AS `hidden`,
2153 `contact`.`archive` AS `archive`,
2154 `contact`.`pending` AS `pending`,
2155 `contact`.`deleted` AS `deleted`,
2156 `contact`.`unsearchable` AS `unsearchable`,
2157 `contact`.`sensitive` AS `sensitive`,
2158 `contact`.`baseurl` AS `baseurl`,
2159 `contact`.`reason` AS `reason`,
2160 `contact`.`closeness` AS `closeness`,
2161 `contact`.`info` AS `info`,
2162 `contact`.`profile-id` AS `profile-id`,
2163 `contact`.`bdyear` AS `bdyear`,
2164 `contact`.`bd` AS `bd`,
2165 `contact`.`notify_new_posts` AS `notify_new_posts`,
2166 `contact`.`fetch_further_information` AS `fetch_further_information`,
2167 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2168 `user`.`parent-uid` AS `parent-uid`,
2169 `user`.`guid` AS `guid`,
2170 `user`.`nickname` AS `nickname`,
2171 `user`.`email` AS `email`,
2172 `user`.`openid` AS `openid`,
2173 `user`.`timezone` AS `timezone`,
2174 `user`.`language` AS `language`,
2175 `user`.`register_date` AS `register_date`,
2176 `user`.`login_date` AS `login_date`,
2177 `user`.`default-location` AS `default-location`,
2178 `user`.`allow_location` AS `allow_location`,
2179 `user`.`theme` AS `theme`,
2180 `user`.`pubkey` AS `upubkey`,
2181 `user`.`prvkey` AS `uprvkey`,
2182 `user`.`sprvkey` AS `sprvkey`,
2183 `user`.`spubkey` AS `spubkey`,
2184 `user`.`verified` AS `verified`,
2185 `user`.`blockwall` AS `blockwall`,
2186 `user`.`hidewall` AS `hidewall`,
2187 `user`.`blocktags` AS `blocktags`,
2188 `user`.`unkmail` AS `unkmail`,
2189 `user`.`cntunkmail` AS `cntunkmail`,
2190 `user`.`notify-flags` AS `notify-flags`,
2191 `user`.`page-flags` AS `page-flags`,
2192 `user`.`account-type` AS `account-type`,
2193 `user`.`prvnets` AS `prvnets`,
2194 `user`.`maxreq` AS `maxreq`,
2195 `user`.`expire` AS `expire`,
2196 `user`.`account_removed` AS `account_removed`,
2197 `user`.`account_expired` AS `account_expired`,
2198 `user`.`account_expires_on` AS `account_expires_on`,
2199 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2200 `user`.`def_gid` AS `def_gid`,
2201 `user`.`allow_cid` AS `allow_cid`,
2202 `user`.`allow_gid` AS `allow_gid`,
2203 `user`.`deny_cid` AS `deny_cid`,
2204 `user`.`deny_gid` AS `deny_gid`,
2205 `user`.`openidserver` AS `openidserver`,
2206 `profile`.`publish` AS `publish`,
2207 `profile`.`net-publish` AS `net-publish`,
2208 `profile`.`hide-friends` AS `hide-friends`,
2209 `profile`.`prv_keywords` AS `prv_keywords`,
2210 `profile`.`pub_keywords` AS `pub_keywords`,
2211 `profile`.`address` AS `address`,
2212 `profile`.`locality` AS `locality`,
2213 `profile`.`region` AS `region`,
2214 `profile`.`postal-code` AS `postal-code`,
2215 `profile`.`country-name` AS `country-name`,
2216 `profile`.`homepage` AS `homepage`,
2217 `profile`.`dob` AS `dob`
2219 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2220 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2223 -- VIEW pending-view
2225 DROP VIEW IF EXISTS `pending-view`;
2226 CREATE VIEW `pending-view` AS SELECT
2227 `register`.`id` AS `id`,
2228 `register`.`hash` AS `hash`,
2229 `register`.`created` AS `created`,
2230 `register`.`uid` AS `uid`,
2231 `register`.`password` AS `password`,
2232 `register`.`language` AS `language`,
2233 `register`.`note` AS `note`,
2234 `contact`.`self` AS `self`,
2235 `contact`.`name` AS `name`,
2236 `contact`.`url` AS `url`,
2237 `contact`.`micro` AS `micro`,
2238 `user`.`email` AS `email`,
2239 `contact`.`nick` AS `nick`
2241 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2242 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2245 -- VIEW tag-search-view
2247 DROP VIEW IF EXISTS `tag-search-view`;
2248 CREATE VIEW `tag-search-view` AS SELECT
2249 `post-tag`.`uri-id` AS `uri-id`,
2250 `post-user`.`uid` AS `uid`,
2251 `post-user`.`id` AS `iid`,
2252 `post-user`.`private` AS `private`,
2253 `post-user`.`wall` AS `wall`,
2254 `post-user`.`origin` AS `origin`,
2255 `post-user`.`global` AS `global`,
2256 `post-user`.`gravity` AS `gravity`,
2257 `post-user`.`received` AS `received`,
2258 `post-user`.`network` AS `network`,
2259 `post-user`.`author-id` AS `author-id`,
2260 `tag`.`name` AS `name`
2262 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
2263 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
2264 WHERE `post-tag`.`type` = 1;
2267 -- VIEW workerqueue-view
2269 DROP VIEW IF EXISTS `workerqueue-view`;
2270 CREATE VIEW `workerqueue-view` AS SELECT
2271 `process`.`pid` AS `pid`,
2272 `workerqueue`.`priority` AS `priority`
2274 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
2275 WHERE NOT `workerqueue`.`done`;