1 -- ------------------------------------------
2 -- Friendica 2021.06-dev (Siberian Iris)
3 -- DB_UPDATE_VERSION 1416
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';
383 -- TABLE application-token
385 CREATE TABLE IF NOT EXISTS `application-token` (
386 `application-id` int unsigned NOT NULL COMMENT '',
387 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
388 `code` varchar(64) NOT NULL COMMENT '',
389 `access_token` varchar(64) NOT NULL COMMENT '',
390 `created_at` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
391 PRIMARY KEY(`application-id`,`uid`),
392 INDEX `uid_id` (`uid`,`application-id`),
393 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
394 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
395 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth user token';
400 CREATE TABLE IF NOT EXISTS `attach` (
401 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
402 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
403 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
404 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
405 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
406 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
407 `data` longblob NOT NULL COMMENT 'file data',
408 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
409 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
410 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
411 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
412 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
413 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
414 `backend-class` tinytext COMMENT 'Storage backend class',
415 `backend-ref` text COMMENT 'Storage backend data reference',
418 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
419 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
424 CREATE TABLE IF NOT EXISTS `auth_codes` (
425 `id` varchar(40) NOT NULL COMMENT '',
426 `client_id` varchar(20) NOT NULL DEFAULT '' COMMENT '',
427 `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
428 `expires` int NOT NULL DEFAULT 0 COMMENT '',
429 `scope` varchar(250) NOT NULL DEFAULT '' COMMENT '',
431 INDEX `client_id` (`client_id`),
432 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE
433 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
438 CREATE TABLE IF NOT EXISTS `cache` (
439 `k` varbinary(255) NOT NULL COMMENT 'cache key',
440 `v` mediumtext COMMENT 'cached serialized value',
441 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
442 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
444 INDEX `k_expires` (`k`,`expires`)
445 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
450 CREATE TABLE IF NOT EXISTS `challenge` (
451 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
452 `challenge` varchar(255) NOT NULL DEFAULT '' COMMENT '',
453 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
454 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
455 `type` varchar(255) NOT NULL DEFAULT '' COMMENT '',
456 `last_update` varchar(255) NOT NULL DEFAULT '' COMMENT '',
458 INDEX `expire` (`expire`)
459 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
464 CREATE TABLE IF NOT EXISTS `config` (
465 `id` int unsigned NOT NULL auto_increment COMMENT '',
466 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
467 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
468 `v` mediumtext COMMENT '',
470 UNIQUE INDEX `cat_k` (`cat`,`k`)
471 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
474 -- TABLE contact-relation
476 CREATE TABLE IF NOT EXISTS `contact-relation` (
477 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
478 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
479 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
480 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
481 `follows` boolean NOT NULL DEFAULT '0' COMMENT '',
482 PRIMARY KEY(`cid`,`relation-cid`),
483 INDEX `relation-cid` (`relation-cid`),
484 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
485 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
486 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
491 CREATE TABLE IF NOT EXISTS `conv` (
492 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
493 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
494 `recips` text COMMENT 'sender_handle;recipient_handle',
495 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
496 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
497 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
498 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
499 `subject` text COMMENT 'subject of initial message',
502 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
503 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
506 -- TABLE conversation
508 CREATE TABLE IF NOT EXISTS `conversation` (
509 `item-uri` varbinary(255) NOT NULL COMMENT 'Original URI of the item - unrelated to the table with the same name',
510 `reply-to-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'URI to which this item is a reply',
511 `conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI',
512 `conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link',
513 `protocol` tinyint unsigned NOT NULL DEFAULT 255 COMMENT 'The protocol of the item',
514 `direction` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'How the message arrived here: 1=push, 2=pull',
515 `source` mediumtext COMMENT 'Original source',
516 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Receiving date',
517 PRIMARY KEY(`item-uri`),
518 INDEX `conversation-uri` (`conversation-uri`),
519 INDEX `received` (`received`)
520 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Raw data and structure information for messages';
523 -- TABLE delayed-post
525 CREATE TABLE IF NOT EXISTS `delayed-post` (
526 `id` int unsigned NOT NULL auto_increment,
527 `uri` varchar(255) COMMENT 'URI of the post that will be distributed later',
528 `uid` mediumint unsigned COMMENT 'Owner User id',
529 `delayed` datetime COMMENT 'delay time',
531 UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
532 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
533 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
536 -- TABLE diaspora-interaction
538 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
539 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
540 `interaction` mediumtext COMMENT 'The Diaspora interaction',
541 PRIMARY KEY(`uri-id`),
542 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
543 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
548 CREATE TABLE IF NOT EXISTS `event` (
549 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
550 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
551 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
552 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
553 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
554 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
555 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
556 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
557 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
558 `summary` text COMMENT 'short description or title of the event',
559 `desc` text COMMENT 'event description',
560 `location` text COMMENT 'event location',
561 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
562 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
563 `adjust` boolean NOT NULL DEFAULT '1' COMMENT 'adjust to timezone of the recipient (0 or 1)',
564 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
565 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
566 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
567 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
568 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
570 INDEX `uid_start` (`uid`,`start`),
572 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
573 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
574 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
579 CREATE TABLE IF NOT EXISTS `fcontact` (
580 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
581 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
582 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
583 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
584 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
585 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
586 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
587 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
588 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
589 `notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
590 `poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
591 `confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
592 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
593 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
594 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
595 `pubkey` text COMMENT '',
596 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
598 INDEX `addr` (`addr`(32)),
599 UNIQUE INDEX `url` (`url`(190))
600 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
605 CREATE TABLE IF NOT EXISTS `fsuggest` (
606 `id` int unsigned NOT NULL auto_increment COMMENT '',
607 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
608 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
609 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
610 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
611 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
612 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
613 `note` text COMMENT '',
614 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
618 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
619 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
620 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
625 CREATE TABLE IF NOT EXISTS `group` (
626 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
627 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
628 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
629 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
630 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
633 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
634 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
637 -- TABLE group_member
639 CREATE TABLE IF NOT EXISTS `group_member` (
640 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
641 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
642 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
644 INDEX `contactid` (`contact-id`),
645 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
646 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
647 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
648 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
653 CREATE TABLE IF NOT EXISTS `gserver-tag` (
654 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
655 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
656 PRIMARY KEY(`gserver-id`,`tag`),
658 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
659 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
664 CREATE TABLE IF NOT EXISTS `hook` (
665 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
666 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
667 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
668 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
669 `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',
671 INDEX `priority` (`priority`),
672 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
673 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
678 CREATE TABLE IF NOT EXISTS `host` (
679 `id` tinyint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
680 `name` varchar(128) NOT NULL DEFAULT '' COMMENT 'The hostname',
682 UNIQUE INDEX `name` (`name`)
683 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Hostname';
686 -- TABLE inbox-status
688 CREATE TABLE IF NOT EXISTS `inbox-status` (
689 `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
690 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
691 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
692 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
693 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
694 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
695 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
697 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
702 CREATE TABLE IF NOT EXISTS `intro` (
703 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
704 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
705 `fid` int unsigned COMMENT '',
706 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
707 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
708 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
709 `note` text COMMENT '',
710 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
711 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
712 `blocked` boolean NOT NULL DEFAULT '1' COMMENT '',
713 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
715 INDEX `contact-id` (`contact-id`),
717 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
718 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
719 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
724 CREATE TABLE IF NOT EXISTS `locks` (
725 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
726 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
727 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
728 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
729 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
731 INDEX `name_expires` (`name`,`expires`)
732 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
737 CREATE TABLE IF NOT EXISTS `mail` (
738 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
739 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
740 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
741 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
742 `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
743 `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
744 `contact-id` varchar(255) COMMENT 'contact.id',
745 `convid` int unsigned COMMENT 'conv.id',
746 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
747 `body` mediumtext COMMENT '',
748 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
749 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
750 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
751 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
752 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
753 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
754 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
756 INDEX `uid_seen` (`uid`,`seen`),
757 INDEX `convid` (`convid`),
758 INDEX `uri` (`uri`(64)),
759 INDEX `parent-uri` (`parent-uri`(64)),
760 INDEX `contactid` (`contact-id`(32)),
761 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
762 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
767 CREATE TABLE IF NOT EXISTS `mailacct` (
768 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
769 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
770 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
771 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
772 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
773 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
774 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
775 `pass` text COMMENT '',
776 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
777 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
778 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
779 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
780 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
783 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
784 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
789 CREATE TABLE IF NOT EXISTS `manage` (
790 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
791 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
792 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
794 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
796 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
797 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
798 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
803 CREATE TABLE IF NOT EXISTS `notify` (
804 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
805 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
806 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
807 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
808 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
809 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
810 `msg` mediumtext COMMENT '',
811 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
812 `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
813 `iid` int unsigned COMMENT '',
814 `parent` int unsigned COMMENT '',
815 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
816 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
817 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
818 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
819 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
820 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
821 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
823 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
824 INDEX `uid_date` (`uid`,`date`),
825 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
826 INDEX `uri-id` (`uri-id`),
827 INDEX `parent-uri-id` (`parent-uri-id`),
828 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
829 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
830 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
831 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
834 -- TABLE notify-threads
836 CREATE TABLE IF NOT EXISTS `notify-threads` (
837 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
838 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
839 `master-parent-item` int unsigned COMMENT 'Deprecated',
840 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
841 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
842 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
844 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
845 INDEX `receiver-uid` (`receiver-uid`),
846 INDEX `notify-id` (`notify-id`),
847 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
848 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
849 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
850 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
855 CREATE TABLE IF NOT EXISTS `oembed` (
856 `url` varbinary(255) NOT NULL COMMENT 'page url',
857 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
858 `content` mediumtext COMMENT 'OEmbed data of the page',
859 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
860 PRIMARY KEY(`url`,`maxwidth`),
861 INDEX `created` (`created`)
862 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
865 -- TABLE openwebauth-token
867 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
868 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
869 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
870 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
871 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
872 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
873 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
876 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
877 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
882 CREATE TABLE IF NOT EXISTS `parsed_url` (
883 `url_hash` binary(64) NOT NULL COMMENT 'page url hash',
884 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
885 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
886 `url` text NOT NULL COMMENT 'page url',
887 `content` mediumtext COMMENT 'page data',
888 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
889 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration',
890 PRIMARY KEY(`url_hash`,`guessing`,`oembed`),
891 INDEX `created` (`created`),
892 INDEX `expires` (`expires`)
893 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
898 CREATE TABLE IF NOT EXISTS `pconfig` (
899 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
900 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
901 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
902 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
903 `v` mediumtext COMMENT 'Value',
905 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
906 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
907 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
912 CREATE TABLE IF NOT EXISTS `photo` (
913 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
914 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
915 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
916 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
917 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
918 `hash` char(32) COMMENT 'hash value of the photo',
919 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
920 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
921 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
922 `desc` text COMMENT '',
923 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
924 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
925 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
926 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
927 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
928 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
929 `data` mediumblob NOT NULL COMMENT '',
930 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
931 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
932 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
933 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
934 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
935 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
936 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
937 `backend-class` tinytext COMMENT 'Storage backend class',
938 `backend-ref` text COMMENT 'Storage backend data reference',
939 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
941 INDEX `contactid` (`contact-id`),
942 INDEX `uid_contactid` (`uid`,`contact-id`),
943 INDEX `uid_profile` (`uid`,`profile`),
944 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
945 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
946 INDEX `resource-id` (`resource-id`),
947 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
948 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
949 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
954 CREATE TABLE IF NOT EXISTS `post` (
955 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
956 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
957 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
958 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
959 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
960 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
961 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
962 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
963 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
964 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
965 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
966 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
967 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
968 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
969 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
970 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
971 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
972 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
973 PRIMARY KEY(`uri-id`),
974 INDEX `parent-uri-id` (`parent-uri-id`),
975 INDEX `thr-parent-id` (`thr-parent-id`),
976 INDEX `external-id` (`external-id`),
977 INDEX `owner-id` (`owner-id`),
978 INDEX `author-id` (`author-id`),
979 INDEX `causer-id` (`causer-id`),
981 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
982 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
983 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
984 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
985 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
986 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
987 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
988 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
989 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
992 -- TABLE post-category
994 CREATE TABLE IF NOT EXISTS `post-category` (
995 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
996 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
997 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
998 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
999 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1000 INDEX `uri-id` (`tid`),
1001 INDEX `uid` (`uid`),
1002 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1003 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1004 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1005 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1008 -- TABLE post-content
1010 CREATE TABLE IF NOT EXISTS `post-content` (
1011 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1012 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1013 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1014 `body` mediumtext COMMENT 'item body content',
1015 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1016 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1017 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1018 `language` text COMMENT 'Language information about this post',
1019 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1020 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1021 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1022 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1023 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1024 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1025 `target` text COMMENT 'JSON encoded target structure if used',
1026 `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',
1027 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1028 PRIMARY KEY(`uri-id`),
1029 INDEX `plink` (`plink`(191)),
1030 INDEX `resource-id` (`resource-id`),
1031 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
1032 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1033 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1036 -- TABLE post-delivery-data
1038 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1039 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1040 `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',
1041 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1042 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1043 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1044 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1045 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1046 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1047 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1048 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1049 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1050 PRIMARY KEY(`uri-id`),
1051 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1052 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1057 CREATE TABLE IF NOT EXISTS `post-media` (
1058 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1059 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1060 `url` varbinary(511) NOT NULL COMMENT 'Media URL',
1061 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1062 `mimetype` varchar(60) COMMENT '',
1063 `height` smallint unsigned COMMENT 'Height of the media',
1064 `width` smallint unsigned COMMENT 'Width of the media',
1065 `size` int unsigned COMMENT 'Media size',
1066 `preview` varbinary(255) COMMENT 'Preview URL',
1067 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1068 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1069 `description` text COMMENT '',
1070 `name` varchar(255) COMMENT 'Name of the media',
1071 `author-url` varbinary(255) COMMENT 'URL of the author of the media',
1072 `author-name` varchar(255) COMMENT 'Name of the author of the media',
1073 `author-image` varbinary(255) COMMENT 'Image of the author of the media',
1074 `publisher-url` varbinary(255) COMMENT 'URL of the publisher of the media',
1075 `publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
1076 `publisher-image` varbinary(255) COMMENT 'Image of the publisher of the media',
1078 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1079 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1080 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1085 CREATE TABLE IF NOT EXISTS `post-tag` (
1086 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1087 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1088 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1089 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1090 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1091 INDEX `tid` (`tid`),
1092 INDEX `cid` (`cid`),
1093 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1094 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1095 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1096 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1099 -- TABLE post-thread
1101 CREATE TABLE IF NOT EXISTS `post-thread` (
1102 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1103 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1104 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1105 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1106 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1107 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1108 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1109 `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',
1110 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1111 PRIMARY KEY(`uri-id`),
1112 INDEX `owner-id` (`owner-id`),
1113 INDEX `author-id` (`author-id`),
1114 INDEX `causer-id` (`causer-id`),
1115 INDEX `received` (`received`),
1116 INDEX `commented` (`commented`),
1117 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1118 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1119 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1120 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1121 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1126 CREATE TABLE IF NOT EXISTS `post-user` (
1127 `id` int unsigned NOT NULL auto_increment,
1128 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1129 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1130 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1131 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1132 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1133 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1134 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1135 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1136 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1137 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1138 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1139 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1140 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1141 `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
1142 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1143 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1144 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1145 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1146 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1147 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1148 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1149 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1150 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1151 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1152 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1153 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1154 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1155 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1156 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1158 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1159 INDEX `uri-id` (`uri-id`),
1160 INDEX `parent-uri-id` (`parent-uri-id`),
1161 INDEX `thr-parent-id` (`thr-parent-id`),
1162 INDEX `external-id` (`external-id`),
1163 INDEX `owner-id` (`owner-id`),
1164 INDEX `author-id` (`author-id`),
1165 INDEX `causer-id` (`causer-id`),
1166 INDEX `vid` (`vid`),
1167 INDEX `contact-id` (`contact-id`),
1168 INDEX `event-id` (`event-id`),
1169 INDEX `psid` (`psid`),
1170 INDEX `author-id_uid` (`author-id`,`uid`),
1171 INDEX `author-id_received` (`author-id`,`received`),
1172 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1173 INDEX `uid_contactid` (`uid`,`contact-id`),
1174 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1175 INDEX `uid_unseen` (`uid`,`unseen`),
1176 INDEX `uid_hidden_uri-id` (`uid`,`hidden`,`uri-id`),
1177 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1178 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1179 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1180 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1181 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1182 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1183 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1184 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1185 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1186 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1187 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1188 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1189 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1192 -- TABLE post-thread-user
1194 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1195 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1196 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1197 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1198 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1199 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1200 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1201 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1202 `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',
1203 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1204 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1205 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'The thread is pinned on the profile page',
1206 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1207 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1208 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1209 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1210 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1211 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1212 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1213 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1214 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1215 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1216 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1217 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1218 PRIMARY KEY(`uid`,`uri-id`),
1219 INDEX `uri-id` (`uri-id`),
1220 INDEX `owner-id` (`owner-id`),
1221 INDEX `author-id` (`author-id`),
1222 INDEX `causer-id` (`causer-id`),
1223 INDEX `uid` (`uid`),
1224 INDEX `contact-id` (`contact-id`),
1225 INDEX `psid` (`psid`),
1226 INDEX `post-user-id` (`post-user-id`),
1227 INDEX `commented` (`commented`),
1228 INDEX `uid_received` (`uid`,`received`),
1229 INDEX `uid_pinned` (`uid`,`pinned`),
1230 INDEX `uid_commented` (`uid`,`commented`),
1231 INDEX `uid_starred` (`uid`,`starred`),
1232 INDEX `uid_mention` (`uid`,`mention`),
1233 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1234 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1235 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1236 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1237 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1238 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1239 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1240 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1241 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1244 -- TABLE post-user-notification
1246 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1247 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1248 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1249 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1250 PRIMARY KEY(`uid`,`uri-id`),
1251 INDEX `uri-id` (`uri-id`),
1252 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1253 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1254 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1259 CREATE TABLE IF NOT EXISTS `process` (
1260 `pid` int unsigned NOT NULL COMMENT '',
1261 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1262 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1264 INDEX `command` (`command`)
1265 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1270 CREATE TABLE IF NOT EXISTS `profile` (
1271 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1272 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1273 `profile-name` varchar(255) COMMENT 'Deprecated',
1274 `is-default` boolean COMMENT 'Deprecated',
1275 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1276 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1277 `pdesc` varchar(255) COMMENT 'Deprecated',
1278 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1279 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1280 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1281 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1282 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1283 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1284 `hometown` varchar(255) COMMENT 'Deprecated',
1285 `gender` varchar(32) COMMENT 'Deprecated',
1286 `marital` varchar(255) COMMENT 'Deprecated',
1287 `with` text COMMENT 'Deprecated',
1288 `howlong` datetime COMMENT 'Deprecated',
1289 `sexual` varchar(255) COMMENT 'Deprecated',
1290 `politic` varchar(255) COMMENT 'Deprecated',
1291 `religion` varchar(255) COMMENT 'Deprecated',
1292 `pub_keywords` text COMMENT '',
1293 `prv_keywords` text COMMENT '',
1294 `likes` text COMMENT 'Deprecated',
1295 `dislikes` text COMMENT 'Deprecated',
1296 `about` text COMMENT 'Profile description',
1297 `summary` varchar(255) COMMENT 'Deprecated',
1298 `music` text COMMENT 'Deprecated',
1299 `book` text COMMENT 'Deprecated',
1300 `tv` text COMMENT 'Deprecated',
1301 `film` text COMMENT 'Deprecated',
1302 `interest` text COMMENT 'Deprecated',
1303 `romance` text COMMENT 'Deprecated',
1304 `work` text COMMENT 'Deprecated',
1305 `education` text COMMENT 'Deprecated',
1306 `contact` text COMMENT 'Deprecated',
1307 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1308 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1309 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1310 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1311 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1312 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1314 INDEX `uid_is-default` (`uid`,`is-default`),
1315 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1316 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1317 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1320 -- TABLE profile_check
1322 CREATE TABLE IF NOT EXISTS `profile_check` (
1323 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1324 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1325 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1326 `dfrn_id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1327 `sec` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1328 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1330 INDEX `uid` (`uid`),
1331 INDEX `cid` (`cid`),
1332 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1333 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1334 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='DFRN remote auth use';
1337 -- TABLE profile_field
1339 CREATE TABLE IF NOT EXISTS `profile_field` (
1340 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1341 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1342 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1343 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1344 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1345 `value` text COMMENT 'Value of the field',
1346 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1347 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1349 INDEX `uid` (`uid`),
1350 INDEX `order` (`order`),
1351 INDEX `psid` (`psid`),
1352 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1353 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1354 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1357 -- TABLE push_subscriber
1359 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1360 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1361 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1362 `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1363 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1364 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1365 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1366 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1367 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1368 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1369 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1371 INDEX `next_try` (`next_try`),
1372 INDEX `uid` (`uid`),
1373 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1374 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1379 CREATE TABLE IF NOT EXISTS `register` (
1380 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1381 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1382 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1383 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1384 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1385 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1386 `note` text COMMENT '',
1388 INDEX `uid` (`uid`),
1389 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1390 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1395 CREATE TABLE IF NOT EXISTS `search` (
1396 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1397 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1398 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1400 INDEX `uid_term` (`uid`,`term`(64)),
1401 INDEX `term` (`term`(64)),
1402 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1403 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1408 CREATE TABLE IF NOT EXISTS `session` (
1409 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1410 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1411 `data` text COMMENT '',
1412 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1414 INDEX `sid` (`sid`(64)),
1415 INDEX `expire` (`expire`)
1416 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1421 CREATE TABLE IF NOT EXISTS `storage` (
1422 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1423 `data` longblob NOT NULL COMMENT 'file data',
1425 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1430 CREATE TABLE IF NOT EXISTS `tokens` (
1431 `id` varchar(40) NOT NULL COMMENT '',
1432 `secret` text COMMENT '',
1433 `client_id` varchar(20) NOT NULL DEFAULT '',
1434 `expires` int NOT NULL DEFAULT 0 COMMENT '',
1435 `scope` varchar(200) NOT NULL DEFAULT '' COMMENT '',
1436 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1438 INDEX `client_id` (`client_id`),
1439 INDEX `uid` (`uid`),
1440 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1441 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1442 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
1447 CREATE TABLE IF NOT EXISTS `userd` (
1448 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1449 `username` varchar(255) NOT NULL COMMENT '',
1451 INDEX `username` (`username`(32))
1452 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1455 -- TABLE user-contact
1457 CREATE TABLE IF NOT EXISTS `user-contact` (
1458 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1459 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1460 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1461 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1462 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1463 PRIMARY KEY(`uid`,`cid`),
1464 INDEX `cid` (`cid`),
1465 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1466 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1467 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1472 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1473 `key` int NOT NULL COMMENT '',
1474 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1476 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1479 -- TABLE workerqueue
1481 CREATE TABLE IF NOT EXISTS `workerqueue` (
1482 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
1483 `command` varchar(100) COMMENT 'Task command',
1484 `parameter` mediumtext COMMENT 'Task parameter',
1485 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
1486 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
1487 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
1488 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
1489 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1490 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1491 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
1493 INDEX `command` (`command`),
1494 INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
1495 INDEX `done_executed` (`done`,`executed`),
1496 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
1497 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
1498 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
1499 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
1500 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
1501 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
1504 -- VIEW post-user-view
1506 DROP VIEW IF EXISTS `post-user-view`;
1507 CREATE VIEW `post-user-view` AS SELECT
1508 `post-user`.`id` AS `id`,
1509 `post-user`.`id` AS `post-user-id`,
1510 `post-user`.`uid` AS `uid`,
1511 `parent-post`.`id` AS `parent`,
1512 `item-uri`.`uri` AS `uri`,
1513 `post-user`.`uri-id` AS `uri-id`,
1514 `parent-item-uri`.`uri` AS `parent-uri`,
1515 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1516 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1517 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1518 `item-uri`.`guid` AS `guid`,
1519 `post-user`.`wall` AS `wall`,
1520 `post-user`.`gravity` AS `gravity`,
1521 `external-item-uri`.`uri` AS `extid`,
1522 `post-user`.`external-id` AS `external-id`,
1523 `post-user`.`created` AS `created`,
1524 `post-user`.`edited` AS `edited`,
1525 `post-thread-user`.`commented` AS `commented`,
1526 `post-user`.`received` AS `received`,
1527 `post-thread-user`.`changed` AS `changed`,
1528 `post-user`.`post-type` AS `post-type`,
1529 `post-user`.`post-reason` AS `post-reason`,
1530 `post-user`.`private` AS `private`,
1531 `post-thread-user`.`pubmail` AS `pubmail`,
1532 `post-user`.`visible` AS `visible`,
1533 `post-thread-user`.`starred` AS `starred`,
1534 `post-thread-user`.`pinned` AS `pinned`,
1535 `post-user`.`unseen` AS `unseen`,
1536 `post-user`.`deleted` AS `deleted`,
1537 `post-user`.`origin` AS `origin`,
1538 `post-thread-user`.`origin` AS `parent-origin`,
1539 `post-thread-user`.`forum_mode` AS `forum_mode`,
1540 `post-thread-user`.`mention` AS `mention`,
1541 `post-user`.`global` AS `global`,
1542 `post-user`.`network` AS `network`,
1543 `post-user`.`vid` AS `vid`,
1544 `post-user`.`psid` AS `psid`,
1545 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1546 `post-content`.`title` AS `title`,
1547 `post-content`.`content-warning` AS `content-warning`,
1548 `post-content`.`raw-body` AS `raw-body`,
1549 `post-content`.`body` AS `body`,
1550 `post-content`.`rendered-hash` AS `rendered-hash`,
1551 `post-content`.`rendered-html` AS `rendered-html`,
1552 `post-content`.`language` AS `language`,
1553 `post-content`.`plink` AS `plink`,
1554 `post-content`.`location` AS `location`,
1555 `post-content`.`coord` AS `coord`,
1556 `post-content`.`app` AS `app`,
1557 `post-content`.`object-type` AS `object-type`,
1558 `post-content`.`object` AS `object`,
1559 `post-content`.`target-type` AS `target-type`,
1560 `post-content`.`target` AS `target`,
1561 `post-content`.`resource-id` AS `resource-id`,
1562 `post-user`.`contact-id` AS `contact-id`,
1563 `contact`.`url` AS `contact-link`,
1564 `contact`.`addr` AS `contact-addr`,
1565 `contact`.`name` AS `contact-name`,
1566 `contact`.`nick` AS `contact-nick`,
1567 `contact`.`thumb` AS `contact-avatar`,
1568 `contact`.`network` AS `contact-network`,
1569 `contact`.`blocked` AS `contact-blocked`,
1570 `contact`.`hidden` AS `contact-hidden`,
1571 `contact`.`readonly` AS `contact-readonly`,
1572 `contact`.`archive` AS `contact-archive`,
1573 `contact`.`pending` AS `contact-pending`,
1574 `contact`.`rel` AS `contact-rel`,
1575 `contact`.`uid` AS `contact-uid`,
1576 `contact`.`contact-type` AS `contact-contact-type`,
1577 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1578 `contact`.`self` AS `self`,
1579 `contact`.`id` AS `cid`,
1580 `contact`.`alias` AS `alias`,
1581 `contact`.`photo` AS `photo`,
1582 `contact`.`name-date` AS `name-date`,
1583 `contact`.`uri-date` AS `uri-date`,
1584 `contact`.`avatar-date` AS `avatar-date`,
1585 `contact`.`thumb` AS `thumb`,
1586 `contact`.`dfrn-id` AS `dfrn-id`,
1587 `post-user`.`author-id` AS `author-id`,
1588 `author`.`url` AS `author-link`,
1589 `author`.`addr` AS `author-addr`,
1590 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1591 `author`.`nick` AS `author-nick`,
1592 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1593 `author`.`network` AS `author-network`,
1594 `author`.`blocked` AS `author-blocked`,
1595 `author`.`hidden` AS `author-hidden`,
1596 `post-user`.`owner-id` AS `owner-id`,
1597 `owner`.`url` AS `owner-link`,
1598 `owner`.`addr` AS `owner-addr`,
1599 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1600 `owner`.`nick` AS `owner-nick`,
1601 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1602 `owner`.`network` AS `owner-network`,
1603 `owner`.`blocked` AS `owner-blocked`,
1604 `owner`.`hidden` AS `owner-hidden`,
1605 `owner`.`contact-type` AS `owner-contact-type`,
1606 `post-user`.`causer-id` AS `causer-id`,
1607 `causer`.`url` AS `causer-link`,
1608 `causer`.`addr` AS `causer-addr`,
1609 `causer`.`name` AS `causer-name`,
1610 `causer`.`nick` AS `causer-nick`,
1611 `causer`.`thumb` AS `causer-avatar`,
1612 `causer`.`network` AS `causer-network`,
1613 `causer`.`blocked` AS `causer-blocked`,
1614 `causer`.`hidden` AS `causer-hidden`,
1615 `causer`.`contact-type` AS `causer-contact-type`,
1616 `post-delivery-data`.`postopts` AS `postopts`,
1617 `post-delivery-data`.`inform` AS `inform`,
1618 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1619 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1620 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1621 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1622 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1623 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1624 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1625 `post-user`.`event-id` AS `event-id`,
1626 `event`.`created` AS `event-created`,
1627 `event`.`edited` AS `event-edited`,
1628 `event`.`start` AS `event-start`,
1629 `event`.`finish` AS `event-finish`,
1630 `event`.`summary` AS `event-summary`,
1631 `event`.`desc` AS `event-desc`,
1632 `event`.`location` AS `event-location`,
1633 `event`.`type` AS `event-type`,
1634 `event`.`nofinish` AS `event-nofinish`,
1635 `event`.`adjust` AS `event-adjust`,
1636 `event`.`ignore` AS `event-ignore`,
1637 `diaspora-interaction`.`interaction` AS `signed_text`,
1638 `parent-item-uri`.`guid` AS `parent-guid`,
1639 `parent-post`.`network` AS `parent-network`,
1640 `parent-post`.`author-id` AS `parent-author-id`,
1641 `parent-post-author`.`url` AS `parent-author-link`,
1642 `parent-post-author`.`name` AS `parent-author-name`,
1643 `parent-post-author`.`network` AS `parent-author-network`
1645 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
1646 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
1647 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
1648 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
1649 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
1650 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
1651 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1652 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1653 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1654 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1655 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1656 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
1657 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
1658 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
1659 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
1660 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
1661 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1664 -- VIEW post-thread-user-view
1666 DROP VIEW IF EXISTS `post-thread-user-view`;
1667 CREATE VIEW `post-thread-user-view` AS SELECT
1668 `post-user`.`id` AS `id`,
1669 `post-user`.`id` AS `post-user-id`,
1670 `post-thread-user`.`uid` AS `uid`,
1671 `parent-post`.`id` AS `parent`,
1672 `item-uri`.`uri` AS `uri`,
1673 `post-thread-user`.`uri-id` AS `uri-id`,
1674 `parent-item-uri`.`uri` AS `parent-uri`,
1675 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1676 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1677 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1678 `item-uri`.`guid` AS `guid`,
1679 `post-thread-user`.`wall` AS `wall`,
1680 `post-user`.`gravity` AS `gravity`,
1681 `external-item-uri`.`uri` AS `extid`,
1682 `post-user`.`external-id` AS `external-id`,
1683 `post-thread-user`.`created` AS `created`,
1684 `post-user`.`edited` AS `edited`,
1685 `post-thread-user`.`commented` AS `commented`,
1686 `post-thread-user`.`received` AS `received`,
1687 `post-thread-user`.`changed` AS `changed`,
1688 `post-user`.`post-type` AS `post-type`,
1689 `post-user`.`post-reason` AS `post-reason`,
1690 `post-user`.`private` AS `private`,
1691 `post-thread-user`.`pubmail` AS `pubmail`,
1692 `post-thread-user`.`ignored` AS `ignored`,
1693 `post-user`.`visible` AS `visible`,
1694 `post-thread-user`.`starred` AS `starred`,
1695 `post-thread-user`.`pinned` AS `pinned`,
1696 `post-thread-user`.`unseen` AS `unseen`,
1697 `post-user`.`deleted` AS `deleted`,
1698 `post-thread-user`.`origin` AS `origin`,
1699 `post-thread-user`.`forum_mode` AS `forum_mode`,
1700 `post-thread-user`.`mention` AS `mention`,
1701 `post-user`.`global` AS `global`,
1702 `post-thread-user`.`network` AS `network`,
1703 `post-user`.`vid` AS `vid`,
1704 `post-thread-user`.`psid` AS `psid`,
1705 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1706 `post-content`.`title` AS `title`,
1707 `post-content`.`content-warning` AS `content-warning`,
1708 `post-content`.`raw-body` AS `raw-body`,
1709 `post-content`.`body` AS `body`,
1710 `post-content`.`rendered-hash` AS `rendered-hash`,
1711 `post-content`.`rendered-html` AS `rendered-html`,
1712 `post-content`.`language` AS `language`,
1713 `post-content`.`plink` AS `plink`,
1714 `post-content`.`location` AS `location`,
1715 `post-content`.`coord` AS `coord`,
1716 `post-content`.`app` AS `app`,
1717 `post-content`.`object-type` AS `object-type`,
1718 `post-content`.`object` AS `object`,
1719 `post-content`.`target-type` AS `target-type`,
1720 `post-content`.`target` AS `target`,
1721 `post-content`.`resource-id` AS `resource-id`,
1722 `post-thread-user`.`contact-id` AS `contact-id`,
1723 `contact`.`url` AS `contact-link`,
1724 `contact`.`addr` AS `contact-addr`,
1725 `contact`.`name` AS `contact-name`,
1726 `contact`.`nick` AS `contact-nick`,
1727 `contact`.`thumb` AS `contact-avatar`,
1728 `contact`.`network` AS `contact-network`,
1729 `contact`.`blocked` AS `contact-blocked`,
1730 `contact`.`hidden` AS `contact-hidden`,
1731 `contact`.`readonly` AS `contact-readonly`,
1732 `contact`.`archive` AS `contact-archive`,
1733 `contact`.`pending` AS `contact-pending`,
1734 `contact`.`rel` AS `contact-rel`,
1735 `contact`.`uid` AS `contact-uid`,
1736 `contact`.`contact-type` AS `contact-contact-type`,
1737 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1738 `contact`.`self` AS `self`,
1739 `contact`.`id` AS `cid`,
1740 `contact`.`alias` AS `alias`,
1741 `contact`.`photo` AS `photo`,
1742 `contact`.`name-date` AS `name-date`,
1743 `contact`.`uri-date` AS `uri-date`,
1744 `contact`.`avatar-date` AS `avatar-date`,
1745 `contact`.`thumb` AS `thumb`,
1746 `contact`.`dfrn-id` AS `dfrn-id`,
1747 `post-thread-user`.`author-id` AS `author-id`,
1748 `author`.`url` AS `author-link`,
1749 `author`.`addr` AS `author-addr`,
1750 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1751 `author`.`nick` AS `author-nick`,
1752 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1753 `author`.`network` AS `author-network`,
1754 `author`.`blocked` AS `author-blocked`,
1755 `author`.`hidden` AS `author-hidden`,
1756 `post-thread-user`.`owner-id` AS `owner-id`,
1757 `owner`.`url` AS `owner-link`,
1758 `owner`.`addr` AS `owner-addr`,
1759 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1760 `owner`.`nick` AS `owner-nick`,
1761 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1762 `owner`.`network` AS `owner-network`,
1763 `owner`.`blocked` AS `owner-blocked`,
1764 `owner`.`hidden` AS `owner-hidden`,
1765 `owner`.`contact-type` AS `owner-contact-type`,
1766 `post-thread-user`.`causer-id` AS `causer-id`,
1767 `causer`.`url` AS `causer-link`,
1768 `causer`.`addr` AS `causer-addr`,
1769 `causer`.`name` AS `causer-name`,
1770 `causer`.`nick` AS `causer-nick`,
1771 `causer`.`thumb` AS `causer-avatar`,
1772 `causer`.`network` AS `causer-network`,
1773 `causer`.`blocked` AS `causer-blocked`,
1774 `causer`.`hidden` AS `causer-hidden`,
1775 `causer`.`contact-type` AS `causer-contact-type`,
1776 `post-delivery-data`.`postopts` AS `postopts`,
1777 `post-delivery-data`.`inform` AS `inform`,
1778 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1779 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1780 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1781 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1782 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1783 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1784 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1785 `post-user`.`event-id` AS `event-id`,
1786 `event`.`created` AS `event-created`,
1787 `event`.`edited` AS `event-edited`,
1788 `event`.`start` AS `event-start`,
1789 `event`.`finish` AS `event-finish`,
1790 `event`.`summary` AS `event-summary`,
1791 `event`.`desc` AS `event-desc`,
1792 `event`.`location` AS `event-location`,
1793 `event`.`type` AS `event-type`,
1794 `event`.`nofinish` AS `event-nofinish`,
1795 `event`.`adjust` AS `event-adjust`,
1796 `event`.`ignore` AS `event-ignore`,
1797 `diaspora-interaction`.`interaction` AS `signed_text`,
1798 `parent-item-uri`.`guid` AS `parent-guid`,
1799 `parent-post`.`network` AS `parent-network`,
1800 `parent-post`.`author-id` AS `parent-author-id`,
1801 `parent-post-author`.`url` AS `parent-author-link`,
1802 `parent-post-author`.`name` AS `parent-author-name`,
1803 `parent-post-author`.`network` AS `parent-author-network`
1804 FROM `post-thread-user`
1805 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
1806 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
1807 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
1808 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
1809 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
1810 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
1811 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1812 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1813 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1814 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1815 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1816 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
1817 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
1818 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
1819 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
1820 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`
1821 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1826 DROP VIEW IF EXISTS `post-view`;
1827 CREATE VIEW `post-view` AS SELECT
1828 `item-uri`.`uri` AS `uri`,
1829 `post`.`uri-id` AS `uri-id`,
1830 `parent-item-uri`.`uri` AS `parent-uri`,
1831 `post`.`parent-uri-id` AS `parent-uri-id`,
1832 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1833 `post`.`thr-parent-id` AS `thr-parent-id`,
1834 `item-uri`.`guid` AS `guid`,
1835 `post`.`gravity` AS `gravity`,
1836 `external-item-uri`.`uri` AS `extid`,
1837 `post`.`external-id` AS `external-id`,
1838 `post`.`created` AS `created`,
1839 `post`.`edited` AS `edited`,
1840 `post-thread`.`commented` AS `commented`,
1841 `post`.`received` AS `received`,
1842 `post-thread`.`changed` AS `changed`,
1843 `post`.`post-type` AS `post-type`,
1844 `post`.`private` AS `private`,
1845 `post`.`visible` AS `visible`,
1846 `post`.`deleted` AS `deleted`,
1847 `post`.`global` AS `global`,
1848 `post`.`network` AS `network`,
1849 `post`.`vid` AS `vid`,
1850 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1851 `post-content`.`title` AS `title`,
1852 `post-content`.`content-warning` AS `content-warning`,
1853 `post-content`.`raw-body` AS `raw-body`,
1854 `post-content`.`body` AS `body`,
1855 `post-content`.`rendered-hash` AS `rendered-hash`,
1856 `post-content`.`rendered-html` AS `rendered-html`,
1857 `post-content`.`language` AS `language`,
1858 `post-content`.`plink` AS `plink`,
1859 `post-content`.`location` AS `location`,
1860 `post-content`.`coord` AS `coord`,
1861 `post-content`.`app` AS `app`,
1862 `post-content`.`object-type` AS `object-type`,
1863 `post-content`.`object` AS `object`,
1864 `post-content`.`target-type` AS `target-type`,
1865 `post-content`.`target` AS `target`,
1866 `post-content`.`resource-id` AS `resource-id`,
1867 `post`.`author-id` AS `author-id`,
1868 `author`.`url` AS `author-link`,
1869 `author`.`addr` AS `author-addr`,
1870 `author`.`name` AS `author-name`,
1871 `author`.`nick` AS `author-nick`,
1872 `author`.`thumb` AS `author-avatar`,
1873 `author`.`network` AS `author-network`,
1874 `author`.`blocked` AS `author-blocked`,
1875 `author`.`hidden` AS `author-hidden`,
1876 `post`.`owner-id` AS `owner-id`,
1877 `owner`.`url` AS `owner-link`,
1878 `owner`.`addr` AS `owner-addr`,
1879 `owner`.`name` AS `owner-name`,
1880 `owner`.`nick` AS `owner-nick`,
1881 `owner`.`thumb` AS `owner-avatar`,
1882 `owner`.`network` AS `owner-network`,
1883 `owner`.`blocked` AS `owner-blocked`,
1884 `owner`.`hidden` AS `owner-hidden`,
1885 `owner`.`contact-type` AS `owner-contact-type`,
1886 `post`.`causer-id` AS `causer-id`,
1887 `causer`.`url` AS `causer-link`,
1888 `causer`.`addr` AS `causer-addr`,
1889 `causer`.`name` AS `causer-name`,
1890 `causer`.`nick` AS `causer-nick`,
1891 `causer`.`thumb` AS `causer-avatar`,
1892 `causer`.`network` AS `causer-network`,
1893 `causer`.`blocked` AS `causer-blocked`,
1894 `causer`.`hidden` AS `causer-hidden`,
1895 `causer`.`contact-type` AS `causer-contact-type`,
1896 `diaspora-interaction`.`interaction` AS `signed_text`,
1897 `parent-item-uri`.`guid` AS `parent-guid`,
1898 `parent-post`.`network` AS `parent-network`,
1899 `parent-post`.`author-id` AS `parent-author-id`,
1900 `parent-post-author`.`url` AS `parent-author-link`,
1901 `parent-post-author`.`name` AS `parent-author-name`,
1902 `parent-post-author`.`network` AS `parent-author-network`
1904 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
1905 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
1906 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
1907 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
1908 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
1909 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
1910 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
1911 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
1912 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
1913 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
1914 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
1915 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
1916 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1919 -- VIEW post-thread-view
1921 DROP VIEW IF EXISTS `post-thread-view`;
1922 CREATE VIEW `post-thread-view` AS SELECT
1923 `item-uri`.`uri` AS `uri`,
1924 `post-thread`.`uri-id` AS `uri-id`,
1925 `parent-item-uri`.`uri` AS `parent-uri`,
1926 `post`.`parent-uri-id` AS `parent-uri-id`,
1927 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1928 `post`.`thr-parent-id` AS `thr-parent-id`,
1929 `item-uri`.`guid` AS `guid`,
1930 `post`.`gravity` AS `gravity`,
1931 `external-item-uri`.`uri` AS `extid`,
1932 `post`.`external-id` AS `external-id`,
1933 `post-thread`.`created` AS `created`,
1934 `post`.`edited` AS `edited`,
1935 `post-thread`.`commented` AS `commented`,
1936 `post-thread`.`received` AS `received`,
1937 `post-thread`.`changed` AS `changed`,
1938 `post`.`post-type` AS `post-type`,
1939 `post`.`private` AS `private`,
1940 `post`.`visible` AS `visible`,
1941 `post`.`deleted` AS `deleted`,
1942 `post`.`global` AS `global`,
1943 `post-thread`.`network` AS `network`,
1944 `post`.`vid` AS `vid`,
1945 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1946 `post-content`.`title` AS `title`,
1947 `post-content`.`content-warning` AS `content-warning`,
1948 `post-content`.`raw-body` AS `raw-body`,
1949 `post-content`.`body` AS `body`,
1950 `post-content`.`rendered-hash` AS `rendered-hash`,
1951 `post-content`.`rendered-html` AS `rendered-html`,
1952 `post-content`.`language` AS `language`,
1953 `post-content`.`plink` AS `plink`,
1954 `post-content`.`location` AS `location`,
1955 `post-content`.`coord` AS `coord`,
1956 `post-content`.`app` AS `app`,
1957 `post-content`.`object-type` AS `object-type`,
1958 `post-content`.`object` AS `object`,
1959 `post-content`.`target-type` AS `target-type`,
1960 `post-content`.`target` AS `target`,
1961 `post-content`.`resource-id` AS `resource-id`,
1962 `post-thread`.`author-id` AS `author-id`,
1963 `author`.`url` AS `author-link`,
1964 `author`.`addr` AS `author-addr`,
1965 `author`.`name` AS `author-name`,
1966 `author`.`nick` AS `author-nick`,
1967 `author`.`thumb` AS `author-avatar`,
1968 `author`.`network` AS `author-network`,
1969 `author`.`blocked` AS `author-blocked`,
1970 `author`.`hidden` AS `author-hidden`,
1971 `post-thread`.`owner-id` AS `owner-id`,
1972 `owner`.`url` AS `owner-link`,
1973 `owner`.`addr` AS `owner-addr`,
1974 `owner`.`name` AS `owner-name`,
1975 `owner`.`nick` AS `owner-nick`,
1976 `owner`.`thumb` AS `owner-avatar`,
1977 `owner`.`network` AS `owner-network`,
1978 `owner`.`blocked` AS `owner-blocked`,
1979 `owner`.`hidden` AS `owner-hidden`,
1980 `owner`.`contact-type` AS `owner-contact-type`,
1981 `post-thread`.`causer-id` AS `causer-id`,
1982 `causer`.`url` AS `causer-link`,
1983 `causer`.`addr` AS `causer-addr`,
1984 `causer`.`name` AS `causer-name`,
1985 `causer`.`nick` AS `causer-nick`,
1986 `causer`.`thumb` AS `causer-avatar`,
1987 `causer`.`network` AS `causer-network`,
1988 `causer`.`blocked` AS `causer-blocked`,
1989 `causer`.`hidden` AS `causer-hidden`,
1990 `causer`.`contact-type` AS `causer-contact-type`,
1991 `diaspora-interaction`.`interaction` AS `signed_text`,
1992 `parent-item-uri`.`guid` AS `parent-guid`,
1993 `parent-post`.`network` AS `parent-network`,
1994 `parent-post`.`author-id` AS `parent-author-id`,
1995 `parent-post-author`.`url` AS `parent-author-link`,
1996 `parent-post-author`.`name` AS `parent-author-name`,
1997 `parent-post-author`.`network` AS `parent-author-network`
1999 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
2000 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
2001 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
2002 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
2003 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
2004 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2005 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2006 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2007 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2008 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
2009 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
2010 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2011 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2014 -- VIEW category-view
2016 DROP VIEW IF EXISTS `category-view`;
2017 CREATE VIEW `category-view` AS SELECT
2018 `post-category`.`uri-id` AS `uri-id`,
2019 `post-category`.`uid` AS `uid`,
2020 `post-category`.`type` AS `type`,
2021 `post-category`.`tid` AS `tid`,
2022 `tag`.`name` AS `name`,
2023 `tag`.`url` AS `url`
2024 FROM `post-category`
2025 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2030 DROP VIEW IF EXISTS `tag-view`;
2031 CREATE VIEW `tag-view` AS SELECT
2032 `post-tag`.`uri-id` AS `uri-id`,
2033 `post-tag`.`type` AS `type`,
2034 `post-tag`.`tid` AS `tid`,
2035 `post-tag`.`cid` AS `cid`,
2036 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2037 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
2039 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2040 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2043 -- VIEW network-item-view
2045 DROP VIEW IF EXISTS `network-item-view`;
2046 CREATE VIEW `network-item-view` AS SELECT
2047 `post-user`.`uri-id` AS `uri-id`,
2048 `parent-post`.`id` AS `parent`,
2049 `post-user`.`received` AS `received`,
2050 `post-thread-user`.`commented` AS `commented`,
2051 `post-user`.`created` AS `created`,
2052 `post-user`.`uid` AS `uid`,
2053 `post-thread-user`.`starred` AS `starred`,
2054 `post-thread-user`.`mention` AS `mention`,
2055 `post-user`.`network` AS `network`,
2056 `post-user`.`unseen` AS `unseen`,
2057 `post-user`.`gravity` AS `gravity`,
2058 `post-user`.`contact-id` AS `contact-id`,
2059 `ownercontact`.`contact-type` AS `contact-type`
2061 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2062 INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2063 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2064 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2065 INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2066 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2067 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2068 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2069 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
2070 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2071 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2074 -- VIEW network-thread-view
2076 DROP VIEW IF EXISTS `network-thread-view`;
2077 CREATE VIEW `network-thread-view` AS SELECT
2078 `post-thread-user`.`uri-id` AS `uri-id`,
2079 `parent-post`.`id` AS `parent`,
2080 `post-thread-user`.`received` AS `received`,
2081 `post-thread-user`.`commented` AS `commented`,
2082 `post-thread-user`.`created` AS `created`,
2083 `post-thread-user`.`uid` AS `uid`,
2084 `post-thread-user`.`starred` AS `starred`,
2085 `post-thread-user`.`mention` AS `mention`,
2086 `post-thread-user`.`network` AS `network`,
2087 `post-thread-user`.`contact-id` AS `contact-id`,
2088 `ownercontact`.`contact-type` AS `contact-type`
2089 FROM `post-thread-user`
2090 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2091 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2092 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2093 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2094 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2095 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2096 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2097 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2098 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2099 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2100 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2105 DROP VIEW IF EXISTS `owner-view`;
2106 CREATE VIEW `owner-view` AS SELECT
2107 `contact`.`id` AS `id`,
2108 `contact`.`uid` AS `uid`,
2109 `contact`.`created` AS `created`,
2110 `contact`.`updated` AS `updated`,
2111 `contact`.`self` AS `self`,
2112 `contact`.`remote_self` AS `remote_self`,
2113 `contact`.`rel` AS `rel`,
2114 `contact`.`duplex` AS `duplex`,
2115 `contact`.`network` AS `network`,
2116 `contact`.`protocol` AS `protocol`,
2117 `contact`.`name` AS `name`,
2118 `contact`.`nick` AS `nick`,
2119 `contact`.`location` AS `location`,
2120 `contact`.`about` AS `about`,
2121 `contact`.`keywords` AS `keywords`,
2122 `contact`.`gender` AS `gender`,
2123 `contact`.`xmpp` AS `xmpp`,
2124 `contact`.`attag` AS `attag`,
2125 `contact`.`avatar` AS `avatar`,
2126 `contact`.`photo` AS `photo`,
2127 `contact`.`thumb` AS `thumb`,
2128 `contact`.`micro` AS `micro`,
2129 `contact`.`site-pubkey` AS `site-pubkey`,
2130 `contact`.`issued-id` AS `issued-id`,
2131 `contact`.`dfrn-id` AS `dfrn-id`,
2132 `contact`.`url` AS `url`,
2133 `contact`.`nurl` AS `nurl`,
2134 `contact`.`addr` AS `addr`,
2135 `contact`.`alias` AS `alias`,
2136 `contact`.`pubkey` AS `pubkey`,
2137 `contact`.`prvkey` AS `prvkey`,
2138 `contact`.`batch` AS `batch`,
2139 `contact`.`request` AS `request`,
2140 `contact`.`notify` AS `notify`,
2141 `contact`.`poll` AS `poll`,
2142 `contact`.`confirm` AS `confirm`,
2143 `contact`.`poco` AS `poco`,
2144 `contact`.`aes_allow` AS `aes_allow`,
2145 `contact`.`ret-aes` AS `ret-aes`,
2146 `contact`.`usehub` AS `usehub`,
2147 `contact`.`subhub` AS `subhub`,
2148 `contact`.`hub-verify` AS `hub-verify`,
2149 `contact`.`last-update` AS `last-update`,
2150 `contact`.`success_update` AS `success_update`,
2151 `contact`.`failure_update` AS `failure_update`,
2152 `contact`.`name-date` AS `name-date`,
2153 `contact`.`uri-date` AS `uri-date`,
2154 `contact`.`avatar-date` AS `avatar-date`,
2155 `contact`.`avatar-date` AS `picdate`,
2156 `contact`.`term-date` AS `term-date`,
2157 `contact`.`last-item` AS `last-item`,
2158 `contact`.`priority` AS `priority`,
2159 `user`.`blocked` AS `blocked`,
2160 `contact`.`block_reason` AS `block_reason`,
2161 `contact`.`readonly` AS `readonly`,
2162 `contact`.`writable` AS `writable`,
2163 `contact`.`forum` AS `forum`,
2164 `contact`.`prv` AS `prv`,
2165 `contact`.`contact-type` AS `contact-type`,
2166 `contact`.`manually-approve` AS `manually-approve`,
2167 `contact`.`hidden` AS `hidden`,
2168 `contact`.`archive` AS `archive`,
2169 `contact`.`pending` AS `pending`,
2170 `contact`.`deleted` AS `deleted`,
2171 `contact`.`unsearchable` AS `unsearchable`,
2172 `contact`.`sensitive` AS `sensitive`,
2173 `contact`.`baseurl` AS `baseurl`,
2174 `contact`.`reason` AS `reason`,
2175 `contact`.`closeness` AS `closeness`,
2176 `contact`.`info` AS `info`,
2177 `contact`.`profile-id` AS `profile-id`,
2178 `contact`.`bdyear` AS `bdyear`,
2179 `contact`.`bd` AS `bd`,
2180 `contact`.`notify_new_posts` AS `notify_new_posts`,
2181 `contact`.`fetch_further_information` AS `fetch_further_information`,
2182 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2183 `user`.`parent-uid` AS `parent-uid`,
2184 `user`.`guid` AS `guid`,
2185 `user`.`nickname` AS `nickname`,
2186 `user`.`email` AS `email`,
2187 `user`.`openid` AS `openid`,
2188 `user`.`timezone` AS `timezone`,
2189 `user`.`language` AS `language`,
2190 `user`.`register_date` AS `register_date`,
2191 `user`.`login_date` AS `login_date`,
2192 `user`.`default-location` AS `default-location`,
2193 `user`.`allow_location` AS `allow_location`,
2194 `user`.`theme` AS `theme`,
2195 `user`.`pubkey` AS `upubkey`,
2196 `user`.`prvkey` AS `uprvkey`,
2197 `user`.`sprvkey` AS `sprvkey`,
2198 `user`.`spubkey` AS `spubkey`,
2199 `user`.`verified` AS `verified`,
2200 `user`.`blockwall` AS `blockwall`,
2201 `user`.`hidewall` AS `hidewall`,
2202 `user`.`blocktags` AS `blocktags`,
2203 `user`.`unkmail` AS `unkmail`,
2204 `user`.`cntunkmail` AS `cntunkmail`,
2205 `user`.`notify-flags` AS `notify-flags`,
2206 `user`.`page-flags` AS `page-flags`,
2207 `user`.`account-type` AS `account-type`,
2208 `user`.`prvnets` AS `prvnets`,
2209 `user`.`maxreq` AS `maxreq`,
2210 `user`.`expire` AS `expire`,
2211 `user`.`account_removed` AS `account_removed`,
2212 `user`.`account_expired` AS `account_expired`,
2213 `user`.`account_expires_on` AS `account_expires_on`,
2214 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2215 `user`.`def_gid` AS `def_gid`,
2216 `user`.`allow_cid` AS `allow_cid`,
2217 `user`.`allow_gid` AS `allow_gid`,
2218 `user`.`deny_cid` AS `deny_cid`,
2219 `user`.`deny_gid` AS `deny_gid`,
2220 `user`.`openidserver` AS `openidserver`,
2221 `profile`.`publish` AS `publish`,
2222 `profile`.`net-publish` AS `net-publish`,
2223 `profile`.`hide-friends` AS `hide-friends`,
2224 `profile`.`prv_keywords` AS `prv_keywords`,
2225 `profile`.`pub_keywords` AS `pub_keywords`,
2226 `profile`.`address` AS `address`,
2227 `profile`.`locality` AS `locality`,
2228 `profile`.`region` AS `region`,
2229 `profile`.`postal-code` AS `postal-code`,
2230 `profile`.`country-name` AS `country-name`,
2231 `profile`.`homepage` AS `homepage`,
2232 `profile`.`dob` AS `dob`
2234 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2235 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2238 -- VIEW pending-view
2240 DROP VIEW IF EXISTS `pending-view`;
2241 CREATE VIEW `pending-view` AS SELECT
2242 `register`.`id` AS `id`,
2243 `register`.`hash` AS `hash`,
2244 `register`.`created` AS `created`,
2245 `register`.`uid` AS `uid`,
2246 `register`.`password` AS `password`,
2247 `register`.`language` AS `language`,
2248 `register`.`note` AS `note`,
2249 `contact`.`self` AS `self`,
2250 `contact`.`name` AS `name`,
2251 `contact`.`url` AS `url`,
2252 `contact`.`micro` AS `micro`,
2253 `user`.`email` AS `email`,
2254 `contact`.`nick` AS `nick`
2256 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2257 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2260 -- VIEW tag-search-view
2262 DROP VIEW IF EXISTS `tag-search-view`;
2263 CREATE VIEW `tag-search-view` AS SELECT
2264 `post-tag`.`uri-id` AS `uri-id`,
2265 `post-user`.`uid` AS `uid`,
2266 `post-user`.`id` AS `iid`,
2267 `post-user`.`private` AS `private`,
2268 `post-user`.`wall` AS `wall`,
2269 `post-user`.`origin` AS `origin`,
2270 `post-user`.`global` AS `global`,
2271 `post-user`.`gravity` AS `gravity`,
2272 `post-user`.`received` AS `received`,
2273 `post-user`.`network` AS `network`,
2274 `post-user`.`author-id` AS `author-id`,
2275 `tag`.`name` AS `name`
2277 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
2278 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
2279 WHERE `post-tag`.`type` = 1;
2282 -- VIEW workerqueue-view
2284 DROP VIEW IF EXISTS `workerqueue-view`;
2285 CREATE VIEW `workerqueue-view` AS SELECT
2286 `process`.`pid` AS `pid`,
2287 `workerqueue`.`priority` AS `priority`
2289 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
2290 WHERE NOT `workerqueue`.`done`;