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