1 -- ------------------------------------------
2 -- Friendica 2021.09-dev (Siberian Iris)
3 -- DB_UPDATE_VERSION 1430
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 `protocol` tinyint unsigned COMMENT 'The protocol of the server',
24 `platform` varchar(255) NOT NULL DEFAULT '' COMMENT '',
25 `relay-subscribe` boolean NOT NULL DEFAULT '0' COMMENT 'Has the server subscribed to the relay system',
26 `relay-scope` varchar(10) NOT NULL DEFAULT '' COMMENT 'The scope of messages that the server wants to get',
27 `detection-method` tinyint unsigned COMMENT 'Method that had been used to detect that server',
28 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
29 `last_poco_query` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
30 `last_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Last successful connection request',
31 `last_failure` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Last failed connection request',
32 `failed` boolean COMMENT 'Connection failed',
33 `next_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Next connection request',
35 UNIQUE INDEX `nurl` (`nurl`(190)),
36 INDEX `next_contact` (`next_contact`),
37 INDEX `network` (`network`)
38 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Global servers';
43 CREATE TABLE IF NOT EXISTS `user` (
44 `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
45 `parent-uid` mediumint unsigned COMMENT 'The parent user that has full control about this user',
46 `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
47 `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
48 `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
49 `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
50 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
51 `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
52 `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
53 `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
54 `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
55 `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
56 `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
57 `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
58 `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
59 `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
60 `pubkey` text COMMENT 'RSA public key 4096 bit',
61 `prvkey` text COMMENT 'RSA private key 4096 bit',
62 `spubkey` text COMMENT '',
63 `sprvkey` text COMMENT '',
64 `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
65 `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
66 `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
67 `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unkown viewers',
68 `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
69 `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
70 `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
71 `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
72 `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
73 `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
74 `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
75 `pwdreset` varchar(255) COMMENT 'Password reset request token',
76 `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
77 `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
78 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
79 `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
80 `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
81 `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
82 `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
83 `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
84 `allow_cid` mediumtext COMMENT 'default permission for this user',
85 `allow_gid` mediumtext COMMENT 'default permission for this user',
86 `deny_cid` mediumtext COMMENT 'default permission for this user',
87 `deny_gid` mediumtext COMMENT 'default permission for this user',
88 `openidserver` text COMMENT '',
90 INDEX `nickname` (`nickname`(32)),
91 INDEX `parent-uid` (`parent-uid`),
92 INDEX `guid` (`guid`),
93 INDEX `email` (`email`(64)),
94 FOREIGN KEY (`parent-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
95 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
100 CREATE TABLE IF NOT EXISTS `item-uri` (
101 `id` int unsigned NOT NULL auto_increment,
102 `uri` varbinary(255) NOT NULL COMMENT 'URI of an item',
103 `guid` varbinary(255) COMMENT 'A unique identifier for an item',
105 UNIQUE INDEX `uri` (`uri`),
106 INDEX `guid` (`guid`)
107 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
112 CREATE TABLE IF NOT EXISTS `contact` (
113 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
114 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
115 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
116 `updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last contact update',
117 `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
118 `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
119 `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
120 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
121 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network of the contact',
122 `protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
123 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
124 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
125 `location` varchar(255) DEFAULT '' COMMENT '',
126 `about` text COMMENT '',
127 `keywords` text COMMENT 'public keywords (interests) of the contact',
128 `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
129 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
130 `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
131 `avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '',
132 `photo` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
133 `thumb` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
134 `micro` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
135 `header` varchar(255) COMMENT 'Header picture',
136 `site-pubkey` text COMMENT 'Deprecated',
137 `issued-id` varchar(255) NOT NULL DEFAULT '' COMMENT 'Deprecated',
138 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT 'Deprecated',
139 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
140 `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
141 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
142 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
143 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
144 `pubkey` text COMMENT 'RSA public key 4096 bit',
145 `prvkey` text COMMENT 'RSA private key 4096 bit',
146 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
147 `request` varchar(255) COMMENT '',
148 `notify` varchar(255) COMMENT '',
149 `poll` varchar(255) COMMENT '',
150 `confirm` varchar(255) COMMENT '',
151 `subscribe` varchar(255) COMMENT '',
152 `poco` varchar(255) COMMENT '',
153 `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
154 `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
155 `usehub` boolean NOT NULL DEFAULT '0' COMMENT '',
156 `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
157 `hub-verify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
158 `last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
159 `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
160 `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
161 `failed` boolean COMMENT 'Connection failed',
162 `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
163 `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
164 `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
165 `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
166 `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
167 `last-discovery` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last follower discovery',
168 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
169 `blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
170 `block_reason` text COMMENT 'Node-wide block reason',
171 `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
172 `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
173 `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum',
174 `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group',
175 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT '',
176 `manually-approve` boolean COMMENT '',
177 `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
178 `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
179 `pending` boolean NOT NULL DEFAULT '1' COMMENT '',
180 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
181 `rating` tinyint NOT NULL DEFAULT 0 COMMENT '',
182 `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
183 `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
184 `baseurl` varchar(255) DEFAULT '' COMMENT 'baseurl of the contact',
185 `gsid` int unsigned COMMENT 'Global Server ID',
186 `reason` text COMMENT '',
187 `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT '',
188 `info` mediumtext COMMENT '',
189 `profile-id` int unsigned COMMENT 'Deprecated',
190 `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
191 `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
192 `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
193 `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
194 `ffi_keyword_denylist` text COMMENT '',
196 INDEX `uid_name` (`uid`,`name`(190)),
197 INDEX `self_uid` (`self`,`uid`),
198 INDEX `alias_uid` (`alias`(128),`uid`),
199 INDEX `pending_uid` (`pending`,`uid`),
200 INDEX `blocked_uid` (`blocked`,`uid`),
201 INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
202 INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
203 INDEX `batch_contact-type` (`batch`(64),`contact-type`),
204 INDEX `addr_uid` (`addr`(128),`uid`),
205 INDEX `nurl_uid` (`nurl`(128),`uid`),
206 INDEX `nick_uid` (`nick`(128),`uid`),
207 INDEX `attag_uid` (`attag`(96),`uid`),
208 INDEX `network_uid_lastupdate` (`network`,`uid`,`last-update`),
209 INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`),
210 INDEX `uid_lastitem` (`uid`,`last-item`),
211 INDEX `baseurl` (`baseurl`(64)),
212 INDEX `uid_contact-type` (`uid`,`contact-type`),
213 INDEX `uid_self_contact-type` (`uid`,`self`,`contact-type`),
214 INDEX `self_network_uid` (`self`,`network`,`uid`),
215 INDEX `gsid` (`gsid`),
216 INDEX `uri-id` (`uri-id`),
217 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
218 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
219 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
220 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
225 CREATE TABLE IF NOT EXISTS `tag` (
226 `id` int unsigned NOT NULL auto_increment COMMENT '',
227 `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
228 `url` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
230 UNIQUE INDEX `type_name_url` (`name`,`url`),
232 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
235 -- TABLE permissionset
237 CREATE TABLE IF NOT EXISTS `permissionset` (
238 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
239 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
240 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
241 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
242 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
243 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
245 INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`uid`,`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30)),
246 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
247 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
252 CREATE TABLE IF NOT EXISTS `verb` (
253 `id` smallint unsigned NOT NULL auto_increment,
254 `name` varchar(100) NOT NULL DEFAULT '' COMMENT '',
256 INDEX `name` (`name`)
257 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activity Verbs';
260 -- TABLE 2fa_app_specific_password
262 CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
263 `id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
264 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
265 `description` varchar(255) COMMENT 'Description of the usage of the password',
266 `hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
267 `generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
268 `last_used` datetime COMMENT 'Datetime the password was last used',
270 INDEX `uid_description` (`uid`,`description`(190)),
271 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
272 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
275 -- TABLE 2fa_recovery_codes
277 CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
278 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
279 `code` varchar(50) NOT NULL COMMENT 'Recovery code string',
280 `generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
281 `used` datetime COMMENT 'Datetime the code was used',
282 PRIMARY KEY(`uid`,`code`),
283 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
284 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
287 -- TABLE 2fa_trusted_browser
289 CREATE TABLE IF NOT EXISTS `2fa_trusted_browser` (
290 `cookie_hash` varchar(80) NOT NULL COMMENT 'Trusted cookie hash',
291 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
292 `user_agent` text COMMENT 'User agent string',
293 `created` datetime NOT NULL COMMENT 'Datetime the trusted browser was recorded',
294 `last_used` datetime COMMENT 'Datetime the trusted browser was last used',
295 PRIMARY KEY(`cookie_hash`),
297 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
298 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication trusted browsers';
303 CREATE TABLE IF NOT EXISTS `addon` (
304 `id` int unsigned NOT NULL auto_increment COMMENT '',
305 `name` varchar(50) NOT NULL DEFAULT '' COMMENT 'addon base (file)name',
306 `version` varchar(50) NOT NULL DEFAULT '' COMMENT 'currently unused',
307 `installed` boolean NOT NULL DEFAULT '0' COMMENT 'currently always 1',
308 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'currently unused',
309 `timestamp` int unsigned NOT NULL DEFAULT 0 COMMENT 'file timestamp to check for reloads',
310 `plugin_admin` boolean NOT NULL DEFAULT '0' COMMENT '1 = has admin config, 0 = has no admin config',
312 INDEX `installed_name` (`installed`,`name`),
313 UNIQUE INDEX `name` (`name`)
314 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registered addons';
319 CREATE TABLE IF NOT EXISTS `apcontact` (
320 `url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
321 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
322 `uuid` varchar(255) COMMENT '',
323 `type` varchar(20) NOT NULL COMMENT '',
324 `following` varchar(255) COMMENT '',
325 `followers` varchar(255) COMMENT '',
326 `inbox` varchar(255) NOT NULL COMMENT '',
327 `outbox` varchar(255) COMMENT '',
328 `sharedinbox` varchar(255) COMMENT '',
329 `manually-approve` boolean COMMENT '',
330 `discoverable` boolean COMMENT 'Mastodon extension: true if profile is published in their directory',
331 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
332 `name` varchar(255) COMMENT '',
333 `about` text COMMENT '',
334 `photo` varchar(255) COMMENT '',
335 `header` varchar(255) COMMENT 'Header picture',
336 `addr` varchar(255) COMMENT '',
337 `alias` varchar(255) COMMENT '',
338 `pubkey` text COMMENT '',
339 `subscribe` varchar(255) COMMENT '',
340 `baseurl` varchar(255) COMMENT 'baseurl of the ap contact',
341 `gsid` int unsigned COMMENT 'Global Server ID',
342 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
343 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
344 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
345 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
346 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
348 INDEX `addr` (`addr`(32)),
349 INDEX `alias` (`alias`(190)),
350 INDEX `followers` (`followers`(190)),
351 INDEX `baseurl` (`baseurl`(190)),
352 INDEX `sharedinbox` (`sharedinbox`(190)),
353 INDEX `gsid` (`gsid`),
354 UNIQUE INDEX `uri-id` (`uri-id`),
355 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
356 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
357 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
362 CREATE TABLE IF NOT EXISTS `application` (
363 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
364 `client_id` varchar(64) NOT NULL COMMENT '',
365 `client_secret` varchar(64) NOT NULL COMMENT '',
366 `name` varchar(255) NOT NULL COMMENT '',
367 `redirect_uri` varchar(255) NOT NULL COMMENT '',
368 `website` varchar(255) COMMENT '',
369 `scopes` varchar(255) COMMENT '',
370 `read` boolean COMMENT 'Read scope',
371 `write` boolean COMMENT 'Write scope',
372 `follow` boolean COMMENT 'Follow scope',
373 `push` boolean COMMENT 'Push scope',
375 UNIQUE INDEX `client_id` (`client_id`)
376 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth application';
379 -- TABLE application-token
381 CREATE TABLE IF NOT EXISTS `application-token` (
382 `application-id` int unsigned NOT NULL COMMENT '',
383 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
384 `code` varchar(64) NOT NULL COMMENT '',
385 `access_token` varchar(64) NOT NULL COMMENT '',
386 `created_at` datetime NOT NULL COMMENT 'creation time',
387 `scopes` varchar(255) COMMENT '',
388 `read` boolean COMMENT 'Read scope',
389 `write` boolean COMMENT 'Write scope',
390 `follow` boolean COMMENT 'Follow scope',
391 `push` boolean COMMENT 'Push scope',
392 PRIMARY KEY(`application-id`,`uid`),
393 INDEX `uid_id` (`uid`,`application-id`),
394 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
395 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
396 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth user token';
401 CREATE TABLE IF NOT EXISTS `attach` (
402 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
403 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
404 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
405 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
406 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
407 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
408 `data` longblob NOT NULL COMMENT 'file data',
409 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
410 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
411 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
412 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
413 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
414 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
415 `backend-class` tinytext COMMENT 'Storage backend class',
416 `backend-ref` text COMMENT 'Storage backend data reference',
419 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
420 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
425 CREATE TABLE IF NOT EXISTS `cache` (
426 `k` varbinary(255) NOT NULL COMMENT 'cache key',
427 `v` mediumtext COMMENT 'cached serialized value',
428 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
429 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
431 INDEX `k_expires` (`k`,`expires`)
432 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
437 CREATE TABLE IF NOT EXISTS `config` (
438 `id` int unsigned NOT NULL auto_increment COMMENT '',
439 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
440 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
441 `v` mediumtext COMMENT '',
443 UNIQUE INDEX `cat_k` (`cat`,`k`)
444 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
447 -- TABLE contact-relation
449 CREATE TABLE IF NOT EXISTS `contact-relation` (
450 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
451 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
452 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
453 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
454 `follows` boolean NOT NULL DEFAULT '0' COMMENT '',
455 PRIMARY KEY(`cid`,`relation-cid`),
456 INDEX `relation-cid` (`relation-cid`),
457 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
458 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
459 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
464 CREATE TABLE IF NOT EXISTS `conv` (
465 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
466 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
467 `recips` text COMMENT 'sender_handle;recipient_handle',
468 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
469 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
470 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
471 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
472 `subject` text COMMENT 'subject of initial message',
475 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
476 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
479 -- TABLE conversation
481 CREATE TABLE IF NOT EXISTS `conversation` (
482 `item-uri` varbinary(255) NOT NULL COMMENT 'Original URI of the item - unrelated to the table with the same name',
483 `reply-to-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'URI to which this item is a reply',
484 `conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI',
485 `conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link',
486 `protocol` tinyint unsigned NOT NULL DEFAULT 255 COMMENT 'The protocol of the item',
487 `direction` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'How the message arrived here: 1=push, 2=pull',
488 `source` mediumtext COMMENT 'Original source',
489 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Receiving date',
490 PRIMARY KEY(`item-uri`),
491 INDEX `conversation-uri` (`conversation-uri`),
492 INDEX `received` (`received`)
493 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Raw data and structure information for messages';
496 -- TABLE delayed-post
498 CREATE TABLE IF NOT EXISTS `delayed-post` (
499 `id` int unsigned NOT NULL auto_increment,
500 `uri` varchar(255) COMMENT 'URI of the post that will be distributed later',
501 `uid` mediumint unsigned COMMENT 'Owner User id',
502 `delayed` datetime COMMENT 'delay time',
504 UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
505 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
506 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
509 -- TABLE diaspora-interaction
511 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
512 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
513 `interaction` mediumtext COMMENT 'The Diaspora interaction',
514 PRIMARY KEY(`uri-id`),
515 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
516 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
521 CREATE TABLE IF NOT EXISTS `event` (
522 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
523 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
524 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
525 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
526 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
527 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the event uri',
528 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
529 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
530 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
531 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
532 `summary` text COMMENT 'short description or title of the event',
533 `desc` text COMMENT 'event description',
534 `location` text COMMENT 'event location',
535 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
536 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
537 `adjust` boolean NOT NULL DEFAULT '1' COMMENT 'adjust to timezone of the recipient (0 or 1)',
538 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
539 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
540 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
541 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
542 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
544 INDEX `uid_start` (`uid`,`start`),
546 INDEX `uri-id` (`uri-id`),
547 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
548 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
549 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
550 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
555 CREATE TABLE IF NOT EXISTS `fcontact` (
556 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
557 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
558 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
559 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the fcontact url',
560 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
561 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
562 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
563 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
564 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
565 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
566 `notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
567 `poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
568 `confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
569 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
570 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
571 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
572 `pubkey` text COMMENT '',
573 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
575 INDEX `addr` (`addr`(32)),
576 UNIQUE INDEX `url` (`url`(190)),
577 UNIQUE INDEX `uri-id` (`uri-id`),
578 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
579 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
584 CREATE TABLE IF NOT EXISTS `fsuggest` (
585 `id` int unsigned NOT NULL auto_increment COMMENT '',
586 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
587 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
588 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
589 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
590 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
591 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
592 `note` text COMMENT '',
593 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
597 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
598 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
599 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
604 CREATE TABLE IF NOT EXISTS `group` (
605 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
606 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
607 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
608 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
609 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
612 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
613 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
616 -- TABLE group_member
618 CREATE TABLE IF NOT EXISTS `group_member` (
619 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
620 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
621 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
623 INDEX `contactid` (`contact-id`),
624 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
625 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
626 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
627 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
632 CREATE TABLE IF NOT EXISTS `gserver-tag` (
633 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
634 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
635 PRIMARY KEY(`gserver-id`,`tag`),
637 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
638 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
643 CREATE TABLE IF NOT EXISTS `hook` (
644 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
645 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
646 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
647 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
648 `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',
650 INDEX `priority` (`priority`),
651 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
652 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
657 CREATE TABLE IF NOT EXISTS `host` (
658 `id` tinyint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
659 `name` varchar(128) NOT NULL DEFAULT '' COMMENT 'The hostname',
661 UNIQUE INDEX `name` (`name`)
662 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Hostname';
665 -- TABLE inbox-status
667 CREATE TABLE IF NOT EXISTS `inbox-status` (
668 `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
669 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
670 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
671 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
672 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
673 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
674 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
676 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
681 CREATE TABLE IF NOT EXISTS `intro` (
682 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
683 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
684 `fid` int unsigned COMMENT '',
685 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
686 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
687 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
688 `note` text COMMENT '',
689 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
690 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
691 `blocked` boolean NOT NULL DEFAULT '1' COMMENT '',
692 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
694 INDEX `contact-id` (`contact-id`),
696 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
697 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
698 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
703 CREATE TABLE IF NOT EXISTS `locks` (
704 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
705 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
706 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
707 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
708 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
710 INDEX `name_expires` (`name`,`expires`)
711 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
716 CREATE TABLE IF NOT EXISTS `mail` (
717 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
718 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
719 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
720 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
721 `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
722 `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
723 `contact-id` varchar(255) COMMENT 'contact.id',
724 `author-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the author of the mail',
725 `convid` int unsigned COMMENT 'conv.id',
726 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
727 `body` mediumtext COMMENT '',
728 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
729 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
730 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
731 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
732 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
733 `uri-id` int unsigned COMMENT 'Item-uri id of the related mail',
734 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
735 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related mail',
736 `thr-parent` varchar(255) COMMENT '',
737 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
738 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
740 INDEX `uid_seen` (`uid`,`seen`),
741 INDEX `convid` (`convid`),
742 INDEX `uri` (`uri`(64)),
743 INDEX `parent-uri` (`parent-uri`(64)),
744 INDEX `contactid` (`contact-id`(32)),
745 INDEX `author-id` (`author-id`),
746 INDEX `uri-id` (`uri-id`),
747 INDEX `parent-uri-id` (`parent-uri-id`),
748 INDEX `thr-parent-id` (`thr-parent-id`),
749 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
750 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
751 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
752 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
753 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
754 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
759 CREATE TABLE IF NOT EXISTS `mailacct` (
760 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
761 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
762 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
763 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
764 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
765 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
766 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
767 `pass` text COMMENT '',
768 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
769 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
770 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
771 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
772 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
775 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
776 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
781 CREATE TABLE IF NOT EXISTS `manage` (
782 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
783 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
784 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
786 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
788 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
789 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
790 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
793 -- TABLE notification
795 CREATE TABLE IF NOT EXISTS `notification` (
796 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
797 `uid` mediumint unsigned COMMENT 'Owner User id',
798 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
799 `type` tinyint unsigned COMMENT '',
800 `actor-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the actor that caused the notification',
801 `target-uri-id` int unsigned COMMENT 'Item-uri id of the related post',
802 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
803 `created` datetime COMMENT '',
804 `seen` boolean DEFAULT '0' COMMENT '',
806 UNIQUE INDEX `uid_vid_type_actor-id_target-uri-id` (`uid`,`vid`,`type`,`actor-id`,`target-uri-id`),
808 INDEX `actor-id` (`actor-id`),
809 INDEX `target-uri-id` (`target-uri-id`),
810 INDEX `parent-uri-id` (`parent-uri-id`),
811 INDEX `seen_uid` (`seen`,`uid`),
812 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
813 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
814 FOREIGN KEY (`actor-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
815 FOREIGN KEY (`target-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
816 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
817 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
822 CREATE TABLE IF NOT EXISTS `notify` (
823 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
824 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
825 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
826 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
827 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
828 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
829 `msg` mediumtext COMMENT '',
830 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
831 `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
832 `iid` int unsigned COMMENT '',
833 `parent` int unsigned COMMENT '',
834 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
835 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
836 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
837 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
838 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
839 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
840 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
842 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
843 INDEX `uid_date` (`uid`,`date`),
844 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
845 INDEX `uri-id` (`uri-id`),
846 INDEX `parent-uri-id` (`parent-uri-id`),
847 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
848 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
849 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
850 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
853 -- TABLE notify-threads
855 CREATE TABLE IF NOT EXISTS `notify-threads` (
856 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
857 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
858 `master-parent-item` int unsigned COMMENT 'Deprecated',
859 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
860 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
861 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
863 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
864 INDEX `receiver-uid` (`receiver-uid`),
865 INDEX `notify-id` (`notify-id`),
866 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
867 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
868 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
869 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
874 CREATE TABLE IF NOT EXISTS `oembed` (
875 `url` varbinary(255) NOT NULL COMMENT 'page url',
876 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
877 `content` mediumtext COMMENT 'OEmbed data of the page',
878 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
879 PRIMARY KEY(`url`,`maxwidth`),
880 INDEX `created` (`created`)
881 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
884 -- TABLE openwebauth-token
886 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
887 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
888 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
889 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
890 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
891 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
892 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
895 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
896 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
901 CREATE TABLE IF NOT EXISTS `parsed_url` (
902 `url_hash` binary(64) NOT NULL COMMENT 'page url hash',
903 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
904 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
905 `url` text NOT NULL COMMENT 'page url',
906 `content` mediumtext COMMENT 'page data',
907 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
908 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration',
909 PRIMARY KEY(`url_hash`,`guessing`,`oembed`),
910 INDEX `created` (`created`),
911 INDEX `expires` (`expires`)
912 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
917 CREATE TABLE IF NOT EXISTS `pconfig` (
918 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
919 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
920 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
921 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
922 `v` mediumtext COMMENT 'Value',
924 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
925 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
926 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
931 CREATE TABLE IF NOT EXISTS `photo` (
932 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
933 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
934 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
935 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
936 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
937 `hash` char(32) COMMENT 'hash value of the photo',
938 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
939 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
940 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
941 `desc` text COMMENT '',
942 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
943 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
944 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
945 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
946 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
947 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
948 `data` mediumblob NOT NULL COMMENT '',
949 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
950 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
951 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
952 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
953 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
954 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
955 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
956 `backend-class` tinytext COMMENT 'Storage backend class',
957 `backend-ref` text COMMENT 'Storage backend data reference',
958 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
960 INDEX `contactid` (`contact-id`),
961 INDEX `uid_contactid` (`uid`,`contact-id`),
962 INDEX `uid_profile` (`uid`,`profile`),
963 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
964 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
965 INDEX `resource-id` (`resource-id`),
966 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
967 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
968 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
973 CREATE TABLE IF NOT EXISTS `post` (
974 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
975 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
976 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
977 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
978 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
979 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
980 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
981 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
982 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
983 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
984 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
985 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
986 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
987 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
988 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
989 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
990 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
991 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
992 PRIMARY KEY(`uri-id`),
993 INDEX `parent-uri-id` (`parent-uri-id`),
994 INDEX `thr-parent-id` (`thr-parent-id`),
995 INDEX `external-id` (`external-id`),
996 INDEX `owner-id` (`owner-id`),
997 INDEX `author-id` (`author-id`),
998 INDEX `causer-id` (`causer-id`),
1000 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1001 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1002 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1003 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1004 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1005 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1006 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1007 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1008 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
1011 -- TABLE post-category
1013 CREATE TABLE IF NOT EXISTS `post-category` (
1014 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1015 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1016 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1017 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1018 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1019 INDEX `uri-id` (`tid`),
1020 INDEX `uid` (`uid`),
1021 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1022 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1023 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1024 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1027 -- TABLE post-content
1029 CREATE TABLE IF NOT EXISTS `post-content` (
1030 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1031 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1032 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1033 `body` mediumtext COMMENT 'item body content',
1034 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1035 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1036 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1037 `language` text COMMENT 'Language information about this post',
1038 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1039 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1040 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1041 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1042 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1043 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1044 `target` text COMMENT 'JSON encoded target structure if used',
1045 `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',
1046 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1047 PRIMARY KEY(`uri-id`),
1048 INDEX `plink` (`plink`(191)),
1049 INDEX `resource-id` (`resource-id`),
1050 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
1051 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1052 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1055 -- TABLE post-delivery-data
1057 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1058 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1059 `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',
1060 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1061 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1062 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1063 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1064 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1065 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1066 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1067 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1068 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1069 PRIMARY KEY(`uri-id`),
1070 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1071 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1076 CREATE TABLE IF NOT EXISTS `post-link` (
1077 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1078 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1079 `url` varbinary(511) NOT NULL COMMENT 'External URL',
1080 `mimetype` varchar(60) COMMENT '',
1082 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1083 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1084 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post related external links';
1089 CREATE TABLE IF NOT EXISTS `post-media` (
1090 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1091 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1092 `url` varbinary(511) NOT NULL COMMENT 'Media URL',
1093 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1094 `mimetype` varchar(60) COMMENT '',
1095 `height` smallint unsigned COMMENT 'Height of the media',
1096 `width` smallint unsigned COMMENT 'Width of the media',
1097 `size` int unsigned COMMENT 'Media size',
1098 `preview` varbinary(255) COMMENT 'Preview URL',
1099 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1100 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1101 `description` text COMMENT '',
1102 `name` varchar(255) COMMENT 'Name of the media',
1103 `author-url` varbinary(255) COMMENT 'URL of the author of the media',
1104 `author-name` varchar(255) COMMENT 'Name of the author of the media',
1105 `author-image` varbinary(255) COMMENT 'Image of the author of the media',
1106 `publisher-url` varbinary(255) COMMENT 'URL of the publisher of the media',
1107 `publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
1108 `publisher-image` varbinary(255) COMMENT 'Image of the publisher of the media',
1110 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1111 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1112 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1117 CREATE TABLE IF NOT EXISTS `post-tag` (
1118 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1119 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1120 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1121 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1122 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1123 INDEX `tid` (`tid`),
1124 INDEX `cid` (`cid`),
1125 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1126 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1127 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1128 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1131 -- TABLE post-thread
1133 CREATE TABLE IF NOT EXISTS `post-thread` (
1134 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1135 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1136 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1137 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1138 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1139 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1140 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1141 `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',
1142 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1143 PRIMARY KEY(`uri-id`),
1144 INDEX `owner-id` (`owner-id`),
1145 INDEX `author-id` (`author-id`),
1146 INDEX `causer-id` (`causer-id`),
1147 INDEX `received` (`received`),
1148 INDEX `commented` (`commented`),
1149 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1150 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1151 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1152 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1153 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1158 CREATE TABLE IF NOT EXISTS `post-user` (
1159 `id` int unsigned NOT NULL auto_increment,
1160 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1161 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1162 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1163 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1164 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1165 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1166 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1167 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1168 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1169 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1170 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1171 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1172 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1173 `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
1174 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1175 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1176 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1177 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1178 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1179 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1180 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1181 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1182 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1183 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1184 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1185 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1186 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1187 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1188 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1190 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1191 INDEX `uri-id` (`uri-id`),
1192 INDEX `parent-uri-id` (`parent-uri-id`),
1193 INDEX `thr-parent-id` (`thr-parent-id`),
1194 INDEX `external-id` (`external-id`),
1195 INDEX `owner-id` (`owner-id`),
1196 INDEX `author-id` (`author-id`),
1197 INDEX `causer-id` (`causer-id`),
1198 INDEX `vid` (`vid`),
1199 INDEX `contact-id` (`contact-id`),
1200 INDEX `event-id` (`event-id`),
1201 INDEX `psid` (`psid`),
1202 INDEX `author-id_uid` (`author-id`,`uid`),
1203 INDEX `author-id_received` (`author-id`,`received`),
1204 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1205 INDEX `uid_contactid` (`uid`,`contact-id`),
1206 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1207 INDEX `uid_unseen` (`uid`,`unseen`),
1208 INDEX `uid_hidden_uri-id` (`uid`,`hidden`,`uri-id`),
1209 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1210 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1211 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1212 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1213 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1214 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1215 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1216 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1217 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1218 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1219 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1220 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1221 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1224 -- TABLE post-thread-user
1226 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1227 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1228 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1229 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1230 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1231 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1232 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1233 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1234 `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',
1235 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1236 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1237 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'The thread is pinned on the profile page',
1238 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1239 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1240 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1241 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1242 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1243 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1244 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1245 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1246 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1247 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1248 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1249 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1250 PRIMARY KEY(`uid`,`uri-id`),
1251 INDEX `uri-id` (`uri-id`),
1252 INDEX `owner-id` (`owner-id`),
1253 INDEX `author-id` (`author-id`),
1254 INDEX `causer-id` (`causer-id`),
1255 INDEX `uid` (`uid`),
1256 INDEX `contact-id` (`contact-id`),
1257 INDEX `psid` (`psid`),
1258 INDEX `post-user-id` (`post-user-id`),
1259 INDEX `commented` (`commented`),
1260 INDEX `uid_received` (`uid`,`received`),
1261 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1262 INDEX `uid_pinned` (`uid`,`pinned`),
1263 INDEX `uid_commented` (`uid`,`commented`),
1264 INDEX `uid_starred` (`uid`,`starred`),
1265 INDEX `uid_mention` (`uid`,`mention`),
1266 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1267 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1268 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1269 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1270 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1271 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1272 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1273 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1274 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1277 -- TABLE post-user-notification
1279 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1280 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1281 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1282 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1283 PRIMARY KEY(`uid`,`uri-id`),
1284 INDEX `uri-id` (`uri-id`),
1285 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1286 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1287 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1292 CREATE TABLE IF NOT EXISTS `process` (
1293 `pid` int unsigned NOT NULL COMMENT '',
1294 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1295 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1297 INDEX `command` (`command`)
1298 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1303 CREATE TABLE IF NOT EXISTS `profile` (
1304 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1305 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1306 `profile-name` varchar(255) COMMENT 'Deprecated',
1307 `is-default` boolean COMMENT 'Deprecated',
1308 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1309 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1310 `pdesc` varchar(255) COMMENT 'Deprecated',
1311 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1312 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1313 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1314 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1315 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1316 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1317 `hometown` varchar(255) COMMENT 'Deprecated',
1318 `gender` varchar(32) COMMENT 'Deprecated',
1319 `marital` varchar(255) COMMENT 'Deprecated',
1320 `with` text COMMENT 'Deprecated',
1321 `howlong` datetime COMMENT 'Deprecated',
1322 `sexual` varchar(255) COMMENT 'Deprecated',
1323 `politic` varchar(255) COMMENT 'Deprecated',
1324 `religion` varchar(255) COMMENT 'Deprecated',
1325 `pub_keywords` text COMMENT '',
1326 `prv_keywords` text COMMENT '',
1327 `likes` text COMMENT 'Deprecated',
1328 `dislikes` text COMMENT 'Deprecated',
1329 `about` text COMMENT 'Profile description',
1330 `summary` varchar(255) COMMENT 'Deprecated',
1331 `music` text COMMENT 'Deprecated',
1332 `book` text COMMENT 'Deprecated',
1333 `tv` text COMMENT 'Deprecated',
1334 `film` text COMMENT 'Deprecated',
1335 `interest` text COMMENT 'Deprecated',
1336 `romance` text COMMENT 'Deprecated',
1337 `work` text COMMENT 'Deprecated',
1338 `education` text COMMENT 'Deprecated',
1339 `contact` text COMMENT 'Deprecated',
1340 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1341 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1342 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1343 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1344 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1345 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1347 INDEX `uid_is-default` (`uid`,`is-default`),
1348 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1349 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1350 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1353 -- TABLE profile_field
1355 CREATE TABLE IF NOT EXISTS `profile_field` (
1356 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1357 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1358 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1359 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1360 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1361 `value` text COMMENT 'Value of the field',
1362 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1363 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1365 INDEX `uid` (`uid`),
1366 INDEX `order` (`order`),
1367 INDEX `psid` (`psid`),
1368 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1369 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1370 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1373 -- TABLE push_subscriber
1375 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1376 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1377 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1378 `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1379 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1380 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1381 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1382 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1383 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1384 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1385 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1387 INDEX `next_try` (`next_try`),
1388 INDEX `uid` (`uid`),
1389 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1390 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1395 CREATE TABLE IF NOT EXISTS `register` (
1396 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1397 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1398 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1399 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1400 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1401 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1402 `note` text COMMENT '',
1404 INDEX `uid` (`uid`),
1405 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1406 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1411 CREATE TABLE IF NOT EXISTS `search` (
1412 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1413 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1414 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1416 INDEX `uid_term` (`uid`,`term`(64)),
1417 INDEX `term` (`term`(64)),
1418 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1419 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1424 CREATE TABLE IF NOT EXISTS `session` (
1425 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1426 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1427 `data` text COMMENT '',
1428 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1430 INDEX `sid` (`sid`(64)),
1431 INDEX `expire` (`expire`)
1432 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1437 CREATE TABLE IF NOT EXISTS `storage` (
1438 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1439 `data` longblob NOT NULL COMMENT 'file data',
1441 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1446 CREATE TABLE IF NOT EXISTS `userd` (
1447 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1448 `username` varchar(255) NOT NULL COMMENT '',
1450 INDEX `username` (`username`(32))
1451 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1454 -- TABLE user-contact
1456 CREATE TABLE IF NOT EXISTS `user-contact` (
1457 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1458 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1459 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1460 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1461 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1462 PRIMARY KEY(`uid`,`cid`),
1463 INDEX `cid` (`cid`),
1464 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1465 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1466 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1471 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1472 `key` int NOT NULL COMMENT '',
1473 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1475 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1478 -- TABLE workerqueue
1480 CREATE TABLE IF NOT EXISTS `workerqueue` (
1481 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
1482 `command` varchar(100) COMMENT 'Task command',
1483 `parameter` mediumtext COMMENT 'Task parameter',
1484 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
1485 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
1486 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
1487 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
1488 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1489 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1490 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
1492 INDEX `command` (`command`),
1493 INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
1494 INDEX `done_executed` (`done`,`executed`),
1495 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
1496 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
1497 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
1498 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
1499 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
1500 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
1503 -- VIEW application-view
1505 DROP VIEW IF EXISTS `application-view`;
1506 CREATE VIEW `application-view` AS SELECT
1507 `application`.`id` AS `id`,
1508 `application-token`.`uid` AS `uid`,
1509 `application`.`name` AS `name`,
1510 `application`.`redirect_uri` AS `redirect_uri`,
1511 `application`.`website` AS `website`,
1512 `application`.`client_id` AS `client_id`,
1513 `application`.`client_secret` AS `client_secret`,
1514 `application-token`.`code` AS `code`,
1515 `application-token`.`access_token` AS `access_token`,
1516 `application-token`.`created_at` AS `created_at`,
1517 `application-token`.`scopes` AS `scopes`,
1518 `application-token`.`read` AS `read`,
1519 `application-token`.`write` AS `write`,
1520 `application-token`.`follow` AS `follow`,
1521 `application-token`.`push` AS `push`
1522 FROM `application-token`
1523 INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`;
1526 -- VIEW post-user-view
1528 DROP VIEW IF EXISTS `post-user-view`;
1529 CREATE VIEW `post-user-view` AS SELECT
1530 `post-user`.`id` AS `id`,
1531 `post-user`.`id` AS `post-user-id`,
1532 `post-user`.`uid` AS `uid`,
1533 `parent-post`.`id` AS `parent`,
1534 `item-uri`.`uri` AS `uri`,
1535 `post-user`.`uri-id` AS `uri-id`,
1536 `parent-item-uri`.`uri` AS `parent-uri`,
1537 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1538 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1539 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1540 `item-uri`.`guid` AS `guid`,
1541 `post-user`.`wall` AS `wall`,
1542 `post-user`.`gravity` AS `gravity`,
1543 `external-item-uri`.`uri` AS `extid`,
1544 `post-user`.`external-id` AS `external-id`,
1545 `post-user`.`created` AS `created`,
1546 `post-user`.`edited` AS `edited`,
1547 `post-thread-user`.`commented` AS `commented`,
1548 `post-user`.`received` AS `received`,
1549 `post-thread-user`.`changed` AS `changed`,
1550 `post-user`.`post-type` AS `post-type`,
1551 `post-user`.`post-reason` AS `post-reason`,
1552 `post-user`.`private` AS `private`,
1553 `post-thread-user`.`pubmail` AS `pubmail`,
1554 `post-user`.`visible` AS `visible`,
1555 `post-thread-user`.`starred` AS `starred`,
1556 `post-thread-user`.`pinned` AS `pinned`,
1557 `post-user`.`unseen` AS `unseen`,
1558 `post-user`.`deleted` AS `deleted`,
1559 `post-user`.`origin` AS `origin`,
1560 `post-thread-user`.`origin` AS `parent-origin`,
1561 `post-thread-user`.`forum_mode` AS `forum_mode`,
1562 `post-thread-user`.`mention` AS `mention`,
1563 `post-user`.`global` AS `global`,
1564 `post-user`.`network` AS `network`,
1565 `post-user`.`vid` AS `vid`,
1566 `post-user`.`psid` AS `psid`,
1567 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1568 `post-content`.`title` AS `title`,
1569 `post-content`.`content-warning` AS `content-warning`,
1570 `post-content`.`raw-body` AS `raw-body`,
1571 `post-content`.`body` AS `body`,
1572 `post-content`.`rendered-hash` AS `rendered-hash`,
1573 `post-content`.`rendered-html` AS `rendered-html`,
1574 `post-content`.`language` AS `language`,
1575 `post-content`.`plink` AS `plink`,
1576 `post-content`.`location` AS `location`,
1577 `post-content`.`coord` AS `coord`,
1578 `post-content`.`app` AS `app`,
1579 `post-content`.`object-type` AS `object-type`,
1580 `post-content`.`object` AS `object`,
1581 `post-content`.`target-type` AS `target-type`,
1582 `post-content`.`target` AS `target`,
1583 `post-content`.`resource-id` AS `resource-id`,
1584 `post-user`.`contact-id` AS `contact-id`,
1585 `contact`.`url` AS `contact-link`,
1586 `contact`.`addr` AS `contact-addr`,
1587 `contact`.`name` AS `contact-name`,
1588 `contact`.`nick` AS `contact-nick`,
1589 `contact`.`thumb` AS `contact-avatar`,
1590 `contact`.`network` AS `contact-network`,
1591 `contact`.`blocked` AS `contact-blocked`,
1592 `contact`.`hidden` AS `contact-hidden`,
1593 `contact`.`readonly` AS `contact-readonly`,
1594 `contact`.`archive` AS `contact-archive`,
1595 `contact`.`pending` AS `contact-pending`,
1596 `contact`.`rel` AS `contact-rel`,
1597 `contact`.`uid` AS `contact-uid`,
1598 `contact`.`contact-type` AS `contact-contact-type`,
1599 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1600 `contact`.`self` AS `self`,
1601 `contact`.`id` AS `cid`,
1602 `contact`.`alias` AS `alias`,
1603 `contact`.`photo` AS `photo`,
1604 `contact`.`name-date` AS `name-date`,
1605 `contact`.`uri-date` AS `uri-date`,
1606 `contact`.`avatar-date` AS `avatar-date`,
1607 `contact`.`thumb` AS `thumb`,
1608 `post-user`.`author-id` AS `author-id`,
1609 `author`.`url` AS `author-link`,
1610 `author`.`addr` AS `author-addr`,
1611 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1612 `author`.`nick` AS `author-nick`,
1613 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1614 `author`.`network` AS `author-network`,
1615 `author`.`blocked` AS `author-blocked`,
1616 `author`.`hidden` AS `author-hidden`,
1617 `post-user`.`owner-id` AS `owner-id`,
1618 `owner`.`url` AS `owner-link`,
1619 `owner`.`addr` AS `owner-addr`,
1620 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1621 `owner`.`nick` AS `owner-nick`,
1622 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1623 `owner`.`network` AS `owner-network`,
1624 `owner`.`blocked` AS `owner-blocked`,
1625 `owner`.`hidden` AS `owner-hidden`,
1626 `owner`.`contact-type` AS `owner-contact-type`,
1627 `post-user`.`causer-id` AS `causer-id`,
1628 `causer`.`url` AS `causer-link`,
1629 `causer`.`addr` AS `causer-addr`,
1630 `causer`.`name` AS `causer-name`,
1631 `causer`.`nick` AS `causer-nick`,
1632 `causer`.`thumb` AS `causer-avatar`,
1633 `causer`.`network` AS `causer-network`,
1634 `causer`.`blocked` AS `causer-blocked`,
1635 `causer`.`hidden` AS `causer-hidden`,
1636 `causer`.`contact-type` AS `causer-contact-type`,
1637 `post-delivery-data`.`postopts` AS `postopts`,
1638 `post-delivery-data`.`inform` AS `inform`,
1639 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1640 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1641 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1642 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1643 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1644 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1645 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1646 `post-user`.`event-id` AS `event-id`,
1647 `event`.`created` AS `event-created`,
1648 `event`.`edited` AS `event-edited`,
1649 `event`.`start` AS `event-start`,
1650 `event`.`finish` AS `event-finish`,
1651 `event`.`summary` AS `event-summary`,
1652 `event`.`desc` AS `event-desc`,
1653 `event`.`location` AS `event-location`,
1654 `event`.`type` AS `event-type`,
1655 `event`.`nofinish` AS `event-nofinish`,
1656 `event`.`adjust` AS `event-adjust`,
1657 `event`.`ignore` AS `event-ignore`,
1658 `diaspora-interaction`.`interaction` AS `signed_text`,
1659 `parent-item-uri`.`guid` AS `parent-guid`,
1660 `parent-post`.`network` AS `parent-network`,
1661 `parent-post`.`author-id` AS `parent-author-id`,
1662 `parent-post-author`.`url` AS `parent-author-link`,
1663 `parent-post-author`.`name` AS `parent-author-name`,
1664 `parent-post-author`.`network` AS `parent-author-network`,
1665 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1666 `parent-post-author`.`hidden` AS `parent-author-hidden`
1668 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
1669 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
1670 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
1671 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
1672 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
1673 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
1674 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1675 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1676 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1677 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1678 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1679 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
1680 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
1681 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
1682 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
1683 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
1684 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1687 -- VIEW post-thread-user-view
1689 DROP VIEW IF EXISTS `post-thread-user-view`;
1690 CREATE VIEW `post-thread-user-view` AS SELECT
1691 `post-user`.`id` AS `id`,
1692 `post-user`.`id` AS `post-user-id`,
1693 `post-thread-user`.`uid` AS `uid`,
1694 `parent-post`.`id` AS `parent`,
1695 `item-uri`.`uri` AS `uri`,
1696 `post-thread-user`.`uri-id` AS `uri-id`,
1697 `parent-item-uri`.`uri` AS `parent-uri`,
1698 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1699 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1700 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1701 `item-uri`.`guid` AS `guid`,
1702 `post-thread-user`.`wall` AS `wall`,
1703 `post-user`.`gravity` AS `gravity`,
1704 `external-item-uri`.`uri` AS `extid`,
1705 `post-user`.`external-id` AS `external-id`,
1706 `post-thread-user`.`created` AS `created`,
1707 `post-user`.`edited` AS `edited`,
1708 `post-thread-user`.`commented` AS `commented`,
1709 `post-thread-user`.`received` AS `received`,
1710 `post-thread-user`.`changed` AS `changed`,
1711 `post-user`.`post-type` AS `post-type`,
1712 `post-user`.`post-reason` AS `post-reason`,
1713 `post-user`.`private` AS `private`,
1714 `post-thread-user`.`pubmail` AS `pubmail`,
1715 `post-thread-user`.`ignored` AS `ignored`,
1716 `post-user`.`visible` AS `visible`,
1717 `post-thread-user`.`starred` AS `starred`,
1718 `post-thread-user`.`pinned` AS `pinned`,
1719 `post-thread-user`.`unseen` AS `unseen`,
1720 `post-user`.`deleted` AS `deleted`,
1721 `post-thread-user`.`origin` AS `origin`,
1722 `post-thread-user`.`forum_mode` AS `forum_mode`,
1723 `post-thread-user`.`mention` AS `mention`,
1724 `post-user`.`global` AS `global`,
1725 `post-thread-user`.`network` AS `network`,
1726 `post-user`.`vid` AS `vid`,
1727 `post-thread-user`.`psid` AS `psid`,
1728 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1729 `post-content`.`title` AS `title`,
1730 `post-content`.`content-warning` AS `content-warning`,
1731 `post-content`.`raw-body` AS `raw-body`,
1732 `post-content`.`body` AS `body`,
1733 `post-content`.`rendered-hash` AS `rendered-hash`,
1734 `post-content`.`rendered-html` AS `rendered-html`,
1735 `post-content`.`language` AS `language`,
1736 `post-content`.`plink` AS `plink`,
1737 `post-content`.`location` AS `location`,
1738 `post-content`.`coord` AS `coord`,
1739 `post-content`.`app` AS `app`,
1740 `post-content`.`object-type` AS `object-type`,
1741 `post-content`.`object` AS `object`,
1742 `post-content`.`target-type` AS `target-type`,
1743 `post-content`.`target` AS `target`,
1744 `post-content`.`resource-id` AS `resource-id`,
1745 `post-thread-user`.`contact-id` AS `contact-id`,
1746 `contact`.`url` AS `contact-link`,
1747 `contact`.`addr` AS `contact-addr`,
1748 `contact`.`name` AS `contact-name`,
1749 `contact`.`nick` AS `contact-nick`,
1750 `contact`.`thumb` AS `contact-avatar`,
1751 `contact`.`network` AS `contact-network`,
1752 `contact`.`blocked` AS `contact-blocked`,
1753 `contact`.`hidden` AS `contact-hidden`,
1754 `contact`.`readonly` AS `contact-readonly`,
1755 `contact`.`archive` AS `contact-archive`,
1756 `contact`.`pending` AS `contact-pending`,
1757 `contact`.`rel` AS `contact-rel`,
1758 `contact`.`uid` AS `contact-uid`,
1759 `contact`.`contact-type` AS `contact-contact-type`,
1760 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1761 `contact`.`self` AS `self`,
1762 `contact`.`id` AS `cid`,
1763 `contact`.`alias` AS `alias`,
1764 `contact`.`photo` AS `photo`,
1765 `contact`.`name-date` AS `name-date`,
1766 `contact`.`uri-date` AS `uri-date`,
1767 `contact`.`avatar-date` AS `avatar-date`,
1768 `contact`.`thumb` AS `thumb`,
1769 `post-thread-user`.`author-id` AS `author-id`,
1770 `author`.`url` AS `author-link`,
1771 `author`.`addr` AS `author-addr`,
1772 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1773 `author`.`nick` AS `author-nick`,
1774 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1775 `author`.`network` AS `author-network`,
1776 `author`.`blocked` AS `author-blocked`,
1777 `author`.`hidden` AS `author-hidden`,
1778 `post-thread-user`.`owner-id` AS `owner-id`,
1779 `owner`.`url` AS `owner-link`,
1780 `owner`.`addr` AS `owner-addr`,
1781 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1782 `owner`.`nick` AS `owner-nick`,
1783 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1784 `owner`.`network` AS `owner-network`,
1785 `owner`.`blocked` AS `owner-blocked`,
1786 `owner`.`hidden` AS `owner-hidden`,
1787 `owner`.`contact-type` AS `owner-contact-type`,
1788 `post-thread-user`.`causer-id` AS `causer-id`,
1789 `causer`.`url` AS `causer-link`,
1790 `causer`.`addr` AS `causer-addr`,
1791 `causer`.`name` AS `causer-name`,
1792 `causer`.`nick` AS `causer-nick`,
1793 `causer`.`thumb` AS `causer-avatar`,
1794 `causer`.`network` AS `causer-network`,
1795 `causer`.`blocked` AS `causer-blocked`,
1796 `causer`.`hidden` AS `causer-hidden`,
1797 `causer`.`contact-type` AS `causer-contact-type`,
1798 `post-delivery-data`.`postopts` AS `postopts`,
1799 `post-delivery-data`.`inform` AS `inform`,
1800 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1801 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1802 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1803 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1804 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1805 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1806 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1807 `post-user`.`event-id` AS `event-id`,
1808 `event`.`created` AS `event-created`,
1809 `event`.`edited` AS `event-edited`,
1810 `event`.`start` AS `event-start`,
1811 `event`.`finish` AS `event-finish`,
1812 `event`.`summary` AS `event-summary`,
1813 `event`.`desc` AS `event-desc`,
1814 `event`.`location` AS `event-location`,
1815 `event`.`type` AS `event-type`,
1816 `event`.`nofinish` AS `event-nofinish`,
1817 `event`.`adjust` AS `event-adjust`,
1818 `event`.`ignore` AS `event-ignore`,
1819 `diaspora-interaction`.`interaction` AS `signed_text`,
1820 `parent-item-uri`.`guid` AS `parent-guid`,
1821 `parent-post`.`network` AS `parent-network`,
1822 `parent-post`.`author-id` AS `parent-author-id`,
1823 `parent-post-author`.`url` AS `parent-author-link`,
1824 `parent-post-author`.`name` AS `parent-author-name`,
1825 `parent-post-author`.`network` AS `parent-author-network`,
1826 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1827 `parent-post-author`.`hidden` AS `parent-author-hidden`
1828 FROM `post-thread-user`
1829 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
1830 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
1831 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
1832 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
1833 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
1834 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
1835 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1836 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1837 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1838 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1839 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1840 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
1841 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
1842 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
1843 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
1844 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-thread-user`.`uid`
1845 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1850 DROP VIEW IF EXISTS `post-view`;
1851 CREATE VIEW `post-view` AS SELECT
1852 `item-uri`.`uri` AS `uri`,
1853 `post`.`uri-id` AS `uri-id`,
1854 `parent-item-uri`.`uri` AS `parent-uri`,
1855 `post`.`parent-uri-id` AS `parent-uri-id`,
1856 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1857 `post`.`thr-parent-id` AS `thr-parent-id`,
1858 `item-uri`.`guid` AS `guid`,
1859 `post`.`gravity` AS `gravity`,
1860 `external-item-uri`.`uri` AS `extid`,
1861 `post`.`external-id` AS `external-id`,
1862 `post`.`created` AS `created`,
1863 `post`.`edited` AS `edited`,
1864 `post-thread`.`commented` AS `commented`,
1865 `post`.`received` AS `received`,
1866 `post-thread`.`changed` AS `changed`,
1867 `post`.`post-type` AS `post-type`,
1868 `post`.`private` AS `private`,
1869 `post`.`visible` AS `visible`,
1870 `post`.`deleted` AS `deleted`,
1871 `post`.`global` AS `global`,
1872 `post`.`network` AS `network`,
1873 `post`.`vid` AS `vid`,
1874 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1875 `post-content`.`title` AS `title`,
1876 `post-content`.`content-warning` AS `content-warning`,
1877 `post-content`.`raw-body` AS `raw-body`,
1878 `post-content`.`body` AS `body`,
1879 `post-content`.`rendered-hash` AS `rendered-hash`,
1880 `post-content`.`rendered-html` AS `rendered-html`,
1881 `post-content`.`language` AS `language`,
1882 `post-content`.`plink` AS `plink`,
1883 `post-content`.`location` AS `location`,
1884 `post-content`.`coord` AS `coord`,
1885 `post-content`.`app` AS `app`,
1886 `post-content`.`object-type` AS `object-type`,
1887 `post-content`.`object` AS `object`,
1888 `post-content`.`target-type` AS `target-type`,
1889 `post-content`.`target` AS `target`,
1890 `post-content`.`resource-id` AS `resource-id`,
1891 `post`.`author-id` AS `contact-id`,
1892 `author`.`url` AS `contact-link`,
1893 `author`.`addr` AS `contact-addr`,
1894 `author`.`name` AS `contact-name`,
1895 `author`.`nick` AS `contact-nick`,
1896 `author`.`thumb` AS `contact-avatar`,
1897 `author`.`network` AS `contact-network`,
1898 `author`.`blocked` AS `contact-blocked`,
1899 `author`.`hidden` AS `contact-hidden`,
1900 `author`.`readonly` AS `contact-readonly`,
1901 `author`.`archive` AS `contact-archive`,
1902 `author`.`pending` AS `contact-pending`,
1903 `author`.`rel` AS `contact-rel`,
1904 `author`.`uid` AS `contact-uid`,
1905 `author`.`contact-type` AS `contact-contact-type`,
1906 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
1908 `author`.`id` AS `cid`,
1909 `author`.`alias` AS `alias`,
1910 `author`.`photo` AS `photo`,
1911 `author`.`name-date` AS `name-date`,
1912 `author`.`uri-date` AS `uri-date`,
1913 `author`.`avatar-date` AS `avatar-date`,
1914 `author`.`thumb` AS `thumb`,
1915 `post`.`author-id` AS `author-id`,
1916 `author`.`url` AS `author-link`,
1917 `author`.`addr` AS `author-addr`,
1918 `author`.`name` AS `author-name`,
1919 `author`.`nick` AS `author-nick`,
1920 `author`.`thumb` AS `author-avatar`,
1921 `author`.`network` AS `author-network`,
1922 `author`.`blocked` AS `author-blocked`,
1923 `author`.`hidden` AS `author-hidden`,
1924 `post`.`owner-id` AS `owner-id`,
1925 `owner`.`url` AS `owner-link`,
1926 `owner`.`addr` AS `owner-addr`,
1927 `owner`.`name` AS `owner-name`,
1928 `owner`.`nick` AS `owner-nick`,
1929 `owner`.`thumb` AS `owner-avatar`,
1930 `owner`.`network` AS `owner-network`,
1931 `owner`.`blocked` AS `owner-blocked`,
1932 `owner`.`hidden` AS `owner-hidden`,
1933 `owner`.`contact-type` AS `owner-contact-type`,
1934 `post`.`causer-id` AS `causer-id`,
1935 `causer`.`url` AS `causer-link`,
1936 `causer`.`addr` AS `causer-addr`,
1937 `causer`.`name` AS `causer-name`,
1938 `causer`.`nick` AS `causer-nick`,
1939 `causer`.`thumb` AS `causer-avatar`,
1940 `causer`.`network` AS `causer-network`,
1941 `causer`.`blocked` AS `causer-blocked`,
1942 `causer`.`hidden` AS `causer-hidden`,
1943 `causer`.`contact-type` AS `causer-contact-type`,
1944 `diaspora-interaction`.`interaction` AS `signed_text`,
1945 `parent-item-uri`.`guid` AS `parent-guid`,
1946 `parent-post`.`network` AS `parent-network`,
1947 `parent-post`.`author-id` AS `parent-author-id`,
1948 `parent-post-author`.`url` AS `parent-author-link`,
1949 `parent-post-author`.`name` AS `parent-author-name`,
1950 `parent-post-author`.`network` AS `parent-author-network`,
1951 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1952 `parent-post-author`.`hidden` AS `parent-author-hidden`
1954 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
1955 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
1956 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
1957 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
1958 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
1959 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
1960 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
1961 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
1962 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
1963 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
1964 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
1965 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
1966 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1969 -- VIEW post-thread-view
1971 DROP VIEW IF EXISTS `post-thread-view`;
1972 CREATE VIEW `post-thread-view` AS SELECT
1973 `item-uri`.`uri` AS `uri`,
1974 `post-thread`.`uri-id` AS `uri-id`,
1975 `parent-item-uri`.`uri` AS `parent-uri`,
1976 `post`.`parent-uri-id` AS `parent-uri-id`,
1977 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1978 `post`.`thr-parent-id` AS `thr-parent-id`,
1979 `item-uri`.`guid` AS `guid`,
1980 `post`.`gravity` AS `gravity`,
1981 `external-item-uri`.`uri` AS `extid`,
1982 `post`.`external-id` AS `external-id`,
1983 `post-thread`.`created` AS `created`,
1984 `post`.`edited` AS `edited`,
1985 `post-thread`.`commented` AS `commented`,
1986 `post-thread`.`received` AS `received`,
1987 `post-thread`.`changed` AS `changed`,
1988 `post`.`post-type` AS `post-type`,
1989 `post`.`private` AS `private`,
1990 `post`.`visible` AS `visible`,
1991 `post`.`deleted` AS `deleted`,
1992 `post`.`global` AS `global`,
1993 `post-thread`.`network` AS `network`,
1994 `post`.`vid` AS `vid`,
1995 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1996 `post-content`.`title` AS `title`,
1997 `post-content`.`content-warning` AS `content-warning`,
1998 `post-content`.`raw-body` AS `raw-body`,
1999 `post-content`.`body` AS `body`,
2000 `post-content`.`rendered-hash` AS `rendered-hash`,
2001 `post-content`.`rendered-html` AS `rendered-html`,
2002 `post-content`.`language` AS `language`,
2003 `post-content`.`plink` AS `plink`,
2004 `post-content`.`location` AS `location`,
2005 `post-content`.`coord` AS `coord`,
2006 `post-content`.`app` AS `app`,
2007 `post-content`.`object-type` AS `object-type`,
2008 `post-content`.`object` AS `object`,
2009 `post-content`.`target-type` AS `target-type`,
2010 `post-content`.`target` AS `target`,
2011 `post-content`.`resource-id` AS `resource-id`,
2012 `post-thread`.`author-id` AS `contact-id`,
2013 `author`.`url` AS `contact-link`,
2014 `author`.`addr` AS `contact-addr`,
2015 `author`.`name` AS `contact-name`,
2016 `author`.`nick` AS `contact-nick`,
2017 `author`.`thumb` AS `contact-avatar`,
2018 `author`.`network` AS `contact-network`,
2019 `author`.`blocked` AS `contact-blocked`,
2020 `author`.`hidden` AS `contact-hidden`,
2021 `author`.`readonly` AS `contact-readonly`,
2022 `author`.`archive` AS `contact-archive`,
2023 `author`.`pending` AS `contact-pending`,
2024 `author`.`rel` AS `contact-rel`,
2025 `author`.`uid` AS `contact-uid`,
2026 `author`.`contact-type` AS `contact-contact-type`,
2027 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2029 `author`.`id` AS `cid`,
2030 `author`.`alias` AS `alias`,
2031 `author`.`photo` AS `photo`,
2032 `author`.`name-date` AS `name-date`,
2033 `author`.`uri-date` AS `uri-date`,
2034 `author`.`avatar-date` AS `avatar-date`,
2035 `author`.`thumb` AS `thumb`,
2036 `post-thread`.`author-id` AS `author-id`,
2037 `author`.`url` AS `author-link`,
2038 `author`.`addr` AS `author-addr`,
2039 `author`.`name` AS `author-name`,
2040 `author`.`nick` AS `author-nick`,
2041 `author`.`thumb` AS `author-avatar`,
2042 `author`.`network` AS `author-network`,
2043 `author`.`blocked` AS `author-blocked`,
2044 `author`.`hidden` AS `author-hidden`,
2045 `post-thread`.`owner-id` AS `owner-id`,
2046 `owner`.`url` AS `owner-link`,
2047 `owner`.`addr` AS `owner-addr`,
2048 `owner`.`name` AS `owner-name`,
2049 `owner`.`nick` AS `owner-nick`,
2050 `owner`.`thumb` AS `owner-avatar`,
2051 `owner`.`network` AS `owner-network`,
2052 `owner`.`blocked` AS `owner-blocked`,
2053 `owner`.`hidden` AS `owner-hidden`,
2054 `owner`.`contact-type` AS `owner-contact-type`,
2055 `post-thread`.`causer-id` AS `causer-id`,
2056 `causer`.`url` AS `causer-link`,
2057 `causer`.`addr` AS `causer-addr`,
2058 `causer`.`name` AS `causer-name`,
2059 `causer`.`nick` AS `causer-nick`,
2060 `causer`.`thumb` AS `causer-avatar`,
2061 `causer`.`network` AS `causer-network`,
2062 `causer`.`blocked` AS `causer-blocked`,
2063 `causer`.`hidden` AS `causer-hidden`,
2064 `causer`.`contact-type` AS `causer-contact-type`,
2065 `diaspora-interaction`.`interaction` AS `signed_text`,
2066 `parent-item-uri`.`guid` AS `parent-guid`,
2067 `parent-post`.`network` AS `parent-network`,
2068 `parent-post`.`author-id` AS `parent-author-id`,
2069 `parent-post-author`.`url` AS `parent-author-link`,
2070 `parent-post-author`.`name` AS `parent-author-name`,
2071 `parent-post-author`.`network` AS `parent-author-network`,
2072 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2073 `parent-post-author`.`hidden` AS `parent-author-hidden`
2075 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
2076 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
2077 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
2078 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
2079 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
2080 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2081 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2082 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2083 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2084 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
2085 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
2086 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2087 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2090 -- VIEW category-view
2092 DROP VIEW IF EXISTS `category-view`;
2093 CREATE VIEW `category-view` AS SELECT
2094 `post-category`.`uri-id` AS `uri-id`,
2095 `post-category`.`uid` AS `uid`,
2096 `post-category`.`type` AS `type`,
2097 `post-category`.`tid` AS `tid`,
2098 `tag`.`name` AS `name`,
2099 `tag`.`url` AS `url`
2100 FROM `post-category`
2101 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2106 DROP VIEW IF EXISTS `tag-view`;
2107 CREATE VIEW `tag-view` AS SELECT
2108 `post-tag`.`uri-id` AS `uri-id`,
2109 `post-tag`.`type` AS `type`,
2110 `post-tag`.`tid` AS `tid`,
2111 `post-tag`.`cid` AS `cid`,
2112 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2113 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
2115 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2116 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2119 -- VIEW network-item-view
2121 DROP VIEW IF EXISTS `network-item-view`;
2122 CREATE VIEW `network-item-view` AS SELECT
2123 `post-user`.`uri-id` AS `uri-id`,
2124 `parent-post`.`id` AS `parent`,
2125 `post-user`.`received` AS `received`,
2126 `post-thread-user`.`commented` AS `commented`,
2127 `post-user`.`created` AS `created`,
2128 `post-user`.`uid` AS `uid`,
2129 `post-thread-user`.`starred` AS `starred`,
2130 `post-thread-user`.`mention` AS `mention`,
2131 `post-user`.`network` AS `network`,
2132 `post-user`.`unseen` AS `unseen`,
2133 `post-user`.`gravity` AS `gravity`,
2134 `post-user`.`contact-id` AS `contact-id`,
2135 `ownercontact`.`contact-type` AS `contact-type`
2137 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2138 INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2139 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2140 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2141 INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2142 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2143 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2144 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2145 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
2146 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2147 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2150 -- VIEW network-thread-view
2152 DROP VIEW IF EXISTS `network-thread-view`;
2153 CREATE VIEW `network-thread-view` AS SELECT
2154 `post-thread-user`.`uri-id` AS `uri-id`,
2155 `parent-post`.`id` AS `parent`,
2156 `post-thread-user`.`received` AS `received`,
2157 `post-thread-user`.`commented` AS `commented`,
2158 `post-thread-user`.`created` AS `created`,
2159 `post-thread-user`.`uid` AS `uid`,
2160 `post-thread-user`.`starred` AS `starred`,
2161 `post-thread-user`.`mention` AS `mention`,
2162 `post-thread-user`.`network` AS `network`,
2163 `post-thread-user`.`contact-id` AS `contact-id`,
2164 `ownercontact`.`contact-type` AS `contact-type`
2165 FROM `post-thread-user`
2166 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2167 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2168 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2169 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2170 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2171 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2172 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2173 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2174 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2175 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2176 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2181 DROP VIEW IF EXISTS `owner-view`;
2182 CREATE VIEW `owner-view` AS SELECT
2183 `contact`.`id` AS `id`,
2184 `contact`.`uid` AS `uid`,
2185 `contact`.`created` AS `created`,
2186 `contact`.`updated` AS `updated`,
2187 `contact`.`self` AS `self`,
2188 `contact`.`remote_self` AS `remote_self`,
2189 `contact`.`rel` AS `rel`,
2190 `contact`.`network` AS `network`,
2191 `contact`.`protocol` AS `protocol`,
2192 `contact`.`name` AS `name`,
2193 `contact`.`nick` AS `nick`,
2194 `contact`.`location` AS `location`,
2195 `contact`.`about` AS `about`,
2196 `contact`.`keywords` AS `keywords`,
2197 `contact`.`gender` AS `gender`,
2198 `contact`.`xmpp` AS `xmpp`,
2199 `contact`.`attag` AS `attag`,
2200 `contact`.`avatar` AS `avatar`,
2201 `contact`.`photo` AS `photo`,
2202 `contact`.`thumb` AS `thumb`,
2203 `contact`.`micro` AS `micro`,
2204 `contact`.`header` AS `header`,
2205 `contact`.`url` AS `url`,
2206 `contact`.`nurl` AS `nurl`,
2207 `contact`.`uri-id` AS `uri-id`,
2208 `contact`.`addr` AS `addr`,
2209 `contact`.`alias` AS `alias`,
2210 `contact`.`pubkey` AS `pubkey`,
2211 `contact`.`prvkey` AS `prvkey`,
2212 `contact`.`batch` AS `batch`,
2213 `contact`.`request` AS `request`,
2214 `contact`.`notify` AS `notify`,
2215 `contact`.`poll` AS `poll`,
2216 `contact`.`confirm` AS `confirm`,
2217 `contact`.`poco` AS `poco`,
2218 `contact`.`usehub` AS `usehub`,
2219 `contact`.`subhub` AS `subhub`,
2220 `contact`.`hub-verify` AS `hub-verify`,
2221 `contact`.`last-update` AS `last-update`,
2222 `contact`.`success_update` AS `success_update`,
2223 `contact`.`failure_update` AS `failure_update`,
2224 `contact`.`name-date` AS `name-date`,
2225 `contact`.`uri-date` AS `uri-date`,
2226 `contact`.`avatar-date` AS `avatar-date`,
2227 `contact`.`avatar-date` AS `picdate`,
2228 `contact`.`term-date` AS `term-date`,
2229 `contact`.`last-item` AS `last-item`,
2230 `contact`.`priority` AS `priority`,
2231 `user`.`blocked` AS `blocked`,
2232 `contact`.`block_reason` AS `block_reason`,
2233 `contact`.`readonly` AS `readonly`,
2234 `contact`.`writable` AS `writable`,
2235 `contact`.`forum` AS `forum`,
2236 `contact`.`prv` AS `prv`,
2237 `contact`.`contact-type` AS `contact-type`,
2238 `contact`.`manually-approve` AS `manually-approve`,
2239 `contact`.`hidden` AS `hidden`,
2240 `contact`.`archive` AS `archive`,
2241 `contact`.`pending` AS `pending`,
2242 `contact`.`deleted` AS `deleted`,
2243 `contact`.`unsearchable` AS `unsearchable`,
2244 `contact`.`sensitive` AS `sensitive`,
2245 `contact`.`baseurl` AS `baseurl`,
2246 `contact`.`reason` AS `reason`,
2247 `contact`.`closeness` AS `closeness`,
2248 `contact`.`info` AS `info`,
2249 `contact`.`profile-id` AS `profile-id`,
2250 `contact`.`bdyear` AS `bdyear`,
2251 `contact`.`bd` AS `bd`,
2252 `contact`.`notify_new_posts` AS `notify_new_posts`,
2253 `contact`.`fetch_further_information` AS `fetch_further_information`,
2254 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2255 `user`.`parent-uid` AS `parent-uid`,
2256 `user`.`guid` AS `guid`,
2257 `user`.`nickname` AS `nickname`,
2258 `user`.`email` AS `email`,
2259 `user`.`openid` AS `openid`,
2260 `user`.`timezone` AS `timezone`,
2261 `user`.`language` AS `language`,
2262 `user`.`register_date` AS `register_date`,
2263 `user`.`login_date` AS `login_date`,
2264 `user`.`default-location` AS `default-location`,
2265 `user`.`allow_location` AS `allow_location`,
2266 `user`.`theme` AS `theme`,
2267 `user`.`pubkey` AS `upubkey`,
2268 `user`.`prvkey` AS `uprvkey`,
2269 `user`.`sprvkey` AS `sprvkey`,
2270 `user`.`spubkey` AS `spubkey`,
2271 `user`.`verified` AS `verified`,
2272 `user`.`blockwall` AS `blockwall`,
2273 `user`.`hidewall` AS `hidewall`,
2274 `user`.`blocktags` AS `blocktags`,
2275 `user`.`unkmail` AS `unkmail`,
2276 `user`.`cntunkmail` AS `cntunkmail`,
2277 `user`.`notify-flags` AS `notify-flags`,
2278 `user`.`page-flags` AS `page-flags`,
2279 `user`.`account-type` AS `account-type`,
2280 `user`.`prvnets` AS `prvnets`,
2281 `user`.`maxreq` AS `maxreq`,
2282 `user`.`expire` AS `expire`,
2283 `user`.`account_removed` AS `account_removed`,
2284 `user`.`account_expired` AS `account_expired`,
2285 `user`.`account_expires_on` AS `account_expires_on`,
2286 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2287 `user`.`def_gid` AS `def_gid`,
2288 `user`.`allow_cid` AS `allow_cid`,
2289 `user`.`allow_gid` AS `allow_gid`,
2290 `user`.`deny_cid` AS `deny_cid`,
2291 `user`.`deny_gid` AS `deny_gid`,
2292 `user`.`openidserver` AS `openidserver`,
2293 `profile`.`publish` AS `publish`,
2294 `profile`.`net-publish` AS `net-publish`,
2295 `profile`.`hide-friends` AS `hide-friends`,
2296 `profile`.`prv_keywords` AS `prv_keywords`,
2297 `profile`.`pub_keywords` AS `pub_keywords`,
2298 `profile`.`address` AS `address`,
2299 `profile`.`locality` AS `locality`,
2300 `profile`.`region` AS `region`,
2301 `profile`.`postal-code` AS `postal-code`,
2302 `profile`.`country-name` AS `country-name`,
2303 `profile`.`homepage` AS `homepage`,
2304 `profile`.`dob` AS `dob`
2306 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2307 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2310 -- VIEW account-view
2312 DROP VIEW IF EXISTS `account-view`;
2313 CREATE VIEW `account-view` AS SELECT
2314 `contact`.`id` AS `id`,
2315 `contact`.`url` AS `url`,
2316 `contact`.`nurl` AS `nurl`,
2317 `contact`.`uri-id` AS `uri-id`,
2318 `contact`.`addr` AS `addr`,
2319 `contact`.`alias` AS `alias`,
2320 `contact`.`name` AS `name`,
2321 `contact`.`nick` AS `nick`,
2322 `contact`.`about` AS `about`,
2323 `contact`.`keywords` AS `keywords`,
2324 `contact`.`xmpp` AS `xmpp`,
2325 `contact`.`avatar` AS `avatar`,
2326 `contact`.`photo` AS `photo`,
2327 `contact`.`thumb` AS `thumb`,
2328 `contact`.`micro` AS `micro`,
2329 `contact`.`header` AS `header`,
2330 `contact`.`created` AS `created`,
2331 `contact`.`updated` AS `updated`,
2332 `contact`.`network` AS `network`,
2333 `contact`.`protocol` AS `protocol`,
2334 `contact`.`location` AS `location`,
2335 `contact`.`attag` AS `attag`,
2336 `contact`.`pubkey` AS `pubkey`,
2337 `contact`.`prvkey` AS `prvkey`,
2338 `contact`.`subscribe` AS `subscribe`,
2339 `contact`.`last-update` AS `last-update`,
2340 `contact`.`success_update` AS `success_update`,
2341 `contact`.`failure_update` AS `failure_update`,
2342 `contact`.`failed` AS `failed`,
2343 `contact`.`last-item` AS `last-item`,
2344 `contact`.`last-discovery` AS `last-discovery`,
2345 `contact`.`contact-type` AS `contact-type`,
2346 `contact`.`manually-approve` AS `manually-approve`,
2347 `contact`.`unsearchable` AS `unsearchable`,
2348 `contact`.`sensitive` AS `sensitive`,
2349 `contact`.`baseurl` AS `baseurl`,
2350 `contact`.`gsid` AS `gsid`,
2351 `contact`.`info` AS `info`,
2352 `contact`.`bdyear` AS `bdyear`,
2353 `contact`.`bd` AS `bd`,
2354 `contact`.`poco` AS `poco`,
2355 `contact`.`name-date` AS `name-date`,
2356 `contact`.`uri-date` AS `uri-date`,
2357 `contact`.`avatar-date` AS `avatar-date`,
2358 `contact`.`term-date` AS `term-date`,
2359 `contact`.`hidden` AS `global-ignored`,
2360 `contact`.`blocked` AS `global-blocked`,
2361 `contact`.`hidden` AS `hidden`,
2362 `contact`.`archive` AS `archive`,
2363 `contact`.`deleted` AS `deleted`,
2364 `contact`.`blocked` AS `blocked`,
2365 `contact`.`request` AS `dfrn-request`,
2366 `contact`.`notify` AS `dfrn-notify`,
2367 `contact`.`poll` AS `dfrn-poll`,
2368 `contact`.`confirm` AS `dfrn-confirm`,
2369 `fcontact`.`guid` AS `diaspora-guid`,
2370 `fcontact`.`batch` AS `diaspora-batch`,
2371 `fcontact`.`notify` AS `diaspora-notify`,
2372 `fcontact`.`poll` AS `diaspora-poll`,
2373 `fcontact`.`alias` AS `diaspora-alias`,
2374 `apcontact`.`uuid` AS `ap-uuid`,
2375 `apcontact`.`type` AS `ap-type`,
2376 `apcontact`.`following` AS `ap-following`,
2377 `apcontact`.`followers` AS `ap-followers`,
2378 `apcontact`.`inbox` AS `ap-inbox`,
2379 `apcontact`.`outbox` AS `ap-outbox`,
2380 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2381 `apcontact`.`generator` AS `ap-generator`,
2382 `apcontact`.`following_count` AS `ap-following_count`,
2383 `apcontact`.`followers_count` AS `ap-followers_count`,
2384 `apcontact`.`statuses_count` AS `ap-statuses_count`
2386 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
2387 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = contact.`uri-id`
2388 WHERE `contact`.`uid` = 0;
2391 -- VIEW account-user-view
2393 DROP VIEW IF EXISTS `account-user-view`;
2394 CREATE VIEW `account-user-view` AS SELECT
2395 `ucontact`.`id` AS `id`,
2396 `contact`.`id` AS `pid`,
2397 `ucontact`.`uid` AS `uid`,
2398 `contact`.`url` AS `url`,
2399 `contact`.`nurl` AS `nurl`,
2400 `contact`.`uri-id` AS `uri-id`,
2401 `contact`.`addr` AS `addr`,
2402 `contact`.`alias` AS `alias`,
2403 `contact`.`name` AS `name`,
2404 `contact`.`nick` AS `nick`,
2405 `contact`.`about` AS `about`,
2406 `contact`.`keywords` AS `keywords`,
2407 `contact`.`xmpp` AS `xmpp`,
2408 `contact`.`avatar` AS `avatar`,
2409 `contact`.`photo` AS `photo`,
2410 `contact`.`thumb` AS `thumb`,
2411 `contact`.`micro` AS `micro`,
2412 `contact`.`header` AS `header`,
2413 `contact`.`created` AS `created`,
2414 `contact`.`updated` AS `updated`,
2415 `ucontact`.`self` AS `self`,
2416 `ucontact`.`remote_self` AS `remote_self`,
2417 `ucontact`.`rel` AS `rel`,
2418 `contact`.`network` AS `network`,
2419 `ucontact`.`protocol` AS `protocol`,
2420 `contact`.`location` AS `location`,
2421 `contact`.`attag` AS `attag`,
2422 `contact`.`pubkey` AS `pubkey`,
2423 `contact`.`prvkey` AS `prvkey`,
2424 `contact`.`subscribe` AS `subscribe`,
2425 `contact`.`last-update` AS `last-update`,
2426 `contact`.`success_update` AS `success_update`,
2427 `contact`.`failure_update` AS `failure_update`,
2428 `contact`.`failed` AS `failed`,
2429 `contact`.`last-item` AS `last-item`,
2430 `contact`.`last-discovery` AS `last-discovery`,
2431 `contact`.`contact-type` AS `contact-type`,
2432 `contact`.`manually-approve` AS `manually-approve`,
2433 `contact`.`unsearchable` AS `unsearchable`,
2434 `contact`.`sensitive` AS `sensitive`,
2435 `contact`.`baseurl` AS `baseurl`,
2436 `contact`.`gsid` AS `gsid`,
2437 `contact`.`info` AS `info`,
2438 `contact`.`bdyear` AS `bdyear`,
2439 `contact`.`bd` AS `bd`,
2440 `contact`.`poco` AS `poco`,
2441 `contact`.`name-date` AS `name-date`,
2442 `contact`.`uri-date` AS `uri-date`,
2443 `contact`.`avatar-date` AS `avatar-date`,
2444 `contact`.`term-date` AS `term-date`,
2445 `contact`.`hidden` AS `global-ignored`,
2446 `contact`.`blocked` AS `global-blocked`,
2447 `ucontact`.`hidden` AS `hidden`,
2448 `ucontact`.`archive` AS `archive`,
2449 `ucontact`.`pending` AS `pending`,
2450 `ucontact`.`deleted` AS `deleted`,
2451 `ucontact`.`notify_new_posts` AS `notify_new_posts`,
2452 `ucontact`.`fetch_further_information` AS `fetch_further_information`,
2453 `ucontact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2454 `ucontact`.`rating` AS `rating`,
2455 `ucontact`.`readonly` AS `readonly`,
2456 `ucontact`.`blocked` AS `blocked`,
2457 `ucontact`.`block_reason` AS `block_reason`,
2458 `ucontact`.`subhub` AS `subhub`,
2459 `ucontact`.`hub-verify` AS `hub-verify`,
2460 `ucontact`.`reason` AS `reason`,
2461 `contact`.`request` AS `dfrn-request`,
2462 `contact`.`notify` AS `dfrn-notify`,
2463 `contact`.`poll` AS `dfrn-poll`,
2464 `contact`.`confirm` AS `dfrn-confirm`,
2465 `fcontact`.`guid` AS `diaspora-guid`,
2466 `fcontact`.`batch` AS `diaspora-batch`,
2467 `fcontact`.`notify` AS `diaspora-notify`,
2468 `fcontact`.`poll` AS `diaspora-poll`,
2469 `fcontact`.`alias` AS `diaspora-alias`,
2470 `apcontact`.`uuid` AS `ap-uuid`,
2471 `apcontact`.`type` AS `ap-type`,
2472 `apcontact`.`following` AS `ap-following`,
2473 `apcontact`.`followers` AS `ap-followers`,
2474 `apcontact`.`inbox` AS `ap-inbox`,
2475 `apcontact`.`outbox` AS `ap-outbox`,
2476 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2477 `apcontact`.`generator` AS `ap-generator`,
2478 `apcontact`.`following_count` AS `ap-following_count`,
2479 `apcontact`.`followers_count` AS `ap-followers_count`,
2480 `apcontact`.`statuses_count` AS `ap-statuses_count`
2481 FROM `contact` AS `ucontact`
2482 INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
2483 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
2484 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = `ucontact`.`uri-id` AND `fcontact`.`network` = 'dspr';
2487 -- VIEW pending-view
2489 DROP VIEW IF EXISTS `pending-view`;
2490 CREATE VIEW `pending-view` AS SELECT
2491 `register`.`id` AS `id`,
2492 `register`.`hash` AS `hash`,
2493 `register`.`created` AS `created`,
2494 `register`.`uid` AS `uid`,
2495 `register`.`password` AS `password`,
2496 `register`.`language` AS `language`,
2497 `register`.`note` AS `note`,
2498 `contact`.`self` AS `self`,
2499 `contact`.`name` AS `name`,
2500 `contact`.`url` AS `url`,
2501 `contact`.`micro` AS `micro`,
2502 `user`.`email` AS `email`,
2503 `contact`.`nick` AS `nick`
2505 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2506 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2509 -- VIEW tag-search-view
2511 DROP VIEW IF EXISTS `tag-search-view`;
2512 CREATE VIEW `tag-search-view` AS SELECT
2513 `post-tag`.`uri-id` AS `uri-id`,
2514 `post-user`.`uid` AS `uid`,
2515 `post-user`.`id` AS `iid`,
2516 `post-user`.`private` AS `private`,
2517 `post-user`.`wall` AS `wall`,
2518 `post-user`.`origin` AS `origin`,
2519 `post-user`.`global` AS `global`,
2520 `post-user`.`gravity` AS `gravity`,
2521 `post-user`.`received` AS `received`,
2522 `post-user`.`network` AS `network`,
2523 `post-user`.`author-id` AS `author-id`,
2524 `tag`.`name` AS `name`
2526 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
2527 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
2528 WHERE `post-tag`.`type` = 1;
2531 -- VIEW workerqueue-view
2533 DROP VIEW IF EXISTS `workerqueue-view`;
2534 CREATE VIEW `workerqueue-view` AS SELECT
2535 `process`.`pid` AS `pid`,
2536 `workerqueue`.`priority` AS `priority`
2538 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
2539 WHERE NOT `workerqueue`.`done`;