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