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