1 -- ------------------------------------------
2 -- Friendica 2020.12-dev (Red Hot Poker)
3 -- DB_UPDATE_VERSION 1381
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 `user` (
40 `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
41 `parent-uid` mediumint unsigned COMMENT 'The parent user that has full control about this user',
42 `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
43 `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
44 `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
45 `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
46 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
47 `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
48 `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
49 `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
50 `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
51 `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
52 `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
53 `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
54 `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
55 `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
56 `pubkey` text COMMENT 'RSA public key 4096 bit',
57 `prvkey` text COMMENT 'RSA private key 4096 bit',
58 `spubkey` text COMMENT '',
59 `sprvkey` text COMMENT '',
60 `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
61 `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
62 `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
63 `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unkown viewers',
64 `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
65 `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
66 `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
67 `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
68 `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
69 `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
70 `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
71 `pwdreset` varchar(255) COMMENT 'Password reset request token',
72 `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
73 `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
74 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
75 `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
76 `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
77 `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
78 `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
79 `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
80 `allow_cid` mediumtext COMMENT 'default permission for this user',
81 `allow_gid` mediumtext COMMENT 'default permission for this user',
82 `deny_cid` mediumtext COMMENT 'default permission for this user',
83 `deny_gid` mediumtext COMMENT 'default permission for this user',
84 `openidserver` text COMMENT '',
86 INDEX `nickname` (`nickname`(32)),
87 INDEX `parent-uid` (`parent-uid`),
88 FOREIGN KEY (`parent-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
89 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
94 CREATE TABLE IF NOT EXISTS `contact` (
95 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
96 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
97 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
98 `updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last contact update',
99 `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
100 `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
101 `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
102 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
103 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network of the contact',
104 `protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
105 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
106 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
107 `location` varchar(255) DEFAULT '' COMMENT '',
108 `about` text COMMENT '',
109 `keywords` text COMMENT 'public keywords (interests) of the contact',
110 `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
111 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
112 `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
113 `avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '',
114 `photo` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
115 `thumb` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
116 `micro` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
117 `site-pubkey` text COMMENT '',
118 `issued-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
119 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
120 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
121 `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
122 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
123 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
124 `pubkey` text COMMENT 'RSA public key 4096 bit',
125 `prvkey` text COMMENT 'RSA private key 4096 bit',
126 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
127 `request` varchar(255) COMMENT '',
128 `notify` varchar(255) COMMENT '',
129 `poll` varchar(255) COMMENT '',
130 `confirm` varchar(255) COMMENT '',
131 `subscribe` varchar(255) COMMENT '',
132 `poco` varchar(255) COMMENT '',
133 `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT '',
134 `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT '',
135 `usehub` boolean NOT NULL DEFAULT '0' COMMENT '',
136 `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
137 `hub-verify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
138 `last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
139 `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
140 `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
141 `failed` boolean COMMENT 'Connection failed',
142 `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
143 `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
144 `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
145 `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
146 `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
147 `last-discovery` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last follower discovery',
148 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
149 `blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
150 `block_reason` text COMMENT 'Node-wide block reason',
151 `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
152 `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
153 `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum',
154 `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group',
155 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT '',
156 `manually-approve` boolean COMMENT '',
157 `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
158 `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
159 `pending` boolean NOT NULL DEFAULT '1' COMMENT '',
160 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
161 `rating` tinyint NOT NULL DEFAULT 0 COMMENT '',
162 `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
163 `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
164 `baseurl` varchar(255) DEFAULT '' COMMENT 'baseurl of the contact',
165 `gsid` int unsigned COMMENT 'Global Server ID',
166 `reason` text COMMENT '',
167 `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT '',
168 `info` mediumtext COMMENT '',
169 `profile-id` int unsigned COMMENT 'Deprecated',
170 `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
171 `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
172 `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
173 `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
174 `ffi_keyword_denylist` text COMMENT '',
176 INDEX `uid_name` (`uid`,`name`(190)),
177 INDEX `self_uid` (`self`,`uid`),
178 INDEX `alias_uid` (`alias`(128),`uid`),
179 INDEX `pending_uid` (`pending`,`uid`),
180 INDEX `blocked_uid` (`blocked`,`uid`),
181 INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
182 INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
183 INDEX `addr_uid` (`addr`(128),`uid`),
184 INDEX `nurl_uid` (`nurl`(128),`uid`),
185 INDEX `nick_uid` (`nick`(128),`uid`),
186 INDEX `attag_uid` (`attag`(96),`uid`),
187 INDEX `dfrn-id` (`dfrn-id`(64)),
188 INDEX `issued-id` (`issued-id`(64)),
189 INDEX `network_uid_lastupdate` (`network`,`uid`,`last-update`),
190 INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`),
191 INDEX `uid_lastitem` (`uid`,`last-item`),
192 INDEX `gsid` (`gsid`),
193 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
194 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
195 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
200 CREATE TABLE IF NOT EXISTS `item-uri` (
201 `id` int unsigned NOT NULL auto_increment,
202 `uri` varbinary(255) NOT NULL COMMENT 'URI of an item',
203 `guid` varbinary(255) COMMENT 'A unique identifier for an item',
205 UNIQUE INDEX `uri` (`uri`),
206 INDEX `guid` (`guid`)
207 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
212 CREATE TABLE IF NOT EXISTS `tag` (
213 `id` int unsigned NOT NULL auto_increment COMMENT '',
214 `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
215 `url` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
217 UNIQUE INDEX `type_name_url` (`name`,`url`),
219 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
224 CREATE TABLE IF NOT EXISTS `clients` (
225 `client_id` varchar(20) NOT NULL COMMENT '',
226 `pw` varchar(20) NOT NULL DEFAULT '' COMMENT '',
227 `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
228 `name` text COMMENT '',
229 `icon` text COMMENT '',
230 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
231 PRIMARY KEY(`client_id`),
233 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
234 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
237 -- TABLE permissionset
239 CREATE TABLE IF NOT EXISTS `permissionset` (
240 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
241 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
242 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
243 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
244 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
245 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
247 INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`uid`,`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30)),
248 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
249 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
254 CREATE TABLE IF NOT EXISTS `verb` (
255 `id` smallint unsigned NOT NULL auto_increment,
256 `name` varchar(100) NOT NULL DEFAULT '' COMMENT '',
258 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activity Verbs';
261 -- TABLE 2fa_app_specific_password
263 CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
264 `id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
265 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
266 `description` varchar(255) COMMENT 'Description of the usage of the password',
267 `hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
268 `generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
269 `last_used` datetime COMMENT 'Datetime the password was last used',
271 INDEX `uid_description` (`uid`,`description`(190)),
272 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
273 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
276 -- TABLE 2fa_recovery_codes
278 CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
279 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
280 `code` varchar(50) NOT NULL COMMENT 'Recovery code string',
281 `generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
282 `used` datetime COMMENT 'Datetime the code was used',
283 PRIMARY KEY(`uid`,`code`),
284 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
285 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
290 CREATE TABLE IF NOT EXISTS `addon` (
291 `id` int unsigned NOT NULL auto_increment COMMENT '',
292 `name` varchar(50) NOT NULL DEFAULT '' COMMENT 'addon base (file)name',
293 `version` varchar(50) NOT NULL DEFAULT '' COMMENT 'currently unused',
294 `installed` boolean NOT NULL DEFAULT '0' COMMENT 'currently always 1',
295 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'currently unused',
296 `timestamp` int unsigned NOT NULL DEFAULT 0 COMMENT 'file timestamp to check for reloads',
297 `plugin_admin` boolean NOT NULL DEFAULT '0' COMMENT '1 = has admin config, 0 = has no admin config',
299 UNIQUE INDEX `name` (`name`)
300 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registered addons';
305 CREATE TABLE IF NOT EXISTS `apcontact` (
306 `url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
307 `uuid` varchar(255) COMMENT '',
308 `type` varchar(20) NOT NULL COMMENT '',
309 `following` varchar(255) COMMENT '',
310 `followers` varchar(255) COMMENT '',
311 `inbox` varchar(255) NOT NULL COMMENT '',
312 `outbox` varchar(255) COMMENT '',
313 `sharedinbox` varchar(255) COMMENT '',
314 `manually-approve` boolean COMMENT '',
315 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
316 `name` varchar(255) COMMENT '',
317 `about` text COMMENT '',
318 `photo` varchar(255) COMMENT '',
319 `addr` varchar(255) COMMENT '',
320 `alias` varchar(255) COMMENT '',
321 `pubkey` text COMMENT '',
322 `subscribe` varchar(255) COMMENT '',
323 `baseurl` varchar(255) COMMENT 'baseurl of the ap contact',
324 `gsid` int unsigned COMMENT 'Global Server ID',
325 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
326 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
327 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
328 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
329 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
331 INDEX `addr` (`addr`(32)),
332 INDEX `alias` (`alias`(190)),
333 INDEX `followers` (`followers`(190)),
334 INDEX `baseurl` (`baseurl`(190)),
335 INDEX `sharedinbox` (`sharedinbox`(190)),
336 INDEX `gsid` (`gsid`),
337 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
338 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
343 CREATE TABLE IF NOT EXISTS `attach` (
344 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
345 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
346 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
347 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
348 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
349 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
350 `data` longblob NOT NULL COMMENT 'file data',
351 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
352 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
353 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
354 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
355 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
356 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
357 `backend-class` tinytext COMMENT 'Storage backend class',
358 `backend-ref` text COMMENT 'Storage backend data reference',
361 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
362 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
367 CREATE TABLE IF NOT EXISTS `auth_codes` (
368 `id` varchar(40) NOT NULL COMMENT '',
369 `client_id` varchar(20) NOT NULL DEFAULT '' COMMENT '',
370 `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
371 `expires` int NOT NULL DEFAULT 0 COMMENT '',
372 `scope` varchar(250) NOT NULL DEFAULT '' COMMENT '',
374 INDEX `client_id` (`client_id`),
375 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE
376 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
381 CREATE TABLE IF NOT EXISTS `cache` (
382 `k` varbinary(255) NOT NULL COMMENT 'cache key',
383 `v` mediumtext COMMENT 'cached serialized value',
384 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
385 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
387 INDEX `k_expires` (`k`,`expires`)
388 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
393 CREATE TABLE IF NOT EXISTS `challenge` (
394 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
395 `challenge` varchar(255) NOT NULL DEFAULT '' COMMENT '',
396 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
397 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
398 `type` varchar(255) NOT NULL DEFAULT '' COMMENT '',
399 `last_update` varchar(255) NOT NULL DEFAULT '' COMMENT '',
401 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
406 CREATE TABLE IF NOT EXISTS `config` (
407 `id` int unsigned NOT NULL auto_increment COMMENT '',
408 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
409 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
410 `v` mediumtext COMMENT '',
412 UNIQUE INDEX `cat_k` (`cat`,`k`)
413 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
416 -- TABLE contact-relation
418 CREATE TABLE IF NOT EXISTS `contact-relation` (
419 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
420 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
421 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
422 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
423 `follows` boolean NOT NULL DEFAULT '0' COMMENT '',
424 PRIMARY KEY(`cid`,`relation-cid`),
425 INDEX `relation-cid` (`relation-cid`),
426 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
427 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
428 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
433 CREATE TABLE IF NOT EXISTS `conv` (
434 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
435 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
436 `recips` text COMMENT 'sender_handle;recipient_handle',
437 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
438 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
439 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
440 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
441 `subject` text COMMENT 'subject of initial message',
444 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
445 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
448 -- TABLE conversation
450 CREATE TABLE IF NOT EXISTS `conversation` (
451 `item-uri` varbinary(255) NOT NULL COMMENT 'Original URI of the item - unrelated to the table with the same name',
452 `reply-to-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'URI to which this item is a reply',
453 `conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI',
454 `conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link',
455 `protocol` tinyint unsigned NOT NULL DEFAULT 255 COMMENT 'The protocol of the item',
456 `direction` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'How the message arrived here: 1=push, 2=pull',
457 `source` mediumtext COMMENT 'Original source',
458 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Receiving date',
459 PRIMARY KEY(`item-uri`),
460 INDEX `conversation-uri` (`conversation-uri`),
461 INDEX `received` (`received`)
462 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Raw data and structure information for messages';
465 -- TABLE diaspora-interaction
467 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
468 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
469 `interaction` mediumtext COMMENT 'The Diaspora interaction',
470 PRIMARY KEY(`uri-id`),
471 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
472 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
477 CREATE TABLE IF NOT EXISTS `event` (
478 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
479 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
480 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
481 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
482 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
483 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
484 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
485 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
486 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
487 `summary` text COMMENT 'short description or title of the event',
488 `desc` text COMMENT 'event description',
489 `location` text COMMENT 'event location',
490 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
491 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
492 `adjust` boolean NOT NULL DEFAULT '1' COMMENT 'adjust to timezone of the recipient (0 or 1)',
493 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
494 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
495 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
496 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
497 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
499 INDEX `uid_start` (`uid`,`start`),
501 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
502 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
503 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
508 CREATE TABLE IF NOT EXISTS `fcontact` (
509 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
510 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
511 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
512 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
513 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
514 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
515 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
516 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
517 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
518 `notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
519 `poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
520 `confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
521 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
522 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
523 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
524 `pubkey` text COMMENT '',
525 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
527 INDEX `addr` (`addr`(32)),
528 UNIQUE INDEX `url` (`url`(190))
529 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
534 CREATE TABLE IF NOT EXISTS `fsuggest` (
535 `id` int unsigned NOT NULL auto_increment COMMENT '',
536 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
537 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
538 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
539 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
540 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
541 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
542 `note` text COMMENT '',
543 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
547 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
548 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
549 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
554 CREATE TABLE IF NOT EXISTS `group` (
555 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
556 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
557 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
558 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
559 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
562 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
563 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
566 -- TABLE group_member
568 CREATE TABLE IF NOT EXISTS `group_member` (
569 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
570 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
571 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
573 INDEX `contactid` (`contact-id`),
574 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
575 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
576 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
577 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
582 CREATE TABLE IF NOT EXISTS `gserver-tag` (
583 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
584 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
585 PRIMARY KEY(`gserver-id`,`tag`),
587 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
588 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
593 CREATE TABLE IF NOT EXISTS `hook` (
594 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
595 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
596 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
597 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
598 `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',
600 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
601 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
606 CREATE TABLE IF NOT EXISTS `host` (
607 `id` tinyint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
608 `name` varchar(128) NOT NULL DEFAULT '' COMMENT 'The hostname',
610 UNIQUE INDEX `name` (`name`)
611 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Hostname';
614 -- TABLE inbox-status
616 CREATE TABLE IF NOT EXISTS `inbox-status` (
617 `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
618 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
619 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
620 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
621 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
622 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
623 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
625 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
630 CREATE TABLE IF NOT EXISTS `intro` (
631 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
632 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
633 `fid` int unsigned COMMENT '',
634 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
635 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
636 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
637 `note` text COMMENT '',
638 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
639 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
640 `blocked` boolean NOT NULL DEFAULT '1' COMMENT '',
641 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
643 INDEX `contact-id` (`contact-id`),
645 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
646 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
647 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
652 CREATE TABLE IF NOT EXISTS `item` (
653 `id` int unsigned NOT NULL auto_increment,
654 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this item',
655 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
656 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
657 `uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
658 `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',
659 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT 'uri of the top-level parent to this item',
660 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the top-level parent uri',
661 `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',
662 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
663 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
664 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
665 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last comment/reply to this item',
666 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
667 `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',
668 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
669 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
670 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
671 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
672 `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',
673 `icid` int unsigned COMMENT 'Id of the item-content table entry that contains the whole item content',
674 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
675 `extid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
676 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
677 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
678 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
679 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
680 `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
681 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been deleted',
682 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
683 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
684 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
685 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
686 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
687 `starred` boolean NOT NULL DEFAULT '0' COMMENT 'item has been favourited',
688 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'item has not been seen',
689 `mention` boolean NOT NULL DEFAULT '0' COMMENT 'The owner of this item was mentioned in it',
690 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
691 `psid` int unsigned COMMENT 'ID of the permission set of this post',
692 `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',
693 `event-id` int unsigned COMMENT 'Used to link to the event.id',
694 `iaid` int unsigned COMMENT 'Deprecated',
695 `attach` mediumtext COMMENT 'Deprecated',
696 `allow_cid` mediumtext COMMENT 'Deprecated',
697 `allow_gid` mediumtext COMMENT 'Deprecated',
698 `deny_cid` mediumtext COMMENT 'Deprecated',
699 `deny_gid` mediumtext COMMENT 'Deprecated',
700 `postopts` text COMMENT 'Deprecated',
701 `inform` mediumtext COMMENT 'Deprecated',
702 `type` varchar(20) COMMENT 'Deprecated',
703 `bookmark` boolean COMMENT 'Deprecated',
704 `file` mediumtext COMMENT 'Deprecated',
705 `location` varchar(255) COMMENT 'Deprecated',
706 `coord` varchar(255) COMMENT 'Deprecated',
707 `tag` mediumtext COMMENT 'Deprecated',
708 `plink` varchar(255) COMMENT 'Deprecated',
709 `title` varchar(255) COMMENT 'Deprecated',
710 `content-warning` varchar(255) COMMENT 'Deprecated',
711 `body` mediumtext COMMENT 'Deprecated',
712 `app` varchar(255) COMMENT 'Deprecated',
713 `verb` varchar(100) COMMENT 'Deprecated',
714 `object-type` varchar(100) COMMENT 'Deprecated',
715 `object` text COMMENT 'Deprecated',
716 `target-type` varchar(100) COMMENT 'Deprecated',
717 `target` text COMMENT 'Deprecated',
718 `author-name` varchar(255) COMMENT 'Deprecated',
719 `author-link` varchar(255) COMMENT 'Deprecated',
720 `author-avatar` varchar(255) COMMENT 'Deprecated',
721 `owner-name` varchar(255) COMMENT 'Deprecated',
722 `owner-link` varchar(255) COMMENT 'Deprecated',
723 `owner-avatar` varchar(255) COMMENT 'Deprecated',
724 `rendered-hash` varchar(32) COMMENT 'Deprecated',
725 `rendered-html` mediumtext COMMENT 'Deprecated',
727 INDEX `guid` (`guid`(191)),
728 INDEX `uri` (`uri`(191)),
729 INDEX `parent` (`parent`),
730 INDEX `parent-uri` (`parent-uri`(191)),
731 INDEX `extid` (`extid`(191)),
732 INDEX `uid_id` (`uid`,`id`),
733 INDEX `uid_contactid_id` (`uid`,`contact-id`,`id`),
734 INDEX `uid_received` (`uid`,`received`),
735 INDEX `uid_commented` (`uid`,`commented`),
736 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
737 INDEX `uid_network_received` (`uid`,`network`,`received`),
738 INDEX `uid_network_commented` (`uid`,`network`,`commented`),
739 INDEX `uid_thrparent` (`uid`,`thr-parent`(190)),
740 INDEX `uid_parenturi` (`uid`,`parent-uri`(190)),
741 INDEX `uid_contactid_received` (`uid`,`contact-id`,`received`),
742 INDEX `authorid_received` (`author-id`,`received`),
743 INDEX `ownerid` (`owner-id`),
744 INDEX `contact-id` (`contact-id`),
745 INDEX `uid_uri` (`uid`,`uri`(190)),
746 INDEX `resource-id` (`resource-id`),
747 INDEX `deleted_changed` (`deleted`,`changed`),
748 INDEX `uid_wall_changed` (`uid`,`wall`,`changed`),
749 INDEX `uid_unseen_wall` (`uid`,`unseen`,`wall`),
750 INDEX `mention_uid_id` (`mention`,`uid`,`id`),
751 INDEX `uid_eventid` (`uid`,`event-id`),
752 INDEX `icid` (`icid`),
753 INDEX `iaid` (`iaid`),
755 INDEX `psid_wall` (`psid`,`wall`),
756 INDEX `uri-id` (`uri-id`),
757 INDEX `parent-uri-id` (`parent-uri-id`),
758 INDEX `thr-parent-id` (`thr-parent-id`),
759 INDEX `causer-id` (`causer-id`),
760 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
761 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
762 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
763 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
764 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
765 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
766 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
767 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
768 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
769 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
770 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
773 -- TABLE item-activity
775 CREATE TABLE IF NOT EXISTS `item-activity` (
776 `id` int unsigned NOT NULL auto_increment,
777 `uri` varchar(255) COMMENT '',
778 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
779 `uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
780 `activity` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
782 UNIQUE INDEX `uri-hash` (`uri-hash`),
783 INDEX `uri` (`uri`(191)),
784 INDEX `uri-id` (`uri-id`),
785 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
786 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activities for items';
789 -- TABLE item-content
791 CREATE TABLE IF NOT EXISTS `item-content` (
792 `id` int unsigned NOT NULL auto_increment,
793 `uri` varchar(255) COMMENT '',
794 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
795 `uri-plink-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
796 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
797 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
798 `body` mediumtext COMMENT 'item body content',
799 `raw-body` mediumtext COMMENT 'Body without embedded media links',
800 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
801 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
802 `language` text COMMENT 'Language information about this post',
803 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
804 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
805 `rendered-html` mediumtext COMMENT 'item.body converted to html',
806 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
807 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
808 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
809 `target` text COMMENT 'JSON encoded target structure if used',
810 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
811 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams verb',
813 UNIQUE INDEX `uri-plink-hash` (`uri-plink-hash`),
814 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
815 INDEX `uri` (`uri`(191)),
816 INDEX `plink` (`plink`(191)),
817 INDEX `uri-id` (`uri-id`),
818 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
819 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
824 CREATE TABLE IF NOT EXISTS `locks` (
825 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
826 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
827 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
828 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
829 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
831 INDEX `name_expires` (`name`,`expires`)
832 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
837 CREATE TABLE IF NOT EXISTS `mail` (
838 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
839 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
840 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
841 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
842 `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
843 `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
844 `contact-id` varchar(255) COMMENT 'contact.id',
845 `convid` int unsigned COMMENT 'conv.id',
846 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
847 `body` mediumtext COMMENT '',
848 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
849 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
850 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
851 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
852 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
853 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
854 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
856 INDEX `uid_seen` (`uid`,`seen`),
857 INDEX `convid` (`convid`),
858 INDEX `uri` (`uri`(64)),
859 INDEX `parent-uri` (`parent-uri`(64)),
860 INDEX `contactid` (`contact-id`(32)),
861 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
862 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
867 CREATE TABLE IF NOT EXISTS `mailacct` (
868 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
869 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
870 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
871 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
872 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
873 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
874 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
875 `pass` text COMMENT '',
876 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
877 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
878 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
879 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
880 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
883 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
884 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
889 CREATE TABLE IF NOT EXISTS `manage` (
890 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
891 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
892 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
894 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
896 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
897 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
898 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
903 CREATE TABLE IF NOT EXISTS `notify` (
904 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
905 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
906 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
907 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
908 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
909 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
910 `msg` mediumtext COMMENT '',
911 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
912 `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
913 `iid` int unsigned COMMENT 'item.id',
914 `parent` int unsigned COMMENT '',
915 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
916 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
917 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
918 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
919 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
920 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
921 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
923 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
924 INDEX `uid_date` (`uid`,`date`),
925 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
926 INDEX `uri-id` (`uri-id`),
927 INDEX `parent-uri-id` (`parent-uri-id`),
928 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
929 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
930 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
931 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
934 -- TABLE notify-threads
936 CREATE TABLE IF NOT EXISTS `notify-threads` (
937 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
938 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
939 `master-parent-item` int unsigned COMMENT '',
940 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
941 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
942 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
944 INDEX `master-parent-item` (`master-parent-item`),
945 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
946 INDEX `receiver-uid` (`receiver-uid`),
947 INDEX `notify-id` (`notify-id`),
948 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
949 FOREIGN KEY (`master-parent-item`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
950 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
951 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
952 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
957 CREATE TABLE IF NOT EXISTS `oembed` (
958 `url` varbinary(255) NOT NULL COMMENT 'page url',
959 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
960 `content` mediumtext COMMENT 'OEmbed data of the page',
961 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
962 PRIMARY KEY(`url`,`maxwidth`),
963 INDEX `created` (`created`)
964 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
967 -- TABLE openwebauth-token
969 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
970 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
971 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
972 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
973 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
974 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
975 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
978 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
979 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
984 CREATE TABLE IF NOT EXISTS `parsed_url` (
985 `url` varbinary(255) NOT NULL COMMENT 'page url',
986 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
987 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
988 `content` mediumtext COMMENT 'page data',
989 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
990 PRIMARY KEY(`url`,`guessing`,`oembed`),
991 INDEX `created` (`created`)
992 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
995 -- TABLE participation
997 CREATE TABLE IF NOT EXISTS `participation` (
998 `iid` int unsigned NOT NULL COMMENT '',
999 `server` varchar(60) NOT NULL COMMENT '',
1000 `cid` int unsigned NOT NULL COMMENT '',
1001 `fid` int unsigned NOT NULL COMMENT '',
1002 PRIMARY KEY(`iid`,`server`),
1003 INDEX `cid` (`cid`),
1004 INDEX `fid` (`fid`),
1005 FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1006 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1007 FOREIGN KEY (`fid`) REFERENCES `fcontact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1008 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Storage for participation messages from Diaspora';
1013 CREATE TABLE IF NOT EXISTS `pconfig` (
1014 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
1015 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1016 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
1017 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
1018 `v` mediumtext COMMENT 'Value',
1020 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
1021 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1022 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
1027 CREATE TABLE IF NOT EXISTS `photo` (
1028 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1029 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1030 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1031 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
1032 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
1033 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
1034 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
1035 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1036 `desc` text COMMENT '',
1037 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
1038 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1039 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
1040 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1041 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
1042 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1043 `data` mediumblob NOT NULL COMMENT '',
1044 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1045 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
1046 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
1047 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
1048 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
1049 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
1050 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
1051 `backend-class` tinytext COMMENT 'Storage backend class',
1052 `backend-ref` text COMMENT 'Storage backend data reference',
1053 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1055 INDEX `contactid` (`contact-id`),
1056 INDEX `uid_contactid` (`uid`,`contact-id`),
1057 INDEX `uid_profile` (`uid`,`profile`),
1058 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
1059 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
1060 INDEX `resource-id` (`resource-id`),
1061 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1062 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1063 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1066 -- TABLE post-category
1068 CREATE TABLE IF NOT EXISTS `post-category` (
1069 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1070 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1071 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1072 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1073 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1074 INDEX `uri-id` (`tid`),
1075 INDEX `uid` (`uid`),
1076 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1077 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1078 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1079 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1082 -- TABLE post-delivery-data
1084 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1085 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1086 `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',
1087 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1088 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1089 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1090 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1091 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1092 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1093 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1094 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1095 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1096 PRIMARY KEY(`uri-id`),
1097 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1098 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1103 CREATE TABLE IF NOT EXISTS `post-media` (
1104 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1105 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1106 `url` varbinary(511) NOT NULL COMMENT 'Media URL',
1107 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1108 `mimetype` varchar(60) COMMENT '',
1109 `height` smallint unsigned COMMENT 'Height of the media',
1110 `width` smallint unsigned COMMENT 'Width of the media',
1111 `size` int unsigned COMMENT 'Media size',
1112 `preview` varbinary(255) COMMENT 'Preview URL',
1113 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1114 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1115 `description` text COMMENT '',
1117 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1118 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1119 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1124 CREATE TABLE IF NOT EXISTS `post-tag` (
1125 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1126 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1127 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1128 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1129 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1130 INDEX `tid` (`tid`),
1131 INDEX `cid` (`cid`),
1132 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1133 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1134 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1135 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1140 CREATE TABLE IF NOT EXISTS `post-user` (
1141 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1142 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1143 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1144 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1145 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1146 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1147 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1148 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1149 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1150 PRIMARY KEY(`uid`,`uri-id`),
1151 INDEX `uri-id` (`uri-id`),
1152 INDEX `contact-id` (`contact-id`),
1153 INDEX `psid` (`psid`),
1154 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1155 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1156 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1157 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1158 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1163 CREATE TABLE IF NOT EXISTS `process` (
1164 `pid` int unsigned NOT NULL COMMENT '',
1165 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1166 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1168 INDEX `command` (`command`)
1169 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1174 CREATE TABLE IF NOT EXISTS `profile` (
1175 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1176 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1177 `profile-name` varchar(255) COMMENT 'Deprecated',
1178 `is-default` boolean COMMENT 'Deprecated',
1179 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1180 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1181 `pdesc` varchar(255) COMMENT 'Deprecated',
1182 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1183 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1184 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1185 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1186 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1187 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1188 `hometown` varchar(255) COMMENT 'Deprecated',
1189 `gender` varchar(32) COMMENT 'Deprecated',
1190 `marital` varchar(255) COMMENT 'Deprecated',
1191 `with` text COMMENT 'Deprecated',
1192 `howlong` datetime COMMENT 'Deprecated',
1193 `sexual` varchar(255) COMMENT 'Deprecated',
1194 `politic` varchar(255) COMMENT 'Deprecated',
1195 `religion` varchar(255) COMMENT 'Deprecated',
1196 `pub_keywords` text COMMENT '',
1197 `prv_keywords` text COMMENT '',
1198 `likes` text COMMENT 'Deprecated',
1199 `dislikes` text COMMENT 'Deprecated',
1200 `about` text COMMENT 'Profile description',
1201 `summary` varchar(255) COMMENT 'Deprecated',
1202 `music` text COMMENT 'Deprecated',
1203 `book` text COMMENT 'Deprecated',
1204 `tv` text COMMENT 'Deprecated',
1205 `film` text COMMENT 'Deprecated',
1206 `interest` text COMMENT 'Deprecated',
1207 `romance` text COMMENT 'Deprecated',
1208 `work` text COMMENT 'Deprecated',
1209 `education` text COMMENT 'Deprecated',
1210 `contact` text COMMENT 'Deprecated',
1211 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1212 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1213 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1214 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1215 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1216 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1218 INDEX `uid_is-default` (`uid`,`is-default`),
1219 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1220 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1221 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1224 -- TABLE profile_check
1226 CREATE TABLE IF NOT EXISTS `profile_check` (
1227 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1228 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1229 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1230 `dfrn_id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1231 `sec` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1232 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1234 INDEX `uid` (`uid`),
1235 INDEX `cid` (`cid`),
1236 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1237 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1238 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='DFRN remote auth use';
1241 -- TABLE profile_field
1243 CREATE TABLE IF NOT EXISTS `profile_field` (
1244 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1245 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1246 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1247 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1248 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1249 `value` text COMMENT 'Value of the field',
1250 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1251 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1253 INDEX `uid` (`uid`),
1254 INDEX `order` (`order`),
1255 INDEX `psid` (`psid`),
1256 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1257 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1258 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1261 -- TABLE push_subscriber
1263 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1264 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1265 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1266 `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1267 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1268 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1269 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1270 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1271 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1272 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1273 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1275 INDEX `next_try` (`next_try`),
1276 INDEX `uid` (`uid`),
1277 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1278 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1283 CREATE TABLE IF NOT EXISTS `register` (
1284 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1285 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1286 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1287 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1288 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1289 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1290 `note` text COMMENT '',
1292 INDEX `uid` (`uid`),
1293 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1294 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1299 CREATE TABLE IF NOT EXISTS `search` (
1300 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1301 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1302 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1304 INDEX `uid` (`uid`),
1305 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1306 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1311 CREATE TABLE IF NOT EXISTS `session` (
1312 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1313 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1314 `data` text COMMENT '',
1315 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1317 INDEX `sid` (`sid`(64)),
1318 INDEX `expire` (`expire`)
1319 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1324 CREATE TABLE IF NOT EXISTS `storage` (
1325 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1326 `data` longblob NOT NULL COMMENT 'file data',
1328 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1333 CREATE TABLE IF NOT EXISTS `thread` (
1334 `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'sequential ID',
1335 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
1336 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1337 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1338 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1339 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1340 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1341 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1342 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1343 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1344 `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1345 `wall` boolean NOT NULL DEFAULT '0' COMMENT '',
1346 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1347 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1348 `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
1349 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1350 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1351 `ignored` boolean NOT NULL DEFAULT '0' COMMENT '',
1352 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
1353 `unseen` boolean NOT NULL DEFAULT '1' COMMENT '',
1354 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '',
1355 `origin` boolean NOT NULL DEFAULT '0' COMMENT '',
1356 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1357 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1358 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1359 `bookmark` boolean COMMENT '',
1361 INDEX `uid_network_commented` (`uid`,`network`,`commented`),
1362 INDEX `uid_network_received` (`uid`,`network`,`received`),
1363 INDEX `uid_contactid_commented` (`uid`,`contact-id`,`commented`),
1364 INDEX `uid_contactid_received` (`uid`,`contact-id`,`received`),
1365 INDEX `contactid` (`contact-id`),
1366 INDEX `ownerid` (`owner-id`),
1367 INDEX `authorid` (`author-id`),
1368 INDEX `uid_received` (`uid`,`received`),
1369 INDEX `uid_commented` (`uid`,`commented`),
1370 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1371 INDEX `private_wall_origin_commented` (`private`,`wall`,`origin`,`commented`),
1372 INDEX `uri-id` (`uri-id`),
1373 FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1374 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1375 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1376 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1377 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1378 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1379 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1384 CREATE TABLE IF NOT EXISTS `tokens` (
1385 `id` varchar(40) NOT NULL COMMENT '',
1386 `secret` text COMMENT '',
1387 `client_id` varchar(20) NOT NULL DEFAULT '',
1388 `expires` int NOT NULL DEFAULT 0 COMMENT '',
1389 `scope` varchar(200) NOT NULL DEFAULT '' COMMENT '',
1390 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1392 INDEX `client_id` (`client_id`),
1393 INDEX `uid` (`uid`),
1394 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1395 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1396 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
1401 CREATE TABLE IF NOT EXISTS `userd` (
1402 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1403 `username` varchar(255) NOT NULL COMMENT '',
1405 INDEX `username` (`username`(32))
1406 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1409 -- TABLE user-contact
1411 CREATE TABLE IF NOT EXISTS `user-contact` (
1412 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1413 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1414 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1415 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1416 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1417 PRIMARY KEY(`uid`,`cid`),
1418 INDEX `cid` (`cid`),
1419 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1420 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1421 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1426 CREATE TABLE IF NOT EXISTS `user-item` (
1427 `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item id',
1428 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1429 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide an item from the user',
1430 `ignored` boolean COMMENT 'Ignore this thread if set',
1431 `pinned` boolean COMMENT 'The item is pinned on the profile page',
1432 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1433 PRIMARY KEY(`uid`,`iid`),
1434 INDEX `uid_pinned` (`uid`,`pinned`),
1435 INDEX `iid_uid` (`iid`,`uid`),
1436 FOREIGN KEY (`iid`) REFERENCES `item` (`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='User specific item data';
1443 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1444 `key` int NOT NULL COMMENT '',
1445 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1447 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1450 -- TABLE workerqueue
1452 CREATE TABLE IF NOT EXISTS `workerqueue` (
1453 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
1454 `parameter` mediumtext COMMENT 'Task command',
1455 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
1456 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
1457 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
1458 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
1459 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1460 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1461 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
1463 INDEX `done_parameter` (`done`,`parameter`(64)),
1464 INDEX `done_executed` (`done`,`executed`),
1465 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
1466 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
1467 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
1468 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
1469 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
1470 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
1473 -- VIEW category-view
1475 DROP VIEW IF EXISTS `category-view`;
1476 CREATE VIEW `category-view` AS SELECT
1477 `post-category`.`uri-id` AS `uri-id`,
1478 `post-category`.`uid` AS `uid`,
1479 `item-uri`.`uri` AS `uri`,
1480 `item-uri`.`guid` AS `guid`,
1481 `post-category`.`type` AS `type`,
1482 `post-category`.`tid` AS `tid`,
1483 `tag`.`name` AS `name`,
1484 `tag`.`url` AS `url`
1485 FROM `post-category`
1486 INNER JOIN `item-uri` ON `item-uri`.id = `post-category`.`uri-id`
1487 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
1492 DROP VIEW IF EXISTS `tag-view`;
1493 CREATE VIEW `tag-view` AS SELECT
1494 `post-tag`.`uri-id` AS `uri-id`,
1495 `item-uri`.`uri` AS `uri`,
1496 `item-uri`.`guid` AS `guid`,
1497 `post-tag`.`type` AS `type`,
1498 `post-tag`.`tid` AS `tid`,
1499 `post-tag`.`cid` AS `cid`,
1500 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
1501 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
1503 INNER JOIN `item-uri` ON `item-uri`.id = `post-tag`.`uri-id`
1504 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
1505 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
1508 -- VIEW network-item-view
1510 DROP VIEW IF EXISTS `network-item-view`;
1511 CREATE VIEW `network-item-view` AS SELECT
1512 `item`.`parent-uri-id` AS `uri-id`,
1513 `item`.`parent-uri` AS `uri`,
1514 `item`.`parent` AS `parent`,
1515 `item`.`received` AS `received`,
1516 `item`.`commented` AS `commented`,
1517 `item`.`created` AS `created`,
1518 `item`.`uid` AS `uid`,
1519 `item`.`starred` AS `starred`,
1520 `item`.`mention` AS `mention`,
1521 `item`.`network` AS `network`,
1522 `item`.`unseen` AS `unseen`,
1523 `item`.`gravity` AS `gravity`,
1524 `item`.`contact-id` AS `contact-id`,
1525 `ownercontact`.`contact-type` AS `contact-type`
1527 INNER JOIN `thread` ON `thread`.`iid` = `item`.`parent`
1528 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
1529 LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
1530 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
1531 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
1532 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
1533 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
1534 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
1535 AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
1536 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
1537 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
1540 -- VIEW network-thread-view
1542 DROP VIEW IF EXISTS `network-thread-view`;
1543 CREATE VIEW `network-thread-view` AS SELECT
1544 `item`.`uri-id` AS `uri-id`,
1545 `item`.`uri` AS `uri`,
1546 `item`.`parent-uri-id` AS `parent-uri-id`,
1547 `thread`.`iid` AS `parent`,
1548 `thread`.`received` AS `received`,
1549 `thread`.`commented` AS `commented`,
1550 `thread`.`created` AS `created`,
1551 `thread`.`uid` AS `uid`,
1552 `thread`.`starred` AS `starred`,
1553 `thread`.`mention` AS `mention`,
1554 `thread`.`network` AS `network`,
1555 `thread`.`contact-id` AS `contact-id`,
1556 `ownercontact`.`contact-type` AS `contact-type`
1558 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
1559 STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
1560 LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
1561 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
1562 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
1563 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
1564 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
1565 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
1566 AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
1567 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
1568 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
1573 DROP VIEW IF EXISTS `owner-view`;
1574 CREATE VIEW `owner-view` AS SELECT
1575 `contact`.`id` AS `id`,
1576 `contact`.`uid` AS `uid`,
1577 `contact`.`created` AS `created`,
1578 `contact`.`updated` AS `updated`,
1579 `contact`.`self` AS `self`,
1580 `contact`.`remote_self` AS `remote_self`,
1581 `contact`.`rel` AS `rel`,
1582 `contact`.`duplex` AS `duplex`,
1583 `contact`.`network` AS `network`,
1584 `contact`.`protocol` AS `protocol`,
1585 `contact`.`name` AS `name`,
1586 `contact`.`nick` AS `nick`,
1587 `contact`.`location` AS `location`,
1588 `contact`.`about` AS `about`,
1589 `contact`.`keywords` AS `keywords`,
1590 `contact`.`gender` AS `gender`,
1591 `contact`.`xmpp` AS `xmpp`,
1592 `contact`.`attag` AS `attag`,
1593 `contact`.`avatar` AS `avatar`,
1594 `contact`.`photo` AS `photo`,
1595 `contact`.`thumb` AS `thumb`,
1596 `contact`.`micro` AS `micro`,
1597 `contact`.`site-pubkey` AS `site-pubkey`,
1598 `contact`.`issued-id` AS `issued-id`,
1599 `contact`.`dfrn-id` AS `dfrn-id`,
1600 `contact`.`url` AS `url`,
1601 `contact`.`nurl` AS `nurl`,
1602 `contact`.`addr` AS `addr`,
1603 `contact`.`alias` AS `alias`,
1604 `contact`.`pubkey` AS `pubkey`,
1605 `contact`.`prvkey` AS `prvkey`,
1606 `contact`.`batch` AS `batch`,
1607 `contact`.`request` AS `request`,
1608 `contact`.`notify` AS `notify`,
1609 `contact`.`poll` AS `poll`,
1610 `contact`.`confirm` AS `confirm`,
1611 `contact`.`poco` AS `poco`,
1612 `contact`.`aes_allow` AS `aes_allow`,
1613 `contact`.`ret-aes` AS `ret-aes`,
1614 `contact`.`usehub` AS `usehub`,
1615 `contact`.`subhub` AS `subhub`,
1616 `contact`.`hub-verify` AS `hub-verify`,
1617 `contact`.`last-update` AS `last-update`,
1618 `contact`.`success_update` AS `success_update`,
1619 `contact`.`failure_update` AS `failure_update`,
1620 `contact`.`name-date` AS `name-date`,
1621 `contact`.`uri-date` AS `uri-date`,
1622 `contact`.`avatar-date` AS `avatar-date`,
1623 `contact`.`avatar-date` AS `picdate`,
1624 `contact`.`term-date` AS `term-date`,
1625 `contact`.`last-item` AS `last-item`,
1626 `contact`.`priority` AS `priority`,
1627 `user`.`blocked` AS `blocked`,
1628 `contact`.`block_reason` AS `block_reason`,
1629 `contact`.`readonly` AS `readonly`,
1630 `contact`.`writable` AS `writable`,
1631 `contact`.`forum` AS `forum`,
1632 `contact`.`prv` AS `prv`,
1633 `contact`.`contact-type` AS `contact-type`,
1634 `contact`.`manually-approve` AS `manually-approve`,
1635 `contact`.`hidden` AS `hidden`,
1636 `contact`.`archive` AS `archive`,
1637 `contact`.`pending` AS `pending`,
1638 `contact`.`deleted` AS `deleted`,
1639 `contact`.`unsearchable` AS `unsearchable`,
1640 `contact`.`sensitive` AS `sensitive`,
1641 `contact`.`baseurl` AS `baseurl`,
1642 `contact`.`reason` AS `reason`,
1643 `contact`.`closeness` AS `closeness`,
1644 `contact`.`info` AS `info`,
1645 `contact`.`profile-id` AS `profile-id`,
1646 `contact`.`bdyear` AS `bdyear`,
1647 `contact`.`bd` AS `bd`,
1648 `contact`.`notify_new_posts` AS `notify_new_posts`,
1649 `contact`.`fetch_further_information` AS `fetch_further_information`,
1650 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
1651 `user`.`parent-uid` AS `parent-uid`,
1652 `user`.`guid` AS `guid`,
1653 `user`.`nickname` AS `nickname`,
1654 `user`.`email` AS `email`,
1655 `user`.`openid` AS `openid`,
1656 `user`.`timezone` AS `timezone`,
1657 `user`.`language` AS `language`,
1658 `user`.`register_date` AS `register_date`,
1659 `user`.`login_date` AS `login_date`,
1660 `user`.`default-location` AS `default-location`,
1661 `user`.`allow_location` AS `allow_location`,
1662 `user`.`theme` AS `theme`,
1663 `user`.`pubkey` AS `upubkey`,
1664 `user`.`prvkey` AS `uprvkey`,
1665 `user`.`sprvkey` AS `sprvkey`,
1666 `user`.`spubkey` AS `spubkey`,
1667 `user`.`verified` AS `verified`,
1668 `user`.`blockwall` AS `blockwall`,
1669 `user`.`hidewall` AS `hidewall`,
1670 `user`.`blocktags` AS `blocktags`,
1671 `user`.`unkmail` AS `unkmail`,
1672 `user`.`cntunkmail` AS `cntunkmail`,
1673 `user`.`notify-flags` AS `notify-flags`,
1674 `user`.`page-flags` AS `page-flags`,
1675 `user`.`account-type` AS `account-type`,
1676 `user`.`prvnets` AS `prvnets`,
1677 `user`.`maxreq` AS `maxreq`,
1678 `user`.`expire` AS `expire`,
1679 `user`.`account_removed` AS `account_removed`,
1680 `user`.`account_expired` AS `account_expired`,
1681 `user`.`account_expires_on` AS `account_expires_on`,
1682 `user`.`expire_notification_sent` AS `expire_notification_sent`,
1683 `user`.`def_gid` AS `def_gid`,
1684 `user`.`allow_cid` AS `allow_cid`,
1685 `user`.`allow_gid` AS `allow_gid`,
1686 `user`.`deny_cid` AS `deny_cid`,
1687 `user`.`deny_gid` AS `deny_gid`,
1688 `user`.`openidserver` AS `openidserver`,
1689 `profile`.`publish` AS `publish`,
1690 `profile`.`net-publish` AS `net-publish`,
1691 `profile`.`hide-friends` AS `hide-friends`,
1692 `profile`.`prv_keywords` AS `prv_keywords`,
1693 `profile`.`pub_keywords` AS `pub_keywords`,
1694 `profile`.`address` AS `address`,
1695 `profile`.`locality` AS `locality`,
1696 `profile`.`region` AS `region`,
1697 `profile`.`postal-code` AS `postal-code`,
1698 `profile`.`country-name` AS `country-name`,
1699 `profile`.`homepage` AS `homepage`,
1700 `profile`.`dob` AS `dob`
1702 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
1703 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
1706 -- VIEW pending-view
1708 DROP VIEW IF EXISTS `pending-view`;
1709 CREATE VIEW `pending-view` AS SELECT
1710 `register`.`id` AS `id`,
1711 `register`.`hash` AS `hash`,
1712 `register`.`created` AS `created`,
1713 `register`.`uid` AS `uid`,
1714 `register`.`password` AS `password`,
1715 `register`.`language` AS `language`,
1716 `register`.`note` AS `note`,
1717 `contact`.`self` AS `self`,
1718 `contact`.`name` AS `name`,
1719 `contact`.`url` AS `url`,
1720 `contact`.`micro` AS `micro`,
1721 `user`.`email` AS `email`,
1722 `contact`.`nick` AS `nick`
1724 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
1725 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
1728 -- VIEW tag-search-view
1730 DROP VIEW IF EXISTS `tag-search-view`;
1731 CREATE VIEW `tag-search-view` AS SELECT
1732 `post-tag`.`uri-id` AS `uri-id`,
1733 `item`.`id` AS `iid`,
1734 `item`.`uri` AS `uri`,
1735 `item`.`guid` AS `guid`,
1736 `item`.`uid` AS `uid`,
1737 `item`.`private` AS `private`,
1738 `item`.`wall` AS `wall`,
1739 `item`.`origin` AS `origin`,
1740 `item`.`gravity` AS `gravity`,
1741 `item`.`received` AS `received`,
1742 `tag`.`name` AS `name`
1744 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
1745 INNER JOIN `item` ON `item`.`uri-id` = `post-tag`.`uri-id`
1746 WHERE `post-tag`.`type` = 1;
1749 -- VIEW workerqueue-view
1751 DROP VIEW IF EXISTS `workerqueue-view`;
1752 CREATE VIEW `workerqueue-view` AS SELECT
1753 `process`.`pid` AS `pid`,
1754 `workerqueue`.`priority` AS `priority`
1756 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
1757 WHERE NOT `workerqueue`.`done`;