1 -- ------------------------------------------
2 -- Friendica 2020.09-dev (Red Hot Poker)
3 -- DB_UPDATE_VERSION 1364
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 `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
102 `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
103 `pending` boolean NOT NULL DEFAULT '1' COMMENT '',
104 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
105 `rating` tinyint NOT NULL DEFAULT 0 COMMENT '',
106 `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
107 `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
108 `baseurl` varchar(255) DEFAULT '' COMMENT 'baseurl of the contact',
109 `gsid` int unsigned COMMENT 'Global Server ID',
110 `reason` text COMMENT '',
111 `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT '',
112 `info` mediumtext COMMENT '',
113 `profile-id` int unsigned COMMENT 'Deprecated',
114 `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
115 `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
116 `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
117 `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
118 `ffi_keyword_denylist` text COMMENT '',
120 INDEX `uid_name` (`uid`,`name`(190)),
121 INDEX `self_uid` (`self`,`uid`),
122 INDEX `alias_uid` (`alias`(96),`uid`),
123 INDEX `pending_uid` (`pending`,`uid`),
124 INDEX `blocked_uid` (`blocked`,`uid`),
125 INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
126 INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
127 INDEX `addr_uid` (`addr`(96),`uid`),
128 INDEX `nurl_uid` (`nurl`(96),`uid`),
129 INDEX `nick_uid` (`nick`(32),`uid`),
130 INDEX `attag_uid` (`attag`(96),`uid`),
131 INDEX `dfrn-id` (`dfrn-id`(64)),
132 INDEX `issued-id` (`issued-id`(64)),
133 INDEX `network_uid_lastupdate` (`network`,`uid`,`last-update`),
134 INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`),
135 INDEX `uid_lastitem` (`uid`,`last-item`),
136 INDEX `gsid` (`gsid`),
137 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
138 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
143 CREATE TABLE IF NOT EXISTS `item-uri` (
144 `id` int unsigned NOT NULL auto_increment,
145 `uri` varbinary(255) NOT NULL COMMENT 'URI of an item',
146 `guid` varbinary(255) COMMENT 'A unique identifier for an item',
148 UNIQUE INDEX `uri` (`uri`),
149 INDEX `guid` (`guid`)
150 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
155 CREATE TABLE IF NOT EXISTS `tag` (
156 `id` int unsigned NOT NULL auto_increment COMMENT '',
157 `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
158 `url` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
160 UNIQUE INDEX `type_name_url` (`name`,`url`),
162 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
167 CREATE TABLE IF NOT EXISTS `user` (
168 `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
169 `parent-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'The parent user that has full control about this user',
170 `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
171 `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
172 `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
173 `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
174 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
175 `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
176 `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
177 `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
178 `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
179 `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
180 `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
181 `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
182 `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
183 `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
184 `pubkey` text COMMENT 'RSA public key 4096 bit',
185 `prvkey` text COMMENT 'RSA private key 4096 bit',
186 `spubkey` text COMMENT '',
187 `sprvkey` text COMMENT '',
188 `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
189 `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
190 `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
191 `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unkown viewers',
192 `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
193 `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
194 `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
195 `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
196 `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
197 `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
198 `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
199 `pwdreset` varchar(255) COMMENT 'Password reset request token',
200 `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
201 `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
202 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
203 `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
204 `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
205 `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
206 `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
207 `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
208 `allow_cid` mediumtext COMMENT 'default permission for this user',
209 `allow_gid` mediumtext COMMENT 'default permission for this user',
210 `deny_cid` mediumtext COMMENT 'default permission for this user',
211 `deny_gid` mediumtext COMMENT 'default permission for this user',
212 `openidserver` text COMMENT '',
214 INDEX `nickname` (`nickname`(32))
215 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
220 CREATE TABLE IF NOT EXISTS `clients` (
221 `client_id` varchar(20) NOT NULL COMMENT '',
222 `pw` varchar(20) NOT NULL DEFAULT '' COMMENT '',
223 `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
224 `name` text COMMENT '',
225 `icon` text COMMENT '',
226 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
227 PRIMARY KEY(`client_id`),
229 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
230 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
233 -- TABLE permissionset
235 CREATE TABLE IF NOT EXISTS `permissionset` (
236 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
237 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
238 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
239 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
240 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
241 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
243 INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30))
244 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
247 -- TABLE 2fa_app_specific_password
249 CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
250 `id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
251 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
252 `description` varchar(255) COMMENT 'Description of the usage of the password',
253 `hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
254 `generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
255 `last_used` datetime COMMENT 'Datetime the password was last used',
257 INDEX `uid_description` (`uid`,`description`(190)),
258 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
259 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
262 -- TABLE 2fa_recovery_codes
264 CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
265 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
266 `code` varchar(50) NOT NULL COMMENT 'Recovery code string',
267 `generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
268 `used` datetime COMMENT 'Datetime the code was used',
269 PRIMARY KEY(`uid`,`code`),
270 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
271 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
276 CREATE TABLE IF NOT EXISTS `addon` (
277 `id` int unsigned NOT NULL auto_increment COMMENT '',
278 `name` varchar(50) NOT NULL DEFAULT '' COMMENT 'addon base (file)name',
279 `version` varchar(50) NOT NULL DEFAULT '' COMMENT 'currently unused',
280 `installed` boolean NOT NULL DEFAULT '0' COMMENT 'currently always 1',
281 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'currently unused',
282 `timestamp` int unsigned NOT NULL DEFAULT 0 COMMENT 'file timestamp to check for reloads',
283 `plugin_admin` boolean NOT NULL DEFAULT '0' COMMENT '1 = has admin config, 0 = has no admin config',
285 UNIQUE INDEX `name` (`name`)
286 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registered addons';
291 CREATE TABLE IF NOT EXISTS `apcontact` (
292 `url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
293 `uuid` varchar(255) COMMENT '',
294 `type` varchar(20) NOT NULL COMMENT '',
295 `following` varchar(255) COMMENT '',
296 `followers` varchar(255) COMMENT '',
297 `inbox` varchar(255) NOT NULL COMMENT '',
298 `outbox` varchar(255) COMMENT '',
299 `sharedinbox` varchar(255) COMMENT '',
300 `manually-approve` boolean COMMENT '',
301 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
302 `name` varchar(255) COMMENT '',
303 `about` text COMMENT '',
304 `photo` varchar(255) COMMENT '',
305 `addr` varchar(255) COMMENT '',
306 `alias` varchar(255) COMMENT '',
307 `pubkey` text COMMENT '',
308 `subscribe` varchar(255) COMMENT '',
309 `baseurl` varchar(255) COMMENT 'baseurl of the ap contact',
310 `gsid` int unsigned COMMENT 'Global Server ID',
311 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
312 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
313 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
314 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
315 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
317 INDEX `addr` (`addr`(32)),
318 INDEX `alias` (`alias`(190)),
319 INDEX `followers` (`followers`(190)),
320 INDEX `baseurl` (`baseurl`(190)),
321 INDEX `gsid` (`gsid`),
322 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
323 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
328 CREATE TABLE IF NOT EXISTS `attach` (
329 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
330 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
331 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
332 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
333 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
334 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
335 `data` longblob NOT NULL COMMENT 'file data',
336 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
337 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
338 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
339 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
340 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
341 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
342 `backend-class` tinytext COMMENT 'Storage backend class',
343 `backend-ref` text COMMENT 'Storage backend data reference',
346 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
347 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
352 CREATE TABLE IF NOT EXISTS `auth_codes` (
353 `id` varchar(40) NOT NULL COMMENT '',
354 `client_id` varchar(20) NOT NULL DEFAULT '' COMMENT '',
355 `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
356 `expires` int NOT NULL DEFAULT 0 COMMENT '',
357 `scope` varchar(250) NOT NULL DEFAULT '' COMMENT '',
359 INDEX `client_id` (`client_id`),
360 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE
361 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
366 CREATE TABLE IF NOT EXISTS `cache` (
367 `k` varbinary(255) NOT NULL COMMENT 'cache key',
368 `v` mediumtext COMMENT 'cached serialized value',
369 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
370 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
372 INDEX `k_expires` (`k`,`expires`)
373 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
378 CREATE TABLE IF NOT EXISTS `challenge` (
379 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
380 `challenge` varchar(255) NOT NULL DEFAULT '' COMMENT '',
381 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
382 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
383 `type` varchar(255) NOT NULL DEFAULT '' COMMENT '',
384 `last_update` varchar(255) NOT NULL DEFAULT '' COMMENT '',
386 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
391 CREATE TABLE IF NOT EXISTS `config` (
392 `id` int unsigned NOT NULL auto_increment COMMENT '',
393 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
394 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
395 `v` mediumtext COMMENT '',
397 UNIQUE INDEX `cat_k` (`cat`,`k`)
398 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
401 -- TABLE contact-relation
403 CREATE TABLE IF NOT EXISTS `contact-relation` (
404 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
405 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
406 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
407 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
408 `follows` boolean NOT NULL DEFAULT '0' COMMENT '',
409 PRIMARY KEY(`cid`,`relation-cid`),
410 INDEX `relation-cid` (`relation-cid`),
411 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
412 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
413 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
418 CREATE TABLE IF NOT EXISTS `conv` (
419 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
420 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
421 `recips` text COMMENT 'sender_handle;recipient_handle',
422 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
423 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
424 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
425 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
426 `subject` text COMMENT 'subject of initial message',
429 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
430 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
433 -- TABLE conversation
435 CREATE TABLE IF NOT EXISTS `conversation` (
436 `item-uri` varbinary(255) NOT NULL COMMENT 'Original URI of the item - unrelated to the table with the same name',
437 `reply-to-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'URI to which this item is a reply',
438 `conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI',
439 `conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link',
440 `protocol` tinyint unsigned NOT NULL DEFAULT 255 COMMENT 'The protocol of the item',
441 `direction` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'How the message arrived here: 1=push, 2=pull',
442 `source` mediumtext COMMENT 'Original source',
443 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Receiving date',
444 PRIMARY KEY(`item-uri`),
445 INDEX `conversation-uri` (`conversation-uri`),
446 INDEX `received` (`received`)
447 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Raw data and structure information for messages';
450 -- TABLE diaspora-interaction
452 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
453 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
454 `interaction` mediumtext COMMENT 'The Diaspora interaction',
455 PRIMARY KEY(`uri-id`),
456 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
457 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
462 CREATE TABLE IF NOT EXISTS `event` (
463 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
464 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
465 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
466 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
467 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
468 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
469 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
470 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
471 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
472 `summary` text COMMENT 'short description or title of the event',
473 `desc` text COMMENT 'event description',
474 `location` text COMMENT 'event location',
475 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
476 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
477 `adjust` boolean NOT NULL DEFAULT '1' COMMENT 'adjust to timezone of the recipient (0 or 1)',
478 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
479 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
480 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
481 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
482 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
484 INDEX `uid_start` (`uid`,`start`),
486 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
487 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
492 CREATE TABLE IF NOT EXISTS `fcontact` (
493 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
494 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
495 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
496 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
497 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
498 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
499 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
500 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
501 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
502 `notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
503 `poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
504 `confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
505 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
506 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
507 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
508 `pubkey` text COMMENT '',
509 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
511 INDEX `addr` (`addr`(32)),
512 UNIQUE INDEX `url` (`url`(190))
513 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
518 CREATE TABLE IF NOT EXISTS `fsuggest` (
519 `id` int unsigned NOT NULL auto_increment COMMENT '',
520 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
521 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
522 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
523 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
524 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
525 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
526 `note` text COMMENT '',
527 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
531 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
532 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
533 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
538 CREATE TABLE IF NOT EXISTS `group` (
539 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
540 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
541 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
542 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
543 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
546 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
547 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
550 -- TABLE group_member
552 CREATE TABLE IF NOT EXISTS `group_member` (
553 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
554 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
555 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
557 INDEX `contactid` (`contact-id`),
558 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
559 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
560 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
561 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
566 CREATE TABLE IF NOT EXISTS `gserver-tag` (
567 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
568 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
569 PRIMARY KEY(`gserver-id`,`tag`),
571 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
572 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
577 CREATE TABLE IF NOT EXISTS `hook` (
578 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
579 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
580 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
581 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
582 `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',
584 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
585 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
588 -- TABLE inbox-status
590 CREATE TABLE IF NOT EXISTS `inbox-status` (
591 `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
592 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
593 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
594 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
595 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
596 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
597 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
599 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
604 CREATE TABLE IF NOT EXISTS `intro` (
605 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
606 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
607 `fid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
608 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
609 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
610 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
611 `note` text COMMENT '',
612 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
613 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
614 `blocked` boolean NOT NULL DEFAULT '1' COMMENT '',
615 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
617 INDEX `contact-id` (`contact-id`),
619 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
620 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
625 CREATE TABLE IF NOT EXISTS `item` (
626 `id` int unsigned NOT NULL auto_increment,
627 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this item',
628 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
629 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
630 `uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
631 `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',
632 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT 'uri of the parent to this item',
633 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
634 `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',
635 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
636 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
637 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
638 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last comment/reply to this item',
639 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
640 `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',
641 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
642 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
643 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
644 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
645 `icid` int unsigned COMMENT 'Id of the item-content table entry that contains the whole item content',
646 `iaid` int unsigned COMMENT 'Id of the item-activity table entry that contains the activity data',
647 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
648 `extid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
649 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
650 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
651 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
652 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
653 `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
654 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been deleted',
655 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
656 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
657 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
658 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
659 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
660 `starred` boolean NOT NULL DEFAULT '0' COMMENT 'item has been favourited',
661 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'item has not been seen',
662 `mention` boolean NOT NULL DEFAULT '0' COMMENT 'The owner of this item was mentioned in it',
663 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
664 `psid` int unsigned COMMENT 'ID of the permission set of this post',
665 `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',
666 `event-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Used to link to the event.id',
667 `attach` mediumtext COMMENT 'JSON structure representing attachments to this item',
668 `allow_cid` mediumtext COMMENT 'Deprecated',
669 `allow_gid` mediumtext COMMENT 'Deprecated',
670 `deny_cid` mediumtext COMMENT 'Deprecated',
671 `deny_gid` mediumtext COMMENT 'Deprecated',
672 `postopts` text COMMENT 'Deprecated',
673 `inform` mediumtext COMMENT 'Deprecated',
674 `type` varchar(20) COMMENT 'Deprecated',
675 `bookmark` boolean COMMENT 'Deprecated',
676 `file` mediumtext COMMENT 'Deprecated',
677 `location` varchar(255) COMMENT 'Deprecated',
678 `coord` varchar(255) COMMENT 'Deprecated',
679 `tag` mediumtext COMMENT 'Deprecated',
680 `plink` varchar(255) COMMENT 'Deprecated',
681 `title` varchar(255) COMMENT 'Deprecated',
682 `content-warning` varchar(255) COMMENT 'Deprecated',
683 `body` mediumtext COMMENT 'Deprecated',
684 `app` varchar(255) COMMENT 'Deprecated',
685 `verb` varchar(100) COMMENT 'Deprecated',
686 `object-type` varchar(100) COMMENT 'Deprecated',
687 `object` text COMMENT 'Deprecated',
688 `target-type` varchar(100) COMMENT 'Deprecated',
689 `target` text COMMENT 'Deprecated',
690 `author-name` varchar(255) COMMENT 'Deprecated',
691 `author-link` varchar(255) COMMENT 'Deprecated',
692 `author-avatar` varchar(255) COMMENT 'Deprecated',
693 `owner-name` varchar(255) COMMENT 'Deprecated',
694 `owner-link` varchar(255) COMMENT 'Deprecated',
695 `owner-avatar` varchar(255) COMMENT 'Deprecated',
696 `rendered-hash` varchar(32) COMMENT 'Deprecated',
697 `rendered-html` mediumtext COMMENT 'Deprecated',
699 INDEX `guid` (`guid`(191)),
700 INDEX `uri` (`uri`(191)),
701 INDEX `parent` (`parent`),
702 INDEX `parent-uri` (`parent-uri`(191)),
703 INDEX `extid` (`extid`(191)),
704 INDEX `uid_id` (`uid`,`id`),
705 INDEX `uid_contactid_id` (`uid`,`contact-id`,`id`),
706 INDEX `uid_received` (`uid`,`received`),
707 INDEX `uid_commented` (`uid`,`commented`),
708 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
709 INDEX `uid_network_received` (`uid`,`network`,`received`),
710 INDEX `uid_network_commented` (`uid`,`network`,`commented`),
711 INDEX `uid_thrparent` (`uid`,`thr-parent`(190)),
712 INDEX `uid_parenturi` (`uid`,`parent-uri`(190)),
713 INDEX `uid_contactid_received` (`uid`,`contact-id`,`received`),
714 INDEX `authorid_received` (`author-id`,`received`),
715 INDEX `ownerid` (`owner-id`),
716 INDEX `contact-id` (`contact-id`),
717 INDEX `uid_uri` (`uid`,`uri`(190)),
718 INDEX `resource-id` (`resource-id`),
719 INDEX `deleted_changed` (`deleted`,`changed`),
720 INDEX `uid_wall_changed` (`uid`,`wall`,`changed`),
721 INDEX `uid_unseen_wall` (`uid`,`unseen`,`wall`),
722 INDEX `mention_uid_id` (`mention`,`uid`,`id`),
723 INDEX `uid_eventid` (`uid`,`event-id`),
724 INDEX `icid` (`icid`),
725 INDEX `iaid` (`iaid`),
726 INDEX `psid_wall` (`psid`,`wall`),
727 INDEX `uri-id` (`uri-id`),
728 INDEX `parent-uri-id` (`parent-uri-id`),
729 INDEX `thr-parent-id` (`thr-parent-id`),
730 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
731 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
732 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
733 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
734 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
737 -- TABLE item-activity
739 CREATE TABLE IF NOT EXISTS `item-activity` (
740 `id` int unsigned NOT NULL auto_increment,
741 `uri` varchar(255) COMMENT '',
742 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
743 `uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
744 `activity` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
746 UNIQUE INDEX `uri-hash` (`uri-hash`),
747 INDEX `uri` (`uri`(191)),
748 INDEX `uri-id` (`uri-id`),
749 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
750 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activities for items';
753 -- TABLE item-content
755 CREATE TABLE IF NOT EXISTS `item-content` (
756 `id` int unsigned NOT NULL auto_increment,
757 `uri` varchar(255) COMMENT '',
758 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
759 `uri-plink-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
760 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
761 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
762 `body` mediumtext COMMENT 'item body content',
763 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
764 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
765 `language` text COMMENT 'Language information about this post',
766 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
767 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
768 `rendered-html` mediumtext COMMENT 'item.body converted to html',
769 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
770 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
771 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
772 `target` text COMMENT 'JSON encoded target structure if used',
773 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
774 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams verb',
776 UNIQUE INDEX `uri-plink-hash` (`uri-plink-hash`),
777 INDEX `uri` (`uri`(191)),
778 INDEX `plink` (`plink`(191)),
779 INDEX `uri-id` (`uri-id`),
780 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
781 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
786 CREATE TABLE IF NOT EXISTS `locks` (
787 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
788 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
789 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
790 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
791 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
793 INDEX `name_expires` (`name`,`expires`)
794 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
799 CREATE TABLE IF NOT EXISTS `mail` (
800 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
801 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
802 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
803 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
804 `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
805 `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
806 `contact-id` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact.id',
807 `convid` int unsigned NOT NULL DEFAULT 0 COMMENT 'conv.id',
808 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
809 `body` mediumtext COMMENT '',
810 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
811 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
812 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
813 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
814 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
815 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
816 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
818 INDEX `uid_seen` (`uid`,`seen`),
819 INDEX `convid` (`convid`),
820 INDEX `uri` (`uri`(64)),
821 INDEX `parent-uri` (`parent-uri`(64)),
822 INDEX `contactid` (`contact-id`(32)),
823 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
824 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
829 CREATE TABLE IF NOT EXISTS `mailacct` (
830 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
831 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
832 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
833 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
834 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
835 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
836 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
837 `pass` text COMMENT '',
838 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
839 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
840 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
841 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
842 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
845 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
846 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
851 CREATE TABLE IF NOT EXISTS `manage` (
852 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
853 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
854 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
856 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
858 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
859 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
860 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
865 CREATE TABLE IF NOT EXISTS `notify` (
866 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
867 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
868 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
869 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
870 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
871 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
872 `msg` mediumtext COMMENT '',
873 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
874 `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
875 `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'item.id',
876 `parent` int unsigned NOT NULL DEFAULT 0 COMMENT '',
877 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
878 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
879 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
880 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
881 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
882 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
883 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
885 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
886 INDEX `uid_date` (`uid`,`date`),
887 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
888 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
889 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
892 -- TABLE notify-threads
894 CREATE TABLE IF NOT EXISTS `notify-threads` (
895 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
896 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
897 `master-parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
898 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
899 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
900 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
902 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
903 INDEX `receiver-uid` (`receiver-uid`),
904 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
905 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
910 CREATE TABLE IF NOT EXISTS `oembed` (
911 `url` varbinary(255) NOT NULL COMMENT 'page url',
912 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
913 `content` mediumtext COMMENT 'OEmbed data of the page',
914 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
915 PRIMARY KEY(`url`,`maxwidth`),
916 INDEX `created` (`created`)
917 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
920 -- TABLE openwebauth-token
922 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
923 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
924 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
925 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
926 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
927 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
928 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
931 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
932 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
937 CREATE TABLE IF NOT EXISTS `parsed_url` (
938 `url` varbinary(255) NOT NULL COMMENT 'page url',
939 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
940 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
941 `content` mediumtext COMMENT 'page data',
942 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
943 PRIMARY KEY(`url`,`guessing`,`oembed`),
944 INDEX `created` (`created`)
945 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
948 -- TABLE participation
950 CREATE TABLE IF NOT EXISTS `participation` (
951 `iid` int unsigned NOT NULL COMMENT '',
952 `server` varchar(60) NOT NULL COMMENT '',
953 `cid` int unsigned NOT NULL COMMENT '',
954 `fid` int unsigned NOT NULL COMMENT '',
955 PRIMARY KEY(`iid`,`server`),
958 FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
959 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
960 FOREIGN KEY (`fid`) REFERENCES `fcontact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
961 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Storage for participation messages from Diaspora';
966 CREATE TABLE IF NOT EXISTS `pconfig` (
967 `id` int unsigned NOT NULL auto_increment COMMENT '',
968 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
969 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
970 `k` varbinary(100) NOT NULL DEFAULT '' COMMENT '',
971 `v` mediumtext COMMENT '',
973 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
974 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
975 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
980 CREATE TABLE IF NOT EXISTS `photo` (
981 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
982 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
983 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
984 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
985 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
986 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
987 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
988 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
989 `desc` text COMMENT '',
990 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
991 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
992 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
993 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
994 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
995 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
996 `data` mediumblob NOT NULL COMMENT '',
997 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
998 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
999 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
1000 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
1001 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
1002 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
1003 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
1004 `backend-class` tinytext COMMENT 'Storage backend class',
1005 `backend-ref` text COMMENT 'Storage backend data reference',
1006 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1008 INDEX `contactid` (`contact-id`),
1009 INDEX `uid_contactid` (`uid`,`contact-id`),
1010 INDEX `uid_profile` (`uid`,`profile`),
1011 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
1012 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
1013 INDEX `resource-id` (`resource-id`),
1014 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1015 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1018 -- TABLE post-category
1020 CREATE TABLE IF NOT EXISTS `post-category` (
1021 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1022 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1023 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1024 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1025 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1026 INDEX `uri-id` (`tid`),
1027 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1028 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1029 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1032 -- TABLE post-delivery-data
1034 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1035 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1036 `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',
1037 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1038 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1039 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1040 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1041 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1042 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1043 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1044 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1045 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1046 PRIMARY KEY(`uri-id`),
1047 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1048 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1053 CREATE TABLE IF NOT EXISTS `post-tag` (
1054 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1055 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1056 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1057 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1058 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1059 INDEX `tid` (`tid`),
1060 INDEX `cid` (`cid`),
1061 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1062 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1063 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1064 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1069 CREATE TABLE IF NOT EXISTS `process` (
1070 `pid` int unsigned NOT NULL COMMENT '',
1071 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1072 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1074 INDEX `command` (`command`)
1075 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1080 CREATE TABLE IF NOT EXISTS `profile` (
1081 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1082 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1083 `profile-name` varchar(255) COMMENT 'Deprecated',
1084 `is-default` boolean COMMENT 'Deprecated',
1085 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1086 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1087 `pdesc` varchar(255) COMMENT 'Deprecated',
1088 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1089 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1090 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1091 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1092 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1093 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1094 `hometown` varchar(255) COMMENT 'Deprecated',
1095 `gender` varchar(32) COMMENT 'Deprecated',
1096 `marital` varchar(255) COMMENT 'Deprecated',
1097 `with` text COMMENT 'Deprecated',
1098 `howlong` datetime COMMENT 'Deprecated',
1099 `sexual` varchar(255) COMMENT 'Deprecated',
1100 `politic` varchar(255) COMMENT 'Deprecated',
1101 `religion` varchar(255) COMMENT 'Deprecated',
1102 `pub_keywords` text COMMENT '',
1103 `prv_keywords` text COMMENT '',
1104 `likes` text COMMENT 'Deprecated',
1105 `dislikes` text COMMENT 'Deprecated',
1106 `about` text COMMENT 'Profile description',
1107 `summary` varchar(255) COMMENT 'Deprecated',
1108 `music` text COMMENT 'Deprecated',
1109 `book` text COMMENT 'Deprecated',
1110 `tv` text COMMENT 'Deprecated',
1111 `film` text COMMENT 'Deprecated',
1112 `interest` text COMMENT 'Deprecated',
1113 `romance` text COMMENT 'Deprecated',
1114 `work` text COMMENT 'Deprecated',
1115 `education` text COMMENT 'Deprecated',
1116 `contact` text COMMENT 'Deprecated',
1117 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1118 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1119 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1120 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1121 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1122 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1124 INDEX `uid_is-default` (`uid`,`is-default`),
1125 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1126 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1127 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1130 -- TABLE profile_check
1132 CREATE TABLE IF NOT EXISTS `profile_check` (
1133 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1134 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1135 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1136 `dfrn_id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1137 `sec` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1138 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1140 INDEX `uid` (`uid`),
1141 INDEX `cid` (`cid`),
1142 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1143 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1144 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='DFRN remote auth use';
1147 -- TABLE profile_field
1149 CREATE TABLE IF NOT EXISTS `profile_field` (
1150 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1151 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1152 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1153 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1154 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1155 `value` text COMMENT 'Value of the field',
1156 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1157 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1159 INDEX `uid` (`uid`),
1160 INDEX `order` (`order`),
1161 INDEX `psid` (`psid`),
1162 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1163 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1164 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1167 -- TABLE push_subscriber
1169 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1170 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1171 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1172 `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1173 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1174 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1175 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1176 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1177 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1178 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1179 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1181 INDEX `next_try` (`next_try`),
1182 INDEX `uid` (`uid`),
1183 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1184 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1189 CREATE TABLE IF NOT EXISTS `register` (
1190 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1191 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1192 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1193 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1194 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1195 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1196 `note` text COMMENT '',
1198 INDEX `uid` (`uid`),
1199 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1200 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1205 CREATE TABLE IF NOT EXISTS `search` (
1206 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1207 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1208 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1210 INDEX `uid` (`uid`),
1211 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1212 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1217 CREATE TABLE IF NOT EXISTS `session` (
1218 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1219 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1220 `data` text COMMENT '',
1221 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1223 INDEX `sid` (`sid`(64)),
1224 INDEX `expire` (`expire`)
1225 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1230 CREATE TABLE IF NOT EXISTS `storage` (
1231 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1232 `data` longblob NOT NULL COMMENT 'file data',
1234 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1239 CREATE TABLE IF NOT EXISTS `thread` (
1240 `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'sequential ID',
1241 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
1242 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1243 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1244 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1245 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1246 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1247 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1248 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1249 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1250 `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1251 `wall` boolean NOT NULL DEFAULT '0' COMMENT '',
1252 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1253 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1254 `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
1255 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1256 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1257 `ignored` boolean NOT NULL DEFAULT '0' COMMENT '',
1258 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
1259 `unseen` boolean NOT NULL DEFAULT '1' COMMENT '',
1260 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '',
1261 `origin` boolean NOT NULL DEFAULT '0' COMMENT '',
1262 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1263 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1264 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1265 `bookmark` boolean COMMENT '',
1267 INDEX `uid_network_commented` (`uid`,`network`,`commented`),
1268 INDEX `uid_network_received` (`uid`,`network`,`received`),
1269 INDEX `uid_contactid_commented` (`uid`,`contact-id`,`commented`),
1270 INDEX `uid_contactid_received` (`uid`,`contact-id`,`received`),
1271 INDEX `contactid` (`contact-id`),
1272 INDEX `ownerid` (`owner-id`),
1273 INDEX `authorid` (`author-id`),
1274 INDEX `uid_received` (`uid`,`received`),
1275 INDEX `uid_commented` (`uid`,`commented`),
1276 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1277 INDEX `private_wall_origin_commented` (`private`,`wall`,`origin`,`commented`),
1278 INDEX `uri-id` (`uri-id`),
1279 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1280 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1285 CREATE TABLE IF NOT EXISTS `tokens` (
1286 `id` varchar(40) NOT NULL COMMENT '',
1287 `secret` text COMMENT '',
1288 `client_id` varchar(20) NOT NULL DEFAULT '',
1289 `expires` int NOT NULL DEFAULT 0 COMMENT '',
1290 `scope` varchar(200) NOT NULL DEFAULT '' COMMENT '',
1291 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1293 INDEX `client_id` (`client_id`),
1294 INDEX `uid` (`uid`),
1295 FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1296 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1297 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
1302 CREATE TABLE IF NOT EXISTS `userd` (
1303 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1304 `username` varchar(255) NOT NULL COMMENT '',
1306 INDEX `username` (`username`(32))
1307 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1310 -- TABLE user-contact
1312 CREATE TABLE IF NOT EXISTS `user-contact` (
1313 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1314 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1315 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1316 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1317 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1318 PRIMARY KEY(`uid`,`cid`),
1319 INDEX `cid` (`cid`),
1320 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1321 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1322 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1327 CREATE TABLE IF NOT EXISTS `user-item` (
1328 `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item id',
1329 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1330 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide an item from the user',
1331 `ignored` boolean COMMENT 'Ignore this thread if set',
1332 `pinned` boolean COMMENT 'The item is pinned on the profile page',
1333 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1334 PRIMARY KEY(`uid`,`iid`),
1335 INDEX `uid_pinned` (`uid`,`pinned`),
1336 INDEX `iid_uid` (`iid`,`uid`),
1337 FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1338 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1339 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific item data';
1344 CREATE TABLE IF NOT EXISTS `verb` (
1345 `id` smallint unsigned NOT NULL auto_increment,
1346 `name` varchar(100) NOT NULL DEFAULT '' COMMENT '',
1348 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activity Verbs';
1353 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1354 `key` int NOT NULL COMMENT '',
1355 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1357 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1360 -- TABLE workerqueue
1362 CREATE TABLE IF NOT EXISTS `workerqueue` (
1363 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
1364 `parameter` mediumtext COMMENT 'Task command',
1365 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
1366 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
1367 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
1368 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
1369 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1370 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1371 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
1373 INDEX `done_parameter` (`done`,`parameter`(64)),
1374 INDEX `done_executed` (`done`,`executed`),
1375 INDEX `done_priority_created` (`done`,`priority`,`created`),
1376 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
1377 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
1378 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
1379 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
1380 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
1383 -- VIEW category-view
1385 DROP VIEW IF EXISTS `category-view`;
1386 CREATE VIEW `category-view` AS SELECT
1387 `post-category`.`uri-id` AS `uri-id`,
1388 `post-category`.`uid` AS `uid`,
1389 `item-uri`.`uri` AS `uri`,
1390 `item-uri`.`guid` AS `guid`,
1391 `post-category`.`type` AS `type`,
1392 `post-category`.`tid` AS `tid`,
1393 `tag`.`name` AS `name`,
1394 `tag`.`url` AS `url`
1395 FROM `post-category`
1396 INNER JOIN `item-uri` ON `item-uri`.id = `post-category`.`uri-id`
1397 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
1402 DROP VIEW IF EXISTS `tag-view`;
1403 CREATE VIEW `tag-view` AS SELECT
1404 `post-tag`.`uri-id` AS `uri-id`,
1405 `item-uri`.`uri` AS `uri`,
1406 `item-uri`.`guid` AS `guid`,
1407 `post-tag`.`type` AS `type`,
1408 `post-tag`.`tid` AS `tid`,
1409 `post-tag`.`cid` AS `cid`,
1410 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
1411 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
1413 INNER JOIN `item-uri` ON `item-uri`.id = `post-tag`.`uri-id`
1414 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
1415 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
1418 -- VIEW network-item-view
1420 DROP VIEW IF EXISTS `network-item-view`;
1421 CREATE VIEW `network-item-view` AS SELECT
1422 `item`.`parent-uri-id` AS `uri-id`,
1423 `item`.`parent-uri` AS `uri`,
1424 `item`.`parent` AS `parent`,
1425 `item`.`received` AS `received`,
1426 `item`.`commented` AS `commented`,
1427 `item`.`created` AS `created`,
1428 `item`.`uid` AS `uid`,
1429 `item`.`starred` AS `starred`,
1430 `item`.`mention` AS `mention`,
1431 `item`.`network` AS `network`,
1432 `item`.`unseen` AS `unseen`,
1433 `item`.`gravity` AS `gravity`,
1434 `item`.`contact-id` AS `contact-id`
1436 INNER JOIN `thread` ON `thread`.`iid` = `item`.`parent`
1437 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
1438 LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
1439 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
1440 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
1441 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
1442 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
1443 AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
1444 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
1445 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
1448 -- VIEW network-thread-view
1450 DROP VIEW IF EXISTS `network-thread-view`;
1451 CREATE VIEW `network-thread-view` AS SELECT
1452 `item`.`uri-id` AS `uri-id`,
1453 `item`.`uri` AS `uri`,
1454 `item`.`parent-uri-id` AS `parent-uri-id`,
1455 `thread`.`iid` AS `parent`,
1456 `thread`.`received` AS `received`,
1457 `thread`.`commented` AS `commented`,
1458 `thread`.`created` AS `created`,
1459 `thread`.`uid` AS `uid`,
1460 `thread`.`starred` AS `starred`,
1461 `thread`.`mention` AS `mention`,
1462 `thread`.`network` AS `network`,
1463 `thread`.`contact-id` AS `contact-id`
1465 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
1466 STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
1467 LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
1468 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
1469 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
1470 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
1471 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
1472 AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
1473 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
1474 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
1479 DROP VIEW IF EXISTS `owner-view`;
1480 CREATE VIEW `owner-view` AS SELECT
1481 `contact`.`id` AS `id`,
1482 `contact`.`uid` AS `uid`,
1483 `contact`.`created` AS `created`,
1484 `contact`.`updated` AS `updated`,
1485 `contact`.`self` AS `self`,
1486 `contact`.`remote_self` AS `remote_self`,
1487 `contact`.`rel` AS `rel`,
1488 `contact`.`duplex` AS `duplex`,
1489 `contact`.`network` AS `network`,
1490 `contact`.`protocol` AS `protocol`,
1491 `contact`.`name` AS `name`,
1492 `contact`.`nick` AS `nick`,
1493 `contact`.`location` AS `location`,
1494 `contact`.`about` AS `about`,
1495 `contact`.`keywords` AS `keywords`,
1496 `contact`.`gender` AS `gender`,
1497 `contact`.`xmpp` AS `xmpp`,
1498 `contact`.`attag` AS `attag`,
1499 `contact`.`avatar` AS `avatar`,
1500 `contact`.`photo` AS `photo`,
1501 `contact`.`thumb` AS `thumb`,
1502 `contact`.`micro` AS `micro`,
1503 `contact`.`site-pubkey` AS `site-pubkey`,
1504 `contact`.`issued-id` AS `issued-id`,
1505 `contact`.`dfrn-id` AS `dfrn-id`,
1506 `contact`.`url` AS `url`,
1507 `contact`.`nurl` AS `nurl`,
1508 `contact`.`addr` AS `addr`,
1509 `contact`.`alias` AS `alias`,
1510 `contact`.`pubkey` AS `pubkey`,
1511 `contact`.`prvkey` AS `prvkey`,
1512 `contact`.`batch` AS `batch`,
1513 `contact`.`request` AS `request`,
1514 `contact`.`notify` AS `notify`,
1515 `contact`.`poll` AS `poll`,
1516 `contact`.`confirm` AS `confirm`,
1517 `contact`.`poco` AS `poco`,
1518 `contact`.`aes_allow` AS `aes_allow`,
1519 `contact`.`ret-aes` AS `ret-aes`,
1520 `contact`.`usehub` AS `usehub`,
1521 `contact`.`subhub` AS `subhub`,
1522 `contact`.`hub-verify` AS `hub-verify`,
1523 `contact`.`last-update` AS `last-update`,
1524 `contact`.`success_update` AS `success_update`,
1525 `contact`.`failure_update` AS `failure_update`,
1526 `contact`.`name-date` AS `name-date`,
1527 `contact`.`uri-date` AS `uri-date`,
1528 `contact`.`avatar-date` AS `avatar-date`,
1529 `contact`.`avatar-date` AS `picdate`,
1530 `contact`.`term-date` AS `term-date`,
1531 `contact`.`last-item` AS `last-item`,
1532 `contact`.`priority` AS `priority`,
1533 `contact`.`blocked` AS `blocked`,
1534 `contact`.`block_reason` AS `block_reason`,
1535 `contact`.`readonly` AS `readonly`,
1536 `contact`.`writable` AS `writable`,
1537 `contact`.`forum` AS `forum`,
1538 `contact`.`prv` AS `prv`,
1539 `contact`.`contact-type` AS `contact-type`,
1540 `contact`.`hidden` AS `hidden`,
1541 `contact`.`archive` AS `archive`,
1542 `contact`.`pending` AS `pending`,
1543 `contact`.`deleted` AS `deleted`,
1544 `contact`.`unsearchable` AS `unsearchable`,
1545 `contact`.`sensitive` AS `sensitive`,
1546 `contact`.`baseurl` AS `baseurl`,
1547 `contact`.`reason` AS `reason`,
1548 `contact`.`closeness` AS `closeness`,
1549 `contact`.`info` AS `info`,
1550 `contact`.`profile-id` AS `profile-id`,
1551 `contact`.`bdyear` AS `bdyear`,
1552 `contact`.`bd` AS `bd`,
1553 `contact`.`notify_new_posts` AS `notify_new_posts`,
1554 `contact`.`fetch_further_information` AS `fetch_further_information`,
1555 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
1556 `user`.`parent-uid` AS `parent-uid`,
1557 `user`.`guid` AS `guid`,
1558 `user`.`nickname` AS `nickname`,
1559 `user`.`email` AS `email`,
1560 `user`.`openid` AS `openid`,
1561 `user`.`timezone` AS `timezone`,
1562 `user`.`language` AS `language`,
1563 `user`.`register_date` AS `register_date`,
1564 `user`.`login_date` AS `login_date`,
1565 `user`.`default-location` AS `default-location`,
1566 `user`.`allow_location` AS `allow_location`,
1567 `user`.`theme` AS `theme`,
1568 `user`.`pubkey` AS `upubkey`,
1569 `user`.`prvkey` AS `uprvkey`,
1570 `user`.`sprvkey` AS `sprvkey`,
1571 `user`.`spubkey` AS `spubkey`,
1572 `user`.`verified` AS `verified`,
1573 `user`.`blockwall` AS `blockwall`,
1574 `user`.`hidewall` AS `hidewall`,
1575 `user`.`blocktags` AS `blocktags`,
1576 `user`.`unkmail` AS `unkmail`,
1577 `user`.`cntunkmail` AS `cntunkmail`,
1578 `user`.`notify-flags` AS `notify-flags`,
1579 `user`.`page-flags` AS `page-flags`,
1580 `user`.`account-type` AS `account-type`,
1581 `user`.`prvnets` AS `prvnets`,
1582 `user`.`maxreq` AS `maxreq`,
1583 `user`.`expire` AS `expire`,
1584 `user`.`account_removed` AS `account_removed`,
1585 `user`.`account_expired` AS `account_expired`,
1586 `user`.`account_expires_on` AS `account_expires_on`,
1587 `user`.`expire_notification_sent` AS `expire_notification_sent`,
1588 `user`.`def_gid` AS `def_gid`,
1589 `user`.`allow_cid` AS `allow_cid`,
1590 `user`.`allow_gid` AS `allow_gid`,
1591 `user`.`deny_cid` AS `deny_cid`,
1592 `user`.`deny_gid` AS `deny_gid`,
1593 `user`.`openidserver` AS `openidserver`,
1594 `profile`.`publish` AS `publish`,
1595 `profile`.`net-publish` AS `net-publish`,
1596 `profile`.`hide-friends` AS `hide-friends`,
1597 `profile`.`prv_keywords` AS `prv_keywords`,
1598 `profile`.`pub_keywords` AS `pub_keywords`,
1599 `profile`.`address` AS `address`,
1600 `profile`.`locality` AS `locality`,
1601 `profile`.`region` AS `region`,
1602 `profile`.`postal-code` AS `postal-code`,
1603 `profile`.`country-name` AS `country-name`,
1604 `profile`.`homepage` AS `homepage`,
1605 `profile`.`dob` AS `dob`
1607 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
1608 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
1611 -- VIEW pending-view
1613 DROP VIEW IF EXISTS `pending-view`;
1614 CREATE VIEW `pending-view` AS SELECT
1615 `register`.`id` AS `id`,
1616 `register`.`hash` AS `hash`,
1617 `register`.`created` AS `created`,
1618 `register`.`uid` AS `uid`,
1619 `register`.`password` AS `password`,
1620 `register`.`language` AS `language`,
1621 `register`.`note` AS `note`,
1622 `contact`.`self` AS `self`,
1623 `contact`.`name` AS `name`,
1624 `contact`.`url` AS `url`,
1625 `contact`.`micro` AS `micro`,
1626 `user`.`email` AS `email`,
1627 `contact`.`nick` AS `nick`
1629 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
1630 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
1633 -- VIEW tag-search-view
1635 DROP VIEW IF EXISTS `tag-search-view`;
1636 CREATE VIEW `tag-search-view` AS SELECT
1637 `post-tag`.`uri-id` AS `uri-id`,
1638 `item`.`id` AS `iid`,
1639 `item`.`uri` AS `uri`,
1640 `item`.`guid` AS `guid`,
1641 `item`.`uid` AS `uid`,
1642 `item`.`private` AS `private`,
1643 `item`.`wall` AS `wall`,
1644 `item`.`origin` AS `origin`,
1645 `item`.`gravity` AS `gravity`,
1646 `item`.`received` AS `received`,
1647 `tag`.`name` AS `name`
1649 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
1650 INNER JOIN `item` ON `item`.`uri-id` = `post-tag`.`uri-id`
1651 WHERE `post-tag`.`type` = 1;
1654 -- VIEW workerqueue-view
1656 DROP VIEW IF EXISTS `workerqueue-view`;
1657 CREATE VIEW `workerqueue-view` AS SELECT
1658 `process`.`pid` AS `pid`,
1659 `workerqueue`.`priority` AS `priority`
1661 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
1662 WHERE NOT `workerqueue`.`done`;