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