1 -- ------------------------------------------
2 -- Friendica 2021.03-dev (Red Hot Poker)
3 -- DB_UPDATE_VERSION 1397
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 `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',
688 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT 'uri of the top-level parent to this item',
689 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the top-level parent uri',
690 `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',
691 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
692 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
693 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
694 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last comment/reply to this item',
695 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
696 `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',
697 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
698 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
699 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
700 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
701 `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',
702 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
703 `extid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
704 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
705 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
706 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
707 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
708 `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
709 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been deleted',
710 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
711 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
712 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'item has not been seen',
713 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
714 `psid` int unsigned COMMENT 'ID of the permission set of this post',
715 `starred` boolean NOT NULL DEFAULT '0' COMMENT 'item has been favourited',
716 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
717 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
718 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
719 `event-id` int unsigned COMMENT 'Used to link to the event.id',
720 `type` varchar(20) COMMENT '',
721 `bookmark` boolean COMMENT '',
722 `mention` boolean NOT NULL DEFAULT '0' COMMENT 'The owner of this item was mentioned in it',
723 `resource-id` varchar(32) COMMENT 'Deprecated',
724 `uri-hash` varchar(80) COMMENT 'Deprecated',
725 `iaid` int unsigned COMMENT 'Deprecated',
726 `icid` int unsigned COMMENT 'Deprecated',
727 `attach` mediumtext COMMENT 'Deprecated',
728 `allow_cid` mediumtext COMMENT 'Deprecated',
729 `allow_gid` mediumtext COMMENT 'Deprecated',
730 `deny_cid` mediumtext COMMENT 'Deprecated',
731 `deny_gid` mediumtext COMMENT 'Deprecated',
732 `postopts` text COMMENT 'Deprecated',
733 `inform` mediumtext 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';
803 CREATE TABLE IF NOT EXISTS `locks` (
804 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
805 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
806 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
807 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
808 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
810 INDEX `name_expires` (`name`,`expires`)
811 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
816 CREATE TABLE IF NOT EXISTS `mail` (
817 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
818 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
819 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
820 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
821 `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
822 `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
823 `contact-id` varchar(255) COMMENT 'contact.id',
824 `convid` int unsigned COMMENT 'conv.id',
825 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
826 `body` mediumtext COMMENT '',
827 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
828 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
829 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
830 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
831 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
832 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
833 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
835 INDEX `uid_seen` (`uid`,`seen`),
836 INDEX `convid` (`convid`),
837 INDEX `uri` (`uri`(64)),
838 INDEX `parent-uri` (`parent-uri`(64)),
839 INDEX `contactid` (`contact-id`(32)),
840 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
841 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
846 CREATE TABLE IF NOT EXISTS `mailacct` (
847 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
848 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
849 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
850 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
851 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
852 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
853 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
854 `pass` text COMMENT '',
855 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
856 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
857 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
858 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
859 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
862 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
863 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
868 CREATE TABLE IF NOT EXISTS `manage` (
869 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
870 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
871 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
873 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
875 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
876 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
877 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
882 CREATE TABLE IF NOT EXISTS `notify` (
883 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
884 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
885 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
886 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
887 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
888 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
889 `msg` mediumtext COMMENT '',
890 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
891 `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
892 `iid` int unsigned COMMENT 'item.id',
893 `parent` int unsigned COMMENT '',
894 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
895 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
896 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
897 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
898 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
899 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
900 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
902 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
903 INDEX `uid_date` (`uid`,`date`),
904 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
905 INDEX `uri-id` (`uri-id`),
906 INDEX `parent-uri-id` (`parent-uri-id`),
907 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
908 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
909 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
910 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
913 -- TABLE notify-threads
915 CREATE TABLE IF NOT EXISTS `notify-threads` (
916 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
917 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
918 `master-parent-item` int unsigned COMMENT '',
919 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
920 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
921 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
923 INDEX `master-parent-item` (`master-parent-item`),
924 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
925 INDEX `receiver-uid` (`receiver-uid`),
926 INDEX `notify-id` (`notify-id`),
927 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
928 FOREIGN KEY (`master-parent-item`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
929 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
930 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
931 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
936 CREATE TABLE IF NOT EXISTS `oembed` (
937 `url` varbinary(255) NOT NULL COMMENT 'page url',
938 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
939 `content` mediumtext COMMENT 'OEmbed data of the page',
940 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
941 PRIMARY KEY(`url`,`maxwidth`),
942 INDEX `created` (`created`)
943 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
946 -- TABLE openwebauth-token
948 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
949 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
950 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
951 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
952 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
953 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
954 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
957 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
958 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
963 CREATE TABLE IF NOT EXISTS `parsed_url` (
964 `url` varbinary(255) NOT NULL COMMENT 'page url',
965 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
966 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
967 `content` mediumtext COMMENT 'page data',
968 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
969 PRIMARY KEY(`url`,`guessing`,`oembed`),
970 INDEX `created` (`created`)
971 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
974 -- TABLE participation
976 CREATE TABLE IF NOT EXISTS `participation` (
977 `iid` int unsigned NOT NULL COMMENT '',
978 `server` varchar(60) NOT NULL COMMENT '',
979 `cid` int unsigned NOT NULL COMMENT '',
980 `fid` int unsigned NOT NULL COMMENT '',
981 PRIMARY KEY(`iid`,`server`),
984 FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
985 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
986 FOREIGN KEY (`fid`) REFERENCES `fcontact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
987 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Storage for participation messages from Diaspora';
992 CREATE TABLE IF NOT EXISTS `pconfig` (
993 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
994 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
995 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
996 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
997 `v` mediumtext COMMENT 'Value',
999 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
1000 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1001 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
1006 CREATE TABLE IF NOT EXISTS `photo` (
1007 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1008 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1009 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1010 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
1011 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
1012 `hash` char(32) COMMENT 'hash value of the photo',
1013 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
1014 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
1015 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1016 `desc` text COMMENT '',
1017 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
1018 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1019 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
1020 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1021 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1022 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1023 `data` mediumblob NOT NULL COMMENT '',
1024 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1025 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
1026 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
1027 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
1028 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
1029 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
1030 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
1031 `backend-class` tinytext COMMENT 'Storage backend class',
1032 `backend-ref` text COMMENT 'Storage backend data reference',
1033 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1035 INDEX `contactid` (`contact-id`),
1036 INDEX `uid_contactid` (`uid`,`contact-id`),
1037 INDEX `uid_profile` (`uid`,`profile`),
1038 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
1039 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
1040 INDEX `resource-id` (`resource-id`),
1041 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1042 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1043 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1046 -- TABLE post-category
1048 CREATE TABLE IF NOT EXISTS `post-category` (
1049 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1050 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1051 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1052 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1053 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1054 INDEX `uri-id` (`tid`),
1055 INDEX `uid` (`uid`),
1056 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1057 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1058 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1059 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1062 -- TABLE post-content
1064 CREATE TABLE IF NOT EXISTS `post-content` (
1065 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1066 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1067 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1068 `body` mediumtext COMMENT 'item body content',
1069 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1070 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1071 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1072 `language` text COMMENT 'Language information about this post',
1073 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1074 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1075 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1076 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1077 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1078 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1079 `target` text COMMENT 'JSON encoded target structure if used',
1080 `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',
1081 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1082 PRIMARY KEY(`uri-id`),
1083 INDEX `plink` (`plink`(191)),
1084 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
1085 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1086 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1089 -- TABLE post-delivery-data
1091 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1092 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1093 `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',
1094 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1095 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1096 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1097 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1098 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1099 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1100 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1101 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1102 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1103 PRIMARY KEY(`uri-id`),
1104 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1105 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1110 CREATE TABLE IF NOT EXISTS `post-media` (
1111 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1112 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1113 `url` varbinary(511) NOT NULL COMMENT 'Media URL',
1114 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1115 `mimetype` varchar(60) COMMENT '',
1116 `height` smallint unsigned COMMENT 'Height of the media',
1117 `width` smallint unsigned COMMENT 'Width of the media',
1118 `size` int unsigned COMMENT 'Media size',
1119 `preview` varbinary(255) COMMENT 'Preview URL',
1120 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1121 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1122 `description` text COMMENT '',
1124 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1125 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1126 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1131 CREATE TABLE IF NOT EXISTS `post-tag` (
1132 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1133 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1134 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1135 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1136 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1137 INDEX `tid` (`tid`),
1138 INDEX `cid` (`cid`),
1139 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1140 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1141 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1142 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1145 -- TABLE post-thread-user
1147 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1148 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1149 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1150 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'The thread is pinned on the profile page',
1151 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1152 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1153 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1154 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1155 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1156 PRIMARY KEY(`uid`,`uri-id`),
1157 INDEX `uid_wall` (`uid`,`wall`),
1158 INDEX `uid_pinned` (`uid`,`pinned`),
1159 INDEX `uri-id` (`uri-id`),
1160 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1161 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1162 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1167 CREATE TABLE IF NOT EXISTS `post-user` (
1168 `id` int unsigned NOT NULL auto_increment,
1169 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1170 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1171 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1172 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1173 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1174 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1175 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1176 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1177 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1179 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1180 INDEX `uri-id` (`uri-id`),
1181 INDEX `contact-id` (`contact-id`),
1182 INDEX `psid` (`psid`),
1183 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1184 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1185 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1186 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1187 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1190 -- TABLE post-user-notification
1192 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1193 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1194 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1195 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1196 PRIMARY KEY(`uid`,`uri-id`),
1197 INDEX `uri-id` (`uri-id`),
1198 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1199 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1200 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1205 CREATE TABLE IF NOT EXISTS `process` (
1206 `pid` int unsigned NOT NULL COMMENT '',
1207 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1208 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1210 INDEX `command` (`command`)
1211 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1216 CREATE TABLE IF NOT EXISTS `profile` (
1217 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1218 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1219 `profile-name` varchar(255) COMMENT 'Deprecated',
1220 `is-default` boolean COMMENT 'Deprecated',
1221 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1222 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1223 `pdesc` varchar(255) COMMENT 'Deprecated',
1224 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1225 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1226 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1227 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1228 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1229 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1230 `hometown` varchar(255) COMMENT 'Deprecated',
1231 `gender` varchar(32) COMMENT 'Deprecated',
1232 `marital` varchar(255) COMMENT 'Deprecated',
1233 `with` text COMMENT 'Deprecated',
1234 `howlong` datetime COMMENT 'Deprecated',
1235 `sexual` varchar(255) COMMENT 'Deprecated',
1236 `politic` varchar(255) COMMENT 'Deprecated',
1237 `religion` varchar(255) COMMENT 'Deprecated',
1238 `pub_keywords` text COMMENT '',
1239 `prv_keywords` text COMMENT '',
1240 `likes` text COMMENT 'Deprecated',
1241 `dislikes` text COMMENT 'Deprecated',
1242 `about` text COMMENT 'Profile description',
1243 `summary` varchar(255) COMMENT 'Deprecated',
1244 `music` text COMMENT 'Deprecated',
1245 `book` text COMMENT 'Deprecated',
1246 `tv` text COMMENT 'Deprecated',
1247 `film` text COMMENT 'Deprecated',
1248 `interest` text COMMENT 'Deprecated',
1249 `romance` text COMMENT 'Deprecated',
1250 `work` text COMMENT 'Deprecated',
1251 `education` text COMMENT 'Deprecated',
1252 `contact` text COMMENT 'Deprecated',
1253 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1254 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1255 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1256 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1257 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1258 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1260 INDEX `uid_is-default` (`uid`,`is-default`),
1261 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1262 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1263 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1266 -- TABLE profile_check
1268 CREATE TABLE IF NOT EXISTS `profile_check` (
1269 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1270 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1271 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1272 `dfrn_id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1273 `sec` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1274 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1276 INDEX `uid` (`uid`),
1277 INDEX `cid` (`cid`),
1278 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1279 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1280 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='DFRN remote auth use';
1283 -- TABLE profile_field
1285 CREATE TABLE IF NOT EXISTS `profile_field` (
1286 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1287 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1288 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1289 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1290 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1291 `value` text COMMENT 'Value of the field',
1292 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1293 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1295 INDEX `uid` (`uid`),
1296 INDEX `order` (`order`),
1297 INDEX `psid` (`psid`),
1298 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1299 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1300 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1303 -- TABLE push_subscriber
1305 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1306 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1307 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1308 `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1309 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1310 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1311 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1312 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1313 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1314 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1315 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1317 INDEX `next_try` (`next_try`),
1318 INDEX `uid` (`uid`),
1319 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1320 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1325 CREATE TABLE IF NOT EXISTS `register` (
1326 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1327 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1328 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1329 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1330 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1331 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1332 `note` text COMMENT '',
1334 INDEX `uid` (`uid`),
1335 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1336 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1341 CREATE TABLE IF NOT EXISTS `search` (
1342 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1343 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1344 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1346 INDEX `uid` (`uid`),
1347 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1348 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1353 CREATE TABLE IF NOT EXISTS `session` (
1354 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1355 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1356 `data` text COMMENT '',
1357 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1359 INDEX `sid` (`sid`(64)),
1360 INDEX `expire` (`expire`)
1361 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1366 CREATE TABLE IF NOT EXISTS `storage` (
1367 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1368 `data` longblob NOT NULL COMMENT 'file data',
1370 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1375 CREATE TABLE IF NOT EXISTS `thread` (
1376 `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'sequential ID',
1377 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
1378 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1379 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1380 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1381 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1382 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1383 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1384 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1385 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1386 `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1387 `wall` boolean NOT NULL DEFAULT '0' COMMENT '',
1388 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1389 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1390 `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
1391 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1392 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1393 `ignored` boolean NOT NULL DEFAULT '0' COMMENT '',
1394 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
1395 `unseen` boolean NOT NULL DEFAULT '1' COMMENT '',
1396 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '',
1397 `origin` boolean NOT NULL DEFAULT '0' COMMENT '',
1398 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1399 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1400 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1401 `bookmark` boolean COMMENT '',
1403 INDEX `uid_network_commented` (`uid`,`network`,`commented`),
1404 INDEX `uid_network_received` (`uid`,`network`,`received`),
1405 INDEX `uid_contactid_commented` (`uid`,`contact-id`,`commented`),
1406 INDEX `uid_contactid_received` (`uid`,`contact-id`,`received`),
1407 INDEX `contactid` (`contact-id`),
1408 INDEX `ownerid` (`owner-id`),
1409 INDEX `authorid` (`author-id`),
1410 INDEX `uid_received` (`uid`,`received`),
1411 INDEX `uid_commented` (`uid`,`commented`),
1412 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1413 INDEX `private_wall_origin_commented` (`private`,`wall`,`origin`,`commented`),
1414 INDEX `uri-id` (`uri-id`),
1415 FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1416 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1417 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1418 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1419 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1420 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1421 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1426 CREATE TABLE IF NOT EXISTS `tokens` (
1427 `id` varchar(40) NOT NULL COMMENT '',
1428 `secret` text COMMENT '',
1429 `client_id` varchar(20) NOT NULL DEFAULT '',
1430 `expires` int NOT NULL DEFAULT 0 COMMENT '',
1431 `scope` varchar(200) NOT NULL DEFAULT '' COMMENT '',
1432 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1434 INDEX `client_id` (`client_id`),
1435 INDEX `uid` (`uid`),
1436 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1437 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1438 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
1443 CREATE TABLE IF NOT EXISTS `userd` (
1444 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1445 `username` varchar(255) NOT NULL COMMENT '',
1447 INDEX `username` (`username`(32))
1448 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1451 -- TABLE user-contact
1453 CREATE TABLE IF NOT EXISTS `user-contact` (
1454 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1455 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1456 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1457 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1458 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1459 PRIMARY KEY(`uid`,`cid`),
1460 INDEX `cid` (`cid`),
1461 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1462 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1463 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1468 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1469 `key` int NOT NULL COMMENT '',
1470 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1472 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1475 -- TABLE workerqueue
1477 CREATE TABLE IF NOT EXISTS `workerqueue` (
1478 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
1479 `command` varchar(100) COMMENT 'Task command',
1480 `parameter` mediumtext COMMENT 'Task parameter',
1481 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
1482 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
1483 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
1484 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
1485 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1486 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1487 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
1489 INDEX `command` (`command`),
1490 INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
1491 INDEX `done_executed` (`done`,`executed`),
1492 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
1493 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
1494 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
1495 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
1496 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
1497 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
1502 DROP VIEW IF EXISTS `post-view`;
1503 CREATE VIEW `post-view` AS SELECT
1504 `item`.`id` AS `id`,
1505 `item`.`id` AS `item_id`,
1506 `post-user`.`id` AS `post-user-id`,
1507 `item`.`uid` AS `uid`,
1508 `item`.`parent` AS `parent`,
1509 `item`.`uri` AS `uri`,
1510 `item`.`uri-id` AS `uri-id`,
1511 `item`.`parent-uri` AS `parent-uri`,
1512 `item`.`parent-uri-id` AS `parent-uri-id`,
1513 `item`.`thr-parent` AS `thr-parent`,
1514 `item`.`thr-parent-id` AS `thr-parent-id`,
1515 `item`.`guid` AS `guid`,
1516 `item`.`type` AS `type`,
1517 `item`.`wall` AS `wall`,
1518 `item`.`gravity` AS `gravity`,
1519 `item`.`extid` AS `extid`,
1520 `item`.`created` AS `created`,
1521 `item`.`edited` AS `edited`,
1522 `item`.`commented` AS `commented`,
1523 `item`.`received` AS `received`,
1524 `item`.`changed` AS `changed`,
1525 `item`.`post-type` AS `post-type`,
1526 `item`.`private` AS `private`,
1527 `item`.`pubmail` AS `pubmail`,
1528 `item`.`moderated` AS `moderated`,
1529 `item`.`visible` AS `visible`,
1530 `item`.`starred` AS `starred`,
1531 `item`.`bookmark` AS `bookmark`,
1532 `item`.`unseen` AS `unseen`,
1533 `item`.`deleted` AS `deleted`,
1534 `item`.`origin` AS `origin`,
1535 `item`.`forum_mode` AS `forum_mode`,
1536 `item`.`mention` AS `mention`,
1537 `item`.`global` AS `global`,
1538 `item`.`network` AS `network`,
1539 `item`.`vid` AS `vid`,
1540 `item`.`psid` AS `psid`,
1541 IF (`item`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1542 `post-content`.`title` AS `title`,
1543 `post-content`.`content-warning` AS `content-warning`,
1544 `post-content`.`raw-body` AS `raw-body`,
1545 `post-content`.`body` AS `body`,
1546 `post-content`.`rendered-hash` AS `rendered-hash`,
1547 `post-content`.`rendered-html` AS `rendered-html`,
1548 `post-content`.`language` AS `language`,
1549 `post-content`.`plink` AS `plink`,
1550 `post-content`.`location` AS `location`,
1551 `post-content`.`coord` AS `coord`,
1552 `post-content`.`app` AS `app`,
1553 `post-content`.`object-type` AS `object-type`,
1554 `post-content`.`object` AS `object`,
1555 `post-content`.`target-type` AS `target-type`,
1556 `post-content`.`target` AS `target`,
1557 `post-content`.`resource-id` AS `resource-id`,
1558 `item`.`contact-id` AS `contact-id`,
1559 `contact`.`url` AS `contact-link`,
1560 `contact`.`addr` AS `contact-addr`,
1561 `contact`.`name` AS `contact-name`,
1562 `contact`.`nick` AS `contact-nick`,
1563 `contact`.`thumb` AS `contact-avatar`,
1564 `contact`.`network` AS `contact-network`,
1565 `contact`.`blocked` AS `contact-blocked`,
1566 `contact`.`hidden` AS `contact-hidden`,
1567 `contact`.`readonly` AS `contact-readonly`,
1568 `contact`.`archive` AS `contact-archive`,
1569 `contact`.`pending` AS `contact-pending`,
1570 `contact`.`rel` AS `contact-rel`,
1571 `contact`.`uid` AS `contact-uid`,
1572 `contact`.`contact-type` AS `contact-contact-type`,
1573 IF (`item`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1574 `contact`.`self` AS `self`,
1575 `contact`.`id` AS `cid`,
1576 `contact`.`alias` AS `alias`,
1577 `contact`.`photo` AS `photo`,
1578 `contact`.`name-date` AS `name-date`,
1579 `contact`.`uri-date` AS `uri-date`,
1580 `contact`.`avatar-date` AS `avatar-date`,
1581 `contact`.`thumb` AS `thumb`,
1582 `contact`.`dfrn-id` AS `dfrn-id`,
1583 `item`.`author-id` AS `author-id`,
1584 `author`.`url` AS `author-link`,
1585 `author`.`addr` AS `author-addr`,
1586 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1587 `author`.`nick` AS `author-nick`,
1588 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1589 `author`.`network` AS `author-network`,
1590 `author`.`blocked` AS `author-blocked`,
1591 `author`.`hidden` AS `author-hidden`,
1592 `item`.`owner-id` AS `owner-id`,
1593 `owner`.`url` AS `owner-link`,
1594 `owner`.`addr` AS `owner-addr`,
1595 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1596 `owner`.`nick` AS `owner-nick`,
1597 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1598 `owner`.`network` AS `owner-network`,
1599 `owner`.`blocked` AS `owner-blocked`,
1600 `owner`.`hidden` AS `owner-hidden`,
1601 `item`.`causer-id` AS `causer-id`,
1602 `causer`.`url` AS `causer-link`,
1603 `causer`.`addr` AS `causer-addr`,
1604 `causer`.`name` AS `causer-name`,
1605 `causer`.`nick` AS `causer-nick`,
1606 `causer`.`thumb` AS `causer-avatar`,
1607 `causer`.`network` AS `causer-network`,
1608 `causer`.`blocked` AS `causer-blocked`,
1609 `causer`.`hidden` AS `causer-hidden`,
1610 `causer`.`contact-type` AS `causer-contact-type`,
1611 `post-delivery-data`.`postopts` AS `postopts`,
1612 `post-delivery-data`.`inform` AS `inform`,
1613 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1614 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1615 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1616 IF (`item`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1617 IF (`item`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1618 IF (`item`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1619 IF (`item`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1620 `item`.`event-id` AS `event-id`,
1621 `event`.`created` AS `event-created`,
1622 `event`.`edited` AS `event-edited`,
1623 `event`.`start` AS `event-start`,
1624 `event`.`finish` AS `event-finish`,
1625 `event`.`summary` AS `event-summary`,
1626 `event`.`desc` AS `event-desc`,
1627 `event`.`location` AS `event-location`,
1628 `event`.`type` AS `event-type`,
1629 `event`.`nofinish` AS `event-nofinish`,
1630 `event`.`adjust` AS `event-adjust`,
1631 `event`.`ignore` AS `event-ignore`,
1632 `diaspora-interaction`.`interaction` AS `signed_text`,
1633 `parent-item`.`guid` AS `parent-guid`,
1634 `parent-item`.`network` AS `parent-network`,
1635 `parent-item`.`author-id` AS `parent-author-id`,
1636 `parent-item-author`.`url` AS `parent-author-link`,
1637 `parent-item-author`.`name` AS `parent-author-name`,
1638 `parent-item-author`.`network` AS `parent-author-network`
1640 LEFT JOIN `post-user` ON `post-user`.`uri-id` = `item`.`uri-id` AND `post-user`.`uid` = `item`.`uid`
1641 STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
1642 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `item`.`author-id`
1643 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `item`.`owner-id`
1644 STRAIGHT_JOIN `contact` AS `causer` ON `causer`.`id` = `item`.`causer-id`
1645 LEFT JOIN `verb` ON `verb`.`id` = `item`.`vid`
1646 LEFT JOIN `event` ON `event`.`id` = `item`.`event-id`
1647 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `item`.`uri-id`
1648 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `item`.`uri-id`
1649 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `item`.`uri-id` AND `item`.`origin`
1650 LEFT JOIN `permissionset` ON `permissionset`.`id` = `item`.`psid`
1651 STRAIGHT_JOIN `item` AS `parent-item` ON `parent-item`.`uri-id` = `item`.`parent-uri-id` AND `parent-item`.`uid` = `item`.`uid`
1652 STRAIGHT_JOIN `contact` AS `parent-item-author` ON `parent-item-author`.`id` = `parent-item`.`author-id`;
1655 -- VIEW post-thread-view
1657 DROP VIEW IF EXISTS `post-thread-view`;
1658 CREATE VIEW `post-thread-view` AS SELECT
1659 `item`.`id` AS `id`,
1660 `thread`.`iid` AS `iid`,
1661 `item`.`id` AS `item_id`,
1662 `thread`.`uid` AS `uid`,
1663 `item`.`parent` AS `parent`,
1664 `item`.`uri` AS `uri`,
1665 `item`.`uri-id` AS `uri-id`,
1666 `item`.`parent-uri` AS `parent-uri`,
1667 `item`.`parent-uri-id` AS `parent-uri-id`,
1668 `item`.`thr-parent` AS `thr-parent`,
1669 `item`.`thr-parent-id` AS `thr-parent-id`,
1670 `item`.`guid` AS `guid`,
1671 `item`.`type` AS `type`,
1672 `thread`.`wall` AS `wall`,
1673 `item`.`gravity` AS `gravity`,
1674 `item`.`extid` AS `extid`,
1675 `thread`.`created` AS `created`,
1676 `item`.`edited` AS `edited`,
1677 `thread`.`commented` AS `commented`,
1678 `thread`.`received` AS `received`,
1679 `thread`.`changed` AS `changed`,
1680 `thread`.`post-type` AS `post-type`,
1681 `thread`.`private` AS `private`,
1682 `thread`.`pubmail` AS `pubmail`,
1683 `thread`.`moderated` AS `moderated`,
1684 `thread`.`ignored` AS `ignored`,
1685 `thread`.`visible` AS `visible`,
1686 `thread`.`starred` AS `starred`,
1687 `item`.`bookmark` AS `bookmark`,
1688 `item`.`unseen` AS `unseen`,
1689 `thread`.`deleted` AS `deleted`,
1690 `thread`.`origin` AS `origin`,
1691 `thread`.`forum_mode` AS `forum_mode`,
1692 `thread`.`mention` AS `mention`,
1693 `item`.`global` AS `global`,
1694 `thread`.`network` AS `network`,
1695 `item`.`vid` AS `vid`,
1696 `item`.`psid` AS `psid`,
1697 IF (`item`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1698 `post-content`.`title` AS `title`,
1699 `post-content`.`content-warning` AS `content-warning`,
1700 `post-content`.`raw-body` AS `raw-body`,
1701 `post-content`.`body` AS `body`,
1702 `post-content`.`rendered-hash` AS `rendered-hash`,
1703 `post-content`.`rendered-html` AS `rendered-html`,
1704 `post-content`.`language` AS `language`,
1705 `post-content`.`plink` AS `plink`,
1706 `post-content`.`location` AS `location`,
1707 `post-content`.`coord` AS `coord`,
1708 `post-content`.`app` AS `app`,
1709 `post-content`.`object-type` AS `object-type`,
1710 `post-content`.`object` AS `object`,
1711 `post-content`.`target-type` AS `target-type`,
1712 `post-content`.`target` AS `target`,
1713 `post-content`.`resource-id` AS `resource-id`,
1714 `thread`.`contact-id` AS `contact-id`,
1715 `contact`.`url` AS `contact-link`,
1716 `contact`.`addr` AS `contact-addr`,
1717 `contact`.`name` AS `contact-name`,
1718 `contact`.`nick` AS `contact-nick`,
1719 `contact`.`thumb` AS `contact-avatar`,
1720 `contact`.`network` AS `contact-network`,
1721 `contact`.`blocked` AS `contact-blocked`,
1722 `contact`.`hidden` AS `contact-hidden`,
1723 `contact`.`readonly` AS `contact-readonly`,
1724 `contact`.`archive` AS `contact-archive`,
1725 `contact`.`pending` AS `contact-pending`,
1726 `contact`.`rel` AS `contact-rel`,
1727 `contact`.`uid` AS `contact-uid`,
1728 `contact`.`contact-type` AS `contact-contact-type`,
1729 IF (`item`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1730 `contact`.`self` AS `self`,
1731 `contact`.`id` AS `cid`,
1732 `contact`.`alias` AS `alias`,
1733 `contact`.`photo` AS `photo`,
1734 `contact`.`name-date` AS `name-date`,
1735 `contact`.`uri-date` AS `uri-date`,
1736 `contact`.`avatar-date` AS `avatar-date`,
1737 `contact`.`thumb` AS `thumb`,
1738 `contact`.`dfrn-id` AS `dfrn-id`,
1739 `thread`.`author-id` AS `author-id`,
1740 `author`.`url` AS `author-link`,
1741 `author`.`addr` AS `author-addr`,
1742 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1743 `author`.`nick` AS `author-nick`,
1744 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1745 `author`.`network` AS `author-network`,
1746 `author`.`blocked` AS `author-blocked`,
1747 `author`.`hidden` AS `author-hidden`,
1748 `thread`.`owner-id` AS `owner-id`,
1749 `owner`.`url` AS `owner-link`,
1750 `owner`.`addr` AS `owner-addr`,
1751 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1752 `owner`.`nick` AS `owner-nick`,
1753 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1754 `owner`.`network` AS `owner-network`,
1755 `owner`.`blocked` AS `owner-blocked`,
1756 `owner`.`hidden` AS `owner-hidden`,
1757 `item`.`causer-id` AS `causer-id`,
1758 `causer`.`url` AS `causer-link`,
1759 `causer`.`addr` AS `causer-addr`,
1760 `causer`.`name` AS `causer-name`,
1761 `causer`.`nick` AS `causer-nick`,
1762 `causer`.`thumb` AS `causer-avatar`,
1763 `causer`.`network` AS `causer-network`,
1764 `causer`.`blocked` AS `causer-blocked`,
1765 `causer`.`hidden` AS `causer-hidden`,
1766 `causer`.`contact-type` AS `causer-contact-type`,
1767 `post-delivery-data`.`postopts` AS `postopts`,
1768 `post-delivery-data`.`inform` AS `inform`,
1769 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1770 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1771 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1772 IF (`item`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1773 IF (`item`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1774 IF (`item`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1775 IF (`item`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1776 `item`.`event-id` AS `event-id`,
1777 `event`.`created` AS `event-created`,
1778 `event`.`edited` AS `event-edited`,
1779 `event`.`start` AS `event-start`,
1780 `event`.`finish` AS `event-finish`,
1781 `event`.`summary` AS `event-summary`,
1782 `event`.`desc` AS `event-desc`,
1783 `event`.`location` AS `event-location`,
1784 `event`.`type` AS `event-type`,
1785 `event`.`nofinish` AS `event-nofinish`,
1786 `event`.`adjust` AS `event-adjust`,
1787 `event`.`ignore` AS `event-ignore`,
1788 `diaspora-interaction`.`interaction` AS `signed_text`,
1789 `parent-item`.`guid` AS `parent-guid`,
1790 `parent-item`.`network` AS `parent-network`,
1791 `parent-item`.`author-id` AS `parent-author-id`,
1792 `parent-item-author`.`url` AS `parent-author-link`,
1793 `parent-item-author`.`name` AS `parent-author-name`,
1794 `parent-item-author`.`network` AS `parent-author-network`
1796 STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
1797 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
1798 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `thread`.`author-id`
1799 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `thread`.`owner-id`
1800 STRAIGHT_JOIN `contact` AS `causer` ON `causer`.`id` = `item`.`causer-id`
1801 LEFT JOIN `verb` ON `verb`.`id` = `item`.`vid`
1802 LEFT JOIN `event` ON `event`.`id` = `item`.`event-id`
1803 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `thread`.`uri-id`
1804 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `thread`.`uri-id`
1805 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `thread`.`uri-id` AND `thread`.`origin`
1806 LEFT JOIN `permissionset` ON `permissionset`.`id` = `item`.`psid`
1807 STRAIGHT_JOIN `item` AS `parent-item` ON `parent-item`.`id` = `item`.`parent`
1808 STRAIGHT_JOIN `contact` AS `parent-item-author` ON `parent-item-author`.`id` = `parent-item`.`author-id`;
1811 -- VIEW category-view
1813 DROP VIEW IF EXISTS `category-view`;
1814 CREATE VIEW `category-view` AS SELECT
1815 `post-category`.`uri-id` AS `uri-id`,
1816 `post-category`.`uid` AS `uid`,
1817 `item-uri`.`uri` AS `uri`,
1818 `item-uri`.`guid` AS `guid`,
1819 `post-category`.`type` AS `type`,
1820 `post-category`.`tid` AS `tid`,
1821 `tag`.`name` AS `name`,
1822 `tag`.`url` AS `url`
1823 FROM `post-category`
1824 INNER JOIN `item-uri` ON `item-uri`.id = `post-category`.`uri-id`
1825 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
1830 DROP VIEW IF EXISTS `tag-view`;
1831 CREATE VIEW `tag-view` AS SELECT
1832 `post-tag`.`uri-id` AS `uri-id`,
1833 `item-uri`.`uri` AS `uri`,
1834 `item-uri`.`guid` AS `guid`,
1835 `post-tag`.`type` AS `type`,
1836 `post-tag`.`tid` AS `tid`,
1837 `post-tag`.`cid` AS `cid`,
1838 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
1839 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
1841 INNER JOIN `item-uri` ON `item-uri`.id = `post-tag`.`uri-id`
1842 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
1843 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
1846 -- VIEW network-item-view
1848 DROP VIEW IF EXISTS `network-item-view`;
1849 CREATE VIEW `network-item-view` AS SELECT
1850 `item`.`parent-uri-id` AS `uri-id`,
1851 `item`.`parent-uri` AS `uri`,
1852 `item`.`parent` AS `parent`,
1853 `item`.`received` AS `received`,
1854 `item`.`commented` AS `commented`,
1855 `item`.`created` AS `created`,
1856 `item`.`uid` AS `uid`,
1857 `item`.`starred` AS `starred`,
1858 `item`.`mention` AS `mention`,
1859 `item`.`network` AS `network`,
1860 `item`.`unseen` AS `unseen`,
1861 `item`.`gravity` AS `gravity`,
1862 `item`.`contact-id` AS `contact-id`,
1863 `ownercontact`.`contact-type` AS `contact-type`
1865 INNER JOIN `thread` ON `thread`.`iid` = `item`.`parent`
1866 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
1867 LEFT JOIN `post-user` ON `post-user`.`uri-id` = `item`.`uri-id` AND `post-user`.`uid` = `thread`.`uid`
1868 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
1869 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
1870 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
1871 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
1872 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
1873 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
1874 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
1875 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
1878 -- VIEW network-thread-view
1880 DROP VIEW IF EXISTS `network-thread-view`;
1881 CREATE VIEW `network-thread-view` AS SELECT
1882 `item`.`uri-id` AS `uri-id`,
1883 `item`.`uri` AS `uri`,
1884 `item`.`parent-uri-id` AS `parent-uri-id`,
1885 `thread`.`iid` AS `parent`,
1886 `thread`.`received` AS `received`,
1887 `thread`.`commented` AS `commented`,
1888 `thread`.`created` AS `created`,
1889 `thread`.`uid` AS `uid`,
1890 `thread`.`starred` AS `starred`,
1891 `thread`.`mention` AS `mention`,
1892 `thread`.`network` AS `network`,
1893 `thread`.`contact-id` AS `contact-id`,
1894 `ownercontact`.`contact-type` AS `contact-type`
1896 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
1897 STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
1898 LEFT JOIN `post-user` ON `post-user`.`uri-id` = `item`.`uri-id` AND `post-user`.`uid` = `thread`.`uid`
1899 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
1900 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
1901 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
1902 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
1903 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
1904 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
1905 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
1906 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
1911 DROP VIEW IF EXISTS `owner-view`;
1912 CREATE VIEW `owner-view` AS SELECT
1913 `contact`.`id` AS `id`,
1914 `contact`.`uid` AS `uid`,
1915 `contact`.`created` AS `created`,
1916 `contact`.`updated` AS `updated`,
1917 `contact`.`self` AS `self`,
1918 `contact`.`remote_self` AS `remote_self`,
1919 `contact`.`rel` AS `rel`,
1920 `contact`.`duplex` AS `duplex`,
1921 `contact`.`network` AS `network`,
1922 `contact`.`protocol` AS `protocol`,
1923 `contact`.`name` AS `name`,
1924 `contact`.`nick` AS `nick`,
1925 `contact`.`location` AS `location`,
1926 `contact`.`about` AS `about`,
1927 `contact`.`keywords` AS `keywords`,
1928 `contact`.`gender` AS `gender`,
1929 `contact`.`xmpp` AS `xmpp`,
1930 `contact`.`attag` AS `attag`,
1931 `contact`.`avatar` AS `avatar`,
1932 `contact`.`photo` AS `photo`,
1933 `contact`.`thumb` AS `thumb`,
1934 `contact`.`micro` AS `micro`,
1935 `contact`.`site-pubkey` AS `site-pubkey`,
1936 `contact`.`issued-id` AS `issued-id`,
1937 `contact`.`dfrn-id` AS `dfrn-id`,
1938 `contact`.`url` AS `url`,
1939 `contact`.`nurl` AS `nurl`,
1940 `contact`.`addr` AS `addr`,
1941 `contact`.`alias` AS `alias`,
1942 `contact`.`pubkey` AS `pubkey`,
1943 `contact`.`prvkey` AS `prvkey`,
1944 `contact`.`batch` AS `batch`,
1945 `contact`.`request` AS `request`,
1946 `contact`.`notify` AS `notify`,
1947 `contact`.`poll` AS `poll`,
1948 `contact`.`confirm` AS `confirm`,
1949 `contact`.`poco` AS `poco`,
1950 `contact`.`aes_allow` AS `aes_allow`,
1951 `contact`.`ret-aes` AS `ret-aes`,
1952 `contact`.`usehub` AS `usehub`,
1953 `contact`.`subhub` AS `subhub`,
1954 `contact`.`hub-verify` AS `hub-verify`,
1955 `contact`.`last-update` AS `last-update`,
1956 `contact`.`success_update` AS `success_update`,
1957 `contact`.`failure_update` AS `failure_update`,
1958 `contact`.`name-date` AS `name-date`,
1959 `contact`.`uri-date` AS `uri-date`,
1960 `contact`.`avatar-date` AS `avatar-date`,
1961 `contact`.`avatar-date` AS `picdate`,
1962 `contact`.`term-date` AS `term-date`,
1963 `contact`.`last-item` AS `last-item`,
1964 `contact`.`priority` AS `priority`,
1965 `user`.`blocked` AS `blocked`,
1966 `contact`.`block_reason` AS `block_reason`,
1967 `contact`.`readonly` AS `readonly`,
1968 `contact`.`writable` AS `writable`,
1969 `contact`.`forum` AS `forum`,
1970 `contact`.`prv` AS `prv`,
1971 `contact`.`contact-type` AS `contact-type`,
1972 `contact`.`manually-approve` AS `manually-approve`,
1973 `contact`.`hidden` AS `hidden`,
1974 `contact`.`archive` AS `archive`,
1975 `contact`.`pending` AS `pending`,
1976 `contact`.`deleted` AS `deleted`,
1977 `contact`.`unsearchable` AS `unsearchable`,
1978 `contact`.`sensitive` AS `sensitive`,
1979 `contact`.`baseurl` AS `baseurl`,
1980 `contact`.`reason` AS `reason`,
1981 `contact`.`closeness` AS `closeness`,
1982 `contact`.`info` AS `info`,
1983 `contact`.`profile-id` AS `profile-id`,
1984 `contact`.`bdyear` AS `bdyear`,
1985 `contact`.`bd` AS `bd`,
1986 `contact`.`notify_new_posts` AS `notify_new_posts`,
1987 `contact`.`fetch_further_information` AS `fetch_further_information`,
1988 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
1989 `user`.`parent-uid` AS `parent-uid`,
1990 `user`.`guid` AS `guid`,
1991 `user`.`nickname` AS `nickname`,
1992 `user`.`email` AS `email`,
1993 `user`.`openid` AS `openid`,
1994 `user`.`timezone` AS `timezone`,
1995 `user`.`language` AS `language`,
1996 `user`.`register_date` AS `register_date`,
1997 `user`.`login_date` AS `login_date`,
1998 `user`.`default-location` AS `default-location`,
1999 `user`.`allow_location` AS `allow_location`,
2000 `user`.`theme` AS `theme`,
2001 `user`.`pubkey` AS `upubkey`,
2002 `user`.`prvkey` AS `uprvkey`,
2003 `user`.`sprvkey` AS `sprvkey`,
2004 `user`.`spubkey` AS `spubkey`,
2005 `user`.`verified` AS `verified`,
2006 `user`.`blockwall` AS `blockwall`,
2007 `user`.`hidewall` AS `hidewall`,
2008 `user`.`blocktags` AS `blocktags`,
2009 `user`.`unkmail` AS `unkmail`,
2010 `user`.`cntunkmail` AS `cntunkmail`,
2011 `user`.`notify-flags` AS `notify-flags`,
2012 `user`.`page-flags` AS `page-flags`,
2013 `user`.`account-type` AS `account-type`,
2014 `user`.`prvnets` AS `prvnets`,
2015 `user`.`maxreq` AS `maxreq`,
2016 `user`.`expire` AS `expire`,
2017 `user`.`account_removed` AS `account_removed`,
2018 `user`.`account_expired` AS `account_expired`,
2019 `user`.`account_expires_on` AS `account_expires_on`,
2020 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2021 `user`.`def_gid` AS `def_gid`,
2022 `user`.`allow_cid` AS `allow_cid`,
2023 `user`.`allow_gid` AS `allow_gid`,
2024 `user`.`deny_cid` AS `deny_cid`,
2025 `user`.`deny_gid` AS `deny_gid`,
2026 `user`.`openidserver` AS `openidserver`,
2027 `profile`.`publish` AS `publish`,
2028 `profile`.`net-publish` AS `net-publish`,
2029 `profile`.`hide-friends` AS `hide-friends`,
2030 `profile`.`prv_keywords` AS `prv_keywords`,
2031 `profile`.`pub_keywords` AS `pub_keywords`,
2032 `profile`.`address` AS `address`,
2033 `profile`.`locality` AS `locality`,
2034 `profile`.`region` AS `region`,
2035 `profile`.`postal-code` AS `postal-code`,
2036 `profile`.`country-name` AS `country-name`,
2037 `profile`.`homepage` AS `homepage`,
2038 `profile`.`dob` AS `dob`
2040 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2041 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2044 -- VIEW pending-view
2046 DROP VIEW IF EXISTS `pending-view`;
2047 CREATE VIEW `pending-view` AS SELECT
2048 `register`.`id` AS `id`,
2049 `register`.`hash` AS `hash`,
2050 `register`.`created` AS `created`,
2051 `register`.`uid` AS `uid`,
2052 `register`.`password` AS `password`,
2053 `register`.`language` AS `language`,
2054 `register`.`note` AS `note`,
2055 `contact`.`self` AS `self`,
2056 `contact`.`name` AS `name`,
2057 `contact`.`url` AS `url`,
2058 `contact`.`micro` AS `micro`,
2059 `user`.`email` AS `email`,
2060 `contact`.`nick` AS `nick`
2062 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2063 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2066 -- VIEW tag-search-view
2068 DROP VIEW IF EXISTS `tag-search-view`;
2069 CREATE VIEW `tag-search-view` AS SELECT
2070 `post-tag`.`uri-id` AS `uri-id`,
2071 `item`.`id` AS `iid`,
2072 `item`.`uri` AS `uri`,
2073 `item`.`guid` AS `guid`,
2074 `item`.`uid` AS `uid`,
2075 `item`.`private` AS `private`,
2076 `item`.`wall` AS `wall`,
2077 `item`.`origin` AS `origin`,
2078 `item`.`gravity` AS `gravity`,
2079 `item`.`received` AS `received`,
2080 `tag`.`name` AS `name`
2082 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
2083 INNER JOIN `item` ON `item`.`uri-id` = `post-tag`.`uri-id`
2084 WHERE `post-tag`.`type` = 1;
2087 -- VIEW workerqueue-view
2089 DROP VIEW IF EXISTS `workerqueue-view`;
2090 CREATE VIEW `workerqueue-view` AS SELECT
2091 `process`.`pid` AS `pid`,
2092 `workerqueue`.`priority` AS `priority`
2094 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
2095 WHERE NOT `workerqueue`.`done`;