1 -- ------------------------------------------
2 -- Friendica 2021.12-rc (Siberian Iris)
3 -- DB_UPDATE_VERSION 1446
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 '',
829 UNIQUE INDEX `uid_vid_type_actor-id_target-uri-id` (`uid`,`vid`,`type`,`actor-id`,`target-uri-id`),
831 INDEX `actor-id` (`actor-id`),
832 INDEX `target-uri-id` (`target-uri-id`),
833 INDEX `parent-uri-id` (`parent-uri-id`),
834 INDEX `seen_uid` (`seen`,`uid`),
835 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
836 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
837 FOREIGN KEY (`actor-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
838 FOREIGN KEY (`target-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
839 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
840 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
845 CREATE TABLE IF NOT EXISTS `notify` (
846 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
847 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
848 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
849 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
850 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
851 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
852 `msg` mediumtext COMMENT '',
853 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
854 `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
855 `iid` int unsigned COMMENT '',
856 `parent` int unsigned COMMENT '',
857 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
858 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
859 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
860 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
861 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
862 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
863 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
865 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
866 INDEX `uid_date` (`uid`,`date`),
867 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
868 INDEX `uri-id` (`uri-id`),
869 INDEX `parent-uri-id` (`parent-uri-id`),
870 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
871 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
872 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
873 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
876 -- TABLE notify-threads
878 CREATE TABLE IF NOT EXISTS `notify-threads` (
879 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
880 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
881 `master-parent-item` int unsigned COMMENT 'Deprecated',
882 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
883 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
884 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
886 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
887 INDEX `receiver-uid` (`receiver-uid`),
888 INDEX `notify-id` (`notify-id`),
889 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
890 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
891 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
892 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
897 CREATE TABLE IF NOT EXISTS `oembed` (
898 `url` varbinary(255) NOT NULL COMMENT 'page url',
899 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
900 `content` mediumtext COMMENT 'OEmbed data of the page',
901 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
902 PRIMARY KEY(`url`,`maxwidth`),
903 INDEX `created` (`created`)
904 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
907 -- TABLE openwebauth-token
909 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
910 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
911 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
912 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
913 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
914 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
915 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
918 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
919 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
924 CREATE TABLE IF NOT EXISTS `parsed_url` (
925 `url_hash` binary(64) NOT NULL COMMENT 'page url hash',
926 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
927 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
928 `url` text NOT NULL COMMENT 'page url',
929 `content` mediumtext COMMENT 'page data',
930 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
931 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration',
932 PRIMARY KEY(`url_hash`,`guessing`,`oembed`),
933 INDEX `created` (`created`),
934 INDEX `expires` (`expires`)
935 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
940 CREATE TABLE IF NOT EXISTS `pconfig` (
941 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
942 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
943 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
944 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
945 `v` mediumtext COMMENT 'Value',
947 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
948 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
949 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
954 CREATE TABLE IF NOT EXISTS `photo` (
955 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
956 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
957 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
958 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
959 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
960 `hash` char(32) COMMENT 'hash value of the photo',
961 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
962 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
963 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
964 `desc` text COMMENT '',
965 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
966 `photo-type` tinyint unsigned COMMENT 'User avatar, user banner, contact avatar, contact banner or default',
967 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
968 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
969 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
970 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
971 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
972 `data` mediumblob NOT NULL COMMENT '',
973 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
974 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
975 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
976 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
977 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
978 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
979 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
980 `backend-class` tinytext COMMENT 'Storage backend class',
981 `backend-ref` text COMMENT 'Storage backend data reference',
982 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
984 INDEX `contactid` (`contact-id`),
985 INDEX `uid_contactid` (`uid`,`contact-id`),
986 INDEX `uid_profile` (`uid`,`profile`),
987 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
988 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
989 INDEX `resource-id` (`resource-id`),
990 INDEX `uid_photo-type` (`uid`,`photo-type`),
991 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
992 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
993 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
998 CREATE TABLE IF NOT EXISTS `post` (
999 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1000 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1001 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1002 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1003 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1004 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1005 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1006 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1007 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1008 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1009 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1010 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1011 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1012 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1013 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1014 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1015 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1016 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1017 PRIMARY KEY(`uri-id`),
1018 INDEX `parent-uri-id` (`parent-uri-id`),
1019 INDEX `thr-parent-id` (`thr-parent-id`),
1020 INDEX `external-id` (`external-id`),
1021 INDEX `owner-id` (`owner-id`),
1022 INDEX `author-id` (`author-id`),
1023 INDEX `causer-id` (`causer-id`),
1024 INDEX `vid` (`vid`),
1025 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1026 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1027 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1028 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1029 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1030 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1031 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1032 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1033 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
1036 -- TABLE post-category
1038 CREATE TABLE IF NOT EXISTS `post-category` (
1039 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1040 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1041 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1042 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1043 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1044 INDEX `uri-id` (`tid`),
1045 INDEX `uid` (`uid`),
1046 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1047 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1048 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1049 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1052 -- TABLE post-content
1054 CREATE TABLE IF NOT EXISTS `post-content` (
1055 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1056 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1057 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1058 `body` mediumtext COMMENT 'item body content',
1059 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1060 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1061 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1062 `language` text COMMENT 'Language information about this post',
1063 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1064 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1065 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1066 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1067 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1068 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1069 `target` text COMMENT 'JSON encoded target structure if used',
1070 `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',
1071 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1072 PRIMARY KEY(`uri-id`),
1073 INDEX `plink` (`plink`(191)),
1074 INDEX `resource-id` (`resource-id`),
1075 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
1076 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1077 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1080 -- TABLE post-delivery-data
1082 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1083 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1084 `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',
1085 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1086 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1087 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1088 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1089 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1090 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1091 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1092 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1093 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1094 PRIMARY KEY(`uri-id`),
1095 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1096 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1101 CREATE TABLE IF NOT EXISTS `post-link` (
1102 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1103 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1104 `url` varbinary(511) NOT NULL COMMENT 'External URL',
1105 `mimetype` varchar(60) COMMENT '',
1107 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1108 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1109 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post related external links';
1114 CREATE TABLE IF NOT EXISTS `post-media` (
1115 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1116 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1117 `url` varbinary(511) NOT NULL COMMENT 'Media URL',
1118 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1119 `mimetype` varchar(60) COMMENT '',
1120 `height` smallint unsigned COMMENT 'Height of the media',
1121 `width` smallint unsigned COMMENT 'Width of the media',
1122 `size` int unsigned COMMENT 'Media size',
1123 `preview` varbinary(255) COMMENT 'Preview URL',
1124 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1125 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1126 `description` text COMMENT '',
1127 `name` varchar(255) COMMENT 'Name of the media',
1128 `author-url` varbinary(255) COMMENT 'URL of the author of the media',
1129 `author-name` varchar(255) COMMENT 'Name of the author of the media',
1130 `author-image` varbinary(255) COMMENT 'Image of the author of the media',
1131 `publisher-url` varbinary(255) COMMENT 'URL of the publisher of the media',
1132 `publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
1133 `publisher-image` varbinary(255) COMMENT 'Image of the publisher of the media',
1135 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1136 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1137 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1142 CREATE TABLE IF NOT EXISTS `post-tag` (
1143 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1144 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1145 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1146 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1147 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1148 INDEX `tid` (`tid`),
1149 INDEX `cid` (`cid`),
1150 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1151 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1152 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1153 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1156 -- TABLE post-thread
1158 CREATE TABLE IF NOT EXISTS `post-thread` (
1159 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1160 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1161 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1162 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1163 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1164 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1165 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1166 `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',
1167 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1168 PRIMARY KEY(`uri-id`),
1169 INDEX `owner-id` (`owner-id`),
1170 INDEX `author-id` (`author-id`),
1171 INDEX `causer-id` (`causer-id`),
1172 INDEX `received` (`received`),
1173 INDEX `commented` (`commented`),
1174 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1175 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1176 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1177 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1178 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1183 CREATE TABLE IF NOT EXISTS `post-user` (
1184 `id` int unsigned NOT NULL auto_increment,
1185 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1186 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1187 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1188 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1189 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1190 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1191 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1192 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1193 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1194 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1195 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1196 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1197 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1198 `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
1199 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1200 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1201 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1202 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1203 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1204 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1205 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1206 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1207 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1208 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1209 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1210 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1211 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1212 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1213 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1215 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1216 INDEX `uri-id` (`uri-id`),
1217 INDEX `parent-uri-id` (`parent-uri-id`),
1218 INDEX `thr-parent-id` (`thr-parent-id`),
1219 INDEX `external-id` (`external-id`),
1220 INDEX `owner-id` (`owner-id`),
1221 INDEX `author-id` (`author-id`),
1222 INDEX `causer-id` (`causer-id`),
1223 INDEX `vid` (`vid`),
1224 INDEX `contact-id` (`contact-id`),
1225 INDEX `event-id` (`event-id`),
1226 INDEX `psid` (`psid`),
1227 INDEX `author-id_uid` (`author-id`,`uid`),
1228 INDEX `author-id_received` (`author-id`,`received`),
1229 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1230 INDEX `uid_contactid` (`uid`,`contact-id`),
1231 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1232 INDEX `uid_unseen` (`uid`,`unseen`),
1233 INDEX `uid_hidden_uri-id` (`uid`,`hidden`,`uri-id`),
1234 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1235 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1236 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1237 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1238 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1239 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1240 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1241 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1242 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1243 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1244 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1245 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1246 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1249 -- TABLE post-thread-user
1251 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1252 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1253 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1254 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1255 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1256 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1257 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1258 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1259 `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',
1260 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1261 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1262 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'The thread is pinned on the profile page',
1263 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1264 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1265 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1266 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1267 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1268 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1269 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1270 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1271 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1272 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1273 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1274 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1275 PRIMARY KEY(`uid`,`uri-id`),
1276 INDEX `uri-id` (`uri-id`),
1277 INDEX `owner-id` (`owner-id`),
1278 INDEX `author-id` (`author-id`),
1279 INDEX `causer-id` (`causer-id`),
1280 INDEX `uid` (`uid`),
1281 INDEX `contact-id` (`contact-id`),
1282 INDEX `psid` (`psid`),
1283 INDEX `post-user-id` (`post-user-id`),
1284 INDEX `commented` (`commented`),
1285 INDEX `uid_received` (`uid`,`received`),
1286 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1287 INDEX `uid_pinned` (`uid`,`pinned`),
1288 INDEX `uid_commented` (`uid`,`commented`),
1289 INDEX `uid_starred` (`uid`,`starred`),
1290 INDEX `uid_mention` (`uid`,`mention`),
1291 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1292 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1293 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1294 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1295 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1296 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1297 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1298 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1299 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1302 -- TABLE post-user-notification
1304 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1305 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1306 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1307 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1308 PRIMARY KEY(`uid`,`uri-id`),
1309 INDEX `uri-id` (`uri-id`),
1310 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1311 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1312 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1317 CREATE TABLE IF NOT EXISTS `process` (
1318 `pid` int unsigned NOT NULL COMMENT 'The ID of the process',
1319 `hostname` varchar(32) NOT NULL COMMENT 'The name of the host the process is ran on',
1320 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1321 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1322 PRIMARY KEY(`pid`,`hostname`),
1323 INDEX `command` (`command`)
1324 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1329 CREATE TABLE IF NOT EXISTS `profile` (
1330 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1331 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1332 `profile-name` varchar(255) COMMENT 'Deprecated',
1333 `is-default` boolean COMMENT 'Deprecated',
1334 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1335 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1336 `pdesc` varchar(255) COMMENT 'Deprecated',
1337 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1338 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1339 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1340 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1341 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1342 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1343 `hometown` varchar(255) COMMENT 'Deprecated',
1344 `gender` varchar(32) COMMENT 'Deprecated',
1345 `marital` varchar(255) COMMENT 'Deprecated',
1346 `with` text COMMENT 'Deprecated',
1347 `howlong` datetime COMMENT 'Deprecated',
1348 `sexual` varchar(255) COMMENT 'Deprecated',
1349 `politic` varchar(255) COMMENT 'Deprecated',
1350 `religion` varchar(255) COMMENT 'Deprecated',
1351 `pub_keywords` text COMMENT '',
1352 `prv_keywords` text COMMENT '',
1353 `likes` text COMMENT 'Deprecated',
1354 `dislikes` text COMMENT 'Deprecated',
1355 `about` text COMMENT 'Profile description',
1356 `summary` varchar(255) COMMENT 'Deprecated',
1357 `music` text COMMENT 'Deprecated',
1358 `book` text COMMENT 'Deprecated',
1359 `tv` text COMMENT 'Deprecated',
1360 `film` text COMMENT 'Deprecated',
1361 `interest` text COMMENT 'Deprecated',
1362 `romance` text COMMENT 'Deprecated',
1363 `work` text COMMENT 'Deprecated',
1364 `education` text COMMENT 'Deprecated',
1365 `contact` text COMMENT 'Deprecated',
1366 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1367 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
1368 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
1369 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1370 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1371 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1372 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1374 INDEX `uid_is-default` (`uid`,`is-default`),
1375 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1376 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1377 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1380 -- TABLE profile_field
1382 CREATE TABLE IF NOT EXISTS `profile_field` (
1383 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1384 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1385 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1386 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1387 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1388 `value` text COMMENT 'Value of the field',
1389 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1390 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1392 INDEX `uid` (`uid`),
1393 INDEX `order` (`order`),
1394 INDEX `psid` (`psid`),
1395 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1396 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1397 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1400 -- TABLE push_subscriber
1402 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1403 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1404 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1405 `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1406 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1407 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1408 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1409 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1410 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1411 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1412 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1414 INDEX `next_try` (`next_try`),
1415 INDEX `uid` (`uid`),
1416 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1417 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1422 CREATE TABLE IF NOT EXISTS `register` (
1423 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1424 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1425 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1426 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1427 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1428 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1429 `note` text COMMENT '',
1431 INDEX `uid` (`uid`),
1432 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1433 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1438 CREATE TABLE IF NOT EXISTS `search` (
1439 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1440 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1441 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1443 INDEX `uid_term` (`uid`,`term`(64)),
1444 INDEX `term` (`term`(64)),
1445 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1446 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1451 CREATE TABLE IF NOT EXISTS `session` (
1452 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1453 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1454 `data` text COMMENT '',
1455 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1457 INDEX `sid` (`sid`(64)),
1458 INDEX `expire` (`expire`)
1459 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1464 CREATE TABLE IF NOT EXISTS `storage` (
1465 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1466 `data` longblob NOT NULL COMMENT 'file data',
1468 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1471 -- TABLE subscription
1473 CREATE TABLE IF NOT EXISTS `subscription` (
1474 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1475 `application-id` int unsigned NOT NULL COMMENT '',
1476 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
1477 `endpoint` varchar(511) COMMENT 'Endpoint URL',
1478 `pubkey` varchar(127) COMMENT 'User agent public key',
1479 `secret` varchar(32) COMMENT 'Auth secret',
1480 `follow` boolean COMMENT '',
1481 `favourite` boolean COMMENT '',
1482 `reblog` boolean COMMENT '',
1483 `mention` boolean COMMENT '',
1484 `poll` boolean COMMENT '',
1485 `follow_request` boolean COMMENT '',
1486 `status` boolean COMMENT '',
1488 UNIQUE INDEX `application-id_uid` (`application-id`,`uid`),
1489 INDEX `uid_application-id` (`uid`,`application-id`),
1490 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1491 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1492 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Push Subscription for the API';
1497 CREATE TABLE IF NOT EXISTS `userd` (
1498 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1499 `username` varchar(255) NOT NULL COMMENT '',
1501 INDEX `username` (`username`(32))
1502 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1505 -- TABLE user-contact
1507 CREATE TABLE IF NOT EXISTS `user-contact` (
1508 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1509 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1510 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
1511 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1512 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1513 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1514 `hidden` boolean COMMENT 'This contact is hidden from the others',
1515 `pending` boolean COMMENT '',
1516 `rel` tinyint unsigned COMMENT 'The kind of the relation between the user and the contact',
1517 `info` mediumtext COMMENT '',
1518 `notify_new_posts` boolean COMMENT '',
1519 `remote_self` boolean COMMENT '',
1520 `fetch_further_information` tinyint unsigned COMMENT '',
1521 `ffi_keyword_denylist` text COMMENT '',
1522 `subhub` boolean COMMENT '',
1523 `hub-verify` varchar(255) COMMENT '',
1524 `protocol` char(4) COMMENT 'Protocol of the contact',
1525 `rating` tinyint COMMENT 'Automatically detected feed poll frequency',
1526 `priority` tinyint unsigned COMMENT 'Feed poll priority',
1527 PRIMARY KEY(`uid`,`cid`),
1528 INDEX `cid` (`cid`),
1529 UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
1530 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1531 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1532 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1533 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1538 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1539 `key` int NOT NULL COMMENT '',
1540 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1542 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1545 -- VIEW application-view
1547 DROP VIEW IF EXISTS `application-view`;
1548 CREATE VIEW `application-view` AS SELECT
1549 `application`.`id` AS `id`,
1550 `application-token`.`uid` AS `uid`,
1551 `application`.`name` AS `name`,
1552 `application`.`redirect_uri` AS `redirect_uri`,
1553 `application`.`website` AS `website`,
1554 `application`.`client_id` AS `client_id`,
1555 `application`.`client_secret` AS `client_secret`,
1556 `application-token`.`code` AS `code`,
1557 `application-token`.`access_token` AS `access_token`,
1558 `application-token`.`created_at` AS `created_at`,
1559 `application-token`.`scopes` AS `scopes`,
1560 `application-token`.`read` AS `read`,
1561 `application-token`.`write` AS `write`,
1562 `application-token`.`follow` AS `follow`,
1563 `application-token`.`push` AS `push`
1564 FROM `application-token`
1565 INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`;
1568 -- VIEW post-user-view
1570 DROP VIEW IF EXISTS `post-user-view`;
1571 CREATE VIEW `post-user-view` AS SELECT
1572 `post-user`.`id` AS `id`,
1573 `post-user`.`id` AS `post-user-id`,
1574 `post-user`.`uid` AS `uid`,
1575 `parent-post`.`id` AS `parent`,
1576 `item-uri`.`uri` AS `uri`,
1577 `post-user`.`uri-id` AS `uri-id`,
1578 `parent-item-uri`.`uri` AS `parent-uri`,
1579 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1580 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1581 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1582 `item-uri`.`guid` AS `guid`,
1583 `post-user`.`wall` AS `wall`,
1584 `post-user`.`gravity` AS `gravity`,
1585 `external-item-uri`.`uri` AS `extid`,
1586 `post-user`.`external-id` AS `external-id`,
1587 `post-user`.`created` AS `created`,
1588 `post-user`.`edited` AS `edited`,
1589 `post-thread-user`.`commented` AS `commented`,
1590 `post-user`.`received` AS `received`,
1591 `post-thread-user`.`changed` AS `changed`,
1592 `post-user`.`post-type` AS `post-type`,
1593 `post-user`.`post-reason` AS `post-reason`,
1594 `post-user`.`private` AS `private`,
1595 `post-thread-user`.`pubmail` AS `pubmail`,
1596 `post-user`.`visible` AS `visible`,
1597 `post-thread-user`.`starred` AS `starred`,
1598 `post-thread-user`.`pinned` AS `pinned`,
1599 `post-user`.`unseen` AS `unseen`,
1600 `post-user`.`deleted` AS `deleted`,
1601 `post-user`.`origin` AS `origin`,
1602 `post-thread-user`.`origin` AS `parent-origin`,
1603 `post-thread-user`.`forum_mode` AS `forum_mode`,
1604 `post-thread-user`.`mention` AS `mention`,
1605 `post-user`.`global` AS `global`,
1606 `post-user`.`network` AS `network`,
1607 `post-user`.`vid` AS `vid`,
1608 `post-user`.`psid` AS `psid`,
1609 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1610 `post-content`.`title` AS `title`,
1611 `post-content`.`content-warning` AS `content-warning`,
1612 `post-content`.`raw-body` AS `raw-body`,
1613 `post-content`.`body` AS `body`,
1614 `post-content`.`rendered-hash` AS `rendered-hash`,
1615 `post-content`.`rendered-html` AS `rendered-html`,
1616 `post-content`.`language` AS `language`,
1617 `post-content`.`plink` AS `plink`,
1618 `post-content`.`location` AS `location`,
1619 `post-content`.`coord` AS `coord`,
1620 `post-content`.`app` AS `app`,
1621 `post-content`.`object-type` AS `object-type`,
1622 `post-content`.`object` AS `object`,
1623 `post-content`.`target-type` AS `target-type`,
1624 `post-content`.`target` AS `target`,
1625 `post-content`.`resource-id` AS `resource-id`,
1626 `post-user`.`contact-id` AS `contact-id`,
1627 `contact`.`url` AS `contact-link`,
1628 `contact`.`addr` AS `contact-addr`,
1629 `contact`.`name` AS `contact-name`,
1630 `contact`.`nick` AS `contact-nick`,
1631 `contact`.`thumb` AS `contact-avatar`,
1632 `contact`.`network` AS `contact-network`,
1633 `contact`.`blocked` AS `contact-blocked`,
1634 `contact`.`hidden` AS `contact-hidden`,
1635 `contact`.`readonly` AS `contact-readonly`,
1636 `contact`.`archive` AS `contact-archive`,
1637 `contact`.`pending` AS `contact-pending`,
1638 `contact`.`rel` AS `contact-rel`,
1639 `contact`.`uid` AS `contact-uid`,
1640 `contact`.`contact-type` AS `contact-contact-type`,
1641 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1642 `contact`.`self` AS `self`,
1643 `contact`.`id` AS `cid`,
1644 `contact`.`alias` AS `alias`,
1645 `contact`.`photo` AS `photo`,
1646 `contact`.`name-date` AS `name-date`,
1647 `contact`.`uri-date` AS `uri-date`,
1648 `contact`.`avatar-date` AS `avatar-date`,
1649 `contact`.`thumb` AS `thumb`,
1650 `post-user`.`author-id` AS `author-id`,
1651 `author`.`url` AS `author-link`,
1652 `author`.`addr` AS `author-addr`,
1653 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1654 `author`.`nick` AS `author-nick`,
1655 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1656 `author`.`network` AS `author-network`,
1657 `author`.`blocked` AS `author-blocked`,
1658 `author`.`hidden` AS `author-hidden`,
1659 `post-user`.`owner-id` AS `owner-id`,
1660 `owner`.`url` AS `owner-link`,
1661 `owner`.`addr` AS `owner-addr`,
1662 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1663 `owner`.`nick` AS `owner-nick`,
1664 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1665 `owner`.`network` AS `owner-network`,
1666 `owner`.`blocked` AS `owner-blocked`,
1667 `owner`.`hidden` AS `owner-hidden`,
1668 `owner`.`contact-type` AS `owner-contact-type`,
1669 `post-user`.`causer-id` AS `causer-id`,
1670 `causer`.`url` AS `causer-link`,
1671 `causer`.`addr` AS `causer-addr`,
1672 `causer`.`name` AS `causer-name`,
1673 `causer`.`nick` AS `causer-nick`,
1674 `causer`.`thumb` AS `causer-avatar`,
1675 `causer`.`network` AS `causer-network`,
1676 `causer`.`blocked` AS `causer-blocked`,
1677 `causer`.`hidden` AS `causer-hidden`,
1678 `causer`.`contact-type` AS `causer-contact-type`,
1679 `post-delivery-data`.`postopts` AS `postopts`,
1680 `post-delivery-data`.`inform` AS `inform`,
1681 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1682 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1683 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1684 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1685 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1686 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1687 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1688 `post-user`.`event-id` AS `event-id`,
1689 `event`.`created` AS `event-created`,
1690 `event`.`edited` AS `event-edited`,
1691 `event`.`start` AS `event-start`,
1692 `event`.`finish` AS `event-finish`,
1693 `event`.`summary` AS `event-summary`,
1694 `event`.`desc` AS `event-desc`,
1695 `event`.`location` AS `event-location`,
1696 `event`.`type` AS `event-type`,
1697 `event`.`nofinish` AS `event-nofinish`,
1698 `event`.`ignore` AS `event-ignore`,
1699 `diaspora-interaction`.`interaction` AS `signed_text`,
1700 `parent-item-uri`.`guid` AS `parent-guid`,
1701 `parent-post`.`network` AS `parent-network`,
1702 `parent-post`.`author-id` AS `parent-author-id`,
1703 `parent-post-author`.`url` AS `parent-author-link`,
1704 `parent-post-author`.`name` AS `parent-author-name`,
1705 `parent-post-author`.`nick` AS `parent-author-nick`,
1706 `parent-post-author`.`network` AS `parent-author-network`,
1707 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1708 `parent-post-author`.`hidden` AS `parent-author-hidden`
1710 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
1711 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
1712 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
1713 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
1714 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
1715 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
1716 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1717 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1718 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1719 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1720 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1721 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
1722 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
1723 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
1724 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
1725 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
1726 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1729 -- VIEW post-thread-user-view
1731 DROP VIEW IF EXISTS `post-thread-user-view`;
1732 CREATE VIEW `post-thread-user-view` AS SELECT
1733 `post-user`.`id` AS `id`,
1734 `post-user`.`id` AS `post-user-id`,
1735 `post-thread-user`.`uid` AS `uid`,
1736 `parent-post`.`id` AS `parent`,
1737 `item-uri`.`uri` AS `uri`,
1738 `post-thread-user`.`uri-id` AS `uri-id`,
1739 `parent-item-uri`.`uri` AS `parent-uri`,
1740 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1741 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1742 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1743 `item-uri`.`guid` AS `guid`,
1744 `post-thread-user`.`wall` AS `wall`,
1745 `post-user`.`gravity` AS `gravity`,
1746 `external-item-uri`.`uri` AS `extid`,
1747 `post-user`.`external-id` AS `external-id`,
1748 `post-thread-user`.`created` AS `created`,
1749 `post-user`.`edited` AS `edited`,
1750 `post-thread-user`.`commented` AS `commented`,
1751 `post-thread-user`.`received` AS `received`,
1752 `post-thread-user`.`changed` AS `changed`,
1753 `post-user`.`post-type` AS `post-type`,
1754 `post-user`.`post-reason` AS `post-reason`,
1755 `post-user`.`private` AS `private`,
1756 `post-thread-user`.`pubmail` AS `pubmail`,
1757 `post-thread-user`.`ignored` AS `ignored`,
1758 `post-user`.`visible` AS `visible`,
1759 `post-thread-user`.`starred` AS `starred`,
1760 `post-thread-user`.`pinned` AS `pinned`,
1761 `post-thread-user`.`unseen` AS `unseen`,
1762 `post-user`.`deleted` AS `deleted`,
1763 `post-thread-user`.`origin` AS `origin`,
1764 `post-thread-user`.`forum_mode` AS `forum_mode`,
1765 `post-thread-user`.`mention` AS `mention`,
1766 `post-user`.`global` AS `global`,
1767 `post-thread-user`.`network` AS `network`,
1768 `post-user`.`vid` AS `vid`,
1769 `post-thread-user`.`psid` AS `psid`,
1770 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1771 `post-content`.`title` AS `title`,
1772 `post-content`.`content-warning` AS `content-warning`,
1773 `post-content`.`raw-body` AS `raw-body`,
1774 `post-content`.`body` AS `body`,
1775 `post-content`.`rendered-hash` AS `rendered-hash`,
1776 `post-content`.`rendered-html` AS `rendered-html`,
1777 `post-content`.`language` AS `language`,
1778 `post-content`.`plink` AS `plink`,
1779 `post-content`.`location` AS `location`,
1780 `post-content`.`coord` AS `coord`,
1781 `post-content`.`app` AS `app`,
1782 `post-content`.`object-type` AS `object-type`,
1783 `post-content`.`object` AS `object`,
1784 `post-content`.`target-type` AS `target-type`,
1785 `post-content`.`target` AS `target`,
1786 `post-content`.`resource-id` AS `resource-id`,
1787 `post-thread-user`.`contact-id` AS `contact-id`,
1788 `contact`.`url` AS `contact-link`,
1789 `contact`.`addr` AS `contact-addr`,
1790 `contact`.`name` AS `contact-name`,
1791 `contact`.`nick` AS `contact-nick`,
1792 `contact`.`thumb` AS `contact-avatar`,
1793 `contact`.`network` AS `contact-network`,
1794 `contact`.`blocked` AS `contact-blocked`,
1795 `contact`.`hidden` AS `contact-hidden`,
1796 `contact`.`readonly` AS `contact-readonly`,
1797 `contact`.`archive` AS `contact-archive`,
1798 `contact`.`pending` AS `contact-pending`,
1799 `contact`.`rel` AS `contact-rel`,
1800 `contact`.`uid` AS `contact-uid`,
1801 `contact`.`contact-type` AS `contact-contact-type`,
1802 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1803 `contact`.`self` AS `self`,
1804 `contact`.`id` AS `cid`,
1805 `contact`.`alias` AS `alias`,
1806 `contact`.`photo` AS `photo`,
1807 `contact`.`name-date` AS `name-date`,
1808 `contact`.`uri-date` AS `uri-date`,
1809 `contact`.`avatar-date` AS `avatar-date`,
1810 `contact`.`thumb` AS `thumb`,
1811 `post-thread-user`.`author-id` AS `author-id`,
1812 `author`.`url` AS `author-link`,
1813 `author`.`addr` AS `author-addr`,
1814 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1815 `author`.`nick` AS `author-nick`,
1816 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1817 `author`.`network` AS `author-network`,
1818 `author`.`blocked` AS `author-blocked`,
1819 `author`.`hidden` AS `author-hidden`,
1820 `post-thread-user`.`owner-id` AS `owner-id`,
1821 `owner`.`url` AS `owner-link`,
1822 `owner`.`addr` AS `owner-addr`,
1823 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1824 `owner`.`nick` AS `owner-nick`,
1825 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1826 `owner`.`network` AS `owner-network`,
1827 `owner`.`blocked` AS `owner-blocked`,
1828 `owner`.`hidden` AS `owner-hidden`,
1829 `owner`.`contact-type` AS `owner-contact-type`,
1830 `post-thread-user`.`causer-id` AS `causer-id`,
1831 `causer`.`url` AS `causer-link`,
1832 `causer`.`addr` AS `causer-addr`,
1833 `causer`.`name` AS `causer-name`,
1834 `causer`.`nick` AS `causer-nick`,
1835 `causer`.`thumb` AS `causer-avatar`,
1836 `causer`.`network` AS `causer-network`,
1837 `causer`.`blocked` AS `causer-blocked`,
1838 `causer`.`hidden` AS `causer-hidden`,
1839 `causer`.`contact-type` AS `causer-contact-type`,
1840 `post-delivery-data`.`postopts` AS `postopts`,
1841 `post-delivery-data`.`inform` AS `inform`,
1842 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1843 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1844 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1845 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1846 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1847 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1848 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1849 `post-user`.`event-id` AS `event-id`,
1850 `event`.`created` AS `event-created`,
1851 `event`.`edited` AS `event-edited`,
1852 `event`.`start` AS `event-start`,
1853 `event`.`finish` AS `event-finish`,
1854 `event`.`summary` AS `event-summary`,
1855 `event`.`desc` AS `event-desc`,
1856 `event`.`location` AS `event-location`,
1857 `event`.`type` AS `event-type`,
1858 `event`.`nofinish` AS `event-nofinish`,
1859 `event`.`ignore` AS `event-ignore`,
1860 `diaspora-interaction`.`interaction` AS `signed_text`,
1861 `parent-item-uri`.`guid` AS `parent-guid`,
1862 `parent-post`.`network` AS `parent-network`,
1863 `parent-post`.`author-id` AS `parent-author-id`,
1864 `parent-post-author`.`url` AS `parent-author-link`,
1865 `parent-post-author`.`name` AS `parent-author-name`,
1866 `parent-post-author`.`network` AS `parent-author-network`,
1867 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1868 `parent-post-author`.`hidden` AS `parent-author-hidden`
1869 FROM `post-thread-user`
1870 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
1871 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
1872 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
1873 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
1874 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
1875 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
1876 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1877 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1878 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1879 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1880 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1881 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
1882 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
1883 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
1884 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
1885 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`
1886 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1891 DROP VIEW IF EXISTS `post-view`;
1892 CREATE VIEW `post-view` AS SELECT
1893 `item-uri`.`uri` AS `uri`,
1894 `post`.`uri-id` AS `uri-id`,
1895 `parent-item-uri`.`uri` AS `parent-uri`,
1896 `post`.`parent-uri-id` AS `parent-uri-id`,
1897 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1898 `post`.`thr-parent-id` AS `thr-parent-id`,
1899 `item-uri`.`guid` AS `guid`,
1900 `post`.`gravity` AS `gravity`,
1901 `external-item-uri`.`uri` AS `extid`,
1902 `post`.`external-id` AS `external-id`,
1903 `post`.`created` AS `created`,
1904 `post`.`edited` AS `edited`,
1905 `post-thread`.`commented` AS `commented`,
1906 `post`.`received` AS `received`,
1907 `post-thread`.`changed` AS `changed`,
1908 `post`.`post-type` AS `post-type`,
1909 `post`.`private` AS `private`,
1910 `post`.`visible` AS `visible`,
1911 `post`.`deleted` AS `deleted`,
1912 `post`.`global` AS `global`,
1913 `post`.`network` AS `network`,
1914 `post`.`vid` AS `vid`,
1915 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1916 `post-content`.`title` AS `title`,
1917 `post-content`.`content-warning` AS `content-warning`,
1918 `post-content`.`raw-body` AS `raw-body`,
1919 `post-content`.`body` AS `body`,
1920 `post-content`.`rendered-hash` AS `rendered-hash`,
1921 `post-content`.`rendered-html` AS `rendered-html`,
1922 `post-content`.`language` AS `language`,
1923 `post-content`.`plink` AS `plink`,
1924 `post-content`.`location` AS `location`,
1925 `post-content`.`coord` AS `coord`,
1926 `post-content`.`app` AS `app`,
1927 `post-content`.`object-type` AS `object-type`,
1928 `post-content`.`object` AS `object`,
1929 `post-content`.`target-type` AS `target-type`,
1930 `post-content`.`target` AS `target`,
1931 `post-content`.`resource-id` AS `resource-id`,
1932 `post`.`author-id` AS `contact-id`,
1933 `author`.`url` AS `contact-link`,
1934 `author`.`addr` AS `contact-addr`,
1935 `author`.`name` AS `contact-name`,
1936 `author`.`nick` AS `contact-nick`,
1937 `author`.`thumb` AS `contact-avatar`,
1938 `author`.`network` AS `contact-network`,
1939 `author`.`blocked` AS `contact-blocked`,
1940 `author`.`hidden` AS `contact-hidden`,
1941 `author`.`readonly` AS `contact-readonly`,
1942 `author`.`archive` AS `contact-archive`,
1943 `author`.`pending` AS `contact-pending`,
1944 `author`.`rel` AS `contact-rel`,
1945 `author`.`uid` AS `contact-uid`,
1946 `author`.`contact-type` AS `contact-contact-type`,
1947 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
1949 `author`.`id` AS `cid`,
1950 `author`.`alias` AS `alias`,
1951 `author`.`photo` AS `photo`,
1952 `author`.`name-date` AS `name-date`,
1953 `author`.`uri-date` AS `uri-date`,
1954 `author`.`avatar-date` AS `avatar-date`,
1955 `author`.`thumb` AS `thumb`,
1956 `post`.`author-id` AS `author-id`,
1957 `author`.`url` AS `author-link`,
1958 `author`.`addr` AS `author-addr`,
1959 `author`.`name` AS `author-name`,
1960 `author`.`nick` AS `author-nick`,
1961 `author`.`thumb` AS `author-avatar`,
1962 `author`.`network` AS `author-network`,
1963 `author`.`blocked` AS `author-blocked`,
1964 `author`.`hidden` AS `author-hidden`,
1965 `post`.`owner-id` AS `owner-id`,
1966 `owner`.`url` AS `owner-link`,
1967 `owner`.`addr` AS `owner-addr`,
1968 `owner`.`name` AS `owner-name`,
1969 `owner`.`nick` AS `owner-nick`,
1970 `owner`.`thumb` AS `owner-avatar`,
1971 `owner`.`network` AS `owner-network`,
1972 `owner`.`blocked` AS `owner-blocked`,
1973 `owner`.`hidden` AS `owner-hidden`,
1974 `owner`.`contact-type` AS `owner-contact-type`,
1975 `post`.`causer-id` AS `causer-id`,
1976 `causer`.`url` AS `causer-link`,
1977 `causer`.`addr` AS `causer-addr`,
1978 `causer`.`name` AS `causer-name`,
1979 `causer`.`nick` AS `causer-nick`,
1980 `causer`.`thumb` AS `causer-avatar`,
1981 `causer`.`network` AS `causer-network`,
1982 `causer`.`blocked` AS `causer-blocked`,
1983 `causer`.`hidden` AS `causer-hidden`,
1984 `causer`.`contact-type` AS `causer-contact-type`,
1985 `diaspora-interaction`.`interaction` AS `signed_text`,
1986 `parent-item-uri`.`guid` AS `parent-guid`,
1987 `parent-post`.`network` AS `parent-network`,
1988 `parent-post`.`author-id` AS `parent-author-id`,
1989 `parent-post-author`.`url` AS `parent-author-link`,
1990 `parent-post-author`.`name` AS `parent-author-name`,
1991 `parent-post-author`.`network` AS `parent-author-network`,
1992 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1993 `parent-post-author`.`hidden` AS `parent-author-hidden`
1995 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
1996 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
1997 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
1998 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
1999 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
2000 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2001 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2002 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2003 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2004 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
2005 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
2006 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2007 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2010 -- VIEW post-thread-view
2012 DROP VIEW IF EXISTS `post-thread-view`;
2013 CREATE VIEW `post-thread-view` AS SELECT
2014 `item-uri`.`uri` AS `uri`,
2015 `post-thread`.`uri-id` AS `uri-id`,
2016 `parent-item-uri`.`uri` AS `parent-uri`,
2017 `post`.`parent-uri-id` AS `parent-uri-id`,
2018 `thr-parent-item-uri`.`uri` AS `thr-parent`,
2019 `post`.`thr-parent-id` AS `thr-parent-id`,
2020 `item-uri`.`guid` AS `guid`,
2021 `post`.`gravity` AS `gravity`,
2022 `external-item-uri`.`uri` AS `extid`,
2023 `post`.`external-id` AS `external-id`,
2024 `post-thread`.`created` AS `created`,
2025 `post`.`edited` AS `edited`,
2026 `post-thread`.`commented` AS `commented`,
2027 `post-thread`.`received` AS `received`,
2028 `post-thread`.`changed` AS `changed`,
2029 `post`.`post-type` AS `post-type`,
2030 `post`.`private` AS `private`,
2031 `post`.`visible` AS `visible`,
2032 `post`.`deleted` AS `deleted`,
2033 `post`.`global` AS `global`,
2034 `post-thread`.`network` AS `network`,
2035 `post`.`vid` AS `vid`,
2036 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2037 `post-content`.`title` AS `title`,
2038 `post-content`.`content-warning` AS `content-warning`,
2039 `post-content`.`raw-body` AS `raw-body`,
2040 `post-content`.`body` AS `body`,
2041 `post-content`.`rendered-hash` AS `rendered-hash`,
2042 `post-content`.`rendered-html` AS `rendered-html`,
2043 `post-content`.`language` AS `language`,
2044 `post-content`.`plink` AS `plink`,
2045 `post-content`.`location` AS `location`,
2046 `post-content`.`coord` AS `coord`,
2047 `post-content`.`app` AS `app`,
2048 `post-content`.`object-type` AS `object-type`,
2049 `post-content`.`object` AS `object`,
2050 `post-content`.`target-type` AS `target-type`,
2051 `post-content`.`target` AS `target`,
2052 `post-content`.`resource-id` AS `resource-id`,
2053 `post-thread`.`author-id` AS `contact-id`,
2054 `author`.`url` AS `contact-link`,
2055 `author`.`addr` AS `contact-addr`,
2056 `author`.`name` AS `contact-name`,
2057 `author`.`nick` AS `contact-nick`,
2058 `author`.`thumb` AS `contact-avatar`,
2059 `author`.`network` AS `contact-network`,
2060 `author`.`blocked` AS `contact-blocked`,
2061 `author`.`hidden` AS `contact-hidden`,
2062 `author`.`readonly` AS `contact-readonly`,
2063 `author`.`archive` AS `contact-archive`,
2064 `author`.`pending` AS `contact-pending`,
2065 `author`.`rel` AS `contact-rel`,
2066 `author`.`uid` AS `contact-uid`,
2067 `author`.`contact-type` AS `contact-contact-type`,
2068 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2070 `author`.`id` AS `cid`,
2071 `author`.`alias` AS `alias`,
2072 `author`.`photo` AS `photo`,
2073 `author`.`name-date` AS `name-date`,
2074 `author`.`uri-date` AS `uri-date`,
2075 `author`.`avatar-date` AS `avatar-date`,
2076 `author`.`thumb` AS `thumb`,
2077 `post-thread`.`author-id` AS `author-id`,
2078 `author`.`url` AS `author-link`,
2079 `author`.`addr` AS `author-addr`,
2080 `author`.`name` AS `author-name`,
2081 `author`.`nick` AS `author-nick`,
2082 `author`.`thumb` AS `author-avatar`,
2083 `author`.`network` AS `author-network`,
2084 `author`.`blocked` AS `author-blocked`,
2085 `author`.`hidden` AS `author-hidden`,
2086 `post-thread`.`owner-id` AS `owner-id`,
2087 `owner`.`url` AS `owner-link`,
2088 `owner`.`addr` AS `owner-addr`,
2089 `owner`.`name` AS `owner-name`,
2090 `owner`.`nick` AS `owner-nick`,
2091 `owner`.`thumb` AS `owner-avatar`,
2092 `owner`.`network` AS `owner-network`,
2093 `owner`.`blocked` AS `owner-blocked`,
2094 `owner`.`hidden` AS `owner-hidden`,
2095 `owner`.`contact-type` AS `owner-contact-type`,
2096 `post-thread`.`causer-id` AS `causer-id`,
2097 `causer`.`url` AS `causer-link`,
2098 `causer`.`addr` AS `causer-addr`,
2099 `causer`.`name` AS `causer-name`,
2100 `causer`.`nick` AS `causer-nick`,
2101 `causer`.`thumb` AS `causer-avatar`,
2102 `causer`.`network` AS `causer-network`,
2103 `causer`.`blocked` AS `causer-blocked`,
2104 `causer`.`hidden` AS `causer-hidden`,
2105 `causer`.`contact-type` AS `causer-contact-type`,
2106 `diaspora-interaction`.`interaction` AS `signed_text`,
2107 `parent-item-uri`.`guid` AS `parent-guid`,
2108 `parent-post`.`network` AS `parent-network`,
2109 `parent-post`.`author-id` AS `parent-author-id`,
2110 `parent-post-author`.`url` AS `parent-author-link`,
2111 `parent-post-author`.`name` AS `parent-author-name`,
2112 `parent-post-author`.`network` AS `parent-author-network`,
2113 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2114 `parent-post-author`.`hidden` AS `parent-author-hidden`
2116 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
2117 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
2118 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
2119 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
2120 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
2121 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2122 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2123 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2124 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2125 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
2126 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
2127 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2128 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2131 -- VIEW category-view
2133 DROP VIEW IF EXISTS `category-view`;
2134 CREATE VIEW `category-view` AS SELECT
2135 `post-category`.`uri-id` AS `uri-id`,
2136 `post-category`.`uid` AS `uid`,
2137 `post-category`.`type` AS `type`,
2138 `post-category`.`tid` AS `tid`,
2139 `tag`.`name` AS `name`,
2140 `tag`.`url` AS `url`
2141 FROM `post-category`
2142 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2147 DROP VIEW IF EXISTS `tag-view`;
2148 CREATE VIEW `tag-view` AS SELECT
2149 `post-tag`.`uri-id` AS `uri-id`,
2150 `post-tag`.`type` AS `type`,
2151 `post-tag`.`tid` AS `tid`,
2152 `post-tag`.`cid` AS `cid`,
2153 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2154 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
2156 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2157 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2160 -- VIEW network-item-view
2162 DROP VIEW IF EXISTS `network-item-view`;
2163 CREATE VIEW `network-item-view` AS SELECT
2164 `post-user`.`uri-id` AS `uri-id`,
2165 `parent-post`.`id` AS `parent`,
2166 `post-user`.`received` AS `received`,
2167 `post-thread-user`.`commented` AS `commented`,
2168 `post-user`.`created` AS `created`,
2169 `post-user`.`uid` AS `uid`,
2170 `post-thread-user`.`starred` AS `starred`,
2171 `post-thread-user`.`mention` AS `mention`,
2172 `post-user`.`network` AS `network`,
2173 `post-user`.`unseen` AS `unseen`,
2174 `post-user`.`gravity` AS `gravity`,
2175 `post-user`.`contact-id` AS `contact-id`,
2176 `ownercontact`.`contact-type` AS `contact-type`
2178 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2179 INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2180 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2181 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2182 INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2183 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2184 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2185 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2186 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
2187 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2188 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2191 -- VIEW network-thread-view
2193 DROP VIEW IF EXISTS `network-thread-view`;
2194 CREATE VIEW `network-thread-view` AS SELECT
2195 `post-thread-user`.`uri-id` AS `uri-id`,
2196 `parent-post`.`id` AS `parent`,
2197 `post-thread-user`.`received` AS `received`,
2198 `post-thread-user`.`commented` AS `commented`,
2199 `post-thread-user`.`created` AS `created`,
2200 `post-thread-user`.`uid` AS `uid`,
2201 `post-thread-user`.`starred` AS `starred`,
2202 `post-thread-user`.`mention` AS `mention`,
2203 `post-thread-user`.`network` AS `network`,
2204 `post-thread-user`.`contact-id` AS `contact-id`,
2205 `ownercontact`.`contact-type` AS `contact-type`
2206 FROM `post-thread-user`
2207 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2208 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2209 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2210 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2211 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2212 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2213 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2214 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2215 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2216 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2217 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2222 DROP VIEW IF EXISTS `owner-view`;
2223 CREATE VIEW `owner-view` AS SELECT
2224 `contact`.`id` AS `id`,
2225 `contact`.`uid` AS `uid`,
2226 `contact`.`created` AS `created`,
2227 `contact`.`updated` AS `updated`,
2228 `contact`.`self` AS `self`,
2229 `contact`.`remote_self` AS `remote_self`,
2230 `contact`.`rel` AS `rel`,
2231 `contact`.`network` AS `network`,
2232 `contact`.`protocol` AS `protocol`,
2233 `contact`.`name` AS `name`,
2234 `contact`.`nick` AS `nick`,
2235 `contact`.`location` AS `location`,
2236 `contact`.`about` AS `about`,
2237 `contact`.`keywords` AS `keywords`,
2238 `contact`.`xmpp` AS `xmpp`,
2239 `contact`.`matrix` AS `matrix`,
2240 `contact`.`attag` AS `attag`,
2241 `contact`.`avatar` AS `avatar`,
2242 `contact`.`photo` AS `photo`,
2243 `contact`.`thumb` AS `thumb`,
2244 `contact`.`micro` AS `micro`,
2245 `contact`.`header` AS `header`,
2246 `contact`.`url` AS `url`,
2247 `contact`.`nurl` AS `nurl`,
2248 `contact`.`uri-id` AS `uri-id`,
2249 `contact`.`addr` AS `addr`,
2250 `contact`.`alias` AS `alias`,
2251 `contact`.`pubkey` AS `pubkey`,
2252 `contact`.`prvkey` AS `prvkey`,
2253 `contact`.`batch` AS `batch`,
2254 `contact`.`request` AS `request`,
2255 `contact`.`notify` AS `notify`,
2256 `contact`.`poll` AS `poll`,
2257 `contact`.`confirm` AS `confirm`,
2258 `contact`.`poco` AS `poco`,
2259 `contact`.`subhub` AS `subhub`,
2260 `contact`.`hub-verify` AS `hub-verify`,
2261 `contact`.`last-update` AS `last-update`,
2262 `contact`.`success_update` AS `success_update`,
2263 `contact`.`failure_update` AS `failure_update`,
2264 `contact`.`name-date` AS `name-date`,
2265 `contact`.`uri-date` AS `uri-date`,
2266 `contact`.`avatar-date` AS `avatar-date`,
2267 `contact`.`avatar-date` AS `picdate`,
2268 `contact`.`term-date` AS `term-date`,
2269 `contact`.`last-item` AS `last-item`,
2270 `contact`.`priority` AS `priority`,
2271 `user`.`blocked` AS `blocked`,
2272 `contact`.`block_reason` AS `block_reason`,
2273 `contact`.`readonly` AS `readonly`,
2274 `contact`.`writable` AS `writable`,
2275 `contact`.`forum` AS `forum`,
2276 `contact`.`prv` AS `prv`,
2277 `contact`.`contact-type` AS `contact-type`,
2278 `contact`.`manually-approve` AS `manually-approve`,
2279 `contact`.`hidden` AS `hidden`,
2280 `contact`.`archive` AS `archive`,
2281 `contact`.`pending` AS `pending`,
2282 `contact`.`deleted` AS `deleted`,
2283 `contact`.`unsearchable` AS `unsearchable`,
2284 `contact`.`sensitive` AS `sensitive`,
2285 `contact`.`baseurl` AS `baseurl`,
2286 `contact`.`reason` AS `reason`,
2287 `contact`.`info` AS `info`,
2288 `contact`.`bdyear` AS `bdyear`,
2289 `contact`.`bd` AS `bd`,
2290 `contact`.`notify_new_posts` AS `notify_new_posts`,
2291 `contact`.`fetch_further_information` AS `fetch_further_information`,
2292 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2293 `user`.`parent-uid` AS `parent-uid`,
2294 `user`.`guid` AS `guid`,
2295 `user`.`nickname` AS `nickname`,
2296 `user`.`email` AS `email`,
2297 `user`.`openid` AS `openid`,
2298 `user`.`timezone` AS `timezone`,
2299 `user`.`language` AS `language`,
2300 `user`.`register_date` AS `register_date`,
2301 `user`.`login_date` AS `login_date`,
2302 `user`.`default-location` AS `default-location`,
2303 `user`.`allow_location` AS `allow_location`,
2304 `user`.`theme` AS `theme`,
2305 `user`.`pubkey` AS `upubkey`,
2306 `user`.`prvkey` AS `uprvkey`,
2307 `user`.`sprvkey` AS `sprvkey`,
2308 `user`.`spubkey` AS `spubkey`,
2309 `user`.`verified` AS `verified`,
2310 `user`.`blockwall` AS `blockwall`,
2311 `user`.`hidewall` AS `hidewall`,
2312 `user`.`blocktags` AS `blocktags`,
2313 `user`.`unkmail` AS `unkmail`,
2314 `user`.`cntunkmail` AS `cntunkmail`,
2315 `user`.`notify-flags` AS `notify-flags`,
2316 `user`.`page-flags` AS `page-flags`,
2317 `user`.`account-type` AS `account-type`,
2318 `user`.`prvnets` AS `prvnets`,
2319 `user`.`maxreq` AS `maxreq`,
2320 `user`.`expire` AS `expire`,
2321 `user`.`account_removed` AS `account_removed`,
2322 `user`.`account_expired` AS `account_expired`,
2323 `user`.`account_expires_on` AS `account_expires_on`,
2324 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2325 `user`.`def_gid` AS `def_gid`,
2326 `user`.`allow_cid` AS `allow_cid`,
2327 `user`.`allow_gid` AS `allow_gid`,
2328 `user`.`deny_cid` AS `deny_cid`,
2329 `user`.`deny_gid` AS `deny_gid`,
2330 `user`.`openidserver` AS `openidserver`,
2331 `profile`.`publish` AS `publish`,
2332 `profile`.`net-publish` AS `net-publish`,
2333 `profile`.`hide-friends` AS `hide-friends`,
2334 `profile`.`prv_keywords` AS `prv_keywords`,
2335 `profile`.`pub_keywords` AS `pub_keywords`,
2336 `profile`.`address` AS `address`,
2337 `profile`.`locality` AS `locality`,
2338 `profile`.`region` AS `region`,
2339 `profile`.`postal-code` AS `postal-code`,
2340 `profile`.`country-name` AS `country-name`,
2341 `profile`.`homepage` AS `homepage`,
2342 `profile`.`dob` AS `dob`
2344 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2345 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2348 -- VIEW account-view
2350 DROP VIEW IF EXISTS `account-view`;
2351 CREATE VIEW `account-view` AS SELECT
2352 `contact`.`id` AS `id`,
2353 `contact`.`url` AS `url`,
2354 `contact`.`nurl` AS `nurl`,
2355 `contact`.`uri-id` AS `uri-id`,
2356 `item-uri`.`guid` AS `guid`,
2357 `contact`.`addr` AS `addr`,
2358 `contact`.`alias` AS `alias`,
2359 `contact`.`name` AS `name`,
2360 `contact`.`nick` AS `nick`,
2361 `contact`.`about` AS `about`,
2362 `contact`.`keywords` AS `keywords`,
2363 `contact`.`xmpp` AS `xmpp`,
2364 `contact`.`matrix` AS `matrix`,
2365 `contact`.`avatar` AS `avatar`,
2366 `contact`.`photo` AS `photo`,
2367 `contact`.`thumb` AS `thumb`,
2368 `contact`.`micro` AS `micro`,
2369 `contact`.`header` AS `header`,
2370 `contact`.`created` AS `created`,
2371 `contact`.`updated` AS `updated`,
2372 `contact`.`network` AS `network`,
2373 `contact`.`protocol` AS `protocol`,
2374 `contact`.`location` AS `location`,
2375 `contact`.`attag` AS `attag`,
2376 `contact`.`pubkey` AS `pubkey`,
2377 `contact`.`prvkey` AS `prvkey`,
2378 `contact`.`subscribe` AS `subscribe`,
2379 `contact`.`last-update` AS `last-update`,
2380 `contact`.`success_update` AS `success_update`,
2381 `contact`.`failure_update` AS `failure_update`,
2382 `contact`.`failed` AS `failed`,
2383 `contact`.`last-item` AS `last-item`,
2384 `contact`.`last-discovery` AS `last-discovery`,
2385 `contact`.`contact-type` AS `contact-type`,
2386 `contact`.`manually-approve` AS `manually-approve`,
2387 `contact`.`unsearchable` AS `unsearchable`,
2388 `contact`.`sensitive` AS `sensitive`,
2389 `contact`.`baseurl` AS `baseurl`,
2390 `contact`.`gsid` AS `gsid`,
2391 `contact`.`info` AS `info`,
2392 `contact`.`bdyear` AS `bdyear`,
2393 `contact`.`bd` AS `bd`,
2394 `contact`.`poco` AS `poco`,
2395 `contact`.`name-date` AS `name-date`,
2396 `contact`.`uri-date` AS `uri-date`,
2397 `contact`.`avatar-date` AS `avatar-date`,
2398 `contact`.`term-date` AS `term-date`,
2399 `contact`.`hidden` AS `global-ignored`,
2400 `contact`.`blocked` AS `global-blocked`,
2401 `contact`.`hidden` AS `hidden`,
2402 `contact`.`archive` AS `archive`,
2403 `contact`.`deleted` AS `deleted`,
2404 `contact`.`blocked` AS `blocked`,
2405 `contact`.`request` AS `dfrn-request`,
2406 `contact`.`notify` AS `dfrn-notify`,
2407 `contact`.`poll` AS `dfrn-poll`,
2408 `contact`.`confirm` AS `dfrn-confirm`,
2409 `fcontact`.`guid` AS `diaspora-guid`,
2410 `fcontact`.`batch` AS `diaspora-batch`,
2411 `fcontact`.`notify` AS `diaspora-notify`,
2412 `fcontact`.`poll` AS `diaspora-poll`,
2413 `fcontact`.`alias` AS `diaspora-alias`,
2414 `apcontact`.`uuid` AS `ap-uuid`,
2415 `apcontact`.`type` AS `ap-type`,
2416 `apcontact`.`following` AS `ap-following`,
2417 `apcontact`.`followers` AS `ap-followers`,
2418 `apcontact`.`inbox` AS `ap-inbox`,
2419 `apcontact`.`outbox` AS `ap-outbox`,
2420 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2421 `apcontact`.`generator` AS `ap-generator`,
2422 `apcontact`.`following_count` AS `ap-following_count`,
2423 `apcontact`.`followers_count` AS `ap-followers_count`,
2424 `apcontact`.`statuses_count` AS `ap-statuses_count`
2426 LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id`
2427 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
2428 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = contact.`uri-id`
2429 WHERE `contact`.`uid` = 0;
2432 -- VIEW account-user-view
2434 DROP VIEW IF EXISTS `account-user-view`;
2435 CREATE VIEW `account-user-view` AS SELECT
2436 `ucontact`.`id` AS `id`,
2437 `contact`.`id` AS `pid`,
2438 `ucontact`.`uid` AS `uid`,
2439 `contact`.`url` AS `url`,
2440 `contact`.`nurl` AS `nurl`,
2441 `contact`.`uri-id` AS `uri-id`,
2442 `item-uri`.`guid` AS `guid`,
2443 `contact`.`addr` AS `addr`,
2444 `contact`.`alias` AS `alias`,
2445 `contact`.`name` AS `name`,
2446 `contact`.`nick` AS `nick`,
2447 `contact`.`about` AS `about`,
2448 `contact`.`keywords` AS `keywords`,
2449 `contact`.`xmpp` AS `xmpp`,
2450 `contact`.`matrix` AS `matrix`,
2451 `contact`.`avatar` AS `avatar`,
2452 `contact`.`photo` AS `photo`,
2453 `contact`.`thumb` AS `thumb`,
2454 `contact`.`micro` AS `micro`,
2455 `contact`.`header` AS `header`,
2456 `contact`.`created` AS `created`,
2457 `contact`.`updated` AS `updated`,
2458 `ucontact`.`self` AS `self`,
2459 `ucontact`.`remote_self` AS `remote_self`,
2460 `ucontact`.`rel` AS `rel`,
2461 `contact`.`network` AS `network`,
2462 `ucontact`.`protocol` AS `protocol`,
2463 `contact`.`location` AS `location`,
2464 `ucontact`.`attag` AS `attag`,
2465 `contact`.`pubkey` AS `pubkey`,
2466 `contact`.`prvkey` AS `prvkey`,
2467 `contact`.`subscribe` AS `subscribe`,
2468 `contact`.`last-update` AS `last-update`,
2469 `contact`.`success_update` AS `success_update`,
2470 `contact`.`failure_update` AS `failure_update`,
2471 `contact`.`failed` AS `failed`,
2472 `contact`.`last-item` AS `last-item`,
2473 `contact`.`last-discovery` AS `last-discovery`,
2474 `contact`.`contact-type` AS `contact-type`,
2475 `contact`.`manually-approve` AS `manually-approve`,
2476 `contact`.`unsearchable` AS `unsearchable`,
2477 `contact`.`sensitive` AS `sensitive`,
2478 `contact`.`baseurl` AS `baseurl`,
2479 `contact`.`gsid` AS `gsid`,
2480 `ucontact`.`info` AS `info`,
2481 `contact`.`bdyear` AS `bdyear`,
2482 `contact`.`bd` AS `bd`,
2483 `contact`.`poco` AS `poco`,
2484 `contact`.`name-date` AS `name-date`,
2485 `contact`.`uri-date` AS `uri-date`,
2486 `contact`.`avatar-date` AS `avatar-date`,
2487 `contact`.`term-date` AS `term-date`,
2488 `contact`.`hidden` AS `global-ignored`,
2489 `contact`.`blocked` AS `global-blocked`,
2490 `ucontact`.`hidden` AS `hidden`,
2491 `ucontact`.`archive` AS `archive`,
2492 `ucontact`.`pending` AS `pending`,
2493 `ucontact`.`deleted` AS `deleted`,
2494 `ucontact`.`notify_new_posts` AS `notify_new_posts`,
2495 `ucontact`.`fetch_further_information` AS `fetch_further_information`,
2496 `ucontact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2497 `ucontact`.`rating` AS `rating`,
2498 `ucontact`.`readonly` AS `readonly`,
2499 `ucontact`.`blocked` AS `blocked`,
2500 `ucontact`.`block_reason` AS `block_reason`,
2501 `ucontact`.`subhub` AS `subhub`,
2502 `ucontact`.`hub-verify` AS `hub-verify`,
2503 `ucontact`.`reason` AS `reason`,
2504 `contact`.`request` AS `dfrn-request`,
2505 `contact`.`notify` AS `dfrn-notify`,
2506 `contact`.`poll` AS `dfrn-poll`,
2507 `contact`.`confirm` AS `dfrn-confirm`,
2508 `fcontact`.`guid` AS `diaspora-guid`,
2509 `fcontact`.`batch` AS `diaspora-batch`,
2510 `fcontact`.`notify` AS `diaspora-notify`,
2511 `fcontact`.`poll` AS `diaspora-poll`,
2512 `fcontact`.`alias` AS `diaspora-alias`,
2513 `apcontact`.`uuid` AS `ap-uuid`,
2514 `apcontact`.`type` AS `ap-type`,
2515 `apcontact`.`following` AS `ap-following`,
2516 `apcontact`.`followers` AS `ap-followers`,
2517 `apcontact`.`inbox` AS `ap-inbox`,
2518 `apcontact`.`outbox` AS `ap-outbox`,
2519 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2520 `apcontact`.`generator` AS `ap-generator`,
2521 `apcontact`.`following_count` AS `ap-following_count`,
2522 `apcontact`.`followers_count` AS `ap-followers_count`,
2523 `apcontact`.`statuses_count` AS `ap-statuses_count`
2524 FROM `contact` AS `ucontact`
2525 INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
2526 LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id`
2527 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
2528 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = `ucontact`.`uri-id` AND `fcontact`.`network` = 'dspr';
2531 -- VIEW pending-view
2533 DROP VIEW IF EXISTS `pending-view`;
2534 CREATE VIEW `pending-view` AS SELECT
2535 `register`.`id` AS `id`,
2536 `register`.`hash` AS `hash`,
2537 `register`.`created` AS `created`,
2538 `register`.`uid` AS `uid`,
2539 `register`.`password` AS `password`,
2540 `register`.`language` AS `language`,
2541 `register`.`note` AS `note`,
2542 `contact`.`self` AS `self`,
2543 `contact`.`name` AS `name`,
2544 `contact`.`url` AS `url`,
2545 `contact`.`micro` AS `micro`,
2546 `user`.`email` AS `email`,
2547 `contact`.`nick` AS `nick`
2549 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2550 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2553 -- VIEW tag-search-view
2555 DROP VIEW IF EXISTS `tag-search-view`;
2556 CREATE VIEW `tag-search-view` AS SELECT
2557 `post-tag`.`uri-id` AS `uri-id`,
2558 `post-user`.`uid` AS `uid`,
2559 `post-user`.`id` AS `iid`,
2560 `post-user`.`private` AS `private`,
2561 `post-user`.`wall` AS `wall`,
2562 `post-user`.`origin` AS `origin`,
2563 `post-user`.`global` AS `global`,
2564 `post-user`.`gravity` AS `gravity`,
2565 `post-user`.`received` AS `received`,
2566 `post-user`.`network` AS `network`,
2567 `post-user`.`author-id` AS `author-id`,
2568 `tag`.`name` AS `name`
2570 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
2571 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
2572 WHERE `post-tag`.`type` = 1;
2575 -- VIEW workerqueue-view
2577 DROP VIEW IF EXISTS `workerqueue-view`;
2578 CREATE VIEW `workerqueue-view` AS SELECT
2579 `process`.`pid` AS `pid`,
2580 `workerqueue`.`priority` AS `priority`
2582 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
2583 WHERE NOT `workerqueue`.`done`;
2586 -- VIEW profile_field-view
2588 DROP VIEW IF EXISTS `profile_field-view`;
2589 CREATE VIEW `profile_field-view` AS SELECT
2590 `profile_field`.`id` AS `id`,
2591 `profile_field`.`uid` AS `uid`,
2592 `profile_field`.`label` AS `label`,
2593 `profile_field`.`value` AS `value`,
2594 `profile_field`.`order` AS `order`,
2595 `profile_field`.`psid` AS `psid`,
2596 `permissionset`.`allow_cid` AS `allow_cid`,
2597 `permissionset`.`allow_gid` AS `allow_gid`,
2598 `permissionset`.`deny_cid` AS `deny_cid`,
2599 `permissionset`.`deny_gid` AS `deny_gid`,
2600 `profile_field`.`created` AS `created`,
2601 `profile_field`.`edited` AS `edited`
2602 FROM `profile_field`
2603 INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`;