1 -- ------------------------------------------
2 -- Friendica 2021.12-rc (Siberian Iris)
3 -- DB_UPDATE_VERSION 1448
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 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network of the contact',
118 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
119 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
120 `location` varchar(255) DEFAULT '' COMMENT '',
121 `about` text COMMENT '',
122 `keywords` text COMMENT 'public keywords (interests) of the contact',
123 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
124 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
125 `avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '',
126 `header` varchar(255) COMMENT 'Header picture',
127 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
128 `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
129 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
130 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
131 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
132 `pubkey` text COMMENT 'RSA public key 4096 bit',
133 `prvkey` text COMMENT 'RSA private key 4096 bit',
134 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
135 `notify` varchar(255) COMMENT '',
136 `poll` varchar(255) COMMENT '',
137 `subscribe` varchar(255) COMMENT '',
138 `last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
139 `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
140 `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
141 `failed` boolean COMMENT 'Connection failed',
142 `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
143 `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
144 `last-discovery` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last follower discovery',
145 `blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
146 `block_reason` text COMMENT 'Node-wide block reason',
147 `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
148 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Person, organisation, news, community, relay',
149 `manually-approve` boolean COMMENT 'Contact requests have to be approved manually',
150 `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
151 `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
152 `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
153 `baseurl` varchar(255) DEFAULT '' COMMENT 'baseurl of the contact',
154 `gsid` int unsigned COMMENT 'Global Server ID',
155 `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
156 `reason` text COMMENT '',
157 `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
158 `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
159 `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
160 `protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
161 `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
162 `hub-verify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
163 `rating` tinyint NOT NULL DEFAULT 0 COMMENT 'Automatically detected feed poll frequency',
164 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Feed poll priority',
165 `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
166 `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
167 `pending` boolean NOT NULL DEFAULT '1' COMMENT 'Contact request is pending',
168 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
169 `info` mediumtext COMMENT '',
170 `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
171 `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
172 `ffi_keyword_denylist` text COMMENT '',
173 `photo` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
174 `thumb` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
175 `micro` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
176 `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
177 `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
178 `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
179 `request` varchar(255) COMMENT '',
180 `confirm` varchar(255) COMMENT '',
181 `poco` varchar(255) COMMENT '',
182 `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
183 `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = false instead',
184 `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = true instead',
185 `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
186 `site-pubkey` text COMMENT 'Deprecated',
187 `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
188 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
189 `issued-id` varchar(255) NOT NULL DEFAULT '' COMMENT 'Deprecated',
190 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT 'Deprecated',
191 `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
192 `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
193 `usehub` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
194 `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT 'Deprecated',
195 `profile-id` int unsigned COMMENT 'Deprecated',
197 INDEX `uid_name` (`uid`,`name`(190)),
198 INDEX `self_uid` (`self`,`uid`),
199 INDEX `alias_uid` (`alias`(128),`uid`),
200 INDEX `pending_uid` (`pending`,`uid`),
201 INDEX `blocked_uid` (`blocked`,`uid`),
202 INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
203 INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
204 INDEX `batch_contact-type` (`batch`(64),`contact-type`),
205 INDEX `addr_uid` (`addr`(128),`uid`),
206 INDEX `nurl_uid` (`nurl`(128),`uid`),
207 INDEX `nick_uid` (`nick`(128),`uid`),
208 INDEX `attag_uid` (`attag`(96),`uid`),
209 INDEX `network_uid_lastupdate` (`network`,`uid`,`last-update`),
210 INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`),
211 INDEX `uid_lastitem` (`uid`,`last-item`),
212 INDEX `baseurl` (`baseurl`(64)),
213 INDEX `uid_contact-type` (`uid`,`contact-type`),
214 INDEX `uid_self_contact-type` (`uid`,`self`,`contact-type`),
215 INDEX `self_network_uid` (`self`,`network`,`uid`),
216 INDEX `gsid` (`gsid`),
217 INDEX `uri-id` (`uri-id`),
218 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
219 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
220 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
221 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
226 CREATE TABLE IF NOT EXISTS `tag` (
227 `id` int unsigned NOT NULL auto_increment COMMENT '',
228 `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
229 `url` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
231 UNIQUE INDEX `type_name_url` (`name`,`url`),
233 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
236 -- TABLE permissionset
238 CREATE TABLE IF NOT EXISTS `permissionset` (
239 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
240 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
241 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
242 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
243 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
244 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
246 INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`uid`,`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30)),
247 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
248 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
253 CREATE TABLE IF NOT EXISTS `verb` (
254 `id` smallint unsigned NOT NULL auto_increment,
255 `name` varchar(100) NOT NULL DEFAULT '' COMMENT '',
257 INDEX `name` (`name`)
258 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activity Verbs';
261 -- TABLE 2fa_app_specific_password
263 CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
264 `id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
265 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
266 `description` varchar(255) COMMENT 'Description of the usage of the password',
267 `hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
268 `generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
269 `last_used` datetime COMMENT 'Datetime the password was last used',
271 INDEX `uid_description` (`uid`,`description`(190)),
272 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
273 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
276 -- TABLE 2fa_recovery_codes
278 CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
279 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
280 `code` varchar(50) NOT NULL COMMENT 'Recovery code string',
281 `generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
282 `used` datetime COMMENT 'Datetime the code was used',
283 PRIMARY KEY(`uid`,`code`),
284 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
285 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
288 -- TABLE 2fa_trusted_browser
290 CREATE TABLE IF NOT EXISTS `2fa_trusted_browser` (
291 `cookie_hash` varchar(80) NOT NULL COMMENT 'Trusted cookie hash',
292 `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
293 `user_agent` text COMMENT 'User agent string',
294 `created` datetime NOT NULL COMMENT 'Datetime the trusted browser was recorded',
295 `last_used` datetime COMMENT 'Datetime the trusted browser was last used',
296 PRIMARY KEY(`cookie_hash`),
298 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
299 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication trusted browsers';
304 CREATE TABLE IF NOT EXISTS `addon` (
305 `id` int unsigned NOT NULL auto_increment COMMENT '',
306 `name` varchar(50) NOT NULL DEFAULT '' COMMENT 'addon base (file)name',
307 `version` varchar(50) NOT NULL DEFAULT '' COMMENT 'currently unused',
308 `installed` boolean NOT NULL DEFAULT '0' COMMENT 'currently always 1',
309 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'currently unused',
310 `timestamp` int unsigned NOT NULL DEFAULT 0 COMMENT 'file timestamp to check for reloads',
311 `plugin_admin` boolean NOT NULL DEFAULT '0' COMMENT '1 = has admin config, 0 = has no admin config',
313 INDEX `installed_name` (`installed`,`name`),
314 UNIQUE INDEX `name` (`name`)
315 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registered addons';
320 CREATE TABLE IF NOT EXISTS `apcontact` (
321 `url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
322 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
323 `uuid` varchar(255) COMMENT '',
324 `type` varchar(20) NOT NULL COMMENT '',
325 `following` varchar(255) COMMENT '',
326 `followers` varchar(255) COMMENT '',
327 `inbox` varchar(255) NOT NULL COMMENT '',
328 `outbox` varchar(255) COMMENT '',
329 `sharedinbox` varchar(255) COMMENT '',
330 `manually-approve` boolean COMMENT '',
331 `discoverable` boolean COMMENT 'Mastodon extension: true if profile is published in their directory',
332 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
333 `name` varchar(255) COMMENT '',
334 `about` text COMMENT '',
335 `xmpp` varchar(255) COMMENT 'XMPP address',
336 `matrix` varchar(255) COMMENT 'Matrix address',
337 `photo` varchar(255) COMMENT '',
338 `header` varchar(255) COMMENT 'Header picture',
339 `addr` varchar(255) COMMENT '',
340 `alias` varchar(255) COMMENT '',
341 `pubkey` text COMMENT '',
342 `subscribe` varchar(255) COMMENT '',
343 `baseurl` varchar(255) COMMENT 'baseurl of the ap contact',
344 `gsid` int unsigned COMMENT 'Global Server ID',
345 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
346 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
347 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
348 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
349 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
351 INDEX `addr` (`addr`(32)),
352 INDEX `alias` (`alias`(190)),
353 INDEX `followers` (`followers`(190)),
354 INDEX `baseurl` (`baseurl`(190)),
355 INDEX `sharedinbox` (`sharedinbox`(190)),
356 INDEX `gsid` (`gsid`),
357 UNIQUE INDEX `uri-id` (`uri-id`),
358 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
359 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
360 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
365 CREATE TABLE IF NOT EXISTS `application` (
366 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
367 `client_id` varchar(64) NOT NULL COMMENT '',
368 `client_secret` varchar(64) NOT NULL COMMENT '',
369 `name` varchar(255) NOT NULL COMMENT '',
370 `redirect_uri` varchar(255) NOT NULL COMMENT '',
371 `website` varchar(255) COMMENT '',
372 `scopes` varchar(255) COMMENT '',
373 `read` boolean COMMENT 'Read scope',
374 `write` boolean COMMENT 'Write scope',
375 `follow` boolean COMMENT 'Follow scope',
376 `push` boolean COMMENT 'Push scope',
378 UNIQUE INDEX `client_id` (`client_id`)
379 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth application';
382 -- TABLE application-token
384 CREATE TABLE IF NOT EXISTS `application-token` (
385 `application-id` int unsigned NOT NULL COMMENT '',
386 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
387 `code` varchar(64) NOT NULL COMMENT '',
388 `access_token` varchar(64) NOT NULL COMMENT '',
389 `created_at` datetime NOT NULL COMMENT 'creation time',
390 `scopes` varchar(255) COMMENT '',
391 `read` boolean COMMENT 'Read scope',
392 `write` boolean COMMENT 'Write scope',
393 `follow` boolean COMMENT 'Follow scope',
394 `push` boolean COMMENT 'Push scope',
395 PRIMARY KEY(`application-id`,`uid`),
396 INDEX `uid_id` (`uid`,`application-id`),
397 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
398 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
399 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth user token';
404 CREATE TABLE IF NOT EXISTS `attach` (
405 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
406 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
407 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
408 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
409 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
410 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
411 `data` longblob NOT NULL COMMENT 'file data',
412 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
413 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
414 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
415 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
416 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
417 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
418 `backend-class` tinytext COMMENT 'Storage backend class',
419 `backend-ref` text COMMENT 'Storage backend data reference',
422 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
423 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
428 CREATE TABLE IF NOT EXISTS `cache` (
429 `k` varbinary(255) NOT NULL COMMENT 'cache key',
430 `v` mediumtext COMMENT 'cached serialized value',
431 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
432 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
434 INDEX `k_expires` (`k`,`expires`)
435 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
440 CREATE TABLE IF NOT EXISTS `config` (
441 `id` int unsigned NOT NULL auto_increment COMMENT '',
442 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
443 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
444 `v` mediumtext COMMENT '',
446 UNIQUE INDEX `cat_k` (`cat`,`k`)
447 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
450 -- TABLE contact-relation
452 CREATE TABLE IF NOT EXISTS `contact-relation` (
453 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
454 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
455 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
456 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
457 `follows` boolean NOT NULL DEFAULT '0' COMMENT '',
458 PRIMARY KEY(`cid`,`relation-cid`),
459 INDEX `relation-cid` (`relation-cid`),
460 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
461 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
462 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
467 CREATE TABLE IF NOT EXISTS `conv` (
468 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
469 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
470 `recips` text COMMENT 'sender_handle;recipient_handle',
471 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
472 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
473 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
474 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
475 `subject` text COMMENT 'subject of initial message',
478 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
479 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
482 -- TABLE conversation
484 CREATE TABLE IF NOT EXISTS `conversation` (
485 `item-uri` varbinary(255) NOT NULL COMMENT 'Original URI of the item - unrelated to the table with the same name',
486 `reply-to-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'URI to which this item is a reply',
487 `conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI',
488 `conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link',
489 `protocol` tinyint unsigned NOT NULL DEFAULT 255 COMMENT 'The protocol of the item',
490 `direction` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'How the message arrived here: 1=push, 2=pull',
491 `source` mediumtext COMMENT 'Original source',
492 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Receiving date',
493 PRIMARY KEY(`item-uri`),
494 INDEX `conversation-uri` (`conversation-uri`),
495 INDEX `received` (`received`)
496 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Raw data and structure information for messages';
501 CREATE TABLE IF NOT EXISTS `workerqueue` (
502 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
503 `command` varchar(100) COMMENT 'Task command',
504 `parameter` mediumtext COMMENT 'Task parameter',
505 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
506 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
507 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
508 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
509 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
510 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
511 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
513 INDEX `command` (`command`),
514 INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
515 INDEX `done_executed` (`done`,`executed`),
516 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
517 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
518 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
519 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
520 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
521 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
524 -- TABLE delayed-post
526 CREATE TABLE IF NOT EXISTS `delayed-post` (
527 `id` int unsigned NOT NULL auto_increment,
528 `uri` varchar(255) COMMENT 'URI of the post that will be distributed later',
529 `uid` mediumint unsigned COMMENT 'Owner User id',
530 `delayed` datetime COMMENT 'delay time',
531 `wid` int unsigned COMMENT 'Workerqueue id',
533 UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
535 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
536 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
537 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
540 -- TABLE diaspora-interaction
542 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
543 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
544 `interaction` mediumtext COMMENT 'The Diaspora interaction',
545 PRIMARY KEY(`uri-id`),
546 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
547 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
552 CREATE TABLE IF NOT EXISTS `event` (
553 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
554 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
555 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
556 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
557 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
558 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the event uri',
559 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
560 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
561 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
562 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
563 `summary` text COMMENT 'short description or title of the event',
564 `desc` text COMMENT 'event description',
565 `location` text COMMENT 'event location',
566 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
567 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
568 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
569 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
570 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
571 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
572 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
574 INDEX `uid_start` (`uid`,`start`),
576 INDEX `uri-id` (`uri-id`),
577 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
578 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
579 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
580 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
585 CREATE TABLE IF NOT EXISTS `fcontact` (
586 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
587 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
588 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
589 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the fcontact url',
590 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
591 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
592 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
593 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
594 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
595 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
596 `notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
597 `poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
598 `confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
599 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
600 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
601 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
602 `pubkey` text COMMENT '',
603 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
604 `interacting_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts this contact interactes with',
605 `interacted_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts that interacted with this contact',
606 `post_count` int unsigned DEFAULT 0 COMMENT 'Number of posts and comments',
608 INDEX `addr` (`addr`(32)),
609 UNIQUE INDEX `url` (`url`(190)),
610 UNIQUE INDEX `uri-id` (`uri-id`),
611 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
612 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
617 CREATE TABLE IF NOT EXISTS `fsuggest` (
618 `id` int unsigned NOT NULL auto_increment COMMENT '',
619 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
620 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
621 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
622 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
623 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
624 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
625 `note` text COMMENT '',
626 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
630 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
631 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
632 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
637 CREATE TABLE IF NOT EXISTS `group` (
638 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
639 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
640 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
641 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
642 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
645 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
646 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
649 -- TABLE group_member
651 CREATE TABLE IF NOT EXISTS `group_member` (
652 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
653 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
654 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
656 INDEX `contactid` (`contact-id`),
657 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
658 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
659 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
660 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
665 CREATE TABLE IF NOT EXISTS `gserver-tag` (
666 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
667 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
668 PRIMARY KEY(`gserver-id`,`tag`),
670 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
671 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
676 CREATE TABLE IF NOT EXISTS `hook` (
677 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
678 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
679 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
680 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
681 `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',
683 INDEX `priority` (`priority`),
684 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
685 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
688 -- TABLE inbox-status
690 CREATE TABLE IF NOT EXISTS `inbox-status` (
691 `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
692 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
693 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
694 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
695 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
696 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
697 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
699 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
704 CREATE TABLE IF NOT EXISTS `intro` (
705 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
706 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
707 `fid` int unsigned COMMENT 'deprecated',
708 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
709 `suggest-cid` int unsigned COMMENT 'Suggested contact',
710 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
711 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
712 `note` text COMMENT '',
713 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
714 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
715 `blocked` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
716 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
718 INDEX `contact-id` (`contact-id`),
719 INDEX `suggest-cid` (`suggest-cid`),
721 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
722 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
723 FOREIGN KEY (`suggest-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
724 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
729 CREATE TABLE IF NOT EXISTS `locks` (
730 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
731 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
732 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
733 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
734 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
736 INDEX `name_expires` (`name`,`expires`)
737 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
742 CREATE TABLE IF NOT EXISTS `mail` (
743 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
744 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
745 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
746 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
747 `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
748 `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
749 `contact-id` varchar(255) COMMENT 'contact.id',
750 `author-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the author of the mail',
751 `convid` int unsigned COMMENT 'conv.id',
752 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
753 `body` mediumtext COMMENT '',
754 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
755 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
756 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
757 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
758 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
759 `uri-id` int unsigned COMMENT 'Item-uri id of the related mail',
760 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
761 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related mail',
762 `thr-parent` varchar(255) COMMENT '',
763 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
764 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
766 INDEX `uid_seen` (`uid`,`seen`),
767 INDEX `convid` (`convid`),
768 INDEX `uri` (`uri`(64)),
769 INDEX `parent-uri` (`parent-uri`(64)),
770 INDEX `contactid` (`contact-id`(32)),
771 INDEX `author-id` (`author-id`),
772 INDEX `uri-id` (`uri-id`),
773 INDEX `parent-uri-id` (`parent-uri-id`),
774 INDEX `thr-parent-id` (`thr-parent-id`),
775 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
776 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
777 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
778 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
779 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
780 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
785 CREATE TABLE IF NOT EXISTS `mailacct` (
786 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
787 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
788 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
789 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
790 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
791 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
792 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
793 `pass` text COMMENT '',
794 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
795 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
796 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
797 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
798 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
801 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
802 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
807 CREATE TABLE IF NOT EXISTS `manage` (
808 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
809 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
810 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
812 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
814 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
815 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
816 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
819 -- TABLE notification
821 CREATE TABLE IF NOT EXISTS `notification` (
822 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
823 `uid` mediumint unsigned COMMENT 'Owner User id',
824 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
825 `type` tinyint unsigned COMMENT '',
826 `actor-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the actor that caused the notification',
827 `target-uri-id` int unsigned COMMENT 'Item-uri id of the related post',
828 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
829 `created` datetime COMMENT '',
830 `seen` boolean DEFAULT '0' COMMENT 'Seen on the desktop',
831 `dismissed` boolean DEFAULT '0' COMMENT 'Dismissed via the API',
833 UNIQUE INDEX `uid_vid_type_actor-id_target-uri-id` (`uid`,`vid`,`type`,`actor-id`,`target-uri-id`),
835 INDEX `actor-id` (`actor-id`),
836 INDEX `target-uri-id` (`target-uri-id`),
837 INDEX `parent-uri-id` (`parent-uri-id`),
838 INDEX `seen_uid` (`seen`,`uid`),
839 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
840 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
841 FOREIGN KEY (`actor-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
842 FOREIGN KEY (`target-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
843 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
844 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
849 CREATE TABLE IF NOT EXISTS `notify` (
850 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
851 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
852 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
853 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
854 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
855 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
856 `msg` mediumtext COMMENT '',
857 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
858 `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
859 `iid` int unsigned COMMENT '',
860 `parent` int unsigned COMMENT '',
861 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
862 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
863 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
864 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
865 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
866 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
867 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
869 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
870 INDEX `uid_date` (`uid`,`date`),
871 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
872 INDEX `uri-id` (`uri-id`),
873 INDEX `parent-uri-id` (`parent-uri-id`),
874 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
875 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
876 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
877 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
880 -- TABLE notify-threads
882 CREATE TABLE IF NOT EXISTS `notify-threads` (
883 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
884 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
885 `master-parent-item` int unsigned COMMENT 'Deprecated',
886 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
887 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
888 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
890 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
891 INDEX `receiver-uid` (`receiver-uid`),
892 INDEX `notify-id` (`notify-id`),
893 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
894 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
895 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
896 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
901 CREATE TABLE IF NOT EXISTS `oembed` (
902 `url` varbinary(255) NOT NULL COMMENT 'page url',
903 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
904 `content` mediumtext COMMENT 'OEmbed data of the page',
905 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
906 PRIMARY KEY(`url`,`maxwidth`),
907 INDEX `created` (`created`)
908 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
911 -- TABLE openwebauth-token
913 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
914 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
915 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
916 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
917 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
918 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
919 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
922 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
923 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
928 CREATE TABLE IF NOT EXISTS `parsed_url` (
929 `url_hash` binary(64) NOT NULL COMMENT 'page url hash',
930 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
931 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
932 `url` text NOT NULL COMMENT 'page url',
933 `content` mediumtext COMMENT 'page data',
934 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
935 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration',
936 PRIMARY KEY(`url_hash`,`guessing`,`oembed`),
937 INDEX `created` (`created`),
938 INDEX `expires` (`expires`)
939 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
944 CREATE TABLE IF NOT EXISTS `pconfig` (
945 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
946 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
947 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
948 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
949 `v` mediumtext COMMENT 'Value',
951 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
952 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
953 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
958 CREATE TABLE IF NOT EXISTS `photo` (
959 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
960 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
961 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
962 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
963 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
964 `hash` char(32) COMMENT 'hash value of the photo',
965 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
966 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
967 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
968 `desc` text COMMENT '',
969 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
970 `photo-type` tinyint unsigned COMMENT 'User avatar, user banner, contact avatar, contact banner or default',
971 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
972 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
973 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
974 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
975 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
976 `data` mediumblob NOT NULL COMMENT '',
977 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
978 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
979 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
980 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
981 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
982 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
983 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
984 `backend-class` tinytext COMMENT 'Storage backend class',
985 `backend-ref` text COMMENT 'Storage backend data reference',
986 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
988 INDEX `contactid` (`contact-id`),
989 INDEX `uid_contactid` (`uid`,`contact-id`),
990 INDEX `uid_profile` (`uid`,`profile`),
991 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
992 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
993 INDEX `resource-id` (`resource-id`),
994 INDEX `uid_photo-type` (`uid`,`photo-type`),
995 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
996 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
997 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1002 CREATE TABLE IF NOT EXISTS `post` (
1003 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1004 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1005 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1006 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1007 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1008 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1009 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1010 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1011 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1012 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1013 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1014 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1015 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1016 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1017 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1018 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1019 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1020 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1021 PRIMARY KEY(`uri-id`),
1022 INDEX `parent-uri-id` (`parent-uri-id`),
1023 INDEX `thr-parent-id` (`thr-parent-id`),
1024 INDEX `external-id` (`external-id`),
1025 INDEX `owner-id` (`owner-id`),
1026 INDEX `author-id` (`author-id`),
1027 INDEX `causer-id` (`causer-id`),
1028 INDEX `vid` (`vid`),
1029 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1030 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1031 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1032 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1033 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1034 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1035 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1036 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1037 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
1040 -- TABLE post-category
1042 CREATE TABLE IF NOT EXISTS `post-category` (
1043 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1044 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1045 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1046 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1047 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1048 INDEX `uri-id` (`tid`),
1049 INDEX `uid` (`uid`),
1050 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1051 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1052 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1053 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1056 -- TABLE post-content
1058 CREATE TABLE IF NOT EXISTS `post-content` (
1059 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1060 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1061 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1062 `body` mediumtext COMMENT 'item body content',
1063 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1064 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1065 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1066 `language` text COMMENT 'Language information about this post',
1067 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1068 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1069 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1070 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1071 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1072 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1073 `target` text COMMENT 'JSON encoded target structure if used',
1074 `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',
1075 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1076 PRIMARY KEY(`uri-id`),
1077 INDEX `plink` (`plink`(191)),
1078 INDEX `resource-id` (`resource-id`),
1079 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
1080 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1081 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1084 -- TABLE post-delivery-data
1086 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1087 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1088 `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',
1089 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1090 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1091 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1092 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1093 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1094 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1095 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1096 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1097 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1098 PRIMARY KEY(`uri-id`),
1099 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1100 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1105 CREATE TABLE IF NOT EXISTS `post-link` (
1106 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1107 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1108 `url` varbinary(511) NOT NULL COMMENT 'External URL',
1109 `mimetype` varchar(60) COMMENT '',
1111 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1112 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1113 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post related external links';
1118 CREATE TABLE IF NOT EXISTS `post-media` (
1119 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1120 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1121 `url` varbinary(511) NOT NULL COMMENT 'Media URL',
1122 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1123 `mimetype` varchar(60) COMMENT '',
1124 `height` smallint unsigned COMMENT 'Height of the media',
1125 `width` smallint unsigned COMMENT 'Width of the media',
1126 `size` int unsigned COMMENT 'Media size',
1127 `preview` varbinary(255) COMMENT 'Preview URL',
1128 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1129 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1130 `description` text COMMENT '',
1131 `name` varchar(255) COMMENT 'Name of the media',
1132 `author-url` varbinary(255) COMMENT 'URL of the author of the media',
1133 `author-name` varchar(255) COMMENT 'Name of the author of the media',
1134 `author-image` varbinary(255) COMMENT 'Image of the author of the media',
1135 `publisher-url` varbinary(255) COMMENT 'URL of the publisher of the media',
1136 `publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
1137 `publisher-image` varbinary(255) COMMENT 'Image of the publisher of the media',
1139 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1140 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1141 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1146 CREATE TABLE IF NOT EXISTS `post-tag` (
1147 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1148 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1149 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1150 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1151 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1152 INDEX `tid` (`tid`),
1153 INDEX `cid` (`cid`),
1154 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1155 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1156 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1157 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1160 -- TABLE post-thread
1162 CREATE TABLE IF NOT EXISTS `post-thread` (
1163 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1164 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1165 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1166 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1167 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1168 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1169 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1170 `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',
1171 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1172 PRIMARY KEY(`uri-id`),
1173 INDEX `owner-id` (`owner-id`),
1174 INDEX `author-id` (`author-id`),
1175 INDEX `causer-id` (`causer-id`),
1176 INDEX `received` (`received`),
1177 INDEX `commented` (`commented`),
1178 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1179 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1180 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1181 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1182 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1187 CREATE TABLE IF NOT EXISTS `post-user` (
1188 `id` int unsigned NOT NULL auto_increment,
1189 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1190 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1191 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1192 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1193 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1194 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1195 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1196 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1197 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1198 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1199 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1200 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1201 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1202 `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
1203 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1204 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1205 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1206 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1207 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1208 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1209 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1210 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1211 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1212 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1213 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1214 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1215 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1216 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1217 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1219 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1220 INDEX `uri-id` (`uri-id`),
1221 INDEX `parent-uri-id` (`parent-uri-id`),
1222 INDEX `thr-parent-id` (`thr-parent-id`),
1223 INDEX `external-id` (`external-id`),
1224 INDEX `owner-id` (`owner-id`),
1225 INDEX `author-id` (`author-id`),
1226 INDEX `causer-id` (`causer-id`),
1227 INDEX `vid` (`vid`),
1228 INDEX `contact-id` (`contact-id`),
1229 INDEX `event-id` (`event-id`),
1230 INDEX `psid` (`psid`),
1231 INDEX `author-id_uid` (`author-id`,`uid`),
1232 INDEX `author-id_received` (`author-id`,`received`),
1233 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1234 INDEX `uid_contactid` (`uid`,`contact-id`),
1235 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1236 INDEX `uid_unseen` (`uid`,`unseen`),
1237 INDEX `uid_hidden_uri-id` (`uid`,`hidden`,`uri-id`),
1238 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1239 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1240 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1241 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1242 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1243 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1244 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1245 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1246 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1247 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1248 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1249 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1250 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1253 -- TABLE post-thread-user
1255 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1256 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1257 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1258 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1259 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1260 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1261 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1262 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1263 `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',
1264 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1265 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1266 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'The thread is pinned on the profile page',
1267 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1268 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1269 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1270 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1271 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1272 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1273 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1274 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1275 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1276 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1277 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1278 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1279 PRIMARY KEY(`uid`,`uri-id`),
1280 INDEX `uri-id` (`uri-id`),
1281 INDEX `owner-id` (`owner-id`),
1282 INDEX `author-id` (`author-id`),
1283 INDEX `causer-id` (`causer-id`),
1284 INDEX `uid` (`uid`),
1285 INDEX `contact-id` (`contact-id`),
1286 INDEX `psid` (`psid`),
1287 INDEX `post-user-id` (`post-user-id`),
1288 INDEX `commented` (`commented`),
1289 INDEX `uid_received` (`uid`,`received`),
1290 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1291 INDEX `uid_pinned` (`uid`,`pinned`),
1292 INDEX `uid_commented` (`uid`,`commented`),
1293 INDEX `uid_starred` (`uid`,`starred`),
1294 INDEX `uid_mention` (`uid`,`mention`),
1295 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1296 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1297 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1298 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1299 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1300 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1301 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1302 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1303 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1306 -- TABLE post-user-notification
1308 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1309 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1310 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1311 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1312 PRIMARY KEY(`uid`,`uri-id`),
1313 INDEX `uri-id` (`uri-id`),
1314 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1315 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1316 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1321 CREATE TABLE IF NOT EXISTS `process` (
1322 `pid` int unsigned NOT NULL COMMENT 'The ID of the process',
1323 `hostname` varchar(32) NOT NULL COMMENT 'The name of the host the process is ran on',
1324 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1325 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1326 PRIMARY KEY(`pid`,`hostname`),
1327 INDEX `command` (`command`)
1328 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1333 CREATE TABLE IF NOT EXISTS `profile` (
1334 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1335 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1336 `profile-name` varchar(255) COMMENT 'Deprecated',
1337 `is-default` boolean COMMENT 'Deprecated',
1338 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1339 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1340 `pdesc` varchar(255) COMMENT 'Deprecated',
1341 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1342 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1343 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1344 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1345 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1346 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1347 `hometown` varchar(255) COMMENT 'Deprecated',
1348 `gender` varchar(32) COMMENT 'Deprecated',
1349 `marital` varchar(255) COMMENT 'Deprecated',
1350 `with` text COMMENT 'Deprecated',
1351 `howlong` datetime COMMENT 'Deprecated',
1352 `sexual` varchar(255) COMMENT 'Deprecated',
1353 `politic` varchar(255) COMMENT 'Deprecated',
1354 `religion` varchar(255) COMMENT 'Deprecated',
1355 `pub_keywords` text COMMENT '',
1356 `prv_keywords` text COMMENT '',
1357 `likes` text COMMENT 'Deprecated',
1358 `dislikes` text COMMENT 'Deprecated',
1359 `about` text COMMENT 'Profile description',
1360 `summary` varchar(255) COMMENT 'Deprecated',
1361 `music` text COMMENT 'Deprecated',
1362 `book` text COMMENT 'Deprecated',
1363 `tv` text COMMENT 'Deprecated',
1364 `film` text COMMENT 'Deprecated',
1365 `interest` text COMMENT 'Deprecated',
1366 `romance` text COMMENT 'Deprecated',
1367 `work` text COMMENT 'Deprecated',
1368 `education` text COMMENT 'Deprecated',
1369 `contact` text COMMENT 'Deprecated',
1370 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1371 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
1372 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
1373 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1374 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1375 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1376 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1378 INDEX `uid_is-default` (`uid`,`is-default`),
1379 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1380 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1381 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1384 -- TABLE profile_field
1386 CREATE TABLE IF NOT EXISTS `profile_field` (
1387 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1388 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1389 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1390 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1391 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1392 `value` text COMMENT 'Value of the field',
1393 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1394 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1396 INDEX `uid` (`uid`),
1397 INDEX `order` (`order`),
1398 INDEX `psid` (`psid`),
1399 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1400 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1401 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1404 -- TABLE push_subscriber
1406 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1407 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1408 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1409 `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1410 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1411 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1412 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1413 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1414 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1415 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1416 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1418 INDEX `next_try` (`next_try`),
1419 INDEX `uid` (`uid`),
1420 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1421 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1426 CREATE TABLE IF NOT EXISTS `register` (
1427 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1428 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1429 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1430 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1431 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1432 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1433 `note` text COMMENT '',
1435 INDEX `uid` (`uid`),
1436 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1437 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1442 CREATE TABLE IF NOT EXISTS `search` (
1443 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1444 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1445 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1447 INDEX `uid_term` (`uid`,`term`(64)),
1448 INDEX `term` (`term`(64)),
1449 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1450 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1455 CREATE TABLE IF NOT EXISTS `session` (
1456 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1457 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1458 `data` text COMMENT '',
1459 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1461 INDEX `sid` (`sid`(64)),
1462 INDEX `expire` (`expire`)
1463 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1468 CREATE TABLE IF NOT EXISTS `storage` (
1469 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1470 `data` longblob NOT NULL COMMENT 'file data',
1472 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1475 -- TABLE subscription
1477 CREATE TABLE IF NOT EXISTS `subscription` (
1478 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1479 `application-id` int unsigned NOT NULL COMMENT '',
1480 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
1481 `endpoint` varchar(511) COMMENT 'Endpoint URL',
1482 `pubkey` varchar(127) COMMENT 'User agent public key',
1483 `secret` varchar(32) COMMENT 'Auth secret',
1484 `follow` boolean COMMENT '',
1485 `favourite` boolean COMMENT '',
1486 `reblog` boolean COMMENT '',
1487 `mention` boolean COMMENT '',
1488 `poll` boolean COMMENT '',
1489 `follow_request` boolean COMMENT '',
1490 `status` boolean COMMENT '',
1492 UNIQUE INDEX `application-id_uid` (`application-id`,`uid`),
1493 INDEX `uid_application-id` (`uid`,`application-id`),
1494 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1495 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1496 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Push Subscription for the API';
1501 CREATE TABLE IF NOT EXISTS `userd` (
1502 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1503 `username` varchar(255) NOT NULL COMMENT '',
1505 INDEX `username` (`username`(32))
1506 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1509 -- TABLE user-contact
1511 CREATE TABLE IF NOT EXISTS `user-contact` (
1512 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1513 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1514 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
1515 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1516 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1517 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1518 `hidden` boolean COMMENT 'This contact is hidden from the others',
1519 `pending` boolean COMMENT '',
1520 `rel` tinyint unsigned COMMENT 'The kind of the relation between the user and the contact',
1521 `info` mediumtext COMMENT '',
1522 `notify_new_posts` boolean COMMENT '',
1523 `remote_self` boolean COMMENT '',
1524 `fetch_further_information` tinyint unsigned COMMENT '',
1525 `ffi_keyword_denylist` text COMMENT '',
1526 `subhub` boolean COMMENT '',
1527 `hub-verify` varchar(255) COMMENT '',
1528 `protocol` char(4) COMMENT 'Protocol of the contact',
1529 `rating` tinyint COMMENT 'Automatically detected feed poll frequency',
1530 `priority` tinyint unsigned COMMENT 'Feed poll priority',
1531 PRIMARY KEY(`uid`,`cid`),
1532 INDEX `cid` (`cid`),
1533 UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
1534 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1535 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1536 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1537 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1542 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1543 `key` int NOT NULL COMMENT '',
1544 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1546 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1549 -- VIEW application-view
1551 DROP VIEW IF EXISTS `application-view`;
1552 CREATE VIEW `application-view` AS SELECT
1553 `application`.`id` AS `id`,
1554 `application-token`.`uid` AS `uid`,
1555 `application`.`name` AS `name`,
1556 `application`.`redirect_uri` AS `redirect_uri`,
1557 `application`.`website` AS `website`,
1558 `application`.`client_id` AS `client_id`,
1559 `application`.`client_secret` AS `client_secret`,
1560 `application-token`.`code` AS `code`,
1561 `application-token`.`access_token` AS `access_token`,
1562 `application-token`.`created_at` AS `created_at`,
1563 `application-token`.`scopes` AS `scopes`,
1564 `application-token`.`read` AS `read`,
1565 `application-token`.`write` AS `write`,
1566 `application-token`.`follow` AS `follow`,
1567 `application-token`.`push` AS `push`
1568 FROM `application-token`
1569 INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`;
1572 -- VIEW post-user-view
1574 DROP VIEW IF EXISTS `post-user-view`;
1575 CREATE VIEW `post-user-view` AS SELECT
1576 `post-user`.`id` AS `id`,
1577 `post-user`.`id` AS `post-user-id`,
1578 `post-user`.`uid` AS `uid`,
1579 `parent-post`.`id` AS `parent`,
1580 `item-uri`.`uri` AS `uri`,
1581 `post-user`.`uri-id` AS `uri-id`,
1582 `parent-item-uri`.`uri` AS `parent-uri`,
1583 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1584 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1585 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1586 `item-uri`.`guid` AS `guid`,
1587 `post-user`.`wall` AS `wall`,
1588 `post-user`.`gravity` AS `gravity`,
1589 `external-item-uri`.`uri` AS `extid`,
1590 `post-user`.`external-id` AS `external-id`,
1591 `post-user`.`created` AS `created`,
1592 `post-user`.`edited` AS `edited`,
1593 `post-thread-user`.`commented` AS `commented`,
1594 `post-user`.`received` AS `received`,
1595 `post-thread-user`.`changed` AS `changed`,
1596 `post-user`.`post-type` AS `post-type`,
1597 `post-user`.`post-reason` AS `post-reason`,
1598 `post-user`.`private` AS `private`,
1599 `post-thread-user`.`pubmail` AS `pubmail`,
1600 `post-user`.`visible` AS `visible`,
1601 `post-thread-user`.`starred` AS `starred`,
1602 `post-thread-user`.`pinned` AS `pinned`,
1603 `post-user`.`unseen` AS `unseen`,
1604 `post-user`.`deleted` AS `deleted`,
1605 `post-user`.`origin` AS `origin`,
1606 `post-thread-user`.`origin` AS `parent-origin`,
1607 `post-thread-user`.`forum_mode` AS `forum_mode`,
1608 `post-thread-user`.`mention` AS `mention`,
1609 `post-user`.`global` AS `global`,
1610 `post-user`.`network` AS `network`,
1611 `post-user`.`vid` AS `vid`,
1612 `post-user`.`psid` AS `psid`,
1613 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1614 `post-content`.`title` AS `title`,
1615 `post-content`.`content-warning` AS `content-warning`,
1616 `post-content`.`raw-body` AS `raw-body`,
1617 `post-content`.`body` AS `body`,
1618 `post-content`.`rendered-hash` AS `rendered-hash`,
1619 `post-content`.`rendered-html` AS `rendered-html`,
1620 `post-content`.`language` AS `language`,
1621 `post-content`.`plink` AS `plink`,
1622 `post-content`.`location` AS `location`,
1623 `post-content`.`coord` AS `coord`,
1624 `post-content`.`app` AS `app`,
1625 `post-content`.`object-type` AS `object-type`,
1626 `post-content`.`object` AS `object`,
1627 `post-content`.`target-type` AS `target-type`,
1628 `post-content`.`target` AS `target`,
1629 `post-content`.`resource-id` AS `resource-id`,
1630 `post-user`.`contact-id` AS `contact-id`,
1631 `contact`.`url` AS `contact-link`,
1632 `contact`.`addr` AS `contact-addr`,
1633 `contact`.`name` AS `contact-name`,
1634 `contact`.`nick` AS `contact-nick`,
1635 `contact`.`thumb` AS `contact-avatar`,
1636 `contact`.`network` AS `contact-network`,
1637 `contact`.`blocked` AS `contact-blocked`,
1638 `contact`.`hidden` AS `contact-hidden`,
1639 `contact`.`readonly` AS `contact-readonly`,
1640 `contact`.`archive` AS `contact-archive`,
1641 `contact`.`pending` AS `contact-pending`,
1642 `contact`.`rel` AS `contact-rel`,
1643 `contact`.`uid` AS `contact-uid`,
1644 `contact`.`contact-type` AS `contact-contact-type`,
1645 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1646 `contact`.`self` AS `self`,
1647 `contact`.`id` AS `cid`,
1648 `contact`.`alias` AS `alias`,
1649 `contact`.`photo` AS `photo`,
1650 `contact`.`name-date` AS `name-date`,
1651 `contact`.`uri-date` AS `uri-date`,
1652 `contact`.`avatar-date` AS `avatar-date`,
1653 `contact`.`thumb` AS `thumb`,
1654 `post-user`.`author-id` AS `author-id`,
1655 `author`.`url` AS `author-link`,
1656 `author`.`addr` AS `author-addr`,
1657 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1658 `author`.`nick` AS `author-nick`,
1659 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1660 `author`.`network` AS `author-network`,
1661 `author`.`blocked` AS `author-blocked`,
1662 `author`.`hidden` AS `author-hidden`,
1663 `post-user`.`owner-id` AS `owner-id`,
1664 `owner`.`url` AS `owner-link`,
1665 `owner`.`addr` AS `owner-addr`,
1666 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1667 `owner`.`nick` AS `owner-nick`,
1668 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1669 `owner`.`network` AS `owner-network`,
1670 `owner`.`blocked` AS `owner-blocked`,
1671 `owner`.`hidden` AS `owner-hidden`,
1672 `owner`.`contact-type` AS `owner-contact-type`,
1673 `post-user`.`causer-id` AS `causer-id`,
1674 `causer`.`url` AS `causer-link`,
1675 `causer`.`addr` AS `causer-addr`,
1676 `causer`.`name` AS `causer-name`,
1677 `causer`.`nick` AS `causer-nick`,
1678 `causer`.`thumb` AS `causer-avatar`,
1679 `causer`.`network` AS `causer-network`,
1680 `causer`.`blocked` AS `causer-blocked`,
1681 `causer`.`hidden` AS `causer-hidden`,
1682 `causer`.`contact-type` AS `causer-contact-type`,
1683 `post-delivery-data`.`postopts` AS `postopts`,
1684 `post-delivery-data`.`inform` AS `inform`,
1685 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1686 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1687 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1688 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1689 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1690 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1691 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1692 `post-user`.`event-id` AS `event-id`,
1693 `event`.`created` AS `event-created`,
1694 `event`.`edited` AS `event-edited`,
1695 `event`.`start` AS `event-start`,
1696 `event`.`finish` AS `event-finish`,
1697 `event`.`summary` AS `event-summary`,
1698 `event`.`desc` AS `event-desc`,
1699 `event`.`location` AS `event-location`,
1700 `event`.`type` AS `event-type`,
1701 `event`.`nofinish` AS `event-nofinish`,
1702 `event`.`ignore` AS `event-ignore`,
1703 `diaspora-interaction`.`interaction` AS `signed_text`,
1704 `parent-item-uri`.`guid` AS `parent-guid`,
1705 `parent-post`.`network` AS `parent-network`,
1706 `parent-post`.`author-id` AS `parent-author-id`,
1707 `parent-post-author`.`url` AS `parent-author-link`,
1708 `parent-post-author`.`name` AS `parent-author-name`,
1709 `parent-post-author`.`nick` AS `parent-author-nick`,
1710 `parent-post-author`.`network` AS `parent-author-network`,
1711 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1712 `parent-post-author`.`hidden` AS `parent-author-hidden`
1714 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
1715 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
1716 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
1717 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
1718 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
1719 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
1720 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1721 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1722 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1723 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1724 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1725 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
1726 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
1727 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
1728 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
1729 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
1730 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1733 -- VIEW post-thread-user-view
1735 DROP VIEW IF EXISTS `post-thread-user-view`;
1736 CREATE VIEW `post-thread-user-view` AS SELECT
1737 `post-user`.`id` AS `id`,
1738 `post-user`.`id` AS `post-user-id`,
1739 `post-thread-user`.`uid` AS `uid`,
1740 `parent-post`.`id` AS `parent`,
1741 `item-uri`.`uri` AS `uri`,
1742 `post-thread-user`.`uri-id` AS `uri-id`,
1743 `parent-item-uri`.`uri` AS `parent-uri`,
1744 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1745 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1746 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1747 `item-uri`.`guid` AS `guid`,
1748 `post-thread-user`.`wall` AS `wall`,
1749 `post-user`.`gravity` AS `gravity`,
1750 `external-item-uri`.`uri` AS `extid`,
1751 `post-user`.`external-id` AS `external-id`,
1752 `post-thread-user`.`created` AS `created`,
1753 `post-user`.`edited` AS `edited`,
1754 `post-thread-user`.`commented` AS `commented`,
1755 `post-thread-user`.`received` AS `received`,
1756 `post-thread-user`.`changed` AS `changed`,
1757 `post-user`.`post-type` AS `post-type`,
1758 `post-user`.`post-reason` AS `post-reason`,
1759 `post-user`.`private` AS `private`,
1760 `post-thread-user`.`pubmail` AS `pubmail`,
1761 `post-thread-user`.`ignored` AS `ignored`,
1762 `post-user`.`visible` AS `visible`,
1763 `post-thread-user`.`starred` AS `starred`,
1764 `post-thread-user`.`pinned` AS `pinned`,
1765 `post-thread-user`.`unseen` AS `unseen`,
1766 `post-user`.`deleted` AS `deleted`,
1767 `post-thread-user`.`origin` AS `origin`,
1768 `post-thread-user`.`forum_mode` AS `forum_mode`,
1769 `post-thread-user`.`mention` AS `mention`,
1770 `post-user`.`global` AS `global`,
1771 `post-thread-user`.`network` AS `network`,
1772 `post-user`.`vid` AS `vid`,
1773 `post-thread-user`.`psid` AS `psid`,
1774 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1775 `post-content`.`title` AS `title`,
1776 `post-content`.`content-warning` AS `content-warning`,
1777 `post-content`.`raw-body` AS `raw-body`,
1778 `post-content`.`body` AS `body`,
1779 `post-content`.`rendered-hash` AS `rendered-hash`,
1780 `post-content`.`rendered-html` AS `rendered-html`,
1781 `post-content`.`language` AS `language`,
1782 `post-content`.`plink` AS `plink`,
1783 `post-content`.`location` AS `location`,
1784 `post-content`.`coord` AS `coord`,
1785 `post-content`.`app` AS `app`,
1786 `post-content`.`object-type` AS `object-type`,
1787 `post-content`.`object` AS `object`,
1788 `post-content`.`target-type` AS `target-type`,
1789 `post-content`.`target` AS `target`,
1790 `post-content`.`resource-id` AS `resource-id`,
1791 `post-thread-user`.`contact-id` AS `contact-id`,
1792 `contact`.`url` AS `contact-link`,
1793 `contact`.`addr` AS `contact-addr`,
1794 `contact`.`name` AS `contact-name`,
1795 `contact`.`nick` AS `contact-nick`,
1796 `contact`.`thumb` AS `contact-avatar`,
1797 `contact`.`network` AS `contact-network`,
1798 `contact`.`blocked` AS `contact-blocked`,
1799 `contact`.`hidden` AS `contact-hidden`,
1800 `contact`.`readonly` AS `contact-readonly`,
1801 `contact`.`archive` AS `contact-archive`,
1802 `contact`.`pending` AS `contact-pending`,
1803 `contact`.`rel` AS `contact-rel`,
1804 `contact`.`uid` AS `contact-uid`,
1805 `contact`.`contact-type` AS `contact-contact-type`,
1806 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1807 `contact`.`self` AS `self`,
1808 `contact`.`id` AS `cid`,
1809 `contact`.`alias` AS `alias`,
1810 `contact`.`photo` AS `photo`,
1811 `contact`.`name-date` AS `name-date`,
1812 `contact`.`uri-date` AS `uri-date`,
1813 `contact`.`avatar-date` AS `avatar-date`,
1814 `contact`.`thumb` AS `thumb`,
1815 `post-thread-user`.`author-id` AS `author-id`,
1816 `author`.`url` AS `author-link`,
1817 `author`.`addr` AS `author-addr`,
1818 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1819 `author`.`nick` AS `author-nick`,
1820 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1821 `author`.`network` AS `author-network`,
1822 `author`.`blocked` AS `author-blocked`,
1823 `author`.`hidden` AS `author-hidden`,
1824 `post-thread-user`.`owner-id` AS `owner-id`,
1825 `owner`.`url` AS `owner-link`,
1826 `owner`.`addr` AS `owner-addr`,
1827 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1828 `owner`.`nick` AS `owner-nick`,
1829 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1830 `owner`.`network` AS `owner-network`,
1831 `owner`.`blocked` AS `owner-blocked`,
1832 `owner`.`hidden` AS `owner-hidden`,
1833 `owner`.`contact-type` AS `owner-contact-type`,
1834 `post-thread-user`.`causer-id` AS `causer-id`,
1835 `causer`.`url` AS `causer-link`,
1836 `causer`.`addr` AS `causer-addr`,
1837 `causer`.`name` AS `causer-name`,
1838 `causer`.`nick` AS `causer-nick`,
1839 `causer`.`thumb` AS `causer-avatar`,
1840 `causer`.`network` AS `causer-network`,
1841 `causer`.`blocked` AS `causer-blocked`,
1842 `causer`.`hidden` AS `causer-hidden`,
1843 `causer`.`contact-type` AS `causer-contact-type`,
1844 `post-delivery-data`.`postopts` AS `postopts`,
1845 `post-delivery-data`.`inform` AS `inform`,
1846 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1847 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1848 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1849 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1850 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1851 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1852 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1853 `post-user`.`event-id` AS `event-id`,
1854 `event`.`created` AS `event-created`,
1855 `event`.`edited` AS `event-edited`,
1856 `event`.`start` AS `event-start`,
1857 `event`.`finish` AS `event-finish`,
1858 `event`.`summary` AS `event-summary`,
1859 `event`.`desc` AS `event-desc`,
1860 `event`.`location` AS `event-location`,
1861 `event`.`type` AS `event-type`,
1862 `event`.`nofinish` AS `event-nofinish`,
1863 `event`.`ignore` AS `event-ignore`,
1864 `diaspora-interaction`.`interaction` AS `signed_text`,
1865 `parent-item-uri`.`guid` AS `parent-guid`,
1866 `parent-post`.`network` AS `parent-network`,
1867 `parent-post`.`author-id` AS `parent-author-id`,
1868 `parent-post-author`.`url` AS `parent-author-link`,
1869 `parent-post-author`.`name` AS `parent-author-name`,
1870 `parent-post-author`.`network` AS `parent-author-network`,
1871 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1872 `parent-post-author`.`hidden` AS `parent-author-hidden`
1873 FROM `post-thread-user`
1874 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
1875 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
1876 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
1877 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
1878 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
1879 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
1880 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1881 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1882 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1883 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1884 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1885 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
1886 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
1887 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
1888 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
1889 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`
1890 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1895 DROP VIEW IF EXISTS `post-view`;
1896 CREATE VIEW `post-view` AS SELECT
1897 `item-uri`.`uri` AS `uri`,
1898 `post`.`uri-id` AS `uri-id`,
1899 `parent-item-uri`.`uri` AS `parent-uri`,
1900 `post`.`parent-uri-id` AS `parent-uri-id`,
1901 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1902 `post`.`thr-parent-id` AS `thr-parent-id`,
1903 `item-uri`.`guid` AS `guid`,
1904 `post`.`gravity` AS `gravity`,
1905 `external-item-uri`.`uri` AS `extid`,
1906 `post`.`external-id` AS `external-id`,
1907 `post`.`created` AS `created`,
1908 `post`.`edited` AS `edited`,
1909 `post-thread`.`commented` AS `commented`,
1910 `post`.`received` AS `received`,
1911 `post-thread`.`changed` AS `changed`,
1912 `post`.`post-type` AS `post-type`,
1913 `post`.`private` AS `private`,
1914 `post`.`visible` AS `visible`,
1915 `post`.`deleted` AS `deleted`,
1916 `post`.`global` AS `global`,
1917 `post`.`network` AS `network`,
1918 `post`.`vid` AS `vid`,
1919 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1920 `post-content`.`title` AS `title`,
1921 `post-content`.`content-warning` AS `content-warning`,
1922 `post-content`.`raw-body` AS `raw-body`,
1923 `post-content`.`body` AS `body`,
1924 `post-content`.`rendered-hash` AS `rendered-hash`,
1925 `post-content`.`rendered-html` AS `rendered-html`,
1926 `post-content`.`language` AS `language`,
1927 `post-content`.`plink` AS `plink`,
1928 `post-content`.`location` AS `location`,
1929 `post-content`.`coord` AS `coord`,
1930 `post-content`.`app` AS `app`,
1931 `post-content`.`object-type` AS `object-type`,
1932 `post-content`.`object` AS `object`,
1933 `post-content`.`target-type` AS `target-type`,
1934 `post-content`.`target` AS `target`,
1935 `post-content`.`resource-id` AS `resource-id`,
1936 `post`.`author-id` AS `contact-id`,
1937 `author`.`url` AS `contact-link`,
1938 `author`.`addr` AS `contact-addr`,
1939 `author`.`name` AS `contact-name`,
1940 `author`.`nick` AS `contact-nick`,
1941 `author`.`thumb` AS `contact-avatar`,
1942 `author`.`network` AS `contact-network`,
1943 `author`.`blocked` AS `contact-blocked`,
1944 `author`.`hidden` AS `contact-hidden`,
1945 `author`.`readonly` AS `contact-readonly`,
1946 `author`.`archive` AS `contact-archive`,
1947 `author`.`pending` AS `contact-pending`,
1948 `author`.`rel` AS `contact-rel`,
1949 `author`.`uid` AS `contact-uid`,
1950 `author`.`contact-type` AS `contact-contact-type`,
1951 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
1953 `author`.`id` AS `cid`,
1954 `author`.`alias` AS `alias`,
1955 `author`.`photo` AS `photo`,
1956 `author`.`name-date` AS `name-date`,
1957 `author`.`uri-date` AS `uri-date`,
1958 `author`.`avatar-date` AS `avatar-date`,
1959 `author`.`thumb` AS `thumb`,
1960 `post`.`author-id` AS `author-id`,
1961 `author`.`url` AS `author-link`,
1962 `author`.`addr` AS `author-addr`,
1963 `author`.`name` AS `author-name`,
1964 `author`.`nick` AS `author-nick`,
1965 `author`.`thumb` AS `author-avatar`,
1966 `author`.`network` AS `author-network`,
1967 `author`.`blocked` AS `author-blocked`,
1968 `author`.`hidden` AS `author-hidden`,
1969 `post`.`owner-id` AS `owner-id`,
1970 `owner`.`url` AS `owner-link`,
1971 `owner`.`addr` AS `owner-addr`,
1972 `owner`.`name` AS `owner-name`,
1973 `owner`.`nick` AS `owner-nick`,
1974 `owner`.`thumb` AS `owner-avatar`,
1975 `owner`.`network` AS `owner-network`,
1976 `owner`.`blocked` AS `owner-blocked`,
1977 `owner`.`hidden` AS `owner-hidden`,
1978 `owner`.`contact-type` AS `owner-contact-type`,
1979 `post`.`causer-id` AS `causer-id`,
1980 `causer`.`url` AS `causer-link`,
1981 `causer`.`addr` AS `causer-addr`,
1982 `causer`.`name` AS `causer-name`,
1983 `causer`.`nick` AS `causer-nick`,
1984 `causer`.`thumb` AS `causer-avatar`,
1985 `causer`.`network` AS `causer-network`,
1986 `causer`.`blocked` AS `causer-blocked`,
1987 `causer`.`hidden` AS `causer-hidden`,
1988 `causer`.`contact-type` AS `causer-contact-type`,
1989 `diaspora-interaction`.`interaction` AS `signed_text`,
1990 `parent-item-uri`.`guid` AS `parent-guid`,
1991 `parent-post`.`network` AS `parent-network`,
1992 `parent-post`.`author-id` AS `parent-author-id`,
1993 `parent-post-author`.`url` AS `parent-author-link`,
1994 `parent-post-author`.`name` AS `parent-author-name`,
1995 `parent-post-author`.`network` AS `parent-author-network`,
1996 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1997 `parent-post-author`.`hidden` AS `parent-author-hidden`
1999 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
2000 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
2001 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
2002 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
2003 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
2004 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2005 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2006 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2007 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2008 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
2009 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
2010 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2011 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2014 -- VIEW post-thread-view
2016 DROP VIEW IF EXISTS `post-thread-view`;
2017 CREATE VIEW `post-thread-view` AS SELECT
2018 `item-uri`.`uri` AS `uri`,
2019 `post-thread`.`uri-id` AS `uri-id`,
2020 `parent-item-uri`.`uri` AS `parent-uri`,
2021 `post`.`parent-uri-id` AS `parent-uri-id`,
2022 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2023 `post`.`thr-parent-id` AS `thr-parent-id`,
2024 `item-uri`.`guid` AS `guid`,
2025 `post`.`gravity` AS `gravity`,
2026 `external-item-uri`.`uri` AS `extid`,
2027 `post`.`external-id` AS `external-id`,
2028 `post-thread`.`created` AS `created`,
2029 `post`.`edited` AS `edited`,
2030 `post-thread`.`commented` AS `commented`,
2031 `post-thread`.`received` AS `received`,
2032 `post-thread`.`changed` AS `changed`,
2033 `post`.`post-type` AS `post-type`,
2034 `post`.`private` AS `private`,
2035 `post`.`visible` AS `visible`,
2036 `post`.`deleted` AS `deleted`,
2037 `post`.`global` AS `global`,
2038 `post-thread`.`network` AS `network`,
2039 `post`.`vid` AS `vid`,
2040 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2041 `post-content`.`title` AS `title`,
2042 `post-content`.`content-warning` AS `content-warning`,
2043 `post-content`.`raw-body` AS `raw-body`,
2044 `post-content`.`body` AS `body`,
2045 `post-content`.`rendered-hash` AS `rendered-hash`,
2046 `post-content`.`rendered-html` AS `rendered-html`,
2047 `post-content`.`language` AS `language`,
2048 `post-content`.`plink` AS `plink`,
2049 `post-content`.`location` AS `location`,
2050 `post-content`.`coord` AS `coord`,
2051 `post-content`.`app` AS `app`,
2052 `post-content`.`object-type` AS `object-type`,
2053 `post-content`.`object` AS `object`,
2054 `post-content`.`target-type` AS `target-type`,
2055 `post-content`.`target` AS `target`,
2056 `post-content`.`resource-id` AS `resource-id`,
2057 `post-thread`.`author-id` AS `contact-id`,
2058 `author`.`url` AS `contact-link`,
2059 `author`.`addr` AS `contact-addr`,
2060 `author`.`name` AS `contact-name`,
2061 `author`.`nick` AS `contact-nick`,
2062 `author`.`thumb` AS `contact-avatar`,
2063 `author`.`network` AS `contact-network`,
2064 `author`.`blocked` AS `contact-blocked`,
2065 `author`.`hidden` AS `contact-hidden`,
2066 `author`.`readonly` AS `contact-readonly`,
2067 `author`.`archive` AS `contact-archive`,
2068 `author`.`pending` AS `contact-pending`,
2069 `author`.`rel` AS `contact-rel`,
2070 `author`.`uid` AS `contact-uid`,
2071 `author`.`contact-type` AS `contact-contact-type`,
2072 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2074 `author`.`id` AS `cid`,
2075 `author`.`alias` AS `alias`,
2076 `author`.`photo` AS `photo`,
2077 `author`.`name-date` AS `name-date`,
2078 `author`.`uri-date` AS `uri-date`,
2079 `author`.`avatar-date` AS `avatar-date`,
2080 `author`.`thumb` AS `thumb`,
2081 `post-thread`.`author-id` AS `author-id`,
2082 `author`.`url` AS `author-link`,
2083 `author`.`addr` AS `author-addr`,
2084 `author`.`name` AS `author-name`,
2085 `author`.`nick` AS `author-nick`,
2086 `author`.`thumb` AS `author-avatar`,
2087 `author`.`network` AS `author-network`,
2088 `author`.`blocked` AS `author-blocked`,
2089 `author`.`hidden` AS `author-hidden`,
2090 `post-thread`.`owner-id` AS `owner-id`,
2091 `owner`.`url` AS `owner-link`,
2092 `owner`.`addr` AS `owner-addr`,
2093 `owner`.`name` AS `owner-name`,
2094 `owner`.`nick` AS `owner-nick`,
2095 `owner`.`thumb` AS `owner-avatar`,
2096 `owner`.`network` AS `owner-network`,
2097 `owner`.`blocked` AS `owner-blocked`,
2098 `owner`.`hidden` AS `owner-hidden`,
2099 `owner`.`contact-type` AS `owner-contact-type`,
2100 `post-thread`.`causer-id` AS `causer-id`,
2101 `causer`.`url` AS `causer-link`,
2102 `causer`.`addr` AS `causer-addr`,
2103 `causer`.`name` AS `causer-name`,
2104 `causer`.`nick` AS `causer-nick`,
2105 `causer`.`thumb` AS `causer-avatar`,
2106 `causer`.`network` AS `causer-network`,
2107 `causer`.`blocked` AS `causer-blocked`,
2108 `causer`.`hidden` AS `causer-hidden`,
2109 `causer`.`contact-type` AS `causer-contact-type`,
2110 `diaspora-interaction`.`interaction` AS `signed_text`,
2111 `parent-item-uri`.`guid` AS `parent-guid`,
2112 `parent-post`.`network` AS `parent-network`,
2113 `parent-post`.`author-id` AS `parent-author-id`,
2114 `parent-post-author`.`url` AS `parent-author-link`,
2115 `parent-post-author`.`name` AS `parent-author-name`,
2116 `parent-post-author`.`network` AS `parent-author-network`,
2117 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2118 `parent-post-author`.`hidden` AS `parent-author-hidden`
2120 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
2121 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
2122 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
2123 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
2124 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
2125 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2126 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2127 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2128 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2129 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
2130 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
2131 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2132 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2135 -- VIEW category-view
2137 DROP VIEW IF EXISTS `category-view`;
2138 CREATE VIEW `category-view` AS SELECT
2139 `post-category`.`uri-id` AS `uri-id`,
2140 `post-category`.`uid` AS `uid`,
2141 `post-category`.`type` AS `type`,
2142 `post-category`.`tid` AS `tid`,
2143 `tag`.`name` AS `name`,
2144 `tag`.`url` AS `url`
2145 FROM `post-category`
2146 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2151 DROP VIEW IF EXISTS `tag-view`;
2152 CREATE VIEW `tag-view` AS SELECT
2153 `post-tag`.`uri-id` AS `uri-id`,
2154 `post-tag`.`type` AS `type`,
2155 `post-tag`.`tid` AS `tid`,
2156 `post-tag`.`cid` AS `cid`,
2157 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2158 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
2160 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2161 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2164 -- VIEW network-item-view
2166 DROP VIEW IF EXISTS `network-item-view`;
2167 CREATE VIEW `network-item-view` AS SELECT
2168 `post-user`.`uri-id` AS `uri-id`,
2169 `parent-post`.`id` AS `parent`,
2170 `post-user`.`received` AS `received`,
2171 `post-thread-user`.`commented` AS `commented`,
2172 `post-user`.`created` AS `created`,
2173 `post-user`.`uid` AS `uid`,
2174 `post-thread-user`.`starred` AS `starred`,
2175 `post-thread-user`.`mention` AS `mention`,
2176 `post-user`.`network` AS `network`,
2177 `post-user`.`unseen` AS `unseen`,
2178 `post-user`.`gravity` AS `gravity`,
2179 `post-user`.`contact-id` AS `contact-id`,
2180 `ownercontact`.`contact-type` AS `contact-type`
2182 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2183 INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2184 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2185 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2186 INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2187 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2188 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2189 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2190 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
2191 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2192 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2195 -- VIEW network-thread-view
2197 DROP VIEW IF EXISTS `network-thread-view`;
2198 CREATE VIEW `network-thread-view` AS SELECT
2199 `post-thread-user`.`uri-id` AS `uri-id`,
2200 `parent-post`.`id` AS `parent`,
2201 `post-thread-user`.`received` AS `received`,
2202 `post-thread-user`.`commented` AS `commented`,
2203 `post-thread-user`.`created` AS `created`,
2204 `post-thread-user`.`uid` AS `uid`,
2205 `post-thread-user`.`starred` AS `starred`,
2206 `post-thread-user`.`mention` AS `mention`,
2207 `post-thread-user`.`network` AS `network`,
2208 `post-thread-user`.`contact-id` AS `contact-id`,
2209 `ownercontact`.`contact-type` AS `contact-type`
2210 FROM `post-thread-user`
2211 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2212 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2213 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2214 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2215 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2216 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2217 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2218 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2219 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2220 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2221 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2226 DROP VIEW IF EXISTS `owner-view`;
2227 CREATE VIEW `owner-view` AS SELECT
2228 `contact`.`id` AS `id`,
2229 `contact`.`uid` AS `uid`,
2230 `contact`.`created` AS `created`,
2231 `contact`.`updated` AS `updated`,
2232 `contact`.`self` AS `self`,
2233 `contact`.`remote_self` AS `remote_self`,
2234 `contact`.`rel` AS `rel`,
2235 `contact`.`network` AS `network`,
2236 `contact`.`protocol` AS `protocol`,
2237 `contact`.`name` AS `name`,
2238 `contact`.`nick` AS `nick`,
2239 `contact`.`location` AS `location`,
2240 `contact`.`about` AS `about`,
2241 `contact`.`keywords` AS `keywords`,
2242 `contact`.`xmpp` AS `xmpp`,
2243 `contact`.`matrix` AS `matrix`,
2244 `contact`.`attag` AS `attag`,
2245 `contact`.`avatar` AS `avatar`,
2246 `contact`.`photo` AS `photo`,
2247 `contact`.`thumb` AS `thumb`,
2248 `contact`.`micro` AS `micro`,
2249 `contact`.`header` AS `header`,
2250 `contact`.`url` AS `url`,
2251 `contact`.`nurl` AS `nurl`,
2252 `contact`.`uri-id` AS `uri-id`,
2253 `contact`.`addr` AS `addr`,
2254 `contact`.`alias` AS `alias`,
2255 `contact`.`pubkey` AS `pubkey`,
2256 `contact`.`prvkey` AS `prvkey`,
2257 `contact`.`batch` AS `batch`,
2258 `contact`.`request` AS `request`,
2259 `contact`.`notify` AS `notify`,
2260 `contact`.`poll` AS `poll`,
2261 `contact`.`confirm` AS `confirm`,
2262 `contact`.`poco` AS `poco`,
2263 `contact`.`subhub` AS `subhub`,
2264 `contact`.`hub-verify` AS `hub-verify`,
2265 `contact`.`last-update` AS `last-update`,
2266 `contact`.`success_update` AS `success_update`,
2267 `contact`.`failure_update` AS `failure_update`,
2268 `contact`.`name-date` AS `name-date`,
2269 `contact`.`uri-date` AS `uri-date`,
2270 `contact`.`avatar-date` AS `avatar-date`,
2271 `contact`.`avatar-date` AS `picdate`,
2272 `contact`.`term-date` AS `term-date`,
2273 `contact`.`last-item` AS `last-item`,
2274 `contact`.`priority` AS `priority`,
2275 `user`.`blocked` AS `blocked`,
2276 `contact`.`block_reason` AS `block_reason`,
2277 `contact`.`readonly` AS `readonly`,
2278 `contact`.`writable` AS `writable`,
2279 `contact`.`forum` AS `forum`,
2280 `contact`.`prv` AS `prv`,
2281 `contact`.`contact-type` AS `contact-type`,
2282 `contact`.`manually-approve` AS `manually-approve`,
2283 `contact`.`hidden` AS `hidden`,
2284 `contact`.`archive` AS `archive`,
2285 `contact`.`pending` AS `pending`,
2286 `contact`.`deleted` AS `deleted`,
2287 `contact`.`unsearchable` AS `unsearchable`,
2288 `contact`.`sensitive` AS `sensitive`,
2289 `contact`.`baseurl` AS `baseurl`,
2290 `contact`.`reason` AS `reason`,
2291 `contact`.`info` AS `info`,
2292 `contact`.`bdyear` AS `bdyear`,
2293 `contact`.`bd` AS `bd`,
2294 `contact`.`notify_new_posts` AS `notify_new_posts`,
2295 `contact`.`fetch_further_information` AS `fetch_further_information`,
2296 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2297 `user`.`parent-uid` AS `parent-uid`,
2298 `user`.`guid` AS `guid`,
2299 `user`.`nickname` AS `nickname`,
2300 `user`.`email` AS `email`,
2301 `user`.`openid` AS `openid`,
2302 `user`.`timezone` AS `timezone`,
2303 `user`.`language` AS `language`,
2304 `user`.`register_date` AS `register_date`,
2305 `user`.`login_date` AS `login_date`,
2306 `user`.`default-location` AS `default-location`,
2307 `user`.`allow_location` AS `allow_location`,
2308 `user`.`theme` AS `theme`,
2309 `user`.`pubkey` AS `upubkey`,
2310 `user`.`prvkey` AS `uprvkey`,
2311 `user`.`sprvkey` AS `sprvkey`,
2312 `user`.`spubkey` AS `spubkey`,
2313 `user`.`verified` AS `verified`,
2314 `user`.`blockwall` AS `blockwall`,
2315 `user`.`hidewall` AS `hidewall`,
2316 `user`.`blocktags` AS `blocktags`,
2317 `user`.`unkmail` AS `unkmail`,
2318 `user`.`cntunkmail` AS `cntunkmail`,
2319 `user`.`notify-flags` AS `notify-flags`,
2320 `user`.`page-flags` AS `page-flags`,
2321 `user`.`account-type` AS `account-type`,
2322 `user`.`prvnets` AS `prvnets`,
2323 `user`.`maxreq` AS `maxreq`,
2324 `user`.`expire` AS `expire`,
2325 `user`.`account_removed` AS `account_removed`,
2326 `user`.`account_expired` AS `account_expired`,
2327 `user`.`account_expires_on` AS `account_expires_on`,
2328 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2329 `user`.`def_gid` AS `def_gid`,
2330 `user`.`allow_cid` AS `allow_cid`,
2331 `user`.`allow_gid` AS `allow_gid`,
2332 `user`.`deny_cid` AS `deny_cid`,
2333 `user`.`deny_gid` AS `deny_gid`,
2334 `user`.`openidserver` AS `openidserver`,
2335 `profile`.`publish` AS `publish`,
2336 `profile`.`net-publish` AS `net-publish`,
2337 `profile`.`hide-friends` AS `hide-friends`,
2338 `profile`.`prv_keywords` AS `prv_keywords`,
2339 `profile`.`pub_keywords` AS `pub_keywords`,
2340 `profile`.`address` AS `address`,
2341 `profile`.`locality` AS `locality`,
2342 `profile`.`region` AS `region`,
2343 `profile`.`postal-code` AS `postal-code`,
2344 `profile`.`country-name` AS `country-name`,
2345 `profile`.`homepage` AS `homepage`,
2346 `profile`.`dob` AS `dob`
2348 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2349 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2352 -- VIEW account-view
2354 DROP VIEW IF EXISTS `account-view`;
2355 CREATE VIEW `account-view` AS SELECT
2356 `contact`.`id` AS `id`,
2357 `contact`.`url` AS `url`,
2358 `contact`.`nurl` AS `nurl`,
2359 `contact`.`uri-id` AS `uri-id`,
2360 `item-uri`.`guid` AS `guid`,
2361 `contact`.`addr` AS `addr`,
2362 `contact`.`alias` AS `alias`,
2363 `contact`.`name` AS `name`,
2364 `contact`.`nick` AS `nick`,
2365 `contact`.`about` AS `about`,
2366 `contact`.`keywords` AS `keywords`,
2367 `contact`.`xmpp` AS `xmpp`,
2368 `contact`.`matrix` AS `matrix`,
2369 `contact`.`avatar` AS `avatar`,
2370 `contact`.`photo` AS `photo`,
2371 `contact`.`thumb` AS `thumb`,
2372 `contact`.`micro` AS `micro`,
2373 `contact`.`header` AS `header`,
2374 `contact`.`created` AS `created`,
2375 `contact`.`updated` AS `updated`,
2376 `contact`.`network` AS `network`,
2377 `contact`.`protocol` AS `protocol`,
2378 `contact`.`location` AS `location`,
2379 `contact`.`attag` AS `attag`,
2380 `contact`.`pubkey` AS `pubkey`,
2381 `contact`.`prvkey` AS `prvkey`,
2382 `contact`.`subscribe` AS `subscribe`,
2383 `contact`.`last-update` AS `last-update`,
2384 `contact`.`success_update` AS `success_update`,
2385 `contact`.`failure_update` AS `failure_update`,
2386 `contact`.`failed` AS `failed`,
2387 `contact`.`last-item` AS `last-item`,
2388 `contact`.`last-discovery` AS `last-discovery`,
2389 `contact`.`contact-type` AS `contact-type`,
2390 `contact`.`manually-approve` AS `manually-approve`,
2391 `contact`.`unsearchable` AS `unsearchable`,
2392 `contact`.`sensitive` AS `sensitive`,
2393 `contact`.`baseurl` AS `baseurl`,
2394 `contact`.`gsid` AS `gsid`,
2395 `contact`.`info` AS `info`,
2396 `contact`.`bdyear` AS `bdyear`,
2397 `contact`.`bd` AS `bd`,
2398 `contact`.`poco` AS `poco`,
2399 `contact`.`name-date` AS `name-date`,
2400 `contact`.`uri-date` AS `uri-date`,
2401 `contact`.`avatar-date` AS `avatar-date`,
2402 `contact`.`term-date` AS `term-date`,
2403 `contact`.`hidden` AS `global-ignored`,
2404 `contact`.`blocked` AS `global-blocked`,
2405 `contact`.`hidden` AS `hidden`,
2406 `contact`.`archive` AS `archive`,
2407 `contact`.`deleted` AS `deleted`,
2408 `contact`.`blocked` AS `blocked`,
2409 `contact`.`request` AS `dfrn-request`,
2410 `contact`.`notify` AS `dfrn-notify`,
2411 `contact`.`poll` AS `dfrn-poll`,
2412 `contact`.`confirm` AS `dfrn-confirm`,
2413 `fcontact`.`guid` AS `diaspora-guid`,
2414 `fcontact`.`batch` AS `diaspora-batch`,
2415 `fcontact`.`notify` AS `diaspora-notify`,
2416 `fcontact`.`poll` AS `diaspora-poll`,
2417 `fcontact`.`alias` AS `diaspora-alias`,
2418 `apcontact`.`uuid` AS `ap-uuid`,
2419 `apcontact`.`type` AS `ap-type`,
2420 `apcontact`.`following` AS `ap-following`,
2421 `apcontact`.`followers` AS `ap-followers`,
2422 `apcontact`.`inbox` AS `ap-inbox`,
2423 `apcontact`.`outbox` AS `ap-outbox`,
2424 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2425 `apcontact`.`generator` AS `ap-generator`,
2426 `apcontact`.`following_count` AS `ap-following_count`,
2427 `apcontact`.`followers_count` AS `ap-followers_count`,
2428 `apcontact`.`statuses_count` AS `ap-statuses_count`
2430 LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id`
2431 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
2432 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = contact.`uri-id`
2433 WHERE `contact`.`uid` = 0;
2436 -- VIEW account-user-view
2438 DROP VIEW IF EXISTS `account-user-view`;
2439 CREATE VIEW `account-user-view` AS SELECT
2440 `ucontact`.`id` AS `id`,
2441 `contact`.`id` AS `pid`,
2442 `ucontact`.`uid` AS `uid`,
2443 `contact`.`url` AS `url`,
2444 `contact`.`nurl` AS `nurl`,
2445 `contact`.`uri-id` AS `uri-id`,
2446 `item-uri`.`guid` AS `guid`,
2447 `contact`.`addr` AS `addr`,
2448 `contact`.`alias` AS `alias`,
2449 `contact`.`name` AS `name`,
2450 `contact`.`nick` AS `nick`,
2451 `contact`.`about` AS `about`,
2452 `contact`.`keywords` AS `keywords`,
2453 `contact`.`xmpp` AS `xmpp`,
2454 `contact`.`matrix` AS `matrix`,
2455 `contact`.`avatar` AS `avatar`,
2456 `contact`.`photo` AS `photo`,
2457 `contact`.`thumb` AS `thumb`,
2458 `contact`.`micro` AS `micro`,
2459 `contact`.`header` AS `header`,
2460 `contact`.`created` AS `created`,
2461 `contact`.`updated` AS `updated`,
2462 `ucontact`.`self` AS `self`,
2463 `ucontact`.`remote_self` AS `remote_self`,
2464 `ucontact`.`rel` AS `rel`,
2465 `contact`.`network` AS `network`,
2466 `ucontact`.`protocol` AS `protocol`,
2467 `contact`.`location` AS `location`,
2468 `ucontact`.`attag` AS `attag`,
2469 `contact`.`pubkey` AS `pubkey`,
2470 `contact`.`prvkey` AS `prvkey`,
2471 `contact`.`subscribe` AS `subscribe`,
2472 `contact`.`last-update` AS `last-update`,
2473 `contact`.`success_update` AS `success_update`,
2474 `contact`.`failure_update` AS `failure_update`,
2475 `contact`.`failed` AS `failed`,
2476 `contact`.`last-item` AS `last-item`,
2477 `contact`.`last-discovery` AS `last-discovery`,
2478 `contact`.`contact-type` AS `contact-type`,
2479 `contact`.`manually-approve` AS `manually-approve`,
2480 `contact`.`unsearchable` AS `unsearchable`,
2481 `contact`.`sensitive` AS `sensitive`,
2482 `contact`.`baseurl` AS `baseurl`,
2483 `contact`.`gsid` AS `gsid`,
2484 `ucontact`.`info` AS `info`,
2485 `contact`.`bdyear` AS `bdyear`,
2486 `contact`.`bd` AS `bd`,
2487 `contact`.`poco` AS `poco`,
2488 `contact`.`name-date` AS `name-date`,
2489 `contact`.`uri-date` AS `uri-date`,
2490 `contact`.`avatar-date` AS `avatar-date`,
2491 `contact`.`term-date` AS `term-date`,
2492 `contact`.`hidden` AS `global-ignored`,
2493 `contact`.`blocked` AS `global-blocked`,
2494 `ucontact`.`hidden` AS `hidden`,
2495 `ucontact`.`archive` AS `archive`,
2496 `ucontact`.`pending` AS `pending`,
2497 `ucontact`.`deleted` AS `deleted`,
2498 `ucontact`.`notify_new_posts` AS `notify_new_posts`,
2499 `ucontact`.`fetch_further_information` AS `fetch_further_information`,
2500 `ucontact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2501 `ucontact`.`rating` AS `rating`,
2502 `ucontact`.`readonly` AS `readonly`,
2503 `ucontact`.`blocked` AS `blocked`,
2504 `ucontact`.`block_reason` AS `block_reason`,
2505 `ucontact`.`subhub` AS `subhub`,
2506 `ucontact`.`hub-verify` AS `hub-verify`,
2507 `ucontact`.`reason` AS `reason`,
2508 `contact`.`request` AS `dfrn-request`,
2509 `contact`.`notify` AS `dfrn-notify`,
2510 `contact`.`poll` AS `dfrn-poll`,
2511 `contact`.`confirm` AS `dfrn-confirm`,
2512 `fcontact`.`guid` AS `diaspora-guid`,
2513 `fcontact`.`batch` AS `diaspora-batch`,
2514 `fcontact`.`notify` AS `diaspora-notify`,
2515 `fcontact`.`poll` AS `diaspora-poll`,
2516 `fcontact`.`alias` AS `diaspora-alias`,
2517 `apcontact`.`uuid` AS `ap-uuid`,
2518 `apcontact`.`type` AS `ap-type`,
2519 `apcontact`.`following` AS `ap-following`,
2520 `apcontact`.`followers` AS `ap-followers`,
2521 `apcontact`.`inbox` AS `ap-inbox`,
2522 `apcontact`.`outbox` AS `ap-outbox`,
2523 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2524 `apcontact`.`generator` AS `ap-generator`,
2525 `apcontact`.`following_count` AS `ap-following_count`,
2526 `apcontact`.`followers_count` AS `ap-followers_count`,
2527 `apcontact`.`statuses_count` AS `ap-statuses_count`
2528 FROM `contact` AS `ucontact`
2529 INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
2530 LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id`
2531 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
2532 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = `ucontact`.`uri-id` AND `fcontact`.`network` = 'dspr';
2535 -- VIEW pending-view
2537 DROP VIEW IF EXISTS `pending-view`;
2538 CREATE VIEW `pending-view` AS SELECT
2539 `register`.`id` AS `id`,
2540 `register`.`hash` AS `hash`,
2541 `register`.`created` AS `created`,
2542 `register`.`uid` AS `uid`,
2543 `register`.`password` AS `password`,
2544 `register`.`language` AS `language`,
2545 `register`.`note` AS `note`,
2546 `contact`.`self` AS `self`,
2547 `contact`.`name` AS `name`,
2548 `contact`.`url` AS `url`,
2549 `contact`.`micro` AS `micro`,
2550 `user`.`email` AS `email`,
2551 `contact`.`nick` AS `nick`
2553 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2554 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2557 -- VIEW tag-search-view
2559 DROP VIEW IF EXISTS `tag-search-view`;
2560 CREATE VIEW `tag-search-view` AS SELECT
2561 `post-tag`.`uri-id` AS `uri-id`,
2562 `post-user`.`uid` AS `uid`,
2563 `post-user`.`id` AS `iid`,
2564 `post-user`.`private` AS `private`,
2565 `post-user`.`wall` AS `wall`,
2566 `post-user`.`origin` AS `origin`,
2567 `post-user`.`global` AS `global`,
2568 `post-user`.`gravity` AS `gravity`,
2569 `post-user`.`received` AS `received`,
2570 `post-user`.`network` AS `network`,
2571 `post-user`.`author-id` AS `author-id`,
2572 `tag`.`name` AS `name`
2574 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
2575 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
2576 WHERE `post-tag`.`type` = 1;
2579 -- VIEW workerqueue-view
2581 DROP VIEW IF EXISTS `workerqueue-view`;
2582 CREATE VIEW `workerqueue-view` AS SELECT
2583 `process`.`pid` AS `pid`,
2584 `workerqueue`.`priority` AS `priority`
2586 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
2587 WHERE NOT `workerqueue`.`done`;
2590 -- VIEW profile_field-view
2592 DROP VIEW IF EXISTS `profile_field-view`;
2593 CREATE VIEW `profile_field-view` AS SELECT
2594 `profile_field`.`id` AS `id`,
2595 `profile_field`.`uid` AS `uid`,
2596 `profile_field`.`label` AS `label`,
2597 `profile_field`.`value` AS `value`,
2598 `profile_field`.`order` AS `order`,
2599 `profile_field`.`psid` AS `psid`,
2600 `permissionset`.`allow_cid` AS `allow_cid`,
2601 `permissionset`.`allow_gid` AS `allow_gid`,
2602 `permissionset`.`deny_cid` AS `deny_cid`,
2603 `permissionset`.`deny_gid` AS `deny_gid`,
2604 `profile_field`.`created` AS `created`,
2605 `profile_field`.`edited` AS `edited`
2606 FROM `profile_field`
2607 INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`;