1 -- ------------------------------------------
2 -- Friendica 2021.03-dev (Red Hot Poker)
3 -- DB_UPDATE_VERSION 1407
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 `addr_uid` (`addr`(128),`uid`),
190 INDEX `nurl_uid` (`nurl`(128),`uid`),
191 INDEX `nick_uid` (`nick`(128),`uid`),
192 INDEX `attag_uid` (`attag`(96),`uid`),
193 INDEX `dfrn-id` (`dfrn-id`(64)),
194 INDEX `issued-id` (`issued-id`(64)),
195 INDEX `network_uid_lastupdate` (`network`,`uid`,`last-update`),
196 INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`),
197 INDEX `uid_lastitem` (`uid`,`last-item`),
198 INDEX `baseurl` (`baseurl`(64)),
199 INDEX `gsid` (`gsid`),
200 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
201 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
202 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
207 CREATE TABLE IF NOT EXISTS `item-uri` (
208 `id` int unsigned NOT NULL auto_increment,
209 `uri` varbinary(255) NOT NULL COMMENT 'URI of an item',
210 `guid` varbinary(255) COMMENT 'A unique identifier for an item',
212 UNIQUE INDEX `uri` (`uri`),
213 INDEX `guid` (`guid`)
214 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
219 CREATE TABLE IF NOT EXISTS `tag` (
220 `id` int unsigned NOT NULL auto_increment COMMENT '',
221 `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
222 `url` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
224 UNIQUE INDEX `type_name_url` (`name`,`url`),
226 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
231 CREATE TABLE IF NOT EXISTS `clients` (
232 `client_id` varchar(20) NOT NULL COMMENT '',
233 `pw` varchar(20) NOT NULL DEFAULT '' COMMENT '',
234 `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
235 `name` text COMMENT '',
236 `icon` text COMMENT '',
237 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
238 PRIMARY KEY(`client_id`),
240 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
241 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
244 -- TABLE permissionset
246 CREATE TABLE IF NOT EXISTS `permissionset` (
247 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
248 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
249 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
250 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
251 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
252 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
254 INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`uid`,`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30)),
255 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
256 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
261 CREATE TABLE IF NOT EXISTS `verb` (
262 `id` smallint unsigned NOT NULL auto_increment,
263 `name` varchar(100) NOT NULL DEFAULT '' COMMENT '',
265 INDEX `name` (`name`)
266 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activity Verbs';
269 -- TABLE 2fa_app_specific_password
271 CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
272 `id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
273 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
274 `description` varchar(255) COMMENT 'Description of the usage of the password',
275 `hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
276 `generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
277 `last_used` datetime COMMENT 'Datetime the password was last used',
279 INDEX `uid_description` (`uid`,`description`(190)),
280 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
281 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
284 -- TABLE 2fa_recovery_codes
286 CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
287 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
288 `code` varchar(50) NOT NULL COMMENT 'Recovery code string',
289 `generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
290 `used` datetime COMMENT 'Datetime the code was used',
291 PRIMARY KEY(`uid`,`code`),
292 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
293 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
296 -- TABLE 2fa_trusted_browser
298 CREATE TABLE IF NOT EXISTS `2fa_trusted_browser` (
299 `cookie_hash` varchar(80) NOT NULL COMMENT 'Trusted cookie hash',
300 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
301 `user_agent` text COMMENT 'User agent string',
302 `created` datetime NOT NULL COMMENT 'Datetime the trusted browser was recorded',
303 `last_used` datetime COMMENT 'Datetime the trusted browser was last used',
304 PRIMARY KEY(`cookie_hash`),
306 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
307 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication trusted browsers';
312 CREATE TABLE IF NOT EXISTS `addon` (
313 `id` int unsigned NOT NULL auto_increment COMMENT '',
314 `name` varchar(50) NOT NULL DEFAULT '' COMMENT 'addon base (file)name',
315 `version` varchar(50) NOT NULL DEFAULT '' COMMENT 'currently unused',
316 `installed` boolean NOT NULL DEFAULT '0' COMMENT 'currently always 1',
317 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'currently unused',
318 `timestamp` int unsigned NOT NULL DEFAULT 0 COMMENT 'file timestamp to check for reloads',
319 `plugin_admin` boolean NOT NULL DEFAULT '0' COMMENT '1 = has admin config, 0 = has no admin config',
321 INDEX `installed_name` (`installed`,`name`),
322 UNIQUE INDEX `name` (`name`)
323 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registered addons';
328 CREATE TABLE IF NOT EXISTS `apcontact` (
329 `url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
330 `uuid` varchar(255) COMMENT '',
331 `type` varchar(20) NOT NULL COMMENT '',
332 `following` varchar(255) COMMENT '',
333 `followers` varchar(255) COMMENT '',
334 `inbox` varchar(255) NOT NULL COMMENT '',
335 `outbox` varchar(255) COMMENT '',
336 `sharedinbox` varchar(255) COMMENT '',
337 `manually-approve` boolean COMMENT '',
338 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
339 `name` varchar(255) COMMENT '',
340 `about` text COMMENT '',
341 `photo` varchar(255) COMMENT '',
342 `addr` varchar(255) COMMENT '',
343 `alias` varchar(255) COMMENT '',
344 `pubkey` text COMMENT '',
345 `subscribe` varchar(255) COMMENT '',
346 `baseurl` varchar(255) COMMENT 'baseurl of the ap contact',
347 `gsid` int unsigned COMMENT 'Global Server ID',
348 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
349 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
350 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
351 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
352 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
354 INDEX `addr` (`addr`(32)),
355 INDEX `alias` (`alias`(190)),
356 INDEX `followers` (`followers`(190)),
357 INDEX `baseurl` (`baseurl`(190)),
358 INDEX `sharedinbox` (`sharedinbox`(190)),
359 INDEX `gsid` (`gsid`),
360 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
361 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
366 CREATE TABLE IF NOT EXISTS `attach` (
367 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
368 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
369 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
370 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
371 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
372 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
373 `data` longblob NOT NULL COMMENT 'file data',
374 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
375 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
376 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
377 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
378 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
379 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
380 `backend-class` tinytext COMMENT 'Storage backend class',
381 `backend-ref` text COMMENT 'Storage backend data reference',
384 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
385 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
390 CREATE TABLE IF NOT EXISTS `auth_codes` (
391 `id` varchar(40) NOT NULL COMMENT '',
392 `client_id` varchar(20) NOT NULL DEFAULT '' COMMENT '',
393 `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
394 `expires` int NOT NULL DEFAULT 0 COMMENT '',
395 `scope` varchar(250) NOT NULL DEFAULT '' COMMENT '',
397 INDEX `client_id` (`client_id`),
398 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE
399 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
404 CREATE TABLE IF NOT EXISTS `cache` (
405 `k` varbinary(255) NOT NULL COMMENT 'cache key',
406 `v` mediumtext COMMENT 'cached serialized value',
407 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
408 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
410 INDEX `k_expires` (`k`,`expires`)
411 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
416 CREATE TABLE IF NOT EXISTS `challenge` (
417 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
418 `challenge` varchar(255) NOT NULL DEFAULT '' COMMENT '',
419 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
420 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
421 `type` varchar(255) NOT NULL DEFAULT '' COMMENT '',
422 `last_update` varchar(255) NOT NULL DEFAULT '' COMMENT '',
424 INDEX `expire` (`expire`)
425 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
430 CREATE TABLE IF NOT EXISTS `config` (
431 `id` int unsigned NOT NULL auto_increment COMMENT '',
432 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
433 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
434 `v` mediumtext COMMENT '',
436 UNIQUE INDEX `cat_k` (`cat`,`k`)
437 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
440 -- TABLE contact-relation
442 CREATE TABLE IF NOT EXISTS `contact-relation` (
443 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
444 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
445 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
446 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
447 `follows` boolean NOT NULL DEFAULT '0' COMMENT '',
448 PRIMARY KEY(`cid`,`relation-cid`),
449 INDEX `relation-cid` (`relation-cid`),
450 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
451 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
452 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
457 CREATE TABLE IF NOT EXISTS `conv` (
458 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
459 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
460 `recips` text COMMENT 'sender_handle;recipient_handle',
461 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
462 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
463 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
464 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
465 `subject` text COMMENT 'subject of initial message',
468 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
469 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
472 -- TABLE conversation
474 CREATE TABLE IF NOT EXISTS `conversation` (
475 `item-uri` varbinary(255) NOT NULL COMMENT 'Original URI of the item - unrelated to the table with the same name',
476 `reply-to-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'URI to which this item is a reply',
477 `conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI',
478 `conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link',
479 `protocol` tinyint unsigned NOT NULL DEFAULT 255 COMMENT 'The protocol of the item',
480 `direction` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'How the message arrived here: 1=push, 2=pull',
481 `source` mediumtext COMMENT 'Original source',
482 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Receiving date',
483 PRIMARY KEY(`item-uri`),
484 INDEX `conversation-uri` (`conversation-uri`),
485 INDEX `received` (`received`)
486 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Raw data and structure information for messages';
489 -- TABLE delayed-post
491 CREATE TABLE IF NOT EXISTS `delayed-post` (
492 `id` int unsigned NOT NULL auto_increment,
493 `uri` varchar(255) COMMENT 'URI of the post that will be distributed later',
494 `uid` mediumint unsigned COMMENT 'Owner User id',
495 `delayed` datetime COMMENT 'delay time',
497 UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
498 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
499 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
502 -- TABLE diaspora-interaction
504 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
505 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
506 `interaction` mediumtext COMMENT 'The Diaspora interaction',
507 PRIMARY KEY(`uri-id`),
508 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
509 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
514 CREATE TABLE IF NOT EXISTS `event` (
515 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
516 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
517 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
518 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
519 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
520 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
521 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
522 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
523 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
524 `summary` text COMMENT 'short description or title of the event',
525 `desc` text COMMENT 'event description',
526 `location` text COMMENT 'event location',
527 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
528 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
529 `adjust` boolean NOT NULL DEFAULT '1' COMMENT 'adjust to timezone of the recipient (0 or 1)',
530 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
531 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
532 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
533 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
534 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
536 INDEX `uid_start` (`uid`,`start`),
538 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
539 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
540 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
545 CREATE TABLE IF NOT EXISTS `fcontact` (
546 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
547 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
548 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
549 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
550 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
551 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
552 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
553 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
554 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
555 `notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
556 `poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
557 `confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
558 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
559 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
560 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
561 `pubkey` text COMMENT '',
562 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
564 INDEX `addr` (`addr`(32)),
565 UNIQUE INDEX `url` (`url`(190))
566 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
571 CREATE TABLE IF NOT EXISTS `fsuggest` (
572 `id` int unsigned NOT NULL auto_increment COMMENT '',
573 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
574 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
575 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
576 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
577 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
578 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
579 `note` text COMMENT '',
580 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
584 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
585 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
586 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
591 CREATE TABLE IF NOT EXISTS `group` (
592 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
593 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
594 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
595 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
596 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
599 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
600 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
603 -- TABLE group_member
605 CREATE TABLE IF NOT EXISTS `group_member` (
606 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
607 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
608 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
610 INDEX `contactid` (`contact-id`),
611 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
612 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
613 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
614 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
619 CREATE TABLE IF NOT EXISTS `gserver-tag` (
620 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
621 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
622 PRIMARY KEY(`gserver-id`,`tag`),
624 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
625 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
630 CREATE TABLE IF NOT EXISTS `hook` (
631 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
632 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
633 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
634 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
635 `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',
637 INDEX `priority` (`priority`),
638 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
639 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
644 CREATE TABLE IF NOT EXISTS `host` (
645 `id` tinyint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
646 `name` varchar(128) NOT NULL DEFAULT '' COMMENT 'The hostname',
648 UNIQUE INDEX `name` (`name`)
649 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Hostname';
652 -- TABLE inbox-status
654 CREATE TABLE IF NOT EXISTS `inbox-status` (
655 `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
656 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
657 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
658 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
659 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
660 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
661 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
663 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
668 CREATE TABLE IF NOT EXISTS `intro` (
669 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
670 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
671 `fid` int unsigned COMMENT '',
672 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
673 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
674 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
675 `note` text COMMENT '',
676 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
677 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
678 `blocked` boolean NOT NULL DEFAULT '1' COMMENT '',
679 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
681 INDEX `contact-id` (`contact-id`),
683 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
684 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
685 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
690 CREATE TABLE IF NOT EXISTS `locks` (
691 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
692 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
693 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
694 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
695 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
697 INDEX `name_expires` (`name`,`expires`)
698 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
703 CREATE TABLE IF NOT EXISTS `mail` (
704 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
705 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
706 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
707 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
708 `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
709 `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
710 `contact-id` varchar(255) COMMENT 'contact.id',
711 `convid` int unsigned COMMENT 'conv.id',
712 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
713 `body` mediumtext COMMENT '',
714 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
715 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
716 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
717 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
718 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
719 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
720 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
722 INDEX `uid_seen` (`uid`,`seen`),
723 INDEX `convid` (`convid`),
724 INDEX `uri` (`uri`(64)),
725 INDEX `parent-uri` (`parent-uri`(64)),
726 INDEX `contactid` (`contact-id`(32)),
727 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
728 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
733 CREATE TABLE IF NOT EXISTS `mailacct` (
734 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
735 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
736 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
737 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
738 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
739 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
740 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
741 `pass` text COMMENT '',
742 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
743 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
744 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
745 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
746 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
749 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
750 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
755 CREATE TABLE IF NOT EXISTS `manage` (
756 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
757 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
758 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
760 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
762 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
763 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
764 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
769 CREATE TABLE IF NOT EXISTS `notify` (
770 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
771 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
772 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
773 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
774 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
775 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
776 `msg` mediumtext COMMENT '',
777 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
778 `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
779 `iid` int unsigned COMMENT '',
780 `parent` int unsigned COMMENT '',
781 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
782 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
783 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
784 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
785 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
786 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
787 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
789 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
790 INDEX `uid_date` (`uid`,`date`),
791 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
792 INDEX `uri-id` (`uri-id`),
793 INDEX `parent-uri-id` (`parent-uri-id`),
794 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
795 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
796 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
797 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
800 -- TABLE notify-threads
802 CREATE TABLE IF NOT EXISTS `notify-threads` (
803 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
804 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
805 `master-parent-item` int unsigned COMMENT 'Deprecated',
806 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
807 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
808 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
810 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
811 INDEX `receiver-uid` (`receiver-uid`),
812 INDEX `notify-id` (`notify-id`),
813 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
814 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
815 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
816 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
821 CREATE TABLE IF NOT EXISTS `oembed` (
822 `url` varbinary(255) NOT NULL COMMENT 'page url',
823 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
824 `content` mediumtext COMMENT 'OEmbed data of the page',
825 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
826 PRIMARY KEY(`url`,`maxwidth`),
827 INDEX `created` (`created`)
828 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
831 -- TABLE openwebauth-token
833 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
834 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
835 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
836 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
837 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
838 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
839 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
842 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
843 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
848 CREATE TABLE IF NOT EXISTS `parsed_url` (
849 `url_hash` binary(64) NOT NULL COMMENT 'page url hash',
850 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
851 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
852 `url` text NOT NULL COMMENT 'page url',
853 `content` mediumtext COMMENT 'page data',
854 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
855 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration',
856 PRIMARY KEY(`url_hash`,`guessing`,`oembed`),
857 INDEX `created` (`created`),
858 INDEX `expires` (`expires`)
859 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
864 CREATE TABLE IF NOT EXISTS `pconfig` (
865 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
866 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
867 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
868 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
869 `v` mediumtext COMMENT 'Value',
871 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
872 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
873 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
878 CREATE TABLE IF NOT EXISTS `photo` (
879 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
880 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
881 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
882 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
883 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
884 `hash` char(32) COMMENT 'hash value of the photo',
885 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
886 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
887 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
888 `desc` text COMMENT '',
889 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
890 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
891 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
892 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
893 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
894 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
895 `data` mediumblob NOT NULL COMMENT '',
896 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
897 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
898 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
899 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
900 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
901 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
902 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
903 `backend-class` tinytext COMMENT 'Storage backend class',
904 `backend-ref` text COMMENT 'Storage backend data reference',
905 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
907 INDEX `contactid` (`contact-id`),
908 INDEX `uid_contactid` (`uid`,`contact-id`),
909 INDEX `uid_profile` (`uid`,`profile`),
910 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
911 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
912 INDEX `resource-id` (`resource-id`),
913 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
914 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
915 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
920 CREATE TABLE IF NOT EXISTS `post` (
921 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
922 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
923 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
924 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
925 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
926 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
927 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
928 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
929 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
930 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
931 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
932 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
933 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
934 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
935 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
936 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
937 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
938 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
939 PRIMARY KEY(`uri-id`),
940 INDEX `parent-uri-id` (`parent-uri-id`),
941 INDEX `thr-parent-id` (`thr-parent-id`),
942 INDEX `external-id` (`external-id`),
943 INDEX `owner-id` (`owner-id`),
944 INDEX `author-id` (`author-id`),
945 INDEX `causer-id` (`causer-id`),
947 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
948 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
949 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
950 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
951 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
952 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
953 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
954 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
955 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
958 -- TABLE post-category
960 CREATE TABLE IF NOT EXISTS `post-category` (
961 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
962 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
963 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
964 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
965 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
966 INDEX `uri-id` (`tid`),
968 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
969 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
970 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
971 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
974 -- TABLE post-content
976 CREATE TABLE IF NOT EXISTS `post-content` (
977 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
978 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
979 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
980 `body` mediumtext COMMENT 'item body content',
981 `raw-body` mediumtext COMMENT 'Body without embedded media links',
982 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
983 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
984 `language` text COMMENT 'Language information about this post',
985 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
986 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
987 `rendered-html` mediumtext COMMENT 'item.body converted to html',
988 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
989 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
990 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
991 `target` text COMMENT 'JSON encoded target structure if used',
992 `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',
993 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
994 PRIMARY KEY(`uri-id`),
995 INDEX `plink` (`plink`(191)),
996 INDEX `resource-id` (`resource-id`),
997 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
998 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
999 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1002 -- TABLE post-delivery-data
1004 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1005 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1006 `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',
1007 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1008 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1009 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1010 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1011 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1012 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1013 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1014 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1015 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1016 PRIMARY KEY(`uri-id`),
1017 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1018 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1023 CREATE TABLE IF NOT EXISTS `post-media` (
1024 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1025 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1026 `url` varbinary(511) NOT NULL COMMENT 'Media URL',
1027 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1028 `mimetype` varchar(60) COMMENT '',
1029 `height` smallint unsigned COMMENT 'Height of the media',
1030 `width` smallint unsigned COMMENT 'Width of the media',
1031 `size` int unsigned COMMENT 'Media size',
1032 `preview` varbinary(255) COMMENT 'Preview URL',
1033 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1034 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1035 `description` text COMMENT '',
1037 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1038 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1039 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1044 CREATE TABLE IF NOT EXISTS `post-tag` (
1045 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1046 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1047 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1048 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1049 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1050 INDEX `tid` (`tid`),
1051 INDEX `cid` (`cid`),
1052 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1053 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1054 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1055 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1058 -- TABLE post-thread
1060 CREATE TABLE IF NOT EXISTS `post-thread` (
1061 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1062 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1063 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1064 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1065 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1066 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1067 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1068 `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',
1069 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1070 PRIMARY KEY(`uri-id`),
1071 INDEX `owner-id` (`owner-id`),
1072 INDEX `author-id` (`author-id`),
1073 INDEX `causer-id` (`causer-id`),
1074 INDEX `received` (`received`),
1075 INDEX `commented` (`commented`),
1076 INDEX `changed` (`changed`),
1077 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1078 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1079 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1080 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1081 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1086 CREATE TABLE IF NOT EXISTS `post-user` (
1087 `id` int unsigned NOT NULL auto_increment,
1088 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1089 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1090 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1091 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1092 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1093 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1094 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1095 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1096 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1097 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1098 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1099 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1100 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
1101 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1102 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1103 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1104 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1105 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1106 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1107 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1108 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1109 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1110 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1111 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1112 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1113 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1114 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1115 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1117 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1118 INDEX `uri-id` (`uri-id`),
1119 INDEX `parent-uri-id` (`parent-uri-id`),
1120 INDEX `thr-parent-id` (`thr-parent-id`),
1121 INDEX `external-id` (`external-id`),
1122 INDEX `owner-id` (`owner-id`),
1123 INDEX `author-id` (`author-id`),
1124 INDEX `causer-id` (`causer-id`),
1125 INDEX `vid` (`vid`),
1126 INDEX `contact-id` (`contact-id`),
1127 INDEX `event-id` (`event-id`),
1128 INDEX `psid` (`psid`),
1129 INDEX `author-id_uid` (`author-id`,`uid`),
1130 INDEX `author-id_received` (`author-id`,`received`),
1131 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1132 INDEX `uid_hidden` (`uid`,`hidden`),
1133 INDEX `uid_contactid` (`uid`,`contact-id`),
1134 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1135 INDEX `uid_unseen` (`uid`,`unseen`),
1136 INDEX `uid_unseen_wall` (`uid`,`unseen`,`wall`),
1137 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1138 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1139 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1140 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1141 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1142 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1143 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1144 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1145 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1146 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1147 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1148 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1149 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1152 -- TABLE post-thread-user
1154 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1155 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1156 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1157 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1158 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1159 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1160 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1161 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1162 `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',
1163 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1164 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1165 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'The thread is pinned on the profile page',
1166 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1167 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1168 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1169 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1170 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1171 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1172 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.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 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1176 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1177 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1178 PRIMARY KEY(`uid`,`uri-id`),
1179 INDEX `uri-id` (`uri-id`),
1180 INDEX `owner-id` (`owner-id`),
1181 INDEX `author-id` (`author-id`),
1182 INDEX `causer-id` (`causer-id`),
1183 INDEX `uid` (`uid`),
1184 INDEX `contact-id` (`contact-id`),
1185 INDEX `psid` (`psid`),
1186 INDEX `post-user-id` (`post-user-id`),
1187 INDEX `commented` (`commented`),
1188 INDEX `received` (`received`),
1189 INDEX `author-id_received` (`author-id`,`received`),
1190 INDEX `uid_pinned` (`uid`,`pinned`),
1191 INDEX `uid_commented` (`uid`,`commented`),
1192 INDEX `mention_uid` (`mention`,`uid`),
1193 INDEX `uid_mention` (`uid`,`mention`),
1194 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1195 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1196 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1197 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1198 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1199 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1200 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1201 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1202 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1205 -- TABLE post-user-notification
1207 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1208 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1209 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1210 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1211 PRIMARY KEY(`uid`,`uri-id`),
1212 INDEX `uri-id` (`uri-id`),
1213 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1214 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1215 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1220 CREATE TABLE IF NOT EXISTS `process` (
1221 `pid` int unsigned NOT NULL COMMENT '',
1222 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1223 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1225 INDEX `command` (`command`)
1226 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1231 CREATE TABLE IF NOT EXISTS `profile` (
1232 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1233 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1234 `profile-name` varchar(255) COMMENT 'Deprecated',
1235 `is-default` boolean COMMENT 'Deprecated',
1236 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1237 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1238 `pdesc` varchar(255) COMMENT 'Deprecated',
1239 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1240 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1241 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1242 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1243 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1244 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1245 `hometown` varchar(255) COMMENT 'Deprecated',
1246 `gender` varchar(32) COMMENT 'Deprecated',
1247 `marital` varchar(255) COMMENT 'Deprecated',
1248 `with` text COMMENT 'Deprecated',
1249 `howlong` datetime COMMENT 'Deprecated',
1250 `sexual` varchar(255) COMMENT 'Deprecated',
1251 `politic` varchar(255) COMMENT 'Deprecated',
1252 `religion` varchar(255) COMMENT 'Deprecated',
1253 `pub_keywords` text COMMENT '',
1254 `prv_keywords` text COMMENT '',
1255 `likes` text COMMENT 'Deprecated',
1256 `dislikes` text COMMENT 'Deprecated',
1257 `about` text COMMENT 'Profile description',
1258 `summary` varchar(255) COMMENT 'Deprecated',
1259 `music` text COMMENT 'Deprecated',
1260 `book` text COMMENT 'Deprecated',
1261 `tv` text COMMENT 'Deprecated',
1262 `film` text COMMENT 'Deprecated',
1263 `interest` text COMMENT 'Deprecated',
1264 `romance` text COMMENT 'Deprecated',
1265 `work` text COMMENT 'Deprecated',
1266 `education` text COMMENT 'Deprecated',
1267 `contact` text COMMENT 'Deprecated',
1268 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1269 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1270 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1271 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1272 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1273 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1275 INDEX `uid_is-default` (`uid`,`is-default`),
1276 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1277 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1278 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1281 -- TABLE profile_check
1283 CREATE TABLE IF NOT EXISTS `profile_check` (
1284 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1285 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1286 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1287 `dfrn_id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1288 `sec` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1289 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1291 INDEX `uid` (`uid`),
1292 INDEX `cid` (`cid`),
1293 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1294 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1295 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='DFRN remote auth use';
1298 -- TABLE profile_field
1300 CREATE TABLE IF NOT EXISTS `profile_field` (
1301 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1302 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1303 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1304 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1305 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1306 `value` text COMMENT 'Value of the field',
1307 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1308 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1310 INDEX `uid` (`uid`),
1311 INDEX `order` (`order`),
1312 INDEX `psid` (`psid`),
1313 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1314 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1315 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1318 -- TABLE push_subscriber
1320 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1321 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1322 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1323 `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1324 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1325 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1326 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1327 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1328 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1329 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1330 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1332 INDEX `next_try` (`next_try`),
1333 INDEX `uid` (`uid`),
1334 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1335 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1340 CREATE TABLE IF NOT EXISTS `register` (
1341 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1342 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1343 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1344 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1345 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1346 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1347 `note` text COMMENT '',
1349 INDEX `uid` (`uid`),
1350 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1351 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1356 CREATE TABLE IF NOT EXISTS `search` (
1357 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1358 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1359 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1361 INDEX `uid_term` (`uid`,`term`(64)),
1362 INDEX `term` (`term`(64)),
1363 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1364 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1369 CREATE TABLE IF NOT EXISTS `session` (
1370 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1371 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1372 `data` text COMMENT '',
1373 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1375 INDEX `sid` (`sid`(64)),
1376 INDEX `expire` (`expire`)
1377 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1382 CREATE TABLE IF NOT EXISTS `storage` (
1383 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1384 `data` longblob NOT NULL COMMENT 'file data',
1386 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1391 CREATE TABLE IF NOT EXISTS `tokens` (
1392 `id` varchar(40) NOT NULL COMMENT '',
1393 `secret` text COMMENT '',
1394 `client_id` varchar(20) NOT NULL DEFAULT '',
1395 `expires` int NOT NULL DEFAULT 0 COMMENT '',
1396 `scope` varchar(200) NOT NULL DEFAULT '' COMMENT '',
1397 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1399 INDEX `client_id` (`client_id`),
1400 INDEX `uid` (`uid`),
1401 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1402 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1403 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
1408 CREATE TABLE IF NOT EXISTS `userd` (
1409 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1410 `username` varchar(255) NOT NULL COMMENT '',
1412 INDEX `username` (`username`(32))
1413 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1416 -- TABLE user-contact
1418 CREATE TABLE IF NOT EXISTS `user-contact` (
1419 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1420 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1421 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1422 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1423 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1424 PRIMARY KEY(`uid`,`cid`),
1425 INDEX `cid` (`cid`),
1426 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1427 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1428 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1433 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1434 `key` int NOT NULL COMMENT '',
1435 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1437 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1440 -- TABLE workerqueue
1442 CREATE TABLE IF NOT EXISTS `workerqueue` (
1443 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
1444 `command` varchar(100) COMMENT 'Task command',
1445 `parameter` mediumtext COMMENT 'Task parameter',
1446 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
1447 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
1448 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
1449 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
1450 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1451 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1452 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
1454 INDEX `command` (`command`),
1455 INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
1456 INDEX `done_executed` (`done`,`executed`),
1457 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
1458 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
1459 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
1460 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
1461 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
1462 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
1465 -- VIEW post-user-view
1467 DROP VIEW IF EXISTS `post-user-view`;
1468 CREATE VIEW `post-user-view` AS SELECT
1469 `post-user`.`id` AS `id`,
1470 `post-user`.`id` AS `post-user-id`,
1471 `post-user`.`uid` AS `uid`,
1472 `parent-post`.`id` AS `parent`,
1473 `item-uri`.`uri` AS `uri`,
1474 `post-user`.`uri-id` AS `uri-id`,
1475 `parent-item-uri`.`uri` AS `parent-uri`,
1476 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1477 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1478 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1479 `item-uri`.`guid` AS `guid`,
1480 `post-user`.`wall` AS `wall`,
1481 `post-user`.`gravity` AS `gravity`,
1482 `external-item-uri`.`uri` AS `extid`,
1483 `post-user`.`external-id` AS `external-id`,
1484 `post-user`.`created` AS `created`,
1485 `post-user`.`edited` AS `edited`,
1486 `post-thread-user`.`commented` AS `commented`,
1487 `post-user`.`received` AS `received`,
1488 `post-thread-user`.`changed` AS `changed`,
1489 `post-user`.`post-type` AS `post-type`,
1490 `post-user`.`private` AS `private`,
1491 `post-thread-user`.`pubmail` AS `pubmail`,
1492 `post-user`.`visible` AS `visible`,
1493 `post-thread-user`.`starred` AS `starred`,
1494 `post-user`.`unseen` AS `unseen`,
1495 `post-user`.`deleted` AS `deleted`,
1496 `post-user`.`origin` AS `origin`,
1497 `post-thread-user`.`origin` AS `parent-origin`,
1498 `post-thread-user`.`forum_mode` AS `forum_mode`,
1499 `post-thread-user`.`mention` AS `mention`,
1500 `post-user`.`global` AS `global`,
1501 `post-user`.`network` AS `network`,
1502 `post-user`.`vid` AS `vid`,
1503 `post-user`.`psid` AS `psid`,
1504 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1505 `post-content`.`title` AS `title`,
1506 `post-content`.`content-warning` AS `content-warning`,
1507 `post-content`.`raw-body` AS `raw-body`,
1508 `post-content`.`body` AS `body`,
1509 `post-content`.`rendered-hash` AS `rendered-hash`,
1510 `post-content`.`rendered-html` AS `rendered-html`,
1511 `post-content`.`language` AS `language`,
1512 `post-content`.`plink` AS `plink`,
1513 `post-content`.`location` AS `location`,
1514 `post-content`.`coord` AS `coord`,
1515 `post-content`.`app` AS `app`,
1516 `post-content`.`object-type` AS `object-type`,
1517 `post-content`.`object` AS `object`,
1518 `post-content`.`target-type` AS `target-type`,
1519 `post-content`.`target` AS `target`,
1520 `post-content`.`resource-id` AS `resource-id`,
1521 `post-user`.`contact-id` AS `contact-id`,
1522 `contact`.`url` AS `contact-link`,
1523 `contact`.`addr` AS `contact-addr`,
1524 `contact`.`name` AS `contact-name`,
1525 `contact`.`nick` AS `contact-nick`,
1526 `contact`.`thumb` AS `contact-avatar`,
1527 `contact`.`network` AS `contact-network`,
1528 `contact`.`blocked` AS `contact-blocked`,
1529 `contact`.`hidden` AS `contact-hidden`,
1530 `contact`.`readonly` AS `contact-readonly`,
1531 `contact`.`archive` AS `contact-archive`,
1532 `contact`.`pending` AS `contact-pending`,
1533 `contact`.`rel` AS `contact-rel`,
1534 `contact`.`uid` AS `contact-uid`,
1535 `contact`.`contact-type` AS `contact-contact-type`,
1536 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1537 `contact`.`self` AS `self`,
1538 `contact`.`id` AS `cid`,
1539 `contact`.`alias` AS `alias`,
1540 `contact`.`photo` AS `photo`,
1541 `contact`.`name-date` AS `name-date`,
1542 `contact`.`uri-date` AS `uri-date`,
1543 `contact`.`avatar-date` AS `avatar-date`,
1544 `contact`.`thumb` AS `thumb`,
1545 `contact`.`dfrn-id` AS `dfrn-id`,
1546 `post-user`.`author-id` AS `author-id`,
1547 `author`.`url` AS `author-link`,
1548 `author`.`addr` AS `author-addr`,
1549 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1550 `author`.`nick` AS `author-nick`,
1551 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1552 `author`.`network` AS `author-network`,
1553 `author`.`blocked` AS `author-blocked`,
1554 `author`.`hidden` AS `author-hidden`,
1555 `post-user`.`owner-id` AS `owner-id`,
1556 `owner`.`url` AS `owner-link`,
1557 `owner`.`addr` AS `owner-addr`,
1558 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1559 `owner`.`nick` AS `owner-nick`,
1560 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1561 `owner`.`network` AS `owner-network`,
1562 `owner`.`blocked` AS `owner-blocked`,
1563 `owner`.`hidden` AS `owner-hidden`,
1564 `owner`.`contact-type` AS `owner-contact-type`,
1565 `post-user`.`causer-id` AS `causer-id`,
1566 `causer`.`url` AS `causer-link`,
1567 `causer`.`addr` AS `causer-addr`,
1568 `causer`.`name` AS `causer-name`,
1569 `causer`.`nick` AS `causer-nick`,
1570 `causer`.`thumb` AS `causer-avatar`,
1571 `causer`.`network` AS `causer-network`,
1572 `causer`.`blocked` AS `causer-blocked`,
1573 `causer`.`hidden` AS `causer-hidden`,
1574 `causer`.`contact-type` AS `causer-contact-type`,
1575 `post-delivery-data`.`postopts` AS `postopts`,
1576 `post-delivery-data`.`inform` AS `inform`,
1577 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1578 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1579 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1580 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1581 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1582 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1583 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1584 `post-user`.`event-id` AS `event-id`,
1585 `event`.`created` AS `event-created`,
1586 `event`.`edited` AS `event-edited`,
1587 `event`.`start` AS `event-start`,
1588 `event`.`finish` AS `event-finish`,
1589 `event`.`summary` AS `event-summary`,
1590 `event`.`desc` AS `event-desc`,
1591 `event`.`location` AS `event-location`,
1592 `event`.`type` AS `event-type`,
1593 `event`.`nofinish` AS `event-nofinish`,
1594 `event`.`adjust` AS `event-adjust`,
1595 `event`.`ignore` AS `event-ignore`,
1596 `diaspora-interaction`.`interaction` AS `signed_text`,
1597 `parent-item-uri`.`guid` AS `parent-guid`,
1598 `parent-post`.`network` AS `parent-network`,
1599 `parent-post`.`author-id` AS `parent-author-id`,
1600 `parent-post-author`.`url` AS `parent-author-link`,
1601 `parent-post-author`.`name` AS `parent-author-name`,
1602 `parent-post-author`.`network` AS `parent-author-network`
1604 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
1605 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
1606 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
1607 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
1608 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
1609 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
1610 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1611 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1612 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1613 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1614 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1615 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
1616 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
1617 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
1618 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
1619 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
1620 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1623 -- VIEW post-thread-user-view
1625 DROP VIEW IF EXISTS `post-thread-user-view`;
1626 CREATE VIEW `post-thread-user-view` AS SELECT
1627 `post-user`.`id` AS `id`,
1628 `post-user`.`id` AS `post-user-id`,
1629 `post-thread-user`.`uid` AS `uid`,
1630 `parent-post`.`id` AS `parent`,
1631 `item-uri`.`uri` AS `uri`,
1632 `post-thread-user`.`uri-id` AS `uri-id`,
1633 `parent-item-uri`.`uri` AS `parent-uri`,
1634 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1635 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1636 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1637 `item-uri`.`guid` AS `guid`,
1638 `post-thread-user`.`wall` AS `wall`,
1639 `post-user`.`gravity` AS `gravity`,
1640 `external-item-uri`.`uri` AS `extid`,
1641 `post-user`.`external-id` AS `external-id`,
1642 `post-thread-user`.`created` AS `created`,
1643 `post-user`.`edited` AS `edited`,
1644 `post-thread-user`.`commented` AS `commented`,
1645 `post-thread-user`.`received` AS `received`,
1646 `post-thread-user`.`changed` AS `changed`,
1647 `post-user`.`post-type` AS `post-type`,
1648 `post-user`.`private` AS `private`,
1649 `post-thread-user`.`pubmail` AS `pubmail`,
1650 `post-thread-user`.`ignored` AS `ignored`,
1651 `post-user`.`visible` AS `visible`,
1652 `post-thread-user`.`starred` AS `starred`,
1653 `post-thread-user`.`unseen` AS `unseen`,
1654 `post-user`.`deleted` AS `deleted`,
1655 `post-thread-user`.`origin` AS `origin`,
1656 `post-thread-user`.`forum_mode` AS `forum_mode`,
1657 `post-thread-user`.`mention` AS `mention`,
1658 `post-user`.`global` AS `global`,
1659 `post-thread-user`.`network` AS `network`,
1660 `post-user`.`vid` AS `vid`,
1661 `post-thread-user`.`psid` AS `psid`,
1662 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1663 `post-content`.`title` AS `title`,
1664 `post-content`.`content-warning` AS `content-warning`,
1665 `post-content`.`raw-body` AS `raw-body`,
1666 `post-content`.`body` AS `body`,
1667 `post-content`.`rendered-hash` AS `rendered-hash`,
1668 `post-content`.`rendered-html` AS `rendered-html`,
1669 `post-content`.`language` AS `language`,
1670 `post-content`.`plink` AS `plink`,
1671 `post-content`.`location` AS `location`,
1672 `post-content`.`coord` AS `coord`,
1673 `post-content`.`app` AS `app`,
1674 `post-content`.`object-type` AS `object-type`,
1675 `post-content`.`object` AS `object`,
1676 `post-content`.`target-type` AS `target-type`,
1677 `post-content`.`target` AS `target`,
1678 `post-content`.`resource-id` AS `resource-id`,
1679 `post-thread-user`.`contact-id` AS `contact-id`,
1680 `contact`.`url` AS `contact-link`,
1681 `contact`.`addr` AS `contact-addr`,
1682 `contact`.`name` AS `contact-name`,
1683 `contact`.`nick` AS `contact-nick`,
1684 `contact`.`thumb` AS `contact-avatar`,
1685 `contact`.`network` AS `contact-network`,
1686 `contact`.`blocked` AS `contact-blocked`,
1687 `contact`.`hidden` AS `contact-hidden`,
1688 `contact`.`readonly` AS `contact-readonly`,
1689 `contact`.`archive` AS `contact-archive`,
1690 `contact`.`pending` AS `contact-pending`,
1691 `contact`.`rel` AS `contact-rel`,
1692 `contact`.`uid` AS `contact-uid`,
1693 `contact`.`contact-type` AS `contact-contact-type`,
1694 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1695 `contact`.`self` AS `self`,
1696 `contact`.`id` AS `cid`,
1697 `contact`.`alias` AS `alias`,
1698 `contact`.`photo` AS `photo`,
1699 `contact`.`name-date` AS `name-date`,
1700 `contact`.`uri-date` AS `uri-date`,
1701 `contact`.`avatar-date` AS `avatar-date`,
1702 `contact`.`thumb` AS `thumb`,
1703 `contact`.`dfrn-id` AS `dfrn-id`,
1704 `post-thread-user`.`author-id` AS `author-id`,
1705 `author`.`url` AS `author-link`,
1706 `author`.`addr` AS `author-addr`,
1707 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1708 `author`.`nick` AS `author-nick`,
1709 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1710 `author`.`network` AS `author-network`,
1711 `author`.`blocked` AS `author-blocked`,
1712 `author`.`hidden` AS `author-hidden`,
1713 `post-thread-user`.`owner-id` AS `owner-id`,
1714 `owner`.`url` AS `owner-link`,
1715 `owner`.`addr` AS `owner-addr`,
1716 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1717 `owner`.`nick` AS `owner-nick`,
1718 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1719 `owner`.`network` AS `owner-network`,
1720 `owner`.`blocked` AS `owner-blocked`,
1721 `owner`.`hidden` AS `owner-hidden`,
1722 `owner`.`contact-type` AS `owner-contact-type`,
1723 `post-thread-user`.`causer-id` AS `causer-id`,
1724 `causer`.`url` AS `causer-link`,
1725 `causer`.`addr` AS `causer-addr`,
1726 `causer`.`name` AS `causer-name`,
1727 `causer`.`nick` AS `causer-nick`,
1728 `causer`.`thumb` AS `causer-avatar`,
1729 `causer`.`network` AS `causer-network`,
1730 `causer`.`blocked` AS `causer-blocked`,
1731 `causer`.`hidden` AS `causer-hidden`,
1732 `causer`.`contact-type` AS `causer-contact-type`,
1733 `post-delivery-data`.`postopts` AS `postopts`,
1734 `post-delivery-data`.`inform` AS `inform`,
1735 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1736 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1737 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1738 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1739 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1740 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1741 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1742 `post-user`.`event-id` AS `event-id`,
1743 `event`.`created` AS `event-created`,
1744 `event`.`edited` AS `event-edited`,
1745 `event`.`start` AS `event-start`,
1746 `event`.`finish` AS `event-finish`,
1747 `event`.`summary` AS `event-summary`,
1748 `event`.`desc` AS `event-desc`,
1749 `event`.`location` AS `event-location`,
1750 `event`.`type` AS `event-type`,
1751 `event`.`nofinish` AS `event-nofinish`,
1752 `event`.`adjust` AS `event-adjust`,
1753 `event`.`ignore` AS `event-ignore`,
1754 `diaspora-interaction`.`interaction` AS `signed_text`,
1755 `parent-item-uri`.`guid` AS `parent-guid`,
1756 `parent-post`.`network` AS `parent-network`,
1757 `parent-post`.`author-id` AS `parent-author-id`,
1758 `parent-post-author`.`url` AS `parent-author-link`,
1759 `parent-post-author`.`name` AS `parent-author-name`,
1760 `parent-post-author`.`network` AS `parent-author-network`
1761 FROM `post-thread-user`
1762 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
1763 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
1764 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
1765 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
1766 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
1767 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
1768 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1769 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1770 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1771 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1772 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1773 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
1774 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
1775 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
1776 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
1777 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`
1778 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1781 -- VIEW category-view
1783 DROP VIEW IF EXISTS `category-view`;
1784 CREATE VIEW `category-view` AS SELECT
1785 `post-category`.`uri-id` AS `uri-id`,
1786 `post-category`.`uid` AS `uid`,
1787 `post-category`.`type` AS `type`,
1788 `post-category`.`tid` AS `tid`,
1789 `tag`.`name` AS `name`,
1790 `tag`.`url` AS `url`
1791 FROM `post-category`
1792 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
1797 DROP VIEW IF EXISTS `tag-view`;
1798 CREATE VIEW `tag-view` AS SELECT
1799 `post-tag`.`uri-id` AS `uri-id`,
1800 `post-tag`.`type` AS `type`,
1801 `post-tag`.`tid` AS `tid`,
1802 `post-tag`.`cid` AS `cid`,
1803 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
1804 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
1806 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
1807 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
1810 -- VIEW network-item-view
1812 DROP VIEW IF EXISTS `network-item-view`;
1813 CREATE VIEW `network-item-view` AS SELECT
1814 `post-user`.`uri-id` AS `uri-id`,
1815 `parent-post`.`id` AS `parent`,
1816 `post-user`.`received` AS `received`,
1817 `post-thread-user`.`commented` AS `commented`,
1818 `post-user`.`created` AS `created`,
1819 `post-user`.`uid` AS `uid`,
1820 `post-thread-user`.`starred` AS `starred`,
1821 `post-thread-user`.`mention` AS `mention`,
1822 `post-user`.`network` AS `network`,
1823 `post-user`.`unseen` AS `unseen`,
1824 `post-user`.`gravity` AS `gravity`,
1825 `post-user`.`contact-id` AS `contact-id`,
1826 `ownercontact`.`contact-type` AS `contact-type`
1828 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
1829 INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
1830 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
1831 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
1832 INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
1833 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
1834 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
1835 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
1836 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
1837 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
1838 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
1841 -- VIEW network-thread-view
1843 DROP VIEW IF EXISTS `network-thread-view`;
1844 CREATE VIEW `network-thread-view` AS SELECT
1845 `post-thread-user`.`uri-id` AS `uri-id`,
1846 `parent-post`.`id` AS `parent`,
1847 `post-thread-user`.`received` AS `received`,
1848 `post-thread-user`.`commented` AS `commented`,
1849 `post-thread-user`.`created` AS `created`,
1850 `post-thread-user`.`uid` AS `uid`,
1851 `post-thread-user`.`starred` AS `starred`,
1852 `post-thread-user`.`mention` AS `mention`,
1853 `post-thread-user`.`network` AS `network`,
1854 `post-thread-user`.`contact-id` AS `contact-id`,
1855 `ownercontact`.`contact-type` AS `contact-type`
1856 FROM `post-thread-user`
1857 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
1858 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
1859 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
1860 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
1861 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
1862 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
1863 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
1864 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
1865 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
1866 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
1867 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
1872 DROP VIEW IF EXISTS `owner-view`;
1873 CREATE VIEW `owner-view` AS SELECT
1874 `contact`.`id` AS `id`,
1875 `contact`.`uid` AS `uid`,
1876 `contact`.`created` AS `created`,
1877 `contact`.`updated` AS `updated`,
1878 `contact`.`self` AS `self`,
1879 `contact`.`remote_self` AS `remote_self`,
1880 `contact`.`rel` AS `rel`,
1881 `contact`.`duplex` AS `duplex`,
1882 `contact`.`network` AS `network`,
1883 `contact`.`protocol` AS `protocol`,
1884 `contact`.`name` AS `name`,
1885 `contact`.`nick` AS `nick`,
1886 `contact`.`location` AS `location`,
1887 `contact`.`about` AS `about`,
1888 `contact`.`keywords` AS `keywords`,
1889 `contact`.`gender` AS `gender`,
1890 `contact`.`xmpp` AS `xmpp`,
1891 `contact`.`attag` AS `attag`,
1892 `contact`.`avatar` AS `avatar`,
1893 `contact`.`photo` AS `photo`,
1894 `contact`.`thumb` AS `thumb`,
1895 `contact`.`micro` AS `micro`,
1896 `contact`.`site-pubkey` AS `site-pubkey`,
1897 `contact`.`issued-id` AS `issued-id`,
1898 `contact`.`dfrn-id` AS `dfrn-id`,
1899 `contact`.`url` AS `url`,
1900 `contact`.`nurl` AS `nurl`,
1901 `contact`.`addr` AS `addr`,
1902 `contact`.`alias` AS `alias`,
1903 `contact`.`pubkey` AS `pubkey`,
1904 `contact`.`prvkey` AS `prvkey`,
1905 `contact`.`batch` AS `batch`,
1906 `contact`.`request` AS `request`,
1907 `contact`.`notify` AS `notify`,
1908 `contact`.`poll` AS `poll`,
1909 `contact`.`confirm` AS `confirm`,
1910 `contact`.`poco` AS `poco`,
1911 `contact`.`aes_allow` AS `aes_allow`,
1912 `contact`.`ret-aes` AS `ret-aes`,
1913 `contact`.`usehub` AS `usehub`,
1914 `contact`.`subhub` AS `subhub`,
1915 `contact`.`hub-verify` AS `hub-verify`,
1916 `contact`.`last-update` AS `last-update`,
1917 `contact`.`success_update` AS `success_update`,
1918 `contact`.`failure_update` AS `failure_update`,
1919 `contact`.`name-date` AS `name-date`,
1920 `contact`.`uri-date` AS `uri-date`,
1921 `contact`.`avatar-date` AS `avatar-date`,
1922 `contact`.`avatar-date` AS `picdate`,
1923 `contact`.`term-date` AS `term-date`,
1924 `contact`.`last-item` AS `last-item`,
1925 `contact`.`priority` AS `priority`,
1926 `user`.`blocked` AS `blocked`,
1927 `contact`.`block_reason` AS `block_reason`,
1928 `contact`.`readonly` AS `readonly`,
1929 `contact`.`writable` AS `writable`,
1930 `contact`.`forum` AS `forum`,
1931 `contact`.`prv` AS `prv`,
1932 `contact`.`contact-type` AS `contact-type`,
1933 `contact`.`manually-approve` AS `manually-approve`,
1934 `contact`.`hidden` AS `hidden`,
1935 `contact`.`archive` AS `archive`,
1936 `contact`.`pending` AS `pending`,
1937 `contact`.`deleted` AS `deleted`,
1938 `contact`.`unsearchable` AS `unsearchable`,
1939 `contact`.`sensitive` AS `sensitive`,
1940 `contact`.`baseurl` AS `baseurl`,
1941 `contact`.`reason` AS `reason`,
1942 `contact`.`closeness` AS `closeness`,
1943 `contact`.`info` AS `info`,
1944 `contact`.`profile-id` AS `profile-id`,
1945 `contact`.`bdyear` AS `bdyear`,
1946 `contact`.`bd` AS `bd`,
1947 `contact`.`notify_new_posts` AS `notify_new_posts`,
1948 `contact`.`fetch_further_information` AS `fetch_further_information`,
1949 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
1950 `user`.`parent-uid` AS `parent-uid`,
1951 `user`.`guid` AS `guid`,
1952 `user`.`nickname` AS `nickname`,
1953 `user`.`email` AS `email`,
1954 `user`.`openid` AS `openid`,
1955 `user`.`timezone` AS `timezone`,
1956 `user`.`language` AS `language`,
1957 `user`.`register_date` AS `register_date`,
1958 `user`.`login_date` AS `login_date`,
1959 `user`.`default-location` AS `default-location`,
1960 `user`.`allow_location` AS `allow_location`,
1961 `user`.`theme` AS `theme`,
1962 `user`.`pubkey` AS `upubkey`,
1963 `user`.`prvkey` AS `uprvkey`,
1964 `user`.`sprvkey` AS `sprvkey`,
1965 `user`.`spubkey` AS `spubkey`,
1966 `user`.`verified` AS `verified`,
1967 `user`.`blockwall` AS `blockwall`,
1968 `user`.`hidewall` AS `hidewall`,
1969 `user`.`blocktags` AS `blocktags`,
1970 `user`.`unkmail` AS `unkmail`,
1971 `user`.`cntunkmail` AS `cntunkmail`,
1972 `user`.`notify-flags` AS `notify-flags`,
1973 `user`.`page-flags` AS `page-flags`,
1974 `user`.`account-type` AS `account-type`,
1975 `user`.`prvnets` AS `prvnets`,
1976 `user`.`maxreq` AS `maxreq`,
1977 `user`.`expire` AS `expire`,
1978 `user`.`account_removed` AS `account_removed`,
1979 `user`.`account_expired` AS `account_expired`,
1980 `user`.`account_expires_on` AS `account_expires_on`,
1981 `user`.`expire_notification_sent` AS `expire_notification_sent`,
1982 `user`.`def_gid` AS `def_gid`,
1983 `user`.`allow_cid` AS `allow_cid`,
1984 `user`.`allow_gid` AS `allow_gid`,
1985 `user`.`deny_cid` AS `deny_cid`,
1986 `user`.`deny_gid` AS `deny_gid`,
1987 `user`.`openidserver` AS `openidserver`,
1988 `profile`.`publish` AS `publish`,
1989 `profile`.`net-publish` AS `net-publish`,
1990 `profile`.`hide-friends` AS `hide-friends`,
1991 `profile`.`prv_keywords` AS `prv_keywords`,
1992 `profile`.`pub_keywords` AS `pub_keywords`,
1993 `profile`.`address` AS `address`,
1994 `profile`.`locality` AS `locality`,
1995 `profile`.`region` AS `region`,
1996 `profile`.`postal-code` AS `postal-code`,
1997 `profile`.`country-name` AS `country-name`,
1998 `profile`.`homepage` AS `homepage`,
1999 `profile`.`dob` AS `dob`
2001 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2002 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2005 -- VIEW pending-view
2007 DROP VIEW IF EXISTS `pending-view`;
2008 CREATE VIEW `pending-view` AS SELECT
2009 `register`.`id` AS `id`,
2010 `register`.`hash` AS `hash`,
2011 `register`.`created` AS `created`,
2012 `register`.`uid` AS `uid`,
2013 `register`.`password` AS `password`,
2014 `register`.`language` AS `language`,
2015 `register`.`note` AS `note`,
2016 `contact`.`self` AS `self`,
2017 `contact`.`name` AS `name`,
2018 `contact`.`url` AS `url`,
2019 `contact`.`micro` AS `micro`,
2020 `user`.`email` AS `email`,
2021 `contact`.`nick` AS `nick`
2023 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2024 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2027 -- VIEW tag-search-view
2029 DROP VIEW IF EXISTS `tag-search-view`;
2030 CREATE VIEW `tag-search-view` AS SELECT
2031 `post-tag`.`uri-id` AS `uri-id`,
2032 `post-user`.`uid` AS `uid`,
2033 `post-user`.`id` AS `iid`,
2034 `post-user`.`private` AS `private`,
2035 `post-user`.`wall` AS `wall`,
2036 `post-user`.`origin` AS `origin`,
2037 `post-user`.`global` AS `global`,
2038 `post-user`.`gravity` AS `gravity`,
2039 `post-user`.`received` AS `received`,
2040 `post-user`.`network` AS `network`,
2041 `tag`.`name` AS `name`
2043 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
2044 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
2045 WHERE `post-tag`.`type` = 1;
2048 -- VIEW workerqueue-view
2050 DROP VIEW IF EXISTS `workerqueue-view`;
2051 CREATE VIEW `workerqueue-view` AS SELECT
2052 `process`.`pid` AS `pid`,
2053 `workerqueue`.`priority` AS `priority`
2055 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
2056 WHERE NOT `workerqueue`.`done`;