1 -- ------------------------------------------
2 -- Friendica 2021.03-dev (Red Hot Poker)
3 -- DB_UPDATE_VERSION 1395
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 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Global servers';
42 CREATE TABLE IF NOT EXISTS `user` (
43 `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
44 `parent-uid` mediumint unsigned COMMENT 'The parent user that has full control about this user',
45 `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
46 `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
47 `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
48 `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
49 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
50 `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
51 `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
52 `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
53 `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
54 `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
55 `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
56 `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
57 `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
58 `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
59 `pubkey` text COMMENT 'RSA public key 4096 bit',
60 `prvkey` text COMMENT 'RSA private key 4096 bit',
61 `spubkey` text COMMENT '',
62 `sprvkey` text COMMENT '',
63 `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
64 `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
65 `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
66 `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unkown viewers',
67 `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
68 `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
69 `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
70 `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
71 `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
72 `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
73 `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
74 `pwdreset` varchar(255) COMMENT 'Password reset request token',
75 `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
76 `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
77 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
78 `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
79 `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
80 `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
81 `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
82 `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
83 `allow_cid` mediumtext COMMENT 'default permission for this user',
84 `allow_gid` mediumtext COMMENT 'default permission for this user',
85 `deny_cid` mediumtext COMMENT 'default permission for this user',
86 `deny_gid` mediumtext COMMENT 'default permission for this user',
87 `openidserver` text COMMENT '',
89 INDEX `nickname` (`nickname`(32)),
90 INDEX `parent-uid` (`parent-uid`),
91 FOREIGN KEY (`parent-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
92 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
97 CREATE TABLE IF NOT EXISTS `contact` (
98 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
99 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
100 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
101 `updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last contact update',
102 `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
103 `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
104 `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
105 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
106 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network of the contact',
107 `protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
108 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
109 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
110 `location` varchar(255) DEFAULT '' COMMENT '',
111 `about` text COMMENT '',
112 `keywords` text COMMENT 'public keywords (interests) of the contact',
113 `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
114 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
115 `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
116 `avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '',
117 `photo` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
118 `thumb` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
119 `micro` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
120 `site-pubkey` text COMMENT '',
121 `issued-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
122 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
123 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
124 `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
125 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
126 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
127 `pubkey` text COMMENT 'RSA public key 4096 bit',
128 `prvkey` text COMMENT 'RSA private key 4096 bit',
129 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
130 `request` varchar(255) COMMENT '',
131 `notify` varchar(255) COMMENT '',
132 `poll` varchar(255) COMMENT '',
133 `confirm` varchar(255) COMMENT '',
134 `subscribe` varchar(255) COMMENT '',
135 `poco` varchar(255) COMMENT '',
136 `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT '',
137 `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT '',
138 `usehub` boolean NOT NULL DEFAULT '0' COMMENT '',
139 `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
140 `hub-verify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
141 `last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
142 `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
143 `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
144 `failed` boolean COMMENT 'Connection failed',
145 `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
146 `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
147 `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
148 `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
149 `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
150 `last-discovery` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last follower discovery',
151 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
152 `blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
153 `block_reason` text COMMENT 'Node-wide block reason',
154 `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
155 `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
156 `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum',
157 `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group',
158 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT '',
159 `manually-approve` boolean COMMENT '',
160 `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
161 `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
162 `pending` boolean NOT NULL DEFAULT '1' COMMENT '',
163 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
164 `rating` tinyint NOT NULL DEFAULT 0 COMMENT '',
165 `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
166 `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
167 `baseurl` varchar(255) DEFAULT '' COMMENT 'baseurl of the contact',
168 `gsid` int unsigned COMMENT 'Global Server ID',
169 `reason` text COMMENT '',
170 `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT '',
171 `info` mediumtext COMMENT '',
172 `profile-id` int unsigned COMMENT 'Deprecated',
173 `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
174 `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
175 `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
176 `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
177 `ffi_keyword_denylist` text COMMENT '',
179 INDEX `uid_name` (`uid`,`name`(190)),
180 INDEX `self_uid` (`self`,`uid`),
181 INDEX `alias_uid` (`alias`(128),`uid`),
182 INDEX `pending_uid` (`pending`,`uid`),
183 INDEX `blocked_uid` (`blocked`,`uid`),
184 INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
185 INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
186 INDEX `addr_uid` (`addr`(128),`uid`),
187 INDEX `nurl_uid` (`nurl`(128),`uid`),
188 INDEX `nick_uid` (`nick`(128),`uid`),
189 INDEX `attag_uid` (`attag`(96),`uid`),
190 INDEX `dfrn-id` (`dfrn-id`(64)),
191 INDEX `issued-id` (`issued-id`(64)),
192 INDEX `network_uid_lastupdate` (`network`,`uid`,`last-update`),
193 INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`),
194 INDEX `uid_lastitem` (`uid`,`last-item`),
195 INDEX `gsid` (`gsid`),
196 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
197 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
198 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
203 CREATE TABLE IF NOT EXISTS `item-uri` (
204 `id` int unsigned NOT NULL auto_increment,
205 `uri` varbinary(255) NOT NULL COMMENT 'URI of an item',
206 `guid` varbinary(255) COMMENT 'A unique identifier for an item',
208 UNIQUE INDEX `uri` (`uri`),
209 INDEX `guid` (`guid`)
210 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
215 CREATE TABLE IF NOT EXISTS `tag` (
216 `id` int unsigned NOT NULL auto_increment COMMENT '',
217 `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
218 `url` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
220 UNIQUE INDEX `type_name_url` (`name`,`url`),
222 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
227 CREATE TABLE IF NOT EXISTS `clients` (
228 `client_id` varchar(20) NOT NULL COMMENT '',
229 `pw` varchar(20) NOT NULL DEFAULT '' COMMENT '',
230 `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
231 `name` text COMMENT '',
232 `icon` text COMMENT '',
233 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
234 PRIMARY KEY(`client_id`),
236 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
237 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
240 -- TABLE permissionset
242 CREATE TABLE IF NOT EXISTS `permissionset` (
243 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
244 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
245 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
246 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
247 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
248 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
250 INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`uid`,`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30)),
251 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
252 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
257 CREATE TABLE IF NOT EXISTS `verb` (
258 `id` smallint unsigned NOT NULL auto_increment,
259 `name` varchar(100) NOT NULL DEFAULT '' COMMENT '',
261 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activity Verbs';
264 -- TABLE 2fa_app_specific_password
266 CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
267 `id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
268 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
269 `description` varchar(255) COMMENT 'Description of the usage of the password',
270 `hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
271 `generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
272 `last_used` datetime COMMENT 'Datetime the password was last used',
274 INDEX `uid_description` (`uid`,`description`(190)),
275 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
276 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
279 -- TABLE 2fa_recovery_codes
281 CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
282 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
283 `code` varchar(50) NOT NULL COMMENT 'Recovery code string',
284 `generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
285 `used` datetime COMMENT 'Datetime the code was used',
286 PRIMARY KEY(`uid`,`code`),
287 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
288 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
291 -- TABLE 2fa_trusted_browser
293 CREATE TABLE IF NOT EXISTS `2fa_trusted_browser` (
294 `cookie_hash` varchar(80) NOT NULL COMMENT 'Trusted cookie hash',
295 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
296 `user_agent` text COMMENT 'User agent string',
297 `created` datetime NOT NULL COMMENT 'Datetime the trusted browser was recorded',
298 `last_used` datetime COMMENT 'Datetime the trusted browser was last used',
299 PRIMARY KEY(`cookie_hash`),
301 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
302 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication trusted browsers';
307 CREATE TABLE IF NOT EXISTS `addon` (
308 `id` int unsigned NOT NULL auto_increment COMMENT '',
309 `name` varchar(50) NOT NULL DEFAULT '' COMMENT 'addon base (file)name',
310 `version` varchar(50) NOT NULL DEFAULT '' COMMENT 'currently unused',
311 `installed` boolean NOT NULL DEFAULT '0' COMMENT 'currently always 1',
312 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'currently unused',
313 `timestamp` int unsigned NOT NULL DEFAULT 0 COMMENT 'file timestamp to check for reloads',
314 `plugin_admin` boolean NOT NULL DEFAULT '0' COMMENT '1 = has admin config, 0 = has no admin config',
316 UNIQUE INDEX `name` (`name`)
317 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registered addons';
322 CREATE TABLE IF NOT EXISTS `apcontact` (
323 `url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
324 `uuid` varchar(255) COMMENT '',
325 `type` varchar(20) NOT NULL COMMENT '',
326 `following` varchar(255) COMMENT '',
327 `followers` varchar(255) COMMENT '',
328 `inbox` varchar(255) NOT NULL COMMENT '',
329 `outbox` varchar(255) COMMENT '',
330 `sharedinbox` varchar(255) COMMENT '',
331 `manually-approve` boolean COMMENT '',
332 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
333 `name` varchar(255) COMMENT '',
334 `about` text COMMENT '',
335 `photo` varchar(255) COMMENT '',
336 `addr` varchar(255) COMMENT '',
337 `alias` varchar(255) COMMENT '',
338 `pubkey` text COMMENT '',
339 `subscribe` varchar(255) COMMENT '',
340 `baseurl` varchar(255) COMMENT 'baseurl of the ap contact',
341 `gsid` int unsigned COMMENT 'Global Server ID',
342 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
343 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
344 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
345 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
346 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
348 INDEX `addr` (`addr`(32)),
349 INDEX `alias` (`alias`(190)),
350 INDEX `followers` (`followers`(190)),
351 INDEX `baseurl` (`baseurl`(190)),
352 INDEX `sharedinbox` (`sharedinbox`(190)),
353 INDEX `gsid` (`gsid`),
354 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
355 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
360 CREATE TABLE IF NOT EXISTS `attach` (
361 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
362 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
363 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
364 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
365 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
366 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
367 `data` longblob NOT NULL COMMENT 'file data',
368 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
369 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
370 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
371 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
372 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
373 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
374 `backend-class` tinytext COMMENT 'Storage backend class',
375 `backend-ref` text COMMENT 'Storage backend data reference',
378 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
379 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
384 CREATE TABLE IF NOT EXISTS `auth_codes` (
385 `id` varchar(40) NOT NULL COMMENT '',
386 `client_id` varchar(20) NOT NULL DEFAULT '' COMMENT '',
387 `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
388 `expires` int NOT NULL DEFAULT 0 COMMENT '',
389 `scope` varchar(250) NOT NULL DEFAULT '' COMMENT '',
391 INDEX `client_id` (`client_id`),
392 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE
393 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
398 CREATE TABLE IF NOT EXISTS `cache` (
399 `k` varbinary(255) NOT NULL COMMENT 'cache key',
400 `v` mediumtext COMMENT 'cached serialized value',
401 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
402 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
404 INDEX `k_expires` (`k`,`expires`)
405 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
410 CREATE TABLE IF NOT EXISTS `challenge` (
411 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
412 `challenge` varchar(255) NOT NULL DEFAULT '' COMMENT '',
413 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
414 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
415 `type` varchar(255) NOT NULL DEFAULT '' COMMENT '',
416 `last_update` varchar(255) NOT NULL DEFAULT '' COMMENT '',
418 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
423 CREATE TABLE IF NOT EXISTS `config` (
424 `id` int unsigned NOT NULL auto_increment COMMENT '',
425 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
426 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
427 `v` mediumtext COMMENT '',
429 UNIQUE INDEX `cat_k` (`cat`,`k`)
430 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
433 -- TABLE contact-relation
435 CREATE TABLE IF NOT EXISTS `contact-relation` (
436 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
437 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
438 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
439 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
440 `follows` boolean NOT NULL DEFAULT '0' COMMENT '',
441 PRIMARY KEY(`cid`,`relation-cid`),
442 INDEX `relation-cid` (`relation-cid`),
443 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
444 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
445 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
450 CREATE TABLE IF NOT EXISTS `conv` (
451 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
452 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
453 `recips` text COMMENT 'sender_handle;recipient_handle',
454 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
455 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
456 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
457 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
458 `subject` text COMMENT 'subject of initial message',
461 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
462 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
465 -- TABLE conversation
467 CREATE TABLE IF NOT EXISTS `conversation` (
468 `item-uri` varbinary(255) NOT NULL COMMENT 'Original URI of the item - unrelated to the table with the same name',
469 `reply-to-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'URI to which this item is a reply',
470 `conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI',
471 `conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link',
472 `protocol` tinyint unsigned NOT NULL DEFAULT 255 COMMENT 'The protocol of the item',
473 `direction` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'How the message arrived here: 1=push, 2=pull',
474 `source` mediumtext COMMENT 'Original source',
475 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Receiving date',
476 PRIMARY KEY(`item-uri`),
477 INDEX `conversation-uri` (`conversation-uri`),
478 INDEX `received` (`received`)
479 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Raw data and structure information for messages';
482 -- TABLE delayed-post
484 CREATE TABLE IF NOT EXISTS `delayed-post` (
485 `id` int unsigned NOT NULL auto_increment,
486 `uri` varchar(255) COMMENT 'URI of the post that will be distributed later',
487 `uid` mediumint unsigned COMMENT 'Owner User id',
488 `delayed` datetime COMMENT 'delay time',
490 UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
491 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
492 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
495 -- TABLE diaspora-interaction
497 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
498 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
499 `interaction` mediumtext COMMENT 'The Diaspora interaction',
500 PRIMARY KEY(`uri-id`),
501 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
502 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
507 CREATE TABLE IF NOT EXISTS `event` (
508 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
509 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
510 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
511 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
512 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
513 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
514 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
515 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
516 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
517 `summary` text COMMENT 'short description or title of the event',
518 `desc` text COMMENT 'event description',
519 `location` text COMMENT 'event location',
520 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
521 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
522 `adjust` boolean NOT NULL DEFAULT '1' COMMENT 'adjust to timezone of the recipient (0 or 1)',
523 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
524 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
525 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
526 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
527 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
529 INDEX `uid_start` (`uid`,`start`),
531 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
532 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
533 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
538 CREATE TABLE IF NOT EXISTS `fcontact` (
539 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
540 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
541 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
542 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
543 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
544 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
545 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
546 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
547 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
548 `notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
549 `poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
550 `confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
551 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
552 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
553 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
554 `pubkey` text COMMENT '',
555 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
557 INDEX `addr` (`addr`(32)),
558 UNIQUE INDEX `url` (`url`(190))
559 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
564 CREATE TABLE IF NOT EXISTS `fsuggest` (
565 `id` int unsigned NOT NULL auto_increment COMMENT '',
566 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
567 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
568 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
569 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
570 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
571 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
572 `note` text COMMENT '',
573 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
577 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
578 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
579 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
584 CREATE TABLE IF NOT EXISTS `group` (
585 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
586 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
587 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
588 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
589 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
592 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
593 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
596 -- TABLE group_member
598 CREATE TABLE IF NOT EXISTS `group_member` (
599 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
600 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
601 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
603 INDEX `contactid` (`contact-id`),
604 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
605 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
606 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
607 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
612 CREATE TABLE IF NOT EXISTS `gserver-tag` (
613 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
614 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
615 PRIMARY KEY(`gserver-id`,`tag`),
617 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
618 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
623 CREATE TABLE IF NOT EXISTS `hook` (
624 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
625 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
626 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
627 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
628 `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',
630 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
631 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
636 CREATE TABLE IF NOT EXISTS `host` (
637 `id` tinyint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
638 `name` varchar(128) NOT NULL DEFAULT '' COMMENT 'The hostname',
640 UNIQUE INDEX `name` (`name`)
641 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Hostname';
644 -- TABLE inbox-status
646 CREATE TABLE IF NOT EXISTS `inbox-status` (
647 `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
648 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
649 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
650 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
651 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
652 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
653 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
655 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
660 CREATE TABLE IF NOT EXISTS `intro` (
661 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
662 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
663 `fid` int unsigned COMMENT '',
664 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
665 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
666 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
667 `note` text COMMENT '',
668 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
669 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
670 `blocked` boolean NOT NULL DEFAULT '1' COMMENT '',
671 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
673 INDEX `contact-id` (`contact-id`),
675 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
676 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
677 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
682 CREATE TABLE IF NOT EXISTS `item` (
683 `id` int unsigned NOT NULL auto_increment,
684 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this item',
685 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
686 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
687 `uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
688 `parent` int unsigned COMMENT 'item.id of the parent to this item if it is a reply of some form; otherwise this must be set to the id of this item',
689 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT 'uri of the top-level parent to this item',
690 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the top-level parent uri',
691 `thr-parent` varchar(255) NOT NULL DEFAULT '' COMMENT 'If the parent of this item is not the top-level item in the conversation, the uri of the immediate parent; otherwise set to parent-uri',
692 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
693 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
694 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
695 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last comment/reply to this item',
696 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
697 `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',
698 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
699 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
700 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
701 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
702 `causer-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
703 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
704 `extid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
705 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
706 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
707 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
708 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
709 `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
710 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been deleted',
711 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
712 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
713 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
714 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
715 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
716 `starred` boolean NOT NULL DEFAULT '0' COMMENT 'item has been favourited',
717 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'item has not been seen',
718 `mention` boolean NOT NULL DEFAULT '0' COMMENT 'The owner of this item was mentioned in it',
719 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
720 `psid` int unsigned COMMENT 'ID of the permission set of this post',
721 `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',
722 `event-id` int unsigned COMMENT 'Used to link to the event.id',
723 `iaid` int unsigned COMMENT 'Deprecated',
724 `icid` int unsigned COMMENT 'Deprecated',
725 `attach` mediumtext COMMENT 'Deprecated',
726 `allow_cid` mediumtext COMMENT 'Deprecated',
727 `allow_gid` mediumtext COMMENT 'Deprecated',
728 `deny_cid` mediumtext COMMENT 'Deprecated',
729 `deny_gid` mediumtext COMMENT 'Deprecated',
730 `postopts` text COMMENT 'Deprecated',
731 `inform` mediumtext COMMENT 'Deprecated',
732 `type` varchar(20) COMMENT 'Deprecated',
733 `bookmark` boolean COMMENT 'Deprecated',
734 `file` mediumtext COMMENT 'Deprecated',
735 `location` varchar(255) COMMENT 'Deprecated',
736 `coord` varchar(255) COMMENT 'Deprecated',
737 `tag` mediumtext COMMENT 'Deprecated',
738 `plink` varchar(255) COMMENT 'Deprecated',
739 `title` varchar(255) COMMENT 'Deprecated',
740 `content-warning` varchar(255) COMMENT 'Deprecated',
741 `body` mediumtext COMMENT 'Deprecated',
742 `app` varchar(255) COMMENT 'Deprecated',
743 `verb` varchar(100) COMMENT 'Deprecated',
744 `object-type` varchar(100) COMMENT 'Deprecated',
745 `object` text COMMENT 'Deprecated',
746 `target-type` varchar(100) COMMENT 'Deprecated',
747 `target` text COMMENT 'Deprecated',
748 `author-name` varchar(255) COMMENT 'Deprecated',
749 `author-link` varchar(255) COMMENT 'Deprecated',
750 `author-avatar` varchar(255) COMMENT 'Deprecated',
751 `owner-name` varchar(255) COMMENT 'Deprecated',
752 `owner-link` varchar(255) COMMENT 'Deprecated',
753 `owner-avatar` varchar(255) COMMENT 'Deprecated',
754 `rendered-hash` varchar(32) COMMENT 'Deprecated',
755 `rendered-html` mediumtext COMMENT 'Deprecated',
757 INDEX `guid` (`guid`(191)),
758 INDEX `uri` (`uri`(191)),
759 INDEX `parent` (`parent`),
760 INDEX `parent-uri` (`parent-uri`(191)),
761 INDEX `extid` (`extid`(191)),
762 INDEX `uid_id` (`uid`,`id`),
763 INDEX `uid_contactid_id` (`uid`,`contact-id`,`id`),
764 INDEX `uid_received` (`uid`,`received`),
765 INDEX `uid_commented` (`uid`,`commented`),
766 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
767 INDEX `uid_network_received` (`uid`,`network`,`received`),
768 INDEX `uid_network_commented` (`uid`,`network`,`commented`),
769 INDEX `uid_thrparent` (`uid`,`thr-parent`(190)),
770 INDEX `uid_parenturi` (`uid`,`parent-uri`(190)),
771 INDEX `uid_contactid_received` (`uid`,`contact-id`,`received`),
772 INDEX `authorid_received` (`author-id`,`received`),
773 INDEX `ownerid` (`owner-id`),
774 INDEX `contact-id` (`contact-id`),
775 INDEX `uid_uri` (`uid`,`uri`(190)),
776 INDEX `resource-id` (`resource-id`),
777 INDEX `deleted_changed` (`deleted`,`changed`),
778 INDEX `uid_wall_changed` (`uid`,`wall`,`changed`),
779 INDEX `uid_unseen_wall` (`uid`,`unseen`,`wall`),
780 INDEX `mention_uid_id` (`mention`,`uid`,`id`),
781 INDEX `uid_eventid` (`uid`,`event-id`),
783 INDEX `psid_wall` (`psid`,`wall`),
784 INDEX `uri-id` (`uri-id`),
785 INDEX `parent-uri-id` (`parent-uri-id`),
786 INDEX `thr-parent-id` (`thr-parent-id`),
787 INDEX `causer-id` (`causer-id`),
788 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
789 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
790 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
791 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
792 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
793 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
794 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
795 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
796 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
797 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
798 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
801 -- TABLE item-activity
803 CREATE TABLE IF NOT EXISTS `item-activity` (
804 `id` int unsigned NOT NULL auto_increment,
805 `uri` varchar(255) COMMENT '',
806 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
807 `uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
808 `activity` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
810 UNIQUE INDEX `uri-hash` (`uri-hash`),
811 INDEX `uri` (`uri`(191)),
812 INDEX `uri-id` (`uri-id`),
813 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
814 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activities for items';
817 -- TABLE item-content
819 CREATE TABLE IF NOT EXISTS `item-content` (
820 `id` int unsigned NOT NULL auto_increment,
821 `uri` varchar(255) COMMENT '',
822 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
823 `uri-plink-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
824 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
825 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
826 `body` mediumtext COMMENT 'item body content',
827 `raw-body` mediumtext COMMENT 'Body without embedded media links',
828 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
829 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
830 `language` text COMMENT 'Language information about this post',
831 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
832 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
833 `rendered-html` mediumtext COMMENT 'item.body converted to html',
834 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
835 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
836 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
837 `target` text COMMENT 'JSON encoded target structure if used',
838 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
839 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams verb',
841 UNIQUE INDEX `uri-plink-hash` (`uri-plink-hash`),
842 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
843 INDEX `uri` (`uri`(191)),
844 INDEX `plink` (`plink`(191)),
845 INDEX `uri-id` (`uri-id`),
846 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
847 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
852 CREATE TABLE IF NOT EXISTS `locks` (
853 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
854 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
855 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
856 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
857 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
859 INDEX `name_expires` (`name`,`expires`)
860 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
865 CREATE TABLE IF NOT EXISTS `mail` (
866 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
867 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
868 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
869 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
870 `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
871 `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
872 `contact-id` varchar(255) COMMENT 'contact.id',
873 `convid` int unsigned COMMENT 'conv.id',
874 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
875 `body` mediumtext COMMENT '',
876 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
877 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
878 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
879 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
880 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
881 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
882 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
884 INDEX `uid_seen` (`uid`,`seen`),
885 INDEX `convid` (`convid`),
886 INDEX `uri` (`uri`(64)),
887 INDEX `parent-uri` (`parent-uri`(64)),
888 INDEX `contactid` (`contact-id`(32)),
889 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
890 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
895 CREATE TABLE IF NOT EXISTS `mailacct` (
896 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
897 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
898 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
899 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
900 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
901 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
902 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
903 `pass` text COMMENT '',
904 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
905 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
906 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
907 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
908 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
911 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
912 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
917 CREATE TABLE IF NOT EXISTS `manage` (
918 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
919 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
920 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
922 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
924 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
925 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
926 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
931 CREATE TABLE IF NOT EXISTS `notify` (
932 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
933 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
934 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
935 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
936 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
937 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
938 `msg` mediumtext COMMENT '',
939 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
940 `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
941 `iid` int unsigned COMMENT 'item.id',
942 `parent` int unsigned COMMENT '',
943 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
944 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
945 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
946 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
947 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
948 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
949 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
951 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
952 INDEX `uid_date` (`uid`,`date`),
953 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
954 INDEX `uri-id` (`uri-id`),
955 INDEX `parent-uri-id` (`parent-uri-id`),
956 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
957 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
958 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
959 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
962 -- TABLE notify-threads
964 CREATE TABLE IF NOT EXISTS `notify-threads` (
965 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
966 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
967 `master-parent-item` int unsigned COMMENT '',
968 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
969 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
970 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
972 INDEX `master-parent-item` (`master-parent-item`),
973 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
974 INDEX `receiver-uid` (`receiver-uid`),
975 INDEX `notify-id` (`notify-id`),
976 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
977 FOREIGN KEY (`master-parent-item`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
978 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
979 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
980 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
985 CREATE TABLE IF NOT EXISTS `oembed` (
986 `url` varbinary(255) NOT NULL COMMENT 'page url',
987 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
988 `content` mediumtext COMMENT 'OEmbed data of the page',
989 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
990 PRIMARY KEY(`url`,`maxwidth`),
991 INDEX `created` (`created`)
992 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
995 -- TABLE openwebauth-token
997 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
998 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
999 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
1000 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
1001 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
1002 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1003 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1005 INDEX `uid` (`uid`),
1006 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1007 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
1012 CREATE TABLE IF NOT EXISTS `parsed_url` (
1013 `url` varbinary(255) NOT NULL COMMENT 'page url',
1014 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
1015 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
1016 `content` mediumtext COMMENT 'page data',
1017 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
1018 PRIMARY KEY(`url`,`guessing`,`oembed`),
1019 INDEX `created` (`created`)
1020 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
1023 -- TABLE participation
1025 CREATE TABLE IF NOT EXISTS `participation` (
1026 `iid` int unsigned NOT NULL COMMENT '',
1027 `server` varchar(60) NOT NULL COMMENT '',
1028 `cid` int unsigned NOT NULL COMMENT '',
1029 `fid` int unsigned NOT NULL COMMENT '',
1030 PRIMARY KEY(`iid`,`server`),
1031 INDEX `cid` (`cid`),
1032 INDEX `fid` (`fid`),
1033 FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1034 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1035 FOREIGN KEY (`fid`) REFERENCES `fcontact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1036 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Storage for participation messages from Diaspora';
1041 CREATE TABLE IF NOT EXISTS `pconfig` (
1042 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
1043 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1044 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
1045 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
1046 `v` mediumtext COMMENT 'Value',
1048 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
1049 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1050 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
1055 CREATE TABLE IF NOT EXISTS `photo` (
1056 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1057 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1058 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1059 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
1060 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
1061 `hash` char(32) COMMENT 'hash value of the photo',
1062 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
1063 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
1064 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1065 `desc` text COMMENT '',
1066 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
1067 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1068 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
1069 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1070 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1071 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1072 `data` mediumblob NOT NULL COMMENT '',
1073 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1074 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
1075 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
1076 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
1077 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
1078 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
1079 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
1080 `backend-class` tinytext COMMENT 'Storage backend class',
1081 `backend-ref` text COMMENT 'Storage backend data reference',
1082 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1084 INDEX `contactid` (`contact-id`),
1085 INDEX `uid_contactid` (`uid`,`contact-id`),
1086 INDEX `uid_profile` (`uid`,`profile`),
1087 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
1088 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
1089 INDEX `resource-id` (`resource-id`),
1090 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1091 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1092 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1095 -- TABLE post-category
1097 CREATE TABLE IF NOT EXISTS `post-category` (
1098 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1099 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1100 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1101 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1102 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1103 INDEX `uri-id` (`tid`),
1104 INDEX `uid` (`uid`),
1105 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1106 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1107 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1108 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1111 -- TABLE post-delivery-data
1113 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1114 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1115 `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',
1116 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1117 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1118 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1119 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1120 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1121 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1122 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1123 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1124 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1125 PRIMARY KEY(`uri-id`),
1126 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1127 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1132 CREATE TABLE IF NOT EXISTS `post-media` (
1133 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1134 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1135 `url` varbinary(511) NOT NULL COMMENT 'Media URL',
1136 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1137 `mimetype` varchar(60) COMMENT '',
1138 `height` smallint unsigned COMMENT 'Height of the media',
1139 `width` smallint unsigned COMMENT 'Width of the media',
1140 `size` int unsigned COMMENT 'Media size',
1141 `preview` varbinary(255) COMMENT 'Preview URL',
1142 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1143 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1144 `description` text COMMENT '',
1146 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1147 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1148 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1153 CREATE TABLE IF NOT EXISTS `post-tag` (
1154 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1155 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1156 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1157 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1158 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1159 INDEX `tid` (`tid`),
1160 INDEX `cid` (`cid`),
1161 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1162 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1163 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1164 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1169 CREATE TABLE IF NOT EXISTS `post-user` (
1170 `id` int unsigned NOT NULL auto_increment,
1171 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1172 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1173 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1174 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1175 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1176 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1177 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1178 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1179 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1181 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1182 INDEX `uri-id` (`uri-id`),
1183 INDEX `contact-id` (`contact-id`),
1184 INDEX `psid` (`psid`),
1185 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1186 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1187 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1188 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1189 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1194 CREATE TABLE IF NOT EXISTS `process` (
1195 `pid` int unsigned NOT NULL COMMENT '',
1196 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1197 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1199 INDEX `command` (`command`)
1200 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1205 CREATE TABLE IF NOT EXISTS `profile` (
1206 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1207 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1208 `profile-name` varchar(255) COMMENT 'Deprecated',
1209 `is-default` boolean COMMENT 'Deprecated',
1210 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1211 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1212 `pdesc` varchar(255) COMMENT 'Deprecated',
1213 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1214 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1215 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1216 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1217 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1218 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1219 `hometown` varchar(255) COMMENT 'Deprecated',
1220 `gender` varchar(32) COMMENT 'Deprecated',
1221 `marital` varchar(255) COMMENT 'Deprecated',
1222 `with` text COMMENT 'Deprecated',
1223 `howlong` datetime COMMENT 'Deprecated',
1224 `sexual` varchar(255) COMMENT 'Deprecated',
1225 `politic` varchar(255) COMMENT 'Deprecated',
1226 `religion` varchar(255) COMMENT 'Deprecated',
1227 `pub_keywords` text COMMENT '',
1228 `prv_keywords` text COMMENT '',
1229 `likes` text COMMENT 'Deprecated',
1230 `dislikes` text COMMENT 'Deprecated',
1231 `about` text COMMENT 'Profile description',
1232 `summary` varchar(255) COMMENT 'Deprecated',
1233 `music` text COMMENT 'Deprecated',
1234 `book` text COMMENT 'Deprecated',
1235 `tv` text COMMENT 'Deprecated',
1236 `film` text COMMENT 'Deprecated',
1237 `interest` text COMMENT 'Deprecated',
1238 `romance` text COMMENT 'Deprecated',
1239 `work` text COMMENT 'Deprecated',
1240 `education` text COMMENT 'Deprecated',
1241 `contact` text COMMENT 'Deprecated',
1242 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1243 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1244 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1245 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1246 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1247 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1249 INDEX `uid_is-default` (`uid`,`is-default`),
1250 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1251 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1252 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1255 -- TABLE profile_check
1257 CREATE TABLE IF NOT EXISTS `profile_check` (
1258 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1259 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1260 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1261 `dfrn_id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1262 `sec` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1263 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1265 INDEX `uid` (`uid`),
1266 INDEX `cid` (`cid`),
1267 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1268 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1269 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='DFRN remote auth use';
1272 -- TABLE profile_field
1274 CREATE TABLE IF NOT EXISTS `profile_field` (
1275 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1276 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1277 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1278 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1279 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1280 `value` text COMMENT 'Value of the field',
1281 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1282 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1284 INDEX `uid` (`uid`),
1285 INDEX `order` (`order`),
1286 INDEX `psid` (`psid`),
1287 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1288 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1289 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1292 -- TABLE push_subscriber
1294 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1295 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1296 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1297 `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1298 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1299 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1300 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1301 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1302 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1303 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1304 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1306 INDEX `next_try` (`next_try`),
1307 INDEX `uid` (`uid`),
1308 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1309 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1314 CREATE TABLE IF NOT EXISTS `register` (
1315 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1316 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1317 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1318 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1319 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1320 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1321 `note` text COMMENT '',
1323 INDEX `uid` (`uid`),
1324 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1325 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1330 CREATE TABLE IF NOT EXISTS `search` (
1331 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1332 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1333 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1335 INDEX `uid` (`uid`),
1336 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1337 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1342 CREATE TABLE IF NOT EXISTS `session` (
1343 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1344 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1345 `data` text COMMENT '',
1346 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1348 INDEX `sid` (`sid`(64)),
1349 INDEX `expire` (`expire`)
1350 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1355 CREATE TABLE IF NOT EXISTS `storage` (
1356 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1357 `data` longblob NOT NULL COMMENT 'file data',
1359 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1364 CREATE TABLE IF NOT EXISTS `thread` (
1365 `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'sequential ID',
1366 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
1367 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1368 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1369 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1370 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1371 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1372 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1373 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1374 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1375 `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1376 `wall` boolean NOT NULL DEFAULT '0' COMMENT '',
1377 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1378 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1379 `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
1380 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1381 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1382 `ignored` boolean NOT NULL DEFAULT '0' COMMENT '',
1383 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
1384 `unseen` boolean NOT NULL DEFAULT '1' COMMENT '',
1385 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '',
1386 `origin` boolean NOT NULL DEFAULT '0' COMMENT '',
1387 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1388 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1389 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1390 `bookmark` boolean COMMENT '',
1392 INDEX `uid_network_commented` (`uid`,`network`,`commented`),
1393 INDEX `uid_network_received` (`uid`,`network`,`received`),
1394 INDEX `uid_contactid_commented` (`uid`,`contact-id`,`commented`),
1395 INDEX `uid_contactid_received` (`uid`,`contact-id`,`received`),
1396 INDEX `contactid` (`contact-id`),
1397 INDEX `ownerid` (`owner-id`),
1398 INDEX `authorid` (`author-id`),
1399 INDEX `uid_received` (`uid`,`received`),
1400 INDEX `uid_commented` (`uid`,`commented`),
1401 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1402 INDEX `private_wall_origin_commented` (`private`,`wall`,`origin`,`commented`),
1403 INDEX `uri-id` (`uri-id`),
1404 FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1405 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1406 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1407 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1408 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1409 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1410 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1415 CREATE TABLE IF NOT EXISTS `tokens` (
1416 `id` varchar(40) NOT NULL COMMENT '',
1417 `secret` text COMMENT '',
1418 `client_id` varchar(20) NOT NULL DEFAULT '',
1419 `expires` int NOT NULL DEFAULT 0 COMMENT '',
1420 `scope` varchar(200) NOT NULL DEFAULT '' COMMENT '',
1421 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1423 INDEX `client_id` (`client_id`),
1424 INDEX `uid` (`uid`),
1425 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1426 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1427 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
1432 CREATE TABLE IF NOT EXISTS `userd` (
1433 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1434 `username` varchar(255) NOT NULL COMMENT '',
1436 INDEX `username` (`username`(32))
1437 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1440 -- TABLE user-contact
1442 CREATE TABLE IF NOT EXISTS `user-contact` (
1443 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1444 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1445 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1446 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1447 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1448 PRIMARY KEY(`uid`,`cid`),
1449 INDEX `cid` (`cid`),
1450 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1451 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1452 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1457 CREATE TABLE IF NOT EXISTS `user-item` (
1458 `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item id',
1459 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1460 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide an item from the user',
1461 `ignored` boolean COMMENT 'Ignore this thread if set',
1462 `pinned` boolean COMMENT 'The item is pinned on the profile page',
1463 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1464 PRIMARY KEY(`uid`,`iid`),
1465 INDEX `uid_pinned` (`uid`,`pinned`),
1466 INDEX `iid_uid` (`iid`,`uid`),
1467 FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1468 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1469 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific item data';
1474 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1475 `key` int NOT NULL COMMENT '',
1476 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1478 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1481 -- TABLE workerqueue
1483 CREATE TABLE IF NOT EXISTS `workerqueue` (
1484 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
1485 `command` varchar(100) COMMENT 'Task command',
1486 `parameter` mediumtext COMMENT 'Task parameter',
1487 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
1488 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
1489 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
1490 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
1491 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1492 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1493 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
1495 INDEX `command` (`command`),
1496 INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
1497 INDEX `done_executed` (`done`,`executed`),
1498 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
1499 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
1500 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
1501 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
1502 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
1503 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
1508 DROP VIEW IF EXISTS `post-view`;
1509 CREATE VIEW `post-view` AS SELECT
1510 `item`.`id` AS `id`,
1511 `item`.`id` AS `item_id`,
1512 `post-user`.`id` AS `post-user-id`,
1513 `item`.`uid` AS `uid`,
1514 `item`.`parent` AS `parent`,
1515 `item`.`uri` AS `uri`,
1516 `item`.`uri-id` AS `uri-id`,
1517 `item`.`parent-uri` AS `parent-uri`,
1518 `item`.`parent-uri-id` AS `parent-uri-id`,
1519 `item`.`thr-parent` AS `thr-parent`,
1520 `item`.`thr-parent-id` AS `thr-parent-id`,
1521 `item`.`guid` AS `guid`,
1522 `item`.`type` AS `type`,
1523 `item`.`wall` AS `wall`,
1524 `item`.`gravity` AS `gravity`,
1525 `item`.`extid` AS `extid`,
1526 `item`.`created` AS `created`,
1527 `item`.`edited` AS `edited`,
1528 `item`.`commented` AS `commented`,
1529 `item`.`received` AS `received`,
1530 `item`.`changed` AS `changed`,
1531 `item`.`resource-id` AS `resource-id`,
1532 `item`.`post-type` AS `post-type`,
1533 `item`.`private` AS `private`,
1534 `item`.`pubmail` AS `pubmail`,
1535 `item`.`moderated` AS `moderated`,
1536 `item`.`visible` AS `visible`,
1537 `item`.`starred` AS `starred`,
1538 `item`.`bookmark` AS `bookmark`,
1539 `item`.`unseen` AS `unseen`,
1540 `item`.`deleted` AS `deleted`,
1541 `item`.`origin` AS `origin`,
1542 `item`.`forum_mode` AS `forum_mode`,
1543 `item`.`mention` AS `mention`,
1544 `item`.`global` AS `global`,
1545 `item`.`network` AS `network`,
1546 `item`.`vid` AS `vid`,
1547 `item`.`psid` AS `psid`,
1548 IF (`item`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1549 `item-content`.`title` AS `title`,
1550 `item-content`.`content-warning` AS `content-warning`,
1551 `item-content`.`raw-body` AS `raw-body`,
1552 `item-content`.`body` AS `body`,
1553 `item-content`.`rendered-hash` AS `rendered-hash`,
1554 `item-content`.`rendered-html` AS `rendered-html`,
1555 `item-content`.`language` AS `language`,
1556 `item-content`.`plink` AS `plink`,
1557 `item-content`.`location` AS `location`,
1558 `item-content`.`coord` AS `coord`,
1559 `item-content`.`app` AS `app`,
1560 `item-content`.`object-type` AS `object-type`,
1561 `item-content`.`object` AS `object`,
1562 `item-content`.`target-type` AS `target-type`,
1563 `item-content`.`target` AS `target`,
1564 `item`.`contact-id` AS `contact-id`,
1565 `contact`.`url` AS `contact-link`,
1566 `contact`.`addr` AS `contact-addr`,
1567 `contact`.`name` AS `contact-name`,
1568 `contact`.`nick` AS `contact-nick`,
1569 `contact`.`thumb` AS `contact-avatar`,
1570 `contact`.`network` AS `contact-network`,
1571 `contact`.`blocked` AS `contact-blocked`,
1572 `contact`.`hidden` AS `contact-hidden`,
1573 `contact`.`readonly` AS `contact-readonly`,
1574 `contact`.`archive` AS `contact-archive`,
1575 `contact`.`pending` AS `contact-pending`,
1576 `contact`.`rel` AS `contact-rel`,
1577 `contact`.`uid` AS `contact-uid`,
1578 `contact`.`contact-type` AS `contact-contact-type`,
1579 IF (`item`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1580 `contact`.`self` AS `self`,
1581 `contact`.`id` AS `cid`,
1582 `contact`.`alias` AS `alias`,
1583 `contact`.`photo` AS `photo`,
1584 `contact`.`name-date` AS `name-date`,
1585 `contact`.`uri-date` AS `uri-date`,
1586 `contact`.`avatar-date` AS `avatar-date`,
1587 `contact`.`thumb` AS `thumb`,
1588 `contact`.`dfrn-id` AS `dfrn-id`,
1589 `item`.`author-id` AS `author-id`,
1590 `author`.`url` AS `author-link`,
1591 `author`.`addr` AS `author-addr`,
1592 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1593 `author`.`nick` AS `author-nick`,
1594 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1595 `author`.`network` AS `author-network`,
1596 `author`.`blocked` AS `author-blocked`,
1597 `author`.`hidden` AS `author-hidden`,
1598 `item`.`owner-id` AS `owner-id`,
1599 `owner`.`url` AS `owner-link`,
1600 `owner`.`addr` AS `owner-addr`,
1601 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1602 `owner`.`nick` AS `owner-nick`,
1603 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1604 `owner`.`network` AS `owner-network`,
1605 `owner`.`blocked` AS `owner-blocked`,
1606 `owner`.`hidden` AS `owner-hidden`,
1607 `item`.`causer-id` AS `causer-id`,
1608 `causer`.`url` AS `causer-link`,
1609 `causer`.`addr` AS `causer-addr`,
1610 `causer`.`name` AS `causer-name`,
1611 `causer`.`nick` AS `causer-nick`,
1612 `causer`.`thumb` AS `causer-avatar`,
1613 `causer`.`network` AS `causer-network`,
1614 `causer`.`blocked` AS `causer-blocked`,
1615 `causer`.`hidden` AS `causer-hidden`,
1616 `causer`.`contact-type` AS `causer-contact-type`,
1617 `post-delivery-data`.`postopts` AS `postopts`,
1618 `post-delivery-data`.`inform` AS `inform`,
1619 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1620 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1621 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1622 IF (`item`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1623 IF (`item`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1624 IF (`item`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1625 IF (`item`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1626 `item`.`event-id` AS `event-id`,
1627 `event`.`created` AS `event-created`,
1628 `event`.`edited` AS `event-edited`,
1629 `event`.`start` AS `event-start`,
1630 `event`.`finish` AS `event-finish`,
1631 `event`.`summary` AS `event-summary`,
1632 `event`.`desc` AS `event-desc`,
1633 `event`.`location` AS `event-location`,
1634 `event`.`type` AS `event-type`,
1635 `event`.`nofinish` AS `event-nofinish`,
1636 `event`.`adjust` AS `event-adjust`,
1637 `event`.`ignore` AS `event-ignore`,
1638 `diaspora-interaction`.`interaction` AS `signed_text`,
1639 `parent-item`.`guid` AS `parent-guid`,
1640 `parent-item`.`network` AS `parent-network`,
1641 `parent-item`.`author-id` AS `parent-author-id`,
1642 `parent-item-author`.`url` AS `parent-author-link`,
1643 `parent-item-author`.`name` AS `parent-author-name`,
1644 `parent-item-author`.`network` AS `parent-author-network`
1646 LEFT JOIN `post-user` ON `post-user`.`uri-id` = `item`.`uri-id` AND `post-user`.`uid` = `item`.`uid`
1647 STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
1648 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `item`.`author-id`
1649 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `item`.`owner-id`
1650 STRAIGHT_JOIN `contact` AS `causer` ON `causer`.`id` = `item`.`causer-id`
1651 LEFT JOIN `verb` ON `verb`.`id` = `item`.`vid`
1652 LEFT JOIN `event` ON `event`.`id` = `item`.`event-id`
1653 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `item`.`uri-id`
1654 LEFT JOIN `item-content` ON `item-content`.`uri-id` = `item`.`uri-id`
1655 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `item`.`uri-id` AND `item`.`origin`
1656 LEFT JOIN `permissionset` ON `permissionset`.`id` = `item`.`psid`
1657 STRAIGHT_JOIN `item` AS `parent-item` ON `parent-item`.`uri-id` = `item`.`parent-uri-id` AND `parent-item`.`uid` = `item`.`uid`
1658 STRAIGHT_JOIN `contact` AS `parent-item-author` ON `parent-item-author`.`id` = `parent-item`.`author-id`;
1661 -- VIEW post-thread-view
1663 DROP VIEW IF EXISTS `post-thread-view`;
1664 CREATE VIEW `post-thread-view` AS SELECT
1665 `item`.`id` AS `id`,
1666 `thread`.`iid` AS `iid`,
1667 `item`.`id` AS `item_id`,
1668 `thread`.`uid` AS `uid`,
1669 `item`.`parent` AS `parent`,
1670 `item`.`uri` AS `uri`,
1671 `item`.`uri-id` AS `uri-id`,
1672 `item`.`parent-uri` AS `parent-uri`,
1673 `item`.`parent-uri-id` AS `parent-uri-id`,
1674 `item`.`thr-parent` AS `thr-parent`,
1675 `item`.`thr-parent-id` AS `thr-parent-id`,
1676 `item`.`guid` AS `guid`,
1677 `item`.`type` AS `type`,
1678 `thread`.`wall` AS `wall`,
1679 `item`.`gravity` AS `gravity`,
1680 `item`.`extid` AS `extid`,
1681 `thread`.`created` AS `created`,
1682 `item`.`edited` AS `edited`,
1683 `thread`.`commented` AS `commented`,
1684 `thread`.`received` AS `received`,
1685 `thread`.`changed` AS `changed`,
1686 `item`.`resource-id` AS `resource-id`,
1687 `thread`.`post-type` AS `post-type`,
1688 `thread`.`private` AS `private`,
1689 `thread`.`pubmail` AS `pubmail`,
1690 `thread`.`moderated` AS `moderated`,
1691 `thread`.`ignored` AS `ignored`,
1692 `thread`.`visible` AS `visible`,
1693 `thread`.`starred` AS `starred`,
1694 `item`.`bookmark` AS `bookmark`,
1695 `item`.`unseen` AS `unseen`,
1696 `thread`.`deleted` AS `deleted`,
1697 `thread`.`origin` AS `origin`,
1698 `thread`.`forum_mode` AS `forum_mode`,
1699 `thread`.`mention` AS `mention`,
1700 `item`.`global` AS `global`,
1701 `thread`.`network` AS `network`,
1702 `item`.`vid` AS `vid`,
1703 `item`.`psid` AS `psid`,
1704 IF (`item`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1705 `item-content`.`title` AS `title`,
1706 `item-content`.`content-warning` AS `content-warning`,
1707 `item-content`.`raw-body` AS `raw-body`,
1708 `item-content`.`body` AS `body`,
1709 `item-content`.`rendered-hash` AS `rendered-hash`,
1710 `item-content`.`rendered-html` AS `rendered-html`,
1711 `item-content`.`language` AS `language`,
1712 `item-content`.`plink` AS `plink`,
1713 `item-content`.`location` AS `location`,
1714 `item-content`.`coord` AS `coord`,
1715 `item-content`.`app` AS `app`,
1716 `item-content`.`object-type` AS `object-type`,
1717 `item-content`.`object` AS `object`,
1718 `item-content`.`target-type` AS `target-type`,
1719 `item-content`.`target` AS `target`,
1720 `thread`.`contact-id` AS `contact-id`,
1721 `contact`.`url` AS `contact-link`,
1722 `contact`.`addr` AS `contact-addr`,
1723 `contact`.`name` AS `contact-name`,
1724 `contact`.`nick` AS `contact-nick`,
1725 `contact`.`thumb` AS `contact-avatar`,
1726 `contact`.`network` AS `contact-network`,
1727 `contact`.`blocked` AS `contact-blocked`,
1728 `contact`.`hidden` AS `contact-hidden`,
1729 `contact`.`readonly` AS `contact-readonly`,
1730 `contact`.`archive` AS `contact-archive`,
1731 `contact`.`pending` AS `contact-pending`,
1732 `contact`.`rel` AS `contact-rel`,
1733 `contact`.`uid` AS `contact-uid`,
1734 `contact`.`contact-type` AS `contact-contact-type`,
1735 IF (`item`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1736 `contact`.`self` AS `self`,
1737 `contact`.`id` AS `cid`,
1738 `contact`.`alias` AS `alias`,
1739 `contact`.`photo` AS `photo`,
1740 `contact`.`name-date` AS `name-date`,
1741 `contact`.`uri-date` AS `uri-date`,
1742 `contact`.`avatar-date` AS `avatar-date`,
1743 `contact`.`thumb` AS `thumb`,
1744 `contact`.`dfrn-id` AS `dfrn-id`,
1745 `thread`.`author-id` AS `author-id`,
1746 `author`.`url` AS `author-link`,
1747 `author`.`addr` AS `author-addr`,
1748 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1749 `author`.`nick` AS `author-nick`,
1750 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1751 `author`.`network` AS `author-network`,
1752 `author`.`blocked` AS `author-blocked`,
1753 `author`.`hidden` AS `author-hidden`,
1754 `thread`.`owner-id` AS `owner-id`,
1755 `owner`.`url` AS `owner-link`,
1756 `owner`.`addr` AS `owner-addr`,
1757 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1758 `owner`.`nick` AS `owner-nick`,
1759 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1760 `owner`.`network` AS `owner-network`,
1761 `owner`.`blocked` AS `owner-blocked`,
1762 `owner`.`hidden` AS `owner-hidden`,
1763 `item`.`causer-id` AS `causer-id`,
1764 `causer`.`url` AS `causer-link`,
1765 `causer`.`addr` AS `causer-addr`,
1766 `causer`.`name` AS `causer-name`,
1767 `causer`.`nick` AS `causer-nick`,
1768 `causer`.`thumb` AS `causer-avatar`,
1769 `causer`.`network` AS `causer-network`,
1770 `causer`.`blocked` AS `causer-blocked`,
1771 `causer`.`hidden` AS `causer-hidden`,
1772 `causer`.`contact-type` AS `causer-contact-type`,
1773 `post-delivery-data`.`postopts` AS `postopts`,
1774 `post-delivery-data`.`inform` AS `inform`,
1775 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1776 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1777 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1778 IF (`item`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1779 IF (`item`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1780 IF (`item`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1781 IF (`item`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1782 `item`.`event-id` AS `event-id`,
1783 `event`.`created` AS `event-created`,
1784 `event`.`edited` AS `event-edited`,
1785 `event`.`start` AS `event-start`,
1786 `event`.`finish` AS `event-finish`,
1787 `event`.`summary` AS `event-summary`,
1788 `event`.`desc` AS `event-desc`,
1789 `event`.`location` AS `event-location`,
1790 `event`.`type` AS `event-type`,
1791 `event`.`nofinish` AS `event-nofinish`,
1792 `event`.`adjust` AS `event-adjust`,
1793 `event`.`ignore` AS `event-ignore`,
1794 `diaspora-interaction`.`interaction` AS `signed_text`,
1795 `parent-item`.`guid` AS `parent-guid`,
1796 `parent-item`.`network` AS `parent-network`,
1797 `parent-item`.`author-id` AS `parent-author-id`,
1798 `parent-item-author`.`url` AS `parent-author-link`,
1799 `parent-item-author`.`name` AS `parent-author-name`,
1800 `parent-item-author`.`network` AS `parent-author-network`
1802 STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
1803 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
1804 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `thread`.`author-id`
1805 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `thread`.`owner-id`
1806 STRAIGHT_JOIN `contact` AS `causer` ON `causer`.`id` = `item`.`causer-id`
1807 LEFT JOIN `verb` ON `verb`.`id` = `item`.`vid`
1808 LEFT JOIN `event` ON `event`.`id` = `item`.`event-id`
1809 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `thread`.`uri-id`
1810 LEFT JOIN `item-content` ON `item-content`.`uri-id` = `thread`.`uri-id`
1811 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `thread`.`uri-id` AND `thread`.`origin`
1812 LEFT JOIN `permissionset` ON `permissionset`.`id` = `item`.`psid`
1813 STRAIGHT_JOIN `item` AS `parent-item` ON `parent-item`.`id` = `item`.`parent`
1814 STRAIGHT_JOIN `contact` AS `parent-item-author` ON `parent-item-author`.`id` = `parent-item`.`author-id`;
1817 -- VIEW category-view
1819 DROP VIEW IF EXISTS `category-view`;
1820 CREATE VIEW `category-view` AS SELECT
1821 `post-category`.`uri-id` AS `uri-id`,
1822 `post-category`.`uid` AS `uid`,
1823 `item-uri`.`uri` AS `uri`,
1824 `item-uri`.`guid` AS `guid`,
1825 `post-category`.`type` AS `type`,
1826 `post-category`.`tid` AS `tid`,
1827 `tag`.`name` AS `name`,
1828 `tag`.`url` AS `url`
1829 FROM `post-category`
1830 INNER JOIN `item-uri` ON `item-uri`.id = `post-category`.`uri-id`
1831 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
1836 DROP VIEW IF EXISTS `tag-view`;
1837 CREATE VIEW `tag-view` AS SELECT
1838 `post-tag`.`uri-id` AS `uri-id`,
1839 `item-uri`.`uri` AS `uri`,
1840 `item-uri`.`guid` AS `guid`,
1841 `post-tag`.`type` AS `type`,
1842 `post-tag`.`tid` AS `tid`,
1843 `post-tag`.`cid` AS `cid`,
1844 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
1845 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
1847 INNER JOIN `item-uri` ON `item-uri`.id = `post-tag`.`uri-id`
1848 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
1849 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
1852 -- VIEW network-item-view
1854 DROP VIEW IF EXISTS `network-item-view`;
1855 CREATE VIEW `network-item-view` AS SELECT
1856 `item`.`parent-uri-id` AS `uri-id`,
1857 `item`.`parent-uri` AS `uri`,
1858 `item`.`parent` AS `parent`,
1859 `item`.`received` AS `received`,
1860 `item`.`commented` AS `commented`,
1861 `item`.`created` AS `created`,
1862 `item`.`uid` AS `uid`,
1863 `item`.`starred` AS `starred`,
1864 `item`.`mention` AS `mention`,
1865 `item`.`network` AS `network`,
1866 `item`.`unseen` AS `unseen`,
1867 `item`.`gravity` AS `gravity`,
1868 `item`.`contact-id` AS `contact-id`,
1869 `ownercontact`.`contact-type` AS `contact-type`
1871 INNER JOIN `thread` ON `thread`.`iid` = `item`.`parent`
1872 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
1873 LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
1874 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
1875 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
1876 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
1877 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
1878 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
1879 AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
1880 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
1881 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
1884 -- VIEW network-thread-view
1886 DROP VIEW IF EXISTS `network-thread-view`;
1887 CREATE VIEW `network-thread-view` AS SELECT
1888 `item`.`uri-id` AS `uri-id`,
1889 `item`.`uri` AS `uri`,
1890 `item`.`parent-uri-id` AS `parent-uri-id`,
1891 `thread`.`iid` AS `parent`,
1892 `thread`.`received` AS `received`,
1893 `thread`.`commented` AS `commented`,
1894 `thread`.`created` AS `created`,
1895 `thread`.`uid` AS `uid`,
1896 `thread`.`starred` AS `starred`,
1897 `thread`.`mention` AS `mention`,
1898 `thread`.`network` AS `network`,
1899 `thread`.`contact-id` AS `contact-id`,
1900 `ownercontact`.`contact-type` AS `contact-type`
1902 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
1903 STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
1904 LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
1905 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
1906 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
1907 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
1908 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
1909 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
1910 AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
1911 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
1912 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
1917 DROP VIEW IF EXISTS `owner-view`;
1918 CREATE VIEW `owner-view` AS SELECT
1919 `contact`.`id` AS `id`,
1920 `contact`.`uid` AS `uid`,
1921 `contact`.`created` AS `created`,
1922 `contact`.`updated` AS `updated`,
1923 `contact`.`self` AS `self`,
1924 `contact`.`remote_self` AS `remote_self`,
1925 `contact`.`rel` AS `rel`,
1926 `contact`.`duplex` AS `duplex`,
1927 `contact`.`network` AS `network`,
1928 `contact`.`protocol` AS `protocol`,
1929 `contact`.`name` AS `name`,
1930 `contact`.`nick` AS `nick`,
1931 `contact`.`location` AS `location`,
1932 `contact`.`about` AS `about`,
1933 `contact`.`keywords` AS `keywords`,
1934 `contact`.`gender` AS `gender`,
1935 `contact`.`xmpp` AS `xmpp`,
1936 `contact`.`attag` AS `attag`,
1937 `contact`.`avatar` AS `avatar`,
1938 `contact`.`photo` AS `photo`,
1939 `contact`.`thumb` AS `thumb`,
1940 `contact`.`micro` AS `micro`,
1941 `contact`.`site-pubkey` AS `site-pubkey`,
1942 `contact`.`issued-id` AS `issued-id`,
1943 `contact`.`dfrn-id` AS `dfrn-id`,
1944 `contact`.`url` AS `url`,
1945 `contact`.`nurl` AS `nurl`,
1946 `contact`.`addr` AS `addr`,
1947 `contact`.`alias` AS `alias`,
1948 `contact`.`pubkey` AS `pubkey`,
1949 `contact`.`prvkey` AS `prvkey`,
1950 `contact`.`batch` AS `batch`,
1951 `contact`.`request` AS `request`,
1952 `contact`.`notify` AS `notify`,
1953 `contact`.`poll` AS `poll`,
1954 `contact`.`confirm` AS `confirm`,
1955 `contact`.`poco` AS `poco`,
1956 `contact`.`aes_allow` AS `aes_allow`,
1957 `contact`.`ret-aes` AS `ret-aes`,
1958 `contact`.`usehub` AS `usehub`,
1959 `contact`.`subhub` AS `subhub`,
1960 `contact`.`hub-verify` AS `hub-verify`,
1961 `contact`.`last-update` AS `last-update`,
1962 `contact`.`success_update` AS `success_update`,
1963 `contact`.`failure_update` AS `failure_update`,
1964 `contact`.`name-date` AS `name-date`,
1965 `contact`.`uri-date` AS `uri-date`,
1966 `contact`.`avatar-date` AS `avatar-date`,
1967 `contact`.`avatar-date` AS `picdate`,
1968 `contact`.`term-date` AS `term-date`,
1969 `contact`.`last-item` AS `last-item`,
1970 `contact`.`priority` AS `priority`,
1971 `user`.`blocked` AS `blocked`,
1972 `contact`.`block_reason` AS `block_reason`,
1973 `contact`.`readonly` AS `readonly`,
1974 `contact`.`writable` AS `writable`,
1975 `contact`.`forum` AS `forum`,
1976 `contact`.`prv` AS `prv`,
1977 `contact`.`contact-type` AS `contact-type`,
1978 `contact`.`manually-approve` AS `manually-approve`,
1979 `contact`.`hidden` AS `hidden`,
1980 `contact`.`archive` AS `archive`,
1981 `contact`.`pending` AS `pending`,
1982 `contact`.`deleted` AS `deleted`,
1983 `contact`.`unsearchable` AS `unsearchable`,
1984 `contact`.`sensitive` AS `sensitive`,
1985 `contact`.`baseurl` AS `baseurl`,
1986 `contact`.`reason` AS `reason`,
1987 `contact`.`closeness` AS `closeness`,
1988 `contact`.`info` AS `info`,
1989 `contact`.`profile-id` AS `profile-id`,
1990 `contact`.`bdyear` AS `bdyear`,
1991 `contact`.`bd` AS `bd`,
1992 `contact`.`notify_new_posts` AS `notify_new_posts`,
1993 `contact`.`fetch_further_information` AS `fetch_further_information`,
1994 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
1995 `user`.`parent-uid` AS `parent-uid`,
1996 `user`.`guid` AS `guid`,
1997 `user`.`nickname` AS `nickname`,
1998 `user`.`email` AS `email`,
1999 `user`.`openid` AS `openid`,
2000 `user`.`timezone` AS `timezone`,
2001 `user`.`language` AS `language`,
2002 `user`.`register_date` AS `register_date`,
2003 `user`.`login_date` AS `login_date`,
2004 `user`.`default-location` AS `default-location`,
2005 `user`.`allow_location` AS `allow_location`,
2006 `user`.`theme` AS `theme`,
2007 `user`.`pubkey` AS `upubkey`,
2008 `user`.`prvkey` AS `uprvkey`,
2009 `user`.`sprvkey` AS `sprvkey`,
2010 `user`.`spubkey` AS `spubkey`,
2011 `user`.`verified` AS `verified`,
2012 `user`.`blockwall` AS `blockwall`,
2013 `user`.`hidewall` AS `hidewall`,
2014 `user`.`blocktags` AS `blocktags`,
2015 `user`.`unkmail` AS `unkmail`,
2016 `user`.`cntunkmail` AS `cntunkmail`,
2017 `user`.`notify-flags` AS `notify-flags`,
2018 `user`.`page-flags` AS `page-flags`,
2019 `user`.`account-type` AS `account-type`,
2020 `user`.`prvnets` AS `prvnets`,
2021 `user`.`maxreq` AS `maxreq`,
2022 `user`.`expire` AS `expire`,
2023 `user`.`account_removed` AS `account_removed`,
2024 `user`.`account_expired` AS `account_expired`,
2025 `user`.`account_expires_on` AS `account_expires_on`,
2026 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2027 `user`.`def_gid` AS `def_gid`,
2028 `user`.`allow_cid` AS `allow_cid`,
2029 `user`.`allow_gid` AS `allow_gid`,
2030 `user`.`deny_cid` AS `deny_cid`,
2031 `user`.`deny_gid` AS `deny_gid`,
2032 `user`.`openidserver` AS `openidserver`,
2033 `profile`.`publish` AS `publish`,
2034 `profile`.`net-publish` AS `net-publish`,
2035 `profile`.`hide-friends` AS `hide-friends`,
2036 `profile`.`prv_keywords` AS `prv_keywords`,
2037 `profile`.`pub_keywords` AS `pub_keywords`,
2038 `profile`.`address` AS `address`,
2039 `profile`.`locality` AS `locality`,
2040 `profile`.`region` AS `region`,
2041 `profile`.`postal-code` AS `postal-code`,
2042 `profile`.`country-name` AS `country-name`,
2043 `profile`.`homepage` AS `homepage`,
2044 `profile`.`dob` AS `dob`
2046 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2047 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2050 -- VIEW pending-view
2052 DROP VIEW IF EXISTS `pending-view`;
2053 CREATE VIEW `pending-view` AS SELECT
2054 `register`.`id` AS `id`,
2055 `register`.`hash` AS `hash`,
2056 `register`.`created` AS `created`,
2057 `register`.`uid` AS `uid`,
2058 `register`.`password` AS `password`,
2059 `register`.`language` AS `language`,
2060 `register`.`note` AS `note`,
2061 `contact`.`self` AS `self`,
2062 `contact`.`name` AS `name`,
2063 `contact`.`url` AS `url`,
2064 `contact`.`micro` AS `micro`,
2065 `user`.`email` AS `email`,
2066 `contact`.`nick` AS `nick`
2068 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2069 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2072 -- VIEW tag-search-view
2074 DROP VIEW IF EXISTS `tag-search-view`;
2075 CREATE VIEW `tag-search-view` AS SELECT
2076 `post-tag`.`uri-id` AS `uri-id`,
2077 `item`.`id` AS `iid`,
2078 `item`.`uri` AS `uri`,
2079 `item`.`guid` AS `guid`,
2080 `item`.`uid` AS `uid`,
2081 `item`.`private` AS `private`,
2082 `item`.`wall` AS `wall`,
2083 `item`.`origin` AS `origin`,
2084 `item`.`gravity` AS `gravity`,
2085 `item`.`received` AS `received`,
2086 `tag`.`name` AS `name`
2088 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
2089 INNER JOIN `item` ON `item`.`uri-id` = `post-tag`.`uri-id`
2090 WHERE `post-tag`.`type` = 1;
2093 -- VIEW workerqueue-view
2095 DROP VIEW IF EXISTS `workerqueue-view`;
2096 CREATE VIEW `workerqueue-view` AS SELECT
2097 `process`.`pid` AS `pid`,
2098 `workerqueue`.`priority` AS `priority`
2100 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
2101 WHERE NOT `workerqueue`.`done`;