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