1 -- ------------------------------------------
2 -- Friendica 2020.12-dev (Red Hot Poker)
3 -- DB_UPDATE_VERSION 1372
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 `platform` varchar(255) NOT NULL DEFAULT '' COMMENT '',
24 `relay-subscribe` boolean NOT NULL DEFAULT '0' COMMENT 'Has the server subscribed to the relay system',
25 `relay-scope` varchar(10) NOT NULL DEFAULT '' COMMENT 'The scope of messages that the server wants to get',
26 `detection-method` tinyint unsigned COMMENT 'Method that had been used to detect that server',
27 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
28 `last_poco_query` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
29 `last_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
30 `last_failure` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
31 `failed` boolean COMMENT 'Connection failed',
33 UNIQUE INDEX `nurl` (`nurl`(190))
34 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Global servers';
39 CREATE TABLE IF NOT EXISTS `contact` (
40 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
41 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
42 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
43 `updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last contact update',
44 `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
45 `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
46 `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
47 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
48 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network of the contact',
49 `protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
50 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
51 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
52 `location` varchar(255) DEFAULT '' COMMENT '',
53 `about` text COMMENT '',
54 `keywords` text COMMENT 'public keywords (interests) of the contact',
55 `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
56 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
57 `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
58 `avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '',
59 `photo` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
60 `thumb` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
61 `micro` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
62 `site-pubkey` text COMMENT '',
63 `issued-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
64 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
65 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
66 `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
67 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
68 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
69 `pubkey` text COMMENT 'RSA public key 4096 bit',
70 `prvkey` text COMMENT 'RSA private key 4096 bit',
71 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
72 `request` varchar(255) COMMENT '',
73 `notify` varchar(255) COMMENT '',
74 `poll` varchar(255) COMMENT '',
75 `confirm` varchar(255) COMMENT '',
76 `subscribe` varchar(255) COMMENT '',
77 `poco` varchar(255) COMMENT '',
78 `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT '',
79 `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT '',
80 `usehub` boolean NOT NULL DEFAULT '0' COMMENT '',
81 `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
82 `hub-verify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
83 `last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
84 `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
85 `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
86 `failed` boolean COMMENT 'Connection failed',
87 `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
88 `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
89 `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
90 `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
91 `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
92 `last-discovery` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last follower discovery',
93 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
94 `blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
95 `block_reason` text COMMENT 'Node-wide block reason',
96 `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
97 `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
98 `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum',
99 `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group',
100 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT '',
101 `manually-approve` boolean COMMENT '',
102 `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
103 `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
104 `pending` boolean NOT NULL DEFAULT '1' COMMENT '',
105 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
106 `rating` tinyint NOT NULL DEFAULT 0 COMMENT '',
107 `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
108 `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
109 `baseurl` varchar(255) DEFAULT '' COMMENT 'baseurl of the contact',
110 `gsid` int unsigned COMMENT 'Global Server ID',
111 `reason` text COMMENT '',
112 `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT '',
113 `info` mediumtext COMMENT '',
114 `profile-id` int unsigned COMMENT 'Deprecated',
115 `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
116 `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
117 `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
118 `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
119 `ffi_keyword_denylist` text COMMENT '',
121 INDEX `uid_name` (`uid`,`name`(190)),
122 INDEX `self_uid` (`self`,`uid`),
123 INDEX `alias_uid` (`alias`(96),`uid`),
124 INDEX `pending_uid` (`pending`,`uid`),
125 INDEX `blocked_uid` (`blocked`,`uid`),
126 INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
127 INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
128 INDEX `addr_uid` (`addr`(96),`uid`),
129 INDEX `nurl_uid` (`nurl`(96),`uid`),
130 INDEX `nick_uid` (`nick`(32),`uid`),
131 INDEX `attag_uid` (`attag`(96),`uid`),
132 INDEX `dfrn-id` (`dfrn-id`(64)),
133 INDEX `issued-id` (`issued-id`(64)),
134 INDEX `network_uid_lastupdate` (`network`,`uid`,`last-update`),
135 INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`),
136 INDEX `uid_lastitem` (`uid`,`last-item`),
137 INDEX `gsid` (`gsid`),
138 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
139 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
144 CREATE TABLE IF NOT EXISTS `item-uri` (
145 `id` int unsigned NOT NULL auto_increment,
146 `uri` varbinary(255) NOT NULL COMMENT 'URI of an item',
147 `guid` varbinary(255) COMMENT 'A unique identifier for an item',
149 UNIQUE INDEX `uri` (`uri`),
150 INDEX `guid` (`guid`)
151 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
156 CREATE TABLE IF NOT EXISTS `tag` (
157 `id` int unsigned NOT NULL auto_increment COMMENT '',
158 `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
159 `url` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
161 UNIQUE INDEX `type_name_url` (`name`,`url`),
163 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
168 CREATE TABLE IF NOT EXISTS `user` (
169 `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
170 `parent-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'The parent user that has full control about this user',
171 `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
172 `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
173 `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
174 `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
175 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
176 `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
177 `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
178 `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
179 `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
180 `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
181 `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
182 `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
183 `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
184 `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
185 `pubkey` text COMMENT 'RSA public key 4096 bit',
186 `prvkey` text COMMENT 'RSA private key 4096 bit',
187 `spubkey` text COMMENT '',
188 `sprvkey` text COMMENT '',
189 `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
190 `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
191 `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
192 `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unkown viewers',
193 `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
194 `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
195 `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
196 `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
197 `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
198 `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
199 `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
200 `pwdreset` varchar(255) COMMENT 'Password reset request token',
201 `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
202 `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
203 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
204 `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
205 `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
206 `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
207 `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
208 `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
209 `allow_cid` mediumtext COMMENT 'default permission for this user',
210 `allow_gid` mediumtext COMMENT 'default permission for this user',
211 `deny_cid` mediumtext COMMENT 'default permission for this user',
212 `deny_gid` mediumtext COMMENT 'default permission for this user',
213 `openidserver` text COMMENT '',
215 INDEX `nickname` (`nickname`(32))
216 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
221 CREATE TABLE IF NOT EXISTS `clients` (
222 `client_id` varchar(20) NOT NULL COMMENT '',
223 `pw` varchar(20) NOT NULL DEFAULT '' COMMENT '',
224 `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
225 `name` text COMMENT '',
226 `icon` text COMMENT '',
227 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
228 PRIMARY KEY(`client_id`),
230 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
231 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
234 -- TABLE permissionset
236 CREATE TABLE IF NOT EXISTS `permissionset` (
237 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
238 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
239 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
240 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
241 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
242 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
244 INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30))
245 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
248 -- TABLE 2fa_app_specific_password
250 CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
251 `id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
252 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
253 `description` varchar(255) COMMENT 'Description of the usage of the password',
254 `hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
255 `generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
256 `last_used` datetime COMMENT 'Datetime the password was last used',
258 INDEX `uid_description` (`uid`,`description`(190)),
259 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
260 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
263 -- TABLE 2fa_recovery_codes
265 CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
266 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
267 `code` varchar(50) NOT NULL COMMENT 'Recovery code string',
268 `generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
269 `used` datetime COMMENT 'Datetime the code was used',
270 PRIMARY KEY(`uid`,`code`),
271 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
272 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
277 CREATE TABLE IF NOT EXISTS `addon` (
278 `id` int unsigned NOT NULL auto_increment COMMENT '',
279 `name` varchar(50) NOT NULL DEFAULT '' COMMENT 'addon base (file)name',
280 `version` varchar(50) NOT NULL DEFAULT '' COMMENT 'currently unused',
281 `installed` boolean NOT NULL DEFAULT '0' COMMENT 'currently always 1',
282 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'currently unused',
283 `timestamp` int unsigned NOT NULL DEFAULT 0 COMMENT 'file timestamp to check for reloads',
284 `plugin_admin` boolean NOT NULL DEFAULT '0' COMMENT '1 = has admin config, 0 = has no admin config',
286 UNIQUE INDEX `name` (`name`)
287 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registered addons';
292 CREATE TABLE IF NOT EXISTS `apcontact` (
293 `url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
294 `uuid` varchar(255) COMMENT '',
295 `type` varchar(20) NOT NULL COMMENT '',
296 `following` varchar(255) COMMENT '',
297 `followers` varchar(255) COMMENT '',
298 `inbox` varchar(255) NOT NULL COMMENT '',
299 `outbox` varchar(255) COMMENT '',
300 `sharedinbox` varchar(255) COMMENT '',
301 `manually-approve` boolean COMMENT '',
302 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
303 `name` varchar(255) COMMENT '',
304 `about` text COMMENT '',
305 `photo` varchar(255) COMMENT '',
306 `addr` varchar(255) COMMENT '',
307 `alias` varchar(255) COMMENT '',
308 `pubkey` text COMMENT '',
309 `subscribe` varchar(255) COMMENT '',
310 `baseurl` varchar(255) COMMENT 'baseurl of the ap contact',
311 `gsid` int unsigned COMMENT 'Global Server ID',
312 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
313 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
314 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
315 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
316 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
318 INDEX `addr` (`addr`(32)),
319 INDEX `alias` (`alias`(190)),
320 INDEX `followers` (`followers`(190)),
321 INDEX `baseurl` (`baseurl`(190)),
322 INDEX `gsid` (`gsid`),
323 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
324 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
329 CREATE TABLE IF NOT EXISTS `attach` (
330 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
331 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
332 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
333 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
334 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
335 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
336 `data` longblob NOT NULL COMMENT 'file data',
337 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
338 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
339 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
340 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
341 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
342 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
343 `backend-class` tinytext COMMENT 'Storage backend class',
344 `backend-ref` text COMMENT 'Storage backend data reference',
347 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
348 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
353 CREATE TABLE IF NOT EXISTS `auth_codes` (
354 `id` varchar(40) NOT NULL COMMENT '',
355 `client_id` varchar(20) NOT NULL DEFAULT '' COMMENT '',
356 `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
357 `expires` int NOT NULL DEFAULT 0 COMMENT '',
358 `scope` varchar(250) NOT NULL DEFAULT '' COMMENT '',
360 INDEX `client_id` (`client_id`),
361 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE
362 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
367 CREATE TABLE IF NOT EXISTS `cache` (
368 `k` varbinary(255) NOT NULL COMMENT 'cache key',
369 `v` mediumtext COMMENT 'cached serialized value',
370 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
371 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
373 INDEX `k_expires` (`k`,`expires`)
374 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
379 CREATE TABLE IF NOT EXISTS `challenge` (
380 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
381 `challenge` varchar(255) NOT NULL DEFAULT '' COMMENT '',
382 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
383 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
384 `type` varchar(255) NOT NULL DEFAULT '' COMMENT '',
385 `last_update` varchar(255) NOT NULL DEFAULT '' COMMENT '',
387 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
392 CREATE TABLE IF NOT EXISTS `config` (
393 `id` int unsigned NOT NULL auto_increment COMMENT '',
394 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
395 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
396 `v` mediumtext COMMENT '',
398 UNIQUE INDEX `cat_k` (`cat`,`k`)
399 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
402 -- TABLE contact-relation
404 CREATE TABLE IF NOT EXISTS `contact-relation` (
405 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
406 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
407 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
408 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
409 `follows` boolean NOT NULL DEFAULT '0' COMMENT '',
410 PRIMARY KEY(`cid`,`relation-cid`),
411 INDEX `relation-cid` (`relation-cid`),
412 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
413 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
414 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
419 CREATE TABLE IF NOT EXISTS `conv` (
420 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
421 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
422 `recips` text COMMENT 'sender_handle;recipient_handle',
423 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
424 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
425 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
426 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
427 `subject` text COMMENT 'subject of initial message',
430 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
431 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
434 -- TABLE conversation
436 CREATE TABLE IF NOT EXISTS `conversation` (
437 `item-uri` varbinary(255) NOT NULL COMMENT 'Original URI of the item - unrelated to the table with the same name',
438 `reply-to-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'URI to which this item is a reply',
439 `conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI',
440 `conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link',
441 `protocol` tinyint unsigned NOT NULL DEFAULT 255 COMMENT 'The protocol of the item',
442 `direction` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'How the message arrived here: 1=push, 2=pull',
443 `source` mediumtext COMMENT 'Original source',
444 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Receiving date',
445 PRIMARY KEY(`item-uri`),
446 INDEX `conversation-uri` (`conversation-uri`),
447 INDEX `received` (`received`)
448 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Raw data and structure information for messages';
451 -- TABLE diaspora-interaction
453 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
454 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
455 `interaction` mediumtext COMMENT 'The Diaspora interaction',
456 PRIMARY KEY(`uri-id`),
457 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
458 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
463 CREATE TABLE IF NOT EXISTS `event` (
464 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
465 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
466 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
467 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
468 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
469 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
470 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
471 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
472 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
473 `summary` text COMMENT 'short description or title of the event',
474 `desc` text COMMENT 'event description',
475 `location` text COMMENT 'event location',
476 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
477 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
478 `adjust` boolean NOT NULL DEFAULT '1' COMMENT 'adjust to timezone of the recipient (0 or 1)',
479 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
480 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
481 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
482 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
483 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
485 INDEX `uid_start` (`uid`,`start`),
487 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
488 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
493 CREATE TABLE IF NOT EXISTS `fcontact` (
494 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
495 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
496 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
497 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
498 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
499 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
500 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
501 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
502 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
503 `notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
504 `poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
505 `confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
506 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
507 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
508 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
509 `pubkey` text COMMENT '',
510 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
512 INDEX `addr` (`addr`(32)),
513 UNIQUE INDEX `url` (`url`(190))
514 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
519 CREATE TABLE IF NOT EXISTS `fsuggest` (
520 `id` int unsigned NOT NULL auto_increment COMMENT '',
521 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
522 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
523 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
524 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
525 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
526 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
527 `note` text COMMENT '',
528 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
532 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
533 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
534 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
539 CREATE TABLE IF NOT EXISTS `group` (
540 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
541 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
542 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
543 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
544 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
547 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
548 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
551 -- TABLE group_member
553 CREATE TABLE IF NOT EXISTS `group_member` (
554 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
555 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
556 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
558 INDEX `contactid` (`contact-id`),
559 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
560 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
561 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
562 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
567 CREATE TABLE IF NOT EXISTS `gserver-tag` (
568 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
569 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
570 PRIMARY KEY(`gserver-id`,`tag`),
572 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
573 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
578 CREATE TABLE IF NOT EXISTS `hook` (
579 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
580 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
581 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
582 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
583 `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',
585 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
586 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
591 CREATE TABLE IF NOT EXISTS `host` (
592 `id` tinyint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
593 `name` varchar(128) NOT NULL DEFAULT '' COMMENT 'The hostname',
595 UNIQUE INDEX `name` (`name`)
596 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Hostname';
599 -- TABLE inbox-status
601 CREATE TABLE IF NOT EXISTS `inbox-status` (
602 `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
603 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
604 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
605 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
606 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
607 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
608 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
610 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
615 CREATE TABLE IF NOT EXISTS `intro` (
616 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
617 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
618 `fid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
619 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
620 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
621 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
622 `note` text COMMENT '',
623 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
624 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
625 `blocked` boolean NOT NULL DEFAULT '1' COMMENT '',
626 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
628 INDEX `contact-id` (`contact-id`),
630 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
631 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
632 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
637 CREATE TABLE IF NOT EXISTS `item` (
638 `id` int unsigned NOT NULL auto_increment,
639 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this item',
640 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
641 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
642 `uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
643 `parent` int unsigned NOT NULL DEFAULT 0 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',
644 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT 'uri of the parent to this item',
645 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
646 `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',
647 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
648 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
649 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
650 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last comment/reply to this item',
651 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
652 `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',
653 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
654 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
655 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
656 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
657 `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',
658 `icid` int unsigned COMMENT 'Id of the item-content table entry that contains the whole item content',
659 `iaid` int unsigned COMMENT 'Id of the item-activity table entry that contains the activity data',
660 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
661 `extid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
662 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
663 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
664 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
665 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
666 `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
667 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been deleted',
668 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
669 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
670 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
671 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
672 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
673 `starred` boolean NOT NULL DEFAULT '0' COMMENT 'item has been favourited',
674 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'item has not been seen',
675 `mention` boolean NOT NULL DEFAULT '0' COMMENT 'The owner of this item was mentioned in it',
676 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
677 `psid` int unsigned COMMENT 'ID of the permission set of this post',
678 `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',
679 `event-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Used to link to the event.id',
680 `attach` mediumtext COMMENT 'Deprecated',
681 `allow_cid` mediumtext COMMENT 'Deprecated',
682 `allow_gid` mediumtext COMMENT 'Deprecated',
683 `deny_cid` mediumtext COMMENT 'Deprecated',
684 `deny_gid` mediumtext COMMENT 'Deprecated',
685 `postopts` text COMMENT 'Deprecated',
686 `inform` mediumtext COMMENT 'Deprecated',
687 `type` varchar(20) COMMENT 'Deprecated',
688 `bookmark` boolean COMMENT 'Deprecated',
689 `file` mediumtext COMMENT 'Deprecated',
690 `location` varchar(255) COMMENT 'Deprecated',
691 `coord` varchar(255) COMMENT 'Deprecated',
692 `tag` mediumtext COMMENT 'Deprecated',
693 `plink` varchar(255) COMMENT 'Deprecated',
694 `title` varchar(255) COMMENT 'Deprecated',
695 `content-warning` varchar(255) COMMENT 'Deprecated',
696 `body` mediumtext COMMENT 'Deprecated',
697 `app` varchar(255) COMMENT 'Deprecated',
698 `verb` varchar(100) COMMENT 'Deprecated',
699 `object-type` varchar(100) COMMENT 'Deprecated',
700 `object` text COMMENT 'Deprecated',
701 `target-type` varchar(100) COMMENT 'Deprecated',
702 `target` text COMMENT 'Deprecated',
703 `author-name` varchar(255) COMMENT 'Deprecated',
704 `author-link` varchar(255) COMMENT 'Deprecated',
705 `author-avatar` varchar(255) COMMENT 'Deprecated',
706 `owner-name` varchar(255) COMMENT 'Deprecated',
707 `owner-link` varchar(255) COMMENT 'Deprecated',
708 `owner-avatar` varchar(255) COMMENT 'Deprecated',
709 `rendered-hash` varchar(32) COMMENT 'Deprecated',
710 `rendered-html` mediumtext COMMENT 'Deprecated',
712 INDEX `guid` (`guid`(191)),
713 INDEX `uri` (`uri`(191)),
714 INDEX `parent` (`parent`),
715 INDEX `parent-uri` (`parent-uri`(191)),
716 INDEX `extid` (`extid`(191)),
717 INDEX `uid_id` (`uid`,`id`),
718 INDEX `uid_contactid_id` (`uid`,`contact-id`,`id`),
719 INDEX `uid_received` (`uid`,`received`),
720 INDEX `uid_commented` (`uid`,`commented`),
721 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
722 INDEX `uid_network_received` (`uid`,`network`,`received`),
723 INDEX `uid_network_commented` (`uid`,`network`,`commented`),
724 INDEX `uid_thrparent` (`uid`,`thr-parent`(190)),
725 INDEX `uid_parenturi` (`uid`,`parent-uri`(190)),
726 INDEX `uid_contactid_received` (`uid`,`contact-id`,`received`),
727 INDEX `authorid_received` (`author-id`,`received`),
728 INDEX `ownerid` (`owner-id`),
729 INDEX `contact-id` (`contact-id`),
730 INDEX `uid_uri` (`uid`,`uri`(190)),
731 INDEX `resource-id` (`resource-id`),
732 INDEX `deleted_changed` (`deleted`,`changed`),
733 INDEX `uid_wall_changed` (`uid`,`wall`,`changed`),
734 INDEX `uid_unseen_wall` (`uid`,`unseen`,`wall`),
735 INDEX `mention_uid_id` (`mention`,`uid`,`id`),
736 INDEX `uid_eventid` (`uid`,`event-id`),
737 INDEX `icid` (`icid`),
738 INDEX `iaid` (`iaid`),
739 INDEX `psid_wall` (`psid`,`wall`),
740 INDEX `uri-id` (`uri-id`),
741 INDEX `parent-uri-id` (`parent-uri-id`),
742 INDEX `thr-parent-id` (`thr-parent-id`),
743 INDEX `causer-id` (`causer-id`),
744 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
745 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
746 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
747 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
748 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
749 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
752 -- TABLE item-activity
754 CREATE TABLE IF NOT EXISTS `item-activity` (
755 `id` int unsigned NOT NULL auto_increment,
756 `uri` varchar(255) COMMENT '',
757 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
758 `uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
759 `activity` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
761 UNIQUE INDEX `uri-hash` (`uri-hash`),
762 INDEX `uri` (`uri`(191)),
763 INDEX `uri-id` (`uri-id`),
764 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
765 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activities for items';
768 -- TABLE item-content
770 CREATE TABLE IF NOT EXISTS `item-content` (
771 `id` int unsigned NOT NULL auto_increment,
772 `uri` varchar(255) COMMENT '',
773 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
774 `uri-plink-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
775 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
776 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
777 `body` mediumtext COMMENT 'item body content',
778 `raw-body` mediumtext COMMENT 'Body without embedded media links',
779 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
780 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
781 `language` text COMMENT 'Language information about this post',
782 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
783 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
784 `rendered-html` mediumtext COMMENT 'item.body converted to html',
785 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
786 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
787 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
788 `target` text COMMENT 'JSON encoded target structure if used',
789 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
790 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams verb',
792 UNIQUE INDEX `uri-plink-hash` (`uri-plink-hash`),
793 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
794 INDEX `uri` (`uri`(191)),
795 INDEX `plink` (`plink`(191)),
796 INDEX `uri-id` (`uri-id`),
797 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
798 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content 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) NOT NULL DEFAULT '' COMMENT 'contact.id',
824 `convid` int unsigned NOT NULL DEFAULT 0 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 NOT NULL DEFAULT 0 COMMENT 'item.id',
893 `parent` int unsigned NOT NULL DEFAULT 0 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 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
906 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
909 -- TABLE notify-threads
911 CREATE TABLE IF NOT EXISTS `notify-threads` (
912 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
913 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
914 `master-parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
915 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
916 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
917 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
919 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
920 INDEX `receiver-uid` (`receiver-uid`),
921 INDEX `notify-id` (`notify-id`),
922 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
923 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
924 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
929 CREATE TABLE IF NOT EXISTS `oembed` (
930 `url` varbinary(255) NOT NULL COMMENT 'page url',
931 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
932 `content` mediumtext COMMENT 'OEmbed data of the page',
933 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
934 PRIMARY KEY(`url`,`maxwidth`),
935 INDEX `created` (`created`)
936 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
939 -- TABLE openwebauth-token
941 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
942 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
943 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
944 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
945 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
946 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
947 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
950 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
955 CREATE TABLE IF NOT EXISTS `parsed_url` (
956 `url` varbinary(255) NOT NULL COMMENT 'page url',
957 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
958 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
959 `content` mediumtext COMMENT 'page data',
960 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
961 PRIMARY KEY(`url`,`guessing`,`oembed`),
962 INDEX `created` (`created`)
963 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
966 -- TABLE participation
968 CREATE TABLE IF NOT EXISTS `participation` (
969 `iid` int unsigned NOT NULL COMMENT '',
970 `server` varchar(60) NOT NULL COMMENT '',
971 `cid` int unsigned NOT NULL COMMENT '',
972 `fid` int unsigned NOT NULL COMMENT '',
973 PRIMARY KEY(`iid`,`server`),
976 FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
977 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
978 FOREIGN KEY (`fid`) REFERENCES `fcontact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
979 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Storage for participation messages from Diaspora';
984 CREATE TABLE IF NOT EXISTS `pconfig` (
985 `id` int unsigned NOT NULL auto_increment COMMENT '',
986 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
987 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
988 `k` varbinary(100) NOT NULL DEFAULT '' COMMENT '',
989 `v` mediumtext COMMENT '',
991 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
992 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
993 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
998 CREATE TABLE IF NOT EXISTS `photo` (
999 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1000 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1001 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1002 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
1003 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
1004 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
1005 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
1006 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1007 `desc` text COMMENT '',
1008 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
1009 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1010 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
1011 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1012 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1013 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1014 `data` mediumblob NOT NULL COMMENT '',
1015 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1016 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
1017 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
1018 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
1019 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
1020 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
1021 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
1022 `backend-class` tinytext COMMENT 'Storage backend class',
1023 `backend-ref` text COMMENT 'Storage backend data reference',
1024 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1026 INDEX `contactid` (`contact-id`),
1027 INDEX `uid_contactid` (`uid`,`contact-id`),
1028 INDEX `uid_profile` (`uid`,`profile`),
1029 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
1030 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
1031 INDEX `resource-id` (`resource-id`),
1032 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1033 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1036 -- TABLE post-category
1038 CREATE TABLE IF NOT EXISTS `post-category` (
1039 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1040 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1041 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1042 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1043 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1044 INDEX `uri-id` (`tid`),
1045 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1046 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1047 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1050 -- TABLE post-delivery-data
1052 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1053 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1054 `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',
1055 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1056 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1057 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1058 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1059 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1060 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1061 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1062 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1063 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1064 PRIMARY KEY(`uri-id`),
1065 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1066 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1071 CREATE TABLE IF NOT EXISTS `post-media` (
1072 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1073 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1074 `url` varbinary(511) NOT NULL COMMENT 'Media URL',
1075 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1076 `mimetype` varchar(60) COMMENT '',
1077 `height` smallint unsigned COMMENT 'Height of the media',
1078 `width` smallint unsigned COMMENT 'Width of the media',
1079 `size` int unsigned COMMENT 'Media size',
1080 `preview` varbinary(255) COMMENT 'Preview URL',
1081 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1082 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1083 `description` text COMMENT '',
1085 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1086 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1087 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1092 CREATE TABLE IF NOT EXISTS `post-tag` (
1093 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1094 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1095 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1096 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1097 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1098 INDEX `tid` (`tid`),
1099 INDEX `cid` (`cid`),
1100 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1101 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1102 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1103 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1108 CREATE TABLE IF NOT EXISTS `process` (
1109 `pid` int unsigned NOT NULL COMMENT '',
1110 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1111 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1113 INDEX `command` (`command`)
1114 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1119 CREATE TABLE IF NOT EXISTS `profile` (
1120 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1121 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1122 `profile-name` varchar(255) COMMENT 'Deprecated',
1123 `is-default` boolean COMMENT 'Deprecated',
1124 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1125 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1126 `pdesc` varchar(255) COMMENT 'Deprecated',
1127 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1128 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1129 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1130 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1131 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1132 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1133 `hometown` varchar(255) COMMENT 'Deprecated',
1134 `gender` varchar(32) COMMENT 'Deprecated',
1135 `marital` varchar(255) COMMENT 'Deprecated',
1136 `with` text COMMENT 'Deprecated',
1137 `howlong` datetime COMMENT 'Deprecated',
1138 `sexual` varchar(255) COMMENT 'Deprecated',
1139 `politic` varchar(255) COMMENT 'Deprecated',
1140 `religion` varchar(255) COMMENT 'Deprecated',
1141 `pub_keywords` text COMMENT '',
1142 `prv_keywords` text COMMENT '',
1143 `likes` text COMMENT 'Deprecated',
1144 `dislikes` text COMMENT 'Deprecated',
1145 `about` text COMMENT 'Profile description',
1146 `summary` varchar(255) COMMENT 'Deprecated',
1147 `music` text COMMENT 'Deprecated',
1148 `book` text COMMENT 'Deprecated',
1149 `tv` text COMMENT 'Deprecated',
1150 `film` text COMMENT 'Deprecated',
1151 `interest` text COMMENT 'Deprecated',
1152 `romance` text COMMENT 'Deprecated',
1153 `work` text COMMENT 'Deprecated',
1154 `education` text COMMENT 'Deprecated',
1155 `contact` text COMMENT 'Deprecated',
1156 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1157 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1158 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1159 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1160 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1161 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1163 INDEX `uid_is-default` (`uid`,`is-default`),
1164 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1165 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1166 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1169 -- TABLE profile_check
1171 CREATE TABLE IF NOT EXISTS `profile_check` (
1172 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1173 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1174 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1175 `dfrn_id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1176 `sec` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1177 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1179 INDEX `uid` (`uid`),
1180 INDEX `cid` (`cid`),
1181 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1182 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1183 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='DFRN remote auth use';
1186 -- TABLE profile_field
1188 CREATE TABLE IF NOT EXISTS `profile_field` (
1189 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1190 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1191 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1192 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1193 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1194 `value` text COMMENT 'Value of the field',
1195 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1196 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1198 INDEX `uid` (`uid`),
1199 INDEX `order` (`order`),
1200 INDEX `psid` (`psid`),
1201 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1202 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1203 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1206 -- TABLE push_subscriber
1208 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1209 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1210 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1211 `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1212 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1213 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1214 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1215 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1216 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1217 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1218 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1220 INDEX `next_try` (`next_try`),
1221 INDEX `uid` (`uid`),
1222 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1223 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1228 CREATE TABLE IF NOT EXISTS `register` (
1229 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1230 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1231 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1232 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1233 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1234 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1235 `note` text COMMENT '',
1237 INDEX `uid` (`uid`),
1238 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1239 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1244 CREATE TABLE IF NOT EXISTS `search` (
1245 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1246 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1247 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1249 INDEX `uid` (`uid`),
1250 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1251 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1256 CREATE TABLE IF NOT EXISTS `session` (
1257 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1258 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1259 `data` text COMMENT '',
1260 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1262 INDEX `sid` (`sid`(64)),
1263 INDEX `expire` (`expire`)
1264 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1269 CREATE TABLE IF NOT EXISTS `storage` (
1270 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1271 `data` longblob NOT NULL COMMENT 'file data',
1273 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1278 CREATE TABLE IF NOT EXISTS `thread` (
1279 `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'sequential ID',
1280 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
1281 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1282 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1283 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1284 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1285 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1286 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1287 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1288 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1289 `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1290 `wall` boolean NOT NULL DEFAULT '0' COMMENT '',
1291 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1292 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1293 `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
1294 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1295 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1296 `ignored` boolean NOT NULL DEFAULT '0' COMMENT '',
1297 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
1298 `unseen` boolean NOT NULL DEFAULT '1' COMMENT '',
1299 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '',
1300 `origin` boolean NOT NULL DEFAULT '0' COMMENT '',
1301 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1302 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1303 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1304 `bookmark` boolean COMMENT '',
1306 INDEX `uid_network_commented` (`uid`,`network`,`commented`),
1307 INDEX `uid_network_received` (`uid`,`network`,`received`),
1308 INDEX `uid_contactid_commented` (`uid`,`contact-id`,`commented`),
1309 INDEX `uid_contactid_received` (`uid`,`contact-id`,`received`),
1310 INDEX `contactid` (`contact-id`),
1311 INDEX `ownerid` (`owner-id`),
1312 INDEX `authorid` (`author-id`),
1313 INDEX `uid_received` (`uid`,`received`),
1314 INDEX `uid_commented` (`uid`,`commented`),
1315 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1316 INDEX `private_wall_origin_commented` (`private`,`wall`,`origin`,`commented`),
1317 INDEX `uri-id` (`uri-id`),
1318 FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1319 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1320 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1325 CREATE TABLE IF NOT EXISTS `tokens` (
1326 `id` varchar(40) NOT NULL COMMENT '',
1327 `secret` text COMMENT '',
1328 `client_id` varchar(20) NOT NULL DEFAULT '',
1329 `expires` int NOT NULL DEFAULT 0 COMMENT '',
1330 `scope` varchar(200) NOT NULL DEFAULT '' COMMENT '',
1331 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1333 INDEX `client_id` (`client_id`),
1334 INDEX `uid` (`uid`),
1335 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1336 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1337 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
1342 CREATE TABLE IF NOT EXISTS `userd` (
1343 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1344 `username` varchar(255) NOT NULL COMMENT '',
1346 INDEX `username` (`username`(32))
1347 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1350 -- TABLE user-contact
1352 CREATE TABLE IF NOT EXISTS `user-contact` (
1353 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1354 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1355 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1356 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1357 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1358 PRIMARY KEY(`uid`,`cid`),
1359 INDEX `cid` (`cid`),
1360 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1361 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1362 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1367 CREATE TABLE IF NOT EXISTS `user-item` (
1368 `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item id',
1369 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1370 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide an item from the user',
1371 `ignored` boolean COMMENT 'Ignore this thread if set',
1372 `pinned` boolean COMMENT 'The item is pinned on the profile page',
1373 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1374 PRIMARY KEY(`uid`,`iid`),
1375 INDEX `uid_pinned` (`uid`,`pinned`),
1376 INDEX `iid_uid` (`iid`,`uid`),
1377 FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1378 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1379 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific item data';
1384 CREATE TABLE IF NOT EXISTS `verb` (
1385 `id` smallint unsigned NOT NULL auto_increment,
1386 `name` varchar(100) NOT NULL DEFAULT '' COMMENT '',
1388 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activity Verbs';
1393 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1394 `key` int NOT NULL COMMENT '',
1395 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1397 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1400 -- TABLE workerqueue
1402 CREATE TABLE IF NOT EXISTS `workerqueue` (
1403 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
1404 `parameter` mediumtext COMMENT 'Task command',
1405 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
1406 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
1407 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
1408 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
1409 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1410 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1411 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
1413 INDEX `done_parameter` (`done`,`parameter`(64)),
1414 INDEX `done_executed` (`done`,`executed`),
1415 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
1416 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
1417 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
1418 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
1419 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
1420 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
1423 -- VIEW category-view
1425 DROP VIEW IF EXISTS `category-view`;
1426 CREATE VIEW `category-view` AS SELECT
1427 `post-category`.`uri-id` AS `uri-id`,
1428 `post-category`.`uid` AS `uid`,
1429 `item-uri`.`uri` AS `uri`,
1430 `item-uri`.`guid` AS `guid`,
1431 `post-category`.`type` AS `type`,
1432 `post-category`.`tid` AS `tid`,
1433 `tag`.`name` AS `name`,
1434 `tag`.`url` AS `url`
1435 FROM `post-category`
1436 INNER JOIN `item-uri` ON `item-uri`.id = `post-category`.`uri-id`
1437 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
1442 DROP VIEW IF EXISTS `tag-view`;
1443 CREATE VIEW `tag-view` AS SELECT
1444 `post-tag`.`uri-id` AS `uri-id`,
1445 `item-uri`.`uri` AS `uri`,
1446 `item-uri`.`guid` AS `guid`,
1447 `post-tag`.`type` AS `type`,
1448 `post-tag`.`tid` AS `tid`,
1449 `post-tag`.`cid` AS `cid`,
1450 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
1451 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
1453 INNER JOIN `item-uri` ON `item-uri`.id = `post-tag`.`uri-id`
1454 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
1455 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
1458 -- VIEW network-item-view
1460 DROP VIEW IF EXISTS `network-item-view`;
1461 CREATE VIEW `network-item-view` AS SELECT
1462 `item`.`parent-uri-id` AS `uri-id`,
1463 `item`.`parent-uri` AS `uri`,
1464 `item`.`parent` AS `parent`,
1465 `item`.`received` AS `received`,
1466 `item`.`commented` AS `commented`,
1467 `item`.`created` AS `created`,
1468 `item`.`uid` AS `uid`,
1469 `item`.`starred` AS `starred`,
1470 `item`.`mention` AS `mention`,
1471 `item`.`network` AS `network`,
1472 `item`.`unseen` AS `unseen`,
1473 `item`.`gravity` AS `gravity`,
1474 `item`.`contact-id` AS `contact-id`,
1475 `ownercontact`.`contact-type` AS `contact-type`
1477 INNER JOIN `thread` ON `thread`.`iid` = `item`.`parent`
1478 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
1479 LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
1480 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
1481 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
1482 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
1483 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
1484 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
1485 AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
1486 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
1487 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
1490 -- VIEW network-thread-view
1492 DROP VIEW IF EXISTS `network-thread-view`;
1493 CREATE VIEW `network-thread-view` AS SELECT
1494 `item`.`uri-id` AS `uri-id`,
1495 `item`.`uri` AS `uri`,
1496 `item`.`parent-uri-id` AS `parent-uri-id`,
1497 `thread`.`iid` AS `parent`,
1498 `thread`.`received` AS `received`,
1499 `thread`.`commented` AS `commented`,
1500 `thread`.`created` AS `created`,
1501 `thread`.`uid` AS `uid`,
1502 `thread`.`starred` AS `starred`,
1503 `thread`.`mention` AS `mention`,
1504 `thread`.`network` AS `network`,
1505 `thread`.`contact-id` AS `contact-id`,
1506 `ownercontact`.`contact-type` AS `contact-type`
1508 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
1509 STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
1510 LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
1511 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
1512 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
1513 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
1514 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
1515 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
1516 AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
1517 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
1518 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
1523 DROP VIEW IF EXISTS `owner-view`;
1524 CREATE VIEW `owner-view` AS SELECT
1525 `contact`.`id` AS `id`,
1526 `contact`.`uid` AS `uid`,
1527 `contact`.`created` AS `created`,
1528 `contact`.`updated` AS `updated`,
1529 `contact`.`self` AS `self`,
1530 `contact`.`remote_self` AS `remote_self`,
1531 `contact`.`rel` AS `rel`,
1532 `contact`.`duplex` AS `duplex`,
1533 `contact`.`network` AS `network`,
1534 `contact`.`protocol` AS `protocol`,
1535 `contact`.`name` AS `name`,
1536 `contact`.`nick` AS `nick`,
1537 `contact`.`location` AS `location`,
1538 `contact`.`about` AS `about`,
1539 `contact`.`keywords` AS `keywords`,
1540 `contact`.`gender` AS `gender`,
1541 `contact`.`xmpp` AS `xmpp`,
1542 `contact`.`attag` AS `attag`,
1543 `contact`.`avatar` AS `avatar`,
1544 `contact`.`photo` AS `photo`,
1545 `contact`.`thumb` AS `thumb`,
1546 `contact`.`micro` AS `micro`,
1547 `contact`.`site-pubkey` AS `site-pubkey`,
1548 `contact`.`issued-id` AS `issued-id`,
1549 `contact`.`dfrn-id` AS `dfrn-id`,
1550 `contact`.`url` AS `url`,
1551 `contact`.`nurl` AS `nurl`,
1552 `contact`.`addr` AS `addr`,
1553 `contact`.`alias` AS `alias`,
1554 `contact`.`pubkey` AS `pubkey`,
1555 `contact`.`prvkey` AS `prvkey`,
1556 `contact`.`batch` AS `batch`,
1557 `contact`.`request` AS `request`,
1558 `contact`.`notify` AS `notify`,
1559 `contact`.`poll` AS `poll`,
1560 `contact`.`confirm` AS `confirm`,
1561 `contact`.`poco` AS `poco`,
1562 `contact`.`aes_allow` AS `aes_allow`,
1563 `contact`.`ret-aes` AS `ret-aes`,
1564 `contact`.`usehub` AS `usehub`,
1565 `contact`.`subhub` AS `subhub`,
1566 `contact`.`hub-verify` AS `hub-verify`,
1567 `contact`.`last-update` AS `last-update`,
1568 `contact`.`success_update` AS `success_update`,
1569 `contact`.`failure_update` AS `failure_update`,
1570 `contact`.`name-date` AS `name-date`,
1571 `contact`.`uri-date` AS `uri-date`,
1572 `contact`.`avatar-date` AS `avatar-date`,
1573 `contact`.`avatar-date` AS `picdate`,
1574 `contact`.`term-date` AS `term-date`,
1575 `contact`.`last-item` AS `last-item`,
1576 `contact`.`priority` AS `priority`,
1577 `user`.`blocked` AS `blocked`,
1578 `contact`.`block_reason` AS `block_reason`,
1579 `contact`.`readonly` AS `readonly`,
1580 `contact`.`writable` AS `writable`,
1581 `contact`.`forum` AS `forum`,
1582 `contact`.`prv` AS `prv`,
1583 `contact`.`contact-type` AS `contact-type`,
1584 `contact`.`manually-approve` AS `manually-approve`,
1585 `contact`.`hidden` AS `hidden`,
1586 `contact`.`archive` AS `archive`,
1587 `contact`.`pending` AS `pending`,
1588 `contact`.`deleted` AS `deleted`,
1589 `contact`.`unsearchable` AS `unsearchable`,
1590 `contact`.`sensitive` AS `sensitive`,
1591 `contact`.`baseurl` AS `baseurl`,
1592 `contact`.`reason` AS `reason`,
1593 `contact`.`closeness` AS `closeness`,
1594 `contact`.`info` AS `info`,
1595 `contact`.`profile-id` AS `profile-id`,
1596 `contact`.`bdyear` AS `bdyear`,
1597 `contact`.`bd` AS `bd`,
1598 `contact`.`notify_new_posts` AS `notify_new_posts`,
1599 `contact`.`fetch_further_information` AS `fetch_further_information`,
1600 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
1601 `user`.`parent-uid` AS `parent-uid`,
1602 `user`.`guid` AS `guid`,
1603 `user`.`nickname` AS `nickname`,
1604 `user`.`email` AS `email`,
1605 `user`.`openid` AS `openid`,
1606 `user`.`timezone` AS `timezone`,
1607 `user`.`language` AS `language`,
1608 `user`.`register_date` AS `register_date`,
1609 `user`.`login_date` AS `login_date`,
1610 `user`.`default-location` AS `default-location`,
1611 `user`.`allow_location` AS `allow_location`,
1612 `user`.`theme` AS `theme`,
1613 `user`.`pubkey` AS `upubkey`,
1614 `user`.`prvkey` AS `uprvkey`,
1615 `user`.`sprvkey` AS `sprvkey`,
1616 `user`.`spubkey` AS `spubkey`,
1617 `user`.`verified` AS `verified`,
1618 `user`.`blockwall` AS `blockwall`,
1619 `user`.`hidewall` AS `hidewall`,
1620 `user`.`blocktags` AS `blocktags`,
1621 `user`.`unkmail` AS `unkmail`,
1622 `user`.`cntunkmail` AS `cntunkmail`,
1623 `user`.`notify-flags` AS `notify-flags`,
1624 `user`.`page-flags` AS `page-flags`,
1625 `user`.`account-type` AS `account-type`,
1626 `user`.`prvnets` AS `prvnets`,
1627 `user`.`maxreq` AS `maxreq`,
1628 `user`.`expire` AS `expire`,
1629 `user`.`account_removed` AS `account_removed`,
1630 `user`.`account_expired` AS `account_expired`,
1631 `user`.`account_expires_on` AS `account_expires_on`,
1632 `user`.`expire_notification_sent` AS `expire_notification_sent`,
1633 `user`.`def_gid` AS `def_gid`,
1634 `user`.`allow_cid` AS `allow_cid`,
1635 `user`.`allow_gid` AS `allow_gid`,
1636 `user`.`deny_cid` AS `deny_cid`,
1637 `user`.`deny_gid` AS `deny_gid`,
1638 `user`.`openidserver` AS `openidserver`,
1639 `profile`.`publish` AS `publish`,
1640 `profile`.`net-publish` AS `net-publish`,
1641 `profile`.`hide-friends` AS `hide-friends`,
1642 `profile`.`prv_keywords` AS `prv_keywords`,
1643 `profile`.`pub_keywords` AS `pub_keywords`,
1644 `profile`.`address` AS `address`,
1645 `profile`.`locality` AS `locality`,
1646 `profile`.`region` AS `region`,
1647 `profile`.`postal-code` AS `postal-code`,
1648 `profile`.`country-name` AS `country-name`,
1649 `profile`.`homepage` AS `homepage`,
1650 `profile`.`dob` AS `dob`
1652 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
1653 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
1656 -- VIEW pending-view
1658 DROP VIEW IF EXISTS `pending-view`;
1659 CREATE VIEW `pending-view` AS SELECT
1660 `register`.`id` AS `id`,
1661 `register`.`hash` AS `hash`,
1662 `register`.`created` AS `created`,
1663 `register`.`uid` AS `uid`,
1664 `register`.`password` AS `password`,
1665 `register`.`language` AS `language`,
1666 `register`.`note` AS `note`,
1667 `contact`.`self` AS `self`,
1668 `contact`.`name` AS `name`,
1669 `contact`.`url` AS `url`,
1670 `contact`.`micro` AS `micro`,
1671 `user`.`email` AS `email`,
1672 `contact`.`nick` AS `nick`
1674 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
1675 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
1678 -- VIEW tag-search-view
1680 DROP VIEW IF EXISTS `tag-search-view`;
1681 CREATE VIEW `tag-search-view` AS SELECT
1682 `post-tag`.`uri-id` AS `uri-id`,
1683 `item`.`id` AS `iid`,
1684 `item`.`uri` AS `uri`,
1685 `item`.`guid` AS `guid`,
1686 `item`.`uid` AS `uid`,
1687 `item`.`private` AS `private`,
1688 `item`.`wall` AS `wall`,
1689 `item`.`origin` AS `origin`,
1690 `item`.`gravity` AS `gravity`,
1691 `item`.`received` AS `received`,
1692 `tag`.`name` AS `name`
1694 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
1695 INNER JOIN `item` ON `item`.`uri-id` = `post-tag`.`uri-id`
1696 WHERE `post-tag`.`type` = 1;
1699 -- VIEW workerqueue-view
1701 DROP VIEW IF EXISTS `workerqueue-view`;
1702 CREATE VIEW `workerqueue-view` AS SELECT
1703 `process`.`pid` AS `pid`,
1704 `workerqueue`.`priority` AS `priority`
1706 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
1707 WHERE NOT `workerqueue`.`done`;