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