1 -- ------------------------------------------
2 -- Friendica 2021.09-dev (Siberian Iris)
3 -- DB_UPDATE_VERSION 1433
4 -- ------------------------------------------
10 CREATE TABLE IF NOT EXISTS `gserver` (
11 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
12 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
13 `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
14 `version` varchar(255) NOT NULL DEFAULT '' COMMENT '',
15 `site_name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
16 `info` text COMMENT '',
17 `register_policy` tinyint NOT NULL DEFAULT 0 COMMENT '',
18 `registered-users` int unsigned NOT NULL DEFAULT 0 COMMENT 'Number of registered users',
19 `directory-type` tinyint DEFAULT 0 COMMENT 'Type of directory service (Poco, Mastodon)',
20 `poco` varchar(255) NOT NULL DEFAULT '' COMMENT '',
21 `noscrape` varchar(255) NOT NULL DEFAULT '' COMMENT '',
22 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
23 `protocol` tinyint unsigned COMMENT 'The protocol of the server',
24 `platform` varchar(255) NOT NULL DEFAULT '' COMMENT '',
25 `relay-subscribe` boolean NOT NULL DEFAULT '0' COMMENT 'Has the server subscribed to the relay system',
26 `relay-scope` varchar(10) NOT NULL DEFAULT '' COMMENT 'The scope of messages that the server wants to get',
27 `detection-method` tinyint unsigned COMMENT 'Method that had been used to detect that server',
28 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
29 `last_poco_query` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
30 `last_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Last successful connection request',
31 `last_failure` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Last failed connection request',
32 `failed` boolean COMMENT 'Connection failed',
33 `next_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Next connection request',
35 UNIQUE INDEX `nurl` (`nurl`(190)),
36 INDEX `next_contact` (`next_contact`),
37 INDEX `network` (`network`)
38 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Global servers';
43 CREATE TABLE IF NOT EXISTS `user` (
44 `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
45 `parent-uid` mediumint unsigned COMMENT 'The parent user that has full control about this user',
46 `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
47 `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
48 `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
49 `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
50 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
51 `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
52 `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
53 `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
54 `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
55 `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
56 `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
57 `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
58 `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
59 `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
60 `pubkey` text COMMENT 'RSA public key 4096 bit',
61 `prvkey` text COMMENT 'RSA private key 4096 bit',
62 `spubkey` text COMMENT '',
63 `sprvkey` text COMMENT '',
64 `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
65 `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
66 `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
67 `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unkown viewers',
68 `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
69 `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
70 `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
71 `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
72 `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
73 `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
74 `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
75 `pwdreset` varchar(255) COMMENT 'Password reset request token',
76 `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
77 `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
78 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
79 `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
80 `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
81 `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
82 `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
83 `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
84 `allow_cid` mediumtext COMMENT 'default permission for this user',
85 `allow_gid` mediumtext COMMENT 'default permission for this user',
86 `deny_cid` mediumtext COMMENT 'default permission for this user',
87 `deny_gid` mediumtext COMMENT 'default permission for this user',
88 `openidserver` text COMMENT '',
90 INDEX `nickname` (`nickname`(32)),
91 INDEX `parent-uid` (`parent-uid`),
92 INDEX `guid` (`guid`),
93 INDEX `email` (`email`(64)),
94 FOREIGN KEY (`parent-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
95 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
100 CREATE TABLE IF NOT EXISTS `item-uri` (
101 `id` int unsigned NOT NULL auto_increment,
102 `uri` varbinary(255) NOT NULL COMMENT 'URI of an item',
103 `guid` varbinary(255) COMMENT 'A unique identifier for an item',
105 UNIQUE INDEX `uri` (`uri`),
106 INDEX `guid` (`guid`)
107 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
112 CREATE TABLE IF NOT EXISTS `contact` (
113 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
114 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
115 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
116 `updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last contact update',
117 `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
118 `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
119 `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
120 `duplex` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
121 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network of the contact',
122 `protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
123 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
124 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
125 `location` varchar(255) DEFAULT '' COMMENT '',
126 `about` text COMMENT '',
127 `keywords` text COMMENT 'public keywords (interests) of the contact',
128 `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
129 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
130 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
131 `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
132 `avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '',
133 `photo` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
134 `thumb` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
135 `micro` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
136 `header` varchar(255) COMMENT 'Header picture',
137 `site-pubkey` text COMMENT 'Deprecated',
138 `issued-id` varchar(255) NOT NULL DEFAULT '' COMMENT 'Deprecated',
139 `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT 'Deprecated',
140 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
141 `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
142 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
143 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
144 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
145 `pubkey` text COMMENT 'RSA public key 4096 bit',
146 `prvkey` text COMMENT 'RSA private key 4096 bit',
147 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
148 `request` varchar(255) COMMENT '',
149 `notify` varchar(255) COMMENT '',
150 `poll` varchar(255) COMMENT '',
151 `confirm` varchar(255) COMMENT '',
152 `subscribe` varchar(255) COMMENT '',
153 `poco` varchar(255) COMMENT '',
154 `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
155 `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
156 `usehub` boolean NOT NULL DEFAULT '0' COMMENT '',
157 `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
158 `hub-verify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
159 `last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
160 `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
161 `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
162 `failed` boolean COMMENT 'Connection failed',
163 `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
164 `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
165 `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
166 `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
167 `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
168 `last-discovery` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last follower discovery',
169 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
170 `blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
171 `block_reason` text COMMENT 'Node-wide block reason',
172 `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
173 `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
174 `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum',
175 `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group',
176 `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT '',
177 `manually-approve` boolean COMMENT '',
178 `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
179 `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
180 `pending` boolean NOT NULL DEFAULT '1' COMMENT '',
181 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
182 `rating` tinyint NOT NULL DEFAULT 0 COMMENT '',
183 `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
184 `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
185 `baseurl` varchar(255) DEFAULT '' COMMENT 'baseurl of the contact',
186 `gsid` int unsigned COMMENT 'Global Server ID',
187 `reason` text COMMENT '',
188 `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT '',
189 `info` mediumtext COMMENT '',
190 `profile-id` int unsigned COMMENT 'Deprecated',
191 `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
192 `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
193 `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
194 `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
195 `ffi_keyword_denylist` text COMMENT '',
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 `adjust` boolean NOT NULL DEFAULT '1' COMMENT 'adjust to timezone of the recipient (0 or 1)',
569 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
570 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
571 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
572 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
573 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
575 INDEX `uid_start` (`uid`,`start`),
577 INDEX `uri-id` (`uri-id`),
578 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
579 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
580 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
581 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
586 CREATE TABLE IF NOT EXISTS `fcontact` (
587 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
588 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
589 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
590 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the fcontact url',
591 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
592 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
593 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
594 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
595 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
596 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
597 `notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
598 `poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
599 `confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
600 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
601 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
602 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
603 `pubkey` text COMMENT '',
604 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
606 INDEX `addr` (`addr`(32)),
607 UNIQUE INDEX `url` (`url`(190)),
608 UNIQUE INDEX `uri-id` (`uri-id`),
609 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
610 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
615 CREATE TABLE IF NOT EXISTS `fsuggest` (
616 `id` int unsigned NOT NULL auto_increment COMMENT '',
617 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
618 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
619 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
620 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
621 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
622 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
623 `note` text COMMENT '',
624 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
628 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
629 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
630 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
635 CREATE TABLE IF NOT EXISTS `group` (
636 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
637 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
638 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
639 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
640 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
643 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
644 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
647 -- TABLE group_member
649 CREATE TABLE IF NOT EXISTS `group_member` (
650 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
651 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
652 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
654 INDEX `contactid` (`contact-id`),
655 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
656 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
657 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
658 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
663 CREATE TABLE IF NOT EXISTS `gserver-tag` (
664 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
665 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
666 PRIMARY KEY(`gserver-id`,`tag`),
668 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
669 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
674 CREATE TABLE IF NOT EXISTS `hook` (
675 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
676 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
677 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
678 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
679 `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',
681 INDEX `priority` (`priority`),
682 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
683 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
688 CREATE TABLE IF NOT EXISTS `host` (
689 `id` tinyint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
690 `name` varchar(128) NOT NULL DEFAULT '' COMMENT 'The hostname',
692 UNIQUE INDEX `name` (`name`)
693 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Hostname';
696 -- TABLE inbox-status
698 CREATE TABLE IF NOT EXISTS `inbox-status` (
699 `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
700 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
701 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
702 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
703 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
704 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
705 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
707 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
712 CREATE TABLE IF NOT EXISTS `intro` (
713 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
714 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
715 `fid` int unsigned COMMENT '',
716 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
717 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
718 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
719 `note` text COMMENT '',
720 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
721 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
722 `blocked` boolean NOT NULL DEFAULT '1' COMMENT '',
723 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
725 INDEX `contact-id` (`contact-id`),
727 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
728 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
729 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
734 CREATE TABLE IF NOT EXISTS `locks` (
735 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
736 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
737 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
738 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
739 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
741 INDEX `name_expires` (`name`,`expires`)
742 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
747 CREATE TABLE IF NOT EXISTS `mail` (
748 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
749 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
750 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
751 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
752 `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
753 `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
754 `contact-id` varchar(255) COMMENT 'contact.id',
755 `author-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the author of the mail',
756 `convid` int unsigned COMMENT 'conv.id',
757 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
758 `body` mediumtext COMMENT '',
759 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
760 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
761 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
762 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
763 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
764 `uri-id` int unsigned COMMENT 'Item-uri id of the related mail',
765 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
766 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related mail',
767 `thr-parent` varchar(255) COMMENT '',
768 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
769 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
771 INDEX `uid_seen` (`uid`,`seen`),
772 INDEX `convid` (`convid`),
773 INDEX `uri` (`uri`(64)),
774 INDEX `parent-uri` (`parent-uri`(64)),
775 INDEX `contactid` (`contact-id`(32)),
776 INDEX `author-id` (`author-id`),
777 INDEX `uri-id` (`uri-id`),
778 INDEX `parent-uri-id` (`parent-uri-id`),
779 INDEX `thr-parent-id` (`thr-parent-id`),
780 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
781 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
782 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
783 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
784 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
785 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
790 CREATE TABLE IF NOT EXISTS `mailacct` (
791 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
792 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
793 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
794 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
795 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
796 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
797 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
798 `pass` text COMMENT '',
799 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
800 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
801 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
802 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
803 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
806 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
807 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
812 CREATE TABLE IF NOT EXISTS `manage` (
813 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
814 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
815 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
817 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
819 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
820 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
821 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
824 -- TABLE notification
826 CREATE TABLE IF NOT EXISTS `notification` (
827 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
828 `uid` mediumint unsigned COMMENT 'Owner User id',
829 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
830 `type` tinyint unsigned COMMENT '',
831 `actor-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the actor that caused the notification',
832 `target-uri-id` int unsigned COMMENT 'Item-uri id of the related post',
833 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
834 `created` datetime COMMENT '',
835 `seen` boolean DEFAULT '0' COMMENT '',
837 UNIQUE INDEX `uid_vid_type_actor-id_target-uri-id` (`uid`,`vid`,`type`,`actor-id`,`target-uri-id`),
839 INDEX `actor-id` (`actor-id`),
840 INDEX `target-uri-id` (`target-uri-id`),
841 INDEX `parent-uri-id` (`parent-uri-id`),
842 INDEX `seen_uid` (`seen`,`uid`),
843 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
844 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
845 FOREIGN KEY (`actor-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
846 FOREIGN KEY (`target-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
847 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
848 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
853 CREATE TABLE IF NOT EXISTS `notify` (
854 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
855 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
856 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
857 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
858 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
859 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
860 `msg` mediumtext COMMENT '',
861 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
862 `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
863 `iid` int unsigned COMMENT '',
864 `parent` int unsigned COMMENT '',
865 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
866 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
867 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
868 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
869 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
870 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
871 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
873 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
874 INDEX `uid_date` (`uid`,`date`),
875 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
876 INDEX `uri-id` (`uri-id`),
877 INDEX `parent-uri-id` (`parent-uri-id`),
878 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
879 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
880 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
881 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
884 -- TABLE notify-threads
886 CREATE TABLE IF NOT EXISTS `notify-threads` (
887 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
888 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
889 `master-parent-item` int unsigned COMMENT 'Deprecated',
890 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
891 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
892 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
894 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
895 INDEX `receiver-uid` (`receiver-uid`),
896 INDEX `notify-id` (`notify-id`),
897 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
898 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
899 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
900 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
905 CREATE TABLE IF NOT EXISTS `oembed` (
906 `url` varbinary(255) NOT NULL COMMENT 'page url',
907 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
908 `content` mediumtext COMMENT 'OEmbed data of the page',
909 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
910 PRIMARY KEY(`url`,`maxwidth`),
911 INDEX `created` (`created`)
912 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
915 -- TABLE openwebauth-token
917 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
918 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
919 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
920 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
921 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
922 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
923 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
926 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
927 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
932 CREATE TABLE IF NOT EXISTS `parsed_url` (
933 `url_hash` binary(64) NOT NULL COMMENT 'page url hash',
934 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
935 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
936 `url` text NOT NULL COMMENT 'page url',
937 `content` mediumtext COMMENT 'page data',
938 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
939 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration',
940 PRIMARY KEY(`url_hash`,`guessing`,`oembed`),
941 INDEX `created` (`created`),
942 INDEX `expires` (`expires`)
943 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
948 CREATE TABLE IF NOT EXISTS `pconfig` (
949 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
950 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
951 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
952 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
953 `v` mediumtext COMMENT 'Value',
955 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
956 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
957 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
962 CREATE TABLE IF NOT EXISTS `photo` (
963 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
964 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
965 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
966 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
967 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
968 `hash` char(32) COMMENT 'hash value of the photo',
969 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
970 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
971 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
972 `desc` text COMMENT '',
973 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
974 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
975 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
976 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
977 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
978 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
979 `data` mediumblob NOT NULL COMMENT '',
980 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
981 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
982 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
983 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
984 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
985 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
986 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
987 `backend-class` tinytext COMMENT 'Storage backend class',
988 `backend-ref` text COMMENT 'Storage backend data reference',
989 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
991 INDEX `contactid` (`contact-id`),
992 INDEX `uid_contactid` (`uid`,`contact-id`),
993 INDEX `uid_profile` (`uid`,`profile`),
994 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
995 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
996 INDEX `resource-id` (`resource-id`),
997 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
998 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
999 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1004 CREATE TABLE IF NOT EXISTS `post` (
1005 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1006 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1007 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1008 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1009 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1010 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1011 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1012 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1013 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1014 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1015 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1016 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1017 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1018 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1019 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1020 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1021 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1022 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1023 PRIMARY KEY(`uri-id`),
1024 INDEX `parent-uri-id` (`parent-uri-id`),
1025 INDEX `thr-parent-id` (`thr-parent-id`),
1026 INDEX `external-id` (`external-id`),
1027 INDEX `owner-id` (`owner-id`),
1028 INDEX `author-id` (`author-id`),
1029 INDEX `causer-id` (`causer-id`),
1030 INDEX `vid` (`vid`),
1031 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1032 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1033 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1034 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1035 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1036 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1037 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1038 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1039 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
1042 -- TABLE post-category
1044 CREATE TABLE IF NOT EXISTS `post-category` (
1045 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1046 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1047 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1048 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1049 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1050 INDEX `uri-id` (`tid`),
1051 INDEX `uid` (`uid`),
1052 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1053 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1054 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1055 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1058 -- TABLE post-content
1060 CREATE TABLE IF NOT EXISTS `post-content` (
1061 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1062 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1063 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1064 `body` mediumtext COMMENT 'item body content',
1065 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1066 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1067 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1068 `language` text COMMENT 'Language information about this post',
1069 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1070 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1071 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1072 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1073 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1074 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1075 `target` text COMMENT 'JSON encoded target structure if used',
1076 `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',
1077 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1078 PRIMARY KEY(`uri-id`),
1079 INDEX `plink` (`plink`(191)),
1080 INDEX `resource-id` (`resource-id`),
1081 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
1082 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1083 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1086 -- TABLE post-delivery-data
1088 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1089 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1090 `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',
1091 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1092 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1093 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1094 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1095 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1096 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1097 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1098 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1099 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1100 PRIMARY KEY(`uri-id`),
1101 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1102 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1107 CREATE TABLE IF NOT EXISTS `post-link` (
1108 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1109 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1110 `url` varbinary(511) NOT NULL COMMENT 'External URL',
1111 `mimetype` varchar(60) COMMENT '',
1113 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1114 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1115 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post related external links';
1120 CREATE TABLE IF NOT EXISTS `post-media` (
1121 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1122 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1123 `url` varbinary(511) NOT NULL COMMENT 'Media URL',
1124 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1125 `mimetype` varchar(60) COMMENT '',
1126 `height` smallint unsigned COMMENT 'Height of the media',
1127 `width` smallint unsigned COMMENT 'Width of the media',
1128 `size` int unsigned COMMENT 'Media size',
1129 `preview` varbinary(255) COMMENT 'Preview URL',
1130 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1131 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1132 `description` text COMMENT '',
1133 `name` varchar(255) COMMENT 'Name of the media',
1134 `author-url` varbinary(255) COMMENT 'URL of the author of the media',
1135 `author-name` varchar(255) COMMENT 'Name of the author of the media',
1136 `author-image` varbinary(255) COMMENT 'Image of the author of the media',
1137 `publisher-url` varbinary(255) COMMENT 'URL of the publisher of the media',
1138 `publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
1139 `publisher-image` varbinary(255) COMMENT 'Image of the publisher of the media',
1141 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1142 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1143 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1148 CREATE TABLE IF NOT EXISTS `post-tag` (
1149 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1150 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1151 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1152 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1153 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1154 INDEX `tid` (`tid`),
1155 INDEX `cid` (`cid`),
1156 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1157 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1158 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1159 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1162 -- TABLE post-thread
1164 CREATE TABLE IF NOT EXISTS `post-thread` (
1165 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1166 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1167 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1168 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1169 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1170 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1171 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1172 `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',
1173 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1174 PRIMARY KEY(`uri-id`),
1175 INDEX `owner-id` (`owner-id`),
1176 INDEX `author-id` (`author-id`),
1177 INDEX `causer-id` (`causer-id`),
1178 INDEX `received` (`received`),
1179 INDEX `commented` (`commented`),
1180 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1181 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1182 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1183 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1184 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1189 CREATE TABLE IF NOT EXISTS `post-user` (
1190 `id` int unsigned NOT NULL auto_increment,
1191 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1192 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1193 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1194 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1195 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1196 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1197 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1198 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1199 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1200 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1201 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1202 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1203 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1204 `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
1205 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1206 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1207 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1208 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1209 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1210 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1211 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1212 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1213 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1214 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1215 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1216 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1217 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1218 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1219 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1221 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1222 INDEX `uri-id` (`uri-id`),
1223 INDEX `parent-uri-id` (`parent-uri-id`),
1224 INDEX `thr-parent-id` (`thr-parent-id`),
1225 INDEX `external-id` (`external-id`),
1226 INDEX `owner-id` (`owner-id`),
1227 INDEX `author-id` (`author-id`),
1228 INDEX `causer-id` (`causer-id`),
1229 INDEX `vid` (`vid`),
1230 INDEX `contact-id` (`contact-id`),
1231 INDEX `event-id` (`event-id`),
1232 INDEX `psid` (`psid`),
1233 INDEX `author-id_uid` (`author-id`,`uid`),
1234 INDEX `author-id_received` (`author-id`,`received`),
1235 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1236 INDEX `uid_contactid` (`uid`,`contact-id`),
1237 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1238 INDEX `uid_unseen` (`uid`,`unseen`),
1239 INDEX `uid_hidden_uri-id` (`uid`,`hidden`,`uri-id`),
1240 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1241 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1242 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1243 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1244 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1245 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1246 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1247 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1248 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1249 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1250 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1251 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1252 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1255 -- TABLE post-thread-user
1257 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1258 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1259 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1260 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1261 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1262 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1263 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1264 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1265 `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',
1266 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1267 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1268 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'The thread is pinned on the profile page',
1269 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1270 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1271 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1272 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1273 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1274 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1275 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1276 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1277 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1278 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1279 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1280 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1281 PRIMARY KEY(`uid`,`uri-id`),
1282 INDEX `uri-id` (`uri-id`),
1283 INDEX `owner-id` (`owner-id`),
1284 INDEX `author-id` (`author-id`),
1285 INDEX `causer-id` (`causer-id`),
1286 INDEX `uid` (`uid`),
1287 INDEX `contact-id` (`contact-id`),
1288 INDEX `psid` (`psid`),
1289 INDEX `post-user-id` (`post-user-id`),
1290 INDEX `commented` (`commented`),
1291 INDEX `uid_received` (`uid`,`received`),
1292 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1293 INDEX `uid_pinned` (`uid`,`pinned`),
1294 INDEX `uid_commented` (`uid`,`commented`),
1295 INDEX `uid_starred` (`uid`,`starred`),
1296 INDEX `uid_mention` (`uid`,`mention`),
1297 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1298 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1299 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1300 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1301 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1302 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1303 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1304 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1305 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1308 -- TABLE post-user-notification
1310 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1311 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1312 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1313 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1314 PRIMARY KEY(`uid`,`uri-id`),
1315 INDEX `uri-id` (`uri-id`),
1316 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1317 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1318 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1323 CREATE TABLE IF NOT EXISTS `process` (
1324 `pid` int unsigned NOT NULL COMMENT '',
1325 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1326 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1328 INDEX `command` (`command`)
1329 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1334 CREATE TABLE IF NOT EXISTS `profile` (
1335 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1336 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1337 `profile-name` varchar(255) COMMENT 'Deprecated',
1338 `is-default` boolean COMMENT 'Deprecated',
1339 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1340 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1341 `pdesc` varchar(255) COMMENT 'Deprecated',
1342 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1343 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1344 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1345 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1346 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1347 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1348 `hometown` varchar(255) COMMENT 'Deprecated',
1349 `gender` varchar(32) COMMENT 'Deprecated',
1350 `marital` varchar(255) COMMENT 'Deprecated',
1351 `with` text COMMENT 'Deprecated',
1352 `howlong` datetime COMMENT 'Deprecated',
1353 `sexual` varchar(255) COMMENT 'Deprecated',
1354 `politic` varchar(255) COMMENT 'Deprecated',
1355 `religion` varchar(255) COMMENT 'Deprecated',
1356 `pub_keywords` text COMMENT '',
1357 `prv_keywords` text COMMENT '',
1358 `likes` text COMMENT 'Deprecated',
1359 `dislikes` text COMMENT 'Deprecated',
1360 `about` text COMMENT 'Profile description',
1361 `summary` varchar(255) COMMENT 'Deprecated',
1362 `music` text COMMENT 'Deprecated',
1363 `book` text COMMENT 'Deprecated',
1364 `tv` text COMMENT 'Deprecated',
1365 `film` text COMMENT 'Deprecated',
1366 `interest` text COMMENT 'Deprecated',
1367 `romance` text COMMENT 'Deprecated',
1368 `work` text COMMENT 'Deprecated',
1369 `education` text COMMENT 'Deprecated',
1370 `contact` text COMMENT 'Deprecated',
1371 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1372 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
1373 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
1374 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1375 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1376 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1377 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1379 INDEX `uid_is-default` (`uid`,`is-default`),
1380 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1381 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1382 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1385 -- TABLE profile_field
1387 CREATE TABLE IF NOT EXISTS `profile_field` (
1388 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1389 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1390 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1391 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1392 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1393 `value` text COMMENT 'Value of the field',
1394 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1395 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1397 INDEX `uid` (`uid`),
1398 INDEX `order` (`order`),
1399 INDEX `psid` (`psid`),
1400 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1401 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1402 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1405 -- TABLE push_subscriber
1407 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1408 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1409 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1410 `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1411 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1412 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1413 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1414 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1415 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1416 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1417 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1419 INDEX `next_try` (`next_try`),
1420 INDEX `uid` (`uid`),
1421 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1422 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1427 CREATE TABLE IF NOT EXISTS `register` (
1428 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1429 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1430 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1431 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1432 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1433 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1434 `note` text COMMENT '',
1436 INDEX `uid` (`uid`),
1437 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1438 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1443 CREATE TABLE IF NOT EXISTS `search` (
1444 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1445 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1446 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1448 INDEX `uid_term` (`uid`,`term`(64)),
1449 INDEX `term` (`term`(64)),
1450 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1451 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1456 CREATE TABLE IF NOT EXISTS `session` (
1457 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1458 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1459 `data` text COMMENT '',
1460 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1462 INDEX `sid` (`sid`(64)),
1463 INDEX `expire` (`expire`)
1464 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1469 CREATE TABLE IF NOT EXISTS `storage` (
1470 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1471 `data` longblob NOT NULL COMMENT 'file data',
1473 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1478 CREATE TABLE IF NOT EXISTS `userd` (
1479 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1480 `username` varchar(255) NOT NULL COMMENT '',
1482 INDEX `username` (`username`(32))
1483 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1486 -- TABLE user-contact
1488 CREATE TABLE IF NOT EXISTS `user-contact` (
1489 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1490 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1491 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1492 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1493 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1494 PRIMARY KEY(`uid`,`cid`),
1495 INDEX `cid` (`cid`),
1496 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1497 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1498 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1503 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1504 `key` int NOT NULL COMMENT '',
1505 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1507 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1510 -- VIEW application-view
1512 DROP VIEW IF EXISTS `application-view`;
1513 CREATE VIEW `application-view` AS SELECT
1514 `application`.`id` AS `id`,
1515 `application-token`.`uid` AS `uid`,
1516 `application`.`name` AS `name`,
1517 `application`.`redirect_uri` AS `redirect_uri`,
1518 `application`.`website` AS `website`,
1519 `application`.`client_id` AS `client_id`,
1520 `application`.`client_secret` AS `client_secret`,
1521 `application-token`.`code` AS `code`,
1522 `application-token`.`access_token` AS `access_token`,
1523 `application-token`.`created_at` AS `created_at`,
1524 `application-token`.`scopes` AS `scopes`,
1525 `application-token`.`read` AS `read`,
1526 `application-token`.`write` AS `write`,
1527 `application-token`.`follow` AS `follow`,
1528 `application-token`.`push` AS `push`
1529 FROM `application-token`
1530 INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`;
1533 -- VIEW post-user-view
1535 DROP VIEW IF EXISTS `post-user-view`;
1536 CREATE VIEW `post-user-view` AS SELECT
1537 `post-user`.`id` AS `id`,
1538 `post-user`.`id` AS `post-user-id`,
1539 `post-user`.`uid` AS `uid`,
1540 `parent-post`.`id` AS `parent`,
1541 `item-uri`.`uri` AS `uri`,
1542 `post-user`.`uri-id` AS `uri-id`,
1543 `parent-item-uri`.`uri` AS `parent-uri`,
1544 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1545 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1546 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1547 `item-uri`.`guid` AS `guid`,
1548 `post-user`.`wall` AS `wall`,
1549 `post-user`.`gravity` AS `gravity`,
1550 `external-item-uri`.`uri` AS `extid`,
1551 `post-user`.`external-id` AS `external-id`,
1552 `post-user`.`created` AS `created`,
1553 `post-user`.`edited` AS `edited`,
1554 `post-thread-user`.`commented` AS `commented`,
1555 `post-user`.`received` AS `received`,
1556 `post-thread-user`.`changed` AS `changed`,
1557 `post-user`.`post-type` AS `post-type`,
1558 `post-user`.`post-reason` AS `post-reason`,
1559 `post-user`.`private` AS `private`,
1560 `post-thread-user`.`pubmail` AS `pubmail`,
1561 `post-user`.`visible` AS `visible`,
1562 `post-thread-user`.`starred` AS `starred`,
1563 `post-thread-user`.`pinned` AS `pinned`,
1564 `post-user`.`unseen` AS `unseen`,
1565 `post-user`.`deleted` AS `deleted`,
1566 `post-user`.`origin` AS `origin`,
1567 `post-thread-user`.`origin` AS `parent-origin`,
1568 `post-thread-user`.`forum_mode` AS `forum_mode`,
1569 `post-thread-user`.`mention` AS `mention`,
1570 `post-user`.`global` AS `global`,
1571 `post-user`.`network` AS `network`,
1572 `post-user`.`vid` AS `vid`,
1573 `post-user`.`psid` AS `psid`,
1574 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1575 `post-content`.`title` AS `title`,
1576 `post-content`.`content-warning` AS `content-warning`,
1577 `post-content`.`raw-body` AS `raw-body`,
1578 `post-content`.`body` AS `body`,
1579 `post-content`.`rendered-hash` AS `rendered-hash`,
1580 `post-content`.`rendered-html` AS `rendered-html`,
1581 `post-content`.`language` AS `language`,
1582 `post-content`.`plink` AS `plink`,
1583 `post-content`.`location` AS `location`,
1584 `post-content`.`coord` AS `coord`,
1585 `post-content`.`app` AS `app`,
1586 `post-content`.`object-type` AS `object-type`,
1587 `post-content`.`object` AS `object`,
1588 `post-content`.`target-type` AS `target-type`,
1589 `post-content`.`target` AS `target`,
1590 `post-content`.`resource-id` AS `resource-id`,
1591 `post-user`.`contact-id` AS `contact-id`,
1592 `contact`.`url` AS `contact-link`,
1593 `contact`.`addr` AS `contact-addr`,
1594 `contact`.`name` AS `contact-name`,
1595 `contact`.`nick` AS `contact-nick`,
1596 `contact`.`thumb` AS `contact-avatar`,
1597 `contact`.`network` AS `contact-network`,
1598 `contact`.`blocked` AS `contact-blocked`,
1599 `contact`.`hidden` AS `contact-hidden`,
1600 `contact`.`readonly` AS `contact-readonly`,
1601 `contact`.`archive` AS `contact-archive`,
1602 `contact`.`pending` AS `contact-pending`,
1603 `contact`.`rel` AS `contact-rel`,
1604 `contact`.`uid` AS `contact-uid`,
1605 `contact`.`contact-type` AS `contact-contact-type`,
1606 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1607 `contact`.`self` AS `self`,
1608 `contact`.`id` AS `cid`,
1609 `contact`.`alias` AS `alias`,
1610 `contact`.`photo` AS `photo`,
1611 `contact`.`name-date` AS `name-date`,
1612 `contact`.`uri-date` AS `uri-date`,
1613 `contact`.`avatar-date` AS `avatar-date`,
1614 `contact`.`thumb` AS `thumb`,
1615 `post-user`.`author-id` AS `author-id`,
1616 `author`.`url` AS `author-link`,
1617 `author`.`addr` AS `author-addr`,
1618 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1619 `author`.`nick` AS `author-nick`,
1620 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1621 `author`.`network` AS `author-network`,
1622 `author`.`blocked` AS `author-blocked`,
1623 `author`.`hidden` AS `author-hidden`,
1624 `post-user`.`owner-id` AS `owner-id`,
1625 `owner`.`url` AS `owner-link`,
1626 `owner`.`addr` AS `owner-addr`,
1627 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1628 `owner`.`nick` AS `owner-nick`,
1629 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1630 `owner`.`network` AS `owner-network`,
1631 `owner`.`blocked` AS `owner-blocked`,
1632 `owner`.`hidden` AS `owner-hidden`,
1633 `owner`.`contact-type` AS `owner-contact-type`,
1634 `post-user`.`causer-id` AS `causer-id`,
1635 `causer`.`url` AS `causer-link`,
1636 `causer`.`addr` AS `causer-addr`,
1637 `causer`.`name` AS `causer-name`,
1638 `causer`.`nick` AS `causer-nick`,
1639 `causer`.`thumb` AS `causer-avatar`,
1640 `causer`.`network` AS `causer-network`,
1641 `causer`.`blocked` AS `causer-blocked`,
1642 `causer`.`hidden` AS `causer-hidden`,
1643 `causer`.`contact-type` AS `causer-contact-type`,
1644 `post-delivery-data`.`postopts` AS `postopts`,
1645 `post-delivery-data`.`inform` AS `inform`,
1646 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1647 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1648 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1649 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1650 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1651 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1652 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1653 `post-user`.`event-id` AS `event-id`,
1654 `event`.`created` AS `event-created`,
1655 `event`.`edited` AS `event-edited`,
1656 `event`.`start` AS `event-start`,
1657 `event`.`finish` AS `event-finish`,
1658 `event`.`summary` AS `event-summary`,
1659 `event`.`desc` AS `event-desc`,
1660 `event`.`location` AS `event-location`,
1661 `event`.`type` AS `event-type`,
1662 `event`.`nofinish` AS `event-nofinish`,
1663 `event`.`adjust` AS `event-adjust`,
1664 `event`.`ignore` AS `event-ignore`,
1665 `diaspora-interaction`.`interaction` AS `signed_text`,
1666 `parent-item-uri`.`guid` AS `parent-guid`,
1667 `parent-post`.`network` AS `parent-network`,
1668 `parent-post`.`author-id` AS `parent-author-id`,
1669 `parent-post-author`.`url` AS `parent-author-link`,
1670 `parent-post-author`.`name` AS `parent-author-name`,
1671 `parent-post-author`.`network` AS `parent-author-network`,
1672 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1673 `parent-post-author`.`hidden` AS `parent-author-hidden`
1675 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
1676 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
1677 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
1678 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
1679 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
1680 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
1681 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1682 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1683 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1684 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1685 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1686 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
1687 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
1688 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
1689 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
1690 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
1691 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1694 -- VIEW post-thread-user-view
1696 DROP VIEW IF EXISTS `post-thread-user-view`;
1697 CREATE VIEW `post-thread-user-view` AS SELECT
1698 `post-user`.`id` AS `id`,
1699 `post-user`.`id` AS `post-user-id`,
1700 `post-thread-user`.`uid` AS `uid`,
1701 `parent-post`.`id` AS `parent`,
1702 `item-uri`.`uri` AS `uri`,
1703 `post-thread-user`.`uri-id` AS `uri-id`,
1704 `parent-item-uri`.`uri` AS `parent-uri`,
1705 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1706 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1707 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1708 `item-uri`.`guid` AS `guid`,
1709 `post-thread-user`.`wall` AS `wall`,
1710 `post-user`.`gravity` AS `gravity`,
1711 `external-item-uri`.`uri` AS `extid`,
1712 `post-user`.`external-id` AS `external-id`,
1713 `post-thread-user`.`created` AS `created`,
1714 `post-user`.`edited` AS `edited`,
1715 `post-thread-user`.`commented` AS `commented`,
1716 `post-thread-user`.`received` AS `received`,
1717 `post-thread-user`.`changed` AS `changed`,
1718 `post-user`.`post-type` AS `post-type`,
1719 `post-user`.`post-reason` AS `post-reason`,
1720 `post-user`.`private` AS `private`,
1721 `post-thread-user`.`pubmail` AS `pubmail`,
1722 `post-thread-user`.`ignored` AS `ignored`,
1723 `post-user`.`visible` AS `visible`,
1724 `post-thread-user`.`starred` AS `starred`,
1725 `post-thread-user`.`pinned` AS `pinned`,
1726 `post-thread-user`.`unseen` AS `unseen`,
1727 `post-user`.`deleted` AS `deleted`,
1728 `post-thread-user`.`origin` AS `origin`,
1729 `post-thread-user`.`forum_mode` AS `forum_mode`,
1730 `post-thread-user`.`mention` AS `mention`,
1731 `post-user`.`global` AS `global`,
1732 `post-thread-user`.`network` AS `network`,
1733 `post-user`.`vid` AS `vid`,
1734 `post-thread-user`.`psid` AS `psid`,
1735 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1736 `post-content`.`title` AS `title`,
1737 `post-content`.`content-warning` AS `content-warning`,
1738 `post-content`.`raw-body` AS `raw-body`,
1739 `post-content`.`body` AS `body`,
1740 `post-content`.`rendered-hash` AS `rendered-hash`,
1741 `post-content`.`rendered-html` AS `rendered-html`,
1742 `post-content`.`language` AS `language`,
1743 `post-content`.`plink` AS `plink`,
1744 `post-content`.`location` AS `location`,
1745 `post-content`.`coord` AS `coord`,
1746 `post-content`.`app` AS `app`,
1747 `post-content`.`object-type` AS `object-type`,
1748 `post-content`.`object` AS `object`,
1749 `post-content`.`target-type` AS `target-type`,
1750 `post-content`.`target` AS `target`,
1751 `post-content`.`resource-id` AS `resource-id`,
1752 `post-thread-user`.`contact-id` AS `contact-id`,
1753 `contact`.`url` AS `contact-link`,
1754 `contact`.`addr` AS `contact-addr`,
1755 `contact`.`name` AS `contact-name`,
1756 `contact`.`nick` AS `contact-nick`,
1757 `contact`.`thumb` AS `contact-avatar`,
1758 `contact`.`network` AS `contact-network`,
1759 `contact`.`blocked` AS `contact-blocked`,
1760 `contact`.`hidden` AS `contact-hidden`,
1761 `contact`.`readonly` AS `contact-readonly`,
1762 `contact`.`archive` AS `contact-archive`,
1763 `contact`.`pending` AS `contact-pending`,
1764 `contact`.`rel` AS `contact-rel`,
1765 `contact`.`uid` AS `contact-uid`,
1766 `contact`.`contact-type` AS `contact-contact-type`,
1767 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1768 `contact`.`self` AS `self`,
1769 `contact`.`id` AS `cid`,
1770 `contact`.`alias` AS `alias`,
1771 `contact`.`photo` AS `photo`,
1772 `contact`.`name-date` AS `name-date`,
1773 `contact`.`uri-date` AS `uri-date`,
1774 `contact`.`avatar-date` AS `avatar-date`,
1775 `contact`.`thumb` AS `thumb`,
1776 `post-thread-user`.`author-id` AS `author-id`,
1777 `author`.`url` AS `author-link`,
1778 `author`.`addr` AS `author-addr`,
1779 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1780 `author`.`nick` AS `author-nick`,
1781 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1782 `author`.`network` AS `author-network`,
1783 `author`.`blocked` AS `author-blocked`,
1784 `author`.`hidden` AS `author-hidden`,
1785 `post-thread-user`.`owner-id` AS `owner-id`,
1786 `owner`.`url` AS `owner-link`,
1787 `owner`.`addr` AS `owner-addr`,
1788 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1789 `owner`.`nick` AS `owner-nick`,
1790 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1791 `owner`.`network` AS `owner-network`,
1792 `owner`.`blocked` AS `owner-blocked`,
1793 `owner`.`hidden` AS `owner-hidden`,
1794 `owner`.`contact-type` AS `owner-contact-type`,
1795 `post-thread-user`.`causer-id` AS `causer-id`,
1796 `causer`.`url` AS `causer-link`,
1797 `causer`.`addr` AS `causer-addr`,
1798 `causer`.`name` AS `causer-name`,
1799 `causer`.`nick` AS `causer-nick`,
1800 `causer`.`thumb` AS `causer-avatar`,
1801 `causer`.`network` AS `causer-network`,
1802 `causer`.`blocked` AS `causer-blocked`,
1803 `causer`.`hidden` AS `causer-hidden`,
1804 `causer`.`contact-type` AS `causer-contact-type`,
1805 `post-delivery-data`.`postopts` AS `postopts`,
1806 `post-delivery-data`.`inform` AS `inform`,
1807 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1808 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1809 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1810 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1811 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1812 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1813 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1814 `post-user`.`event-id` AS `event-id`,
1815 `event`.`created` AS `event-created`,
1816 `event`.`edited` AS `event-edited`,
1817 `event`.`start` AS `event-start`,
1818 `event`.`finish` AS `event-finish`,
1819 `event`.`summary` AS `event-summary`,
1820 `event`.`desc` AS `event-desc`,
1821 `event`.`location` AS `event-location`,
1822 `event`.`type` AS `event-type`,
1823 `event`.`nofinish` AS `event-nofinish`,
1824 `event`.`adjust` AS `event-adjust`,
1825 `event`.`ignore` AS `event-ignore`,
1826 `diaspora-interaction`.`interaction` AS `signed_text`,
1827 `parent-item-uri`.`guid` AS `parent-guid`,
1828 `parent-post`.`network` AS `parent-network`,
1829 `parent-post`.`author-id` AS `parent-author-id`,
1830 `parent-post-author`.`url` AS `parent-author-link`,
1831 `parent-post-author`.`name` AS `parent-author-name`,
1832 `parent-post-author`.`network` AS `parent-author-network`,
1833 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1834 `parent-post-author`.`hidden` AS `parent-author-hidden`
1835 FROM `post-thread-user`
1836 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
1837 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
1838 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
1839 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
1840 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
1841 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
1842 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1843 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1844 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1845 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1846 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1847 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
1848 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
1849 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
1850 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
1851 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`
1852 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1857 DROP VIEW IF EXISTS `post-view`;
1858 CREATE VIEW `post-view` AS SELECT
1859 `item-uri`.`uri` AS `uri`,
1860 `post`.`uri-id` AS `uri-id`,
1861 `parent-item-uri`.`uri` AS `parent-uri`,
1862 `post`.`parent-uri-id` AS `parent-uri-id`,
1863 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1864 `post`.`thr-parent-id` AS `thr-parent-id`,
1865 `item-uri`.`guid` AS `guid`,
1866 `post`.`gravity` AS `gravity`,
1867 `external-item-uri`.`uri` AS `extid`,
1868 `post`.`external-id` AS `external-id`,
1869 `post`.`created` AS `created`,
1870 `post`.`edited` AS `edited`,
1871 `post-thread`.`commented` AS `commented`,
1872 `post`.`received` AS `received`,
1873 `post-thread`.`changed` AS `changed`,
1874 `post`.`post-type` AS `post-type`,
1875 `post`.`private` AS `private`,
1876 `post`.`visible` AS `visible`,
1877 `post`.`deleted` AS `deleted`,
1878 `post`.`global` AS `global`,
1879 `post`.`network` AS `network`,
1880 `post`.`vid` AS `vid`,
1881 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1882 `post-content`.`title` AS `title`,
1883 `post-content`.`content-warning` AS `content-warning`,
1884 `post-content`.`raw-body` AS `raw-body`,
1885 `post-content`.`body` AS `body`,
1886 `post-content`.`rendered-hash` AS `rendered-hash`,
1887 `post-content`.`rendered-html` AS `rendered-html`,
1888 `post-content`.`language` AS `language`,
1889 `post-content`.`plink` AS `plink`,
1890 `post-content`.`location` AS `location`,
1891 `post-content`.`coord` AS `coord`,
1892 `post-content`.`app` AS `app`,
1893 `post-content`.`object-type` AS `object-type`,
1894 `post-content`.`object` AS `object`,
1895 `post-content`.`target-type` AS `target-type`,
1896 `post-content`.`target` AS `target`,
1897 `post-content`.`resource-id` AS `resource-id`,
1898 `post`.`author-id` AS `contact-id`,
1899 `author`.`url` AS `contact-link`,
1900 `author`.`addr` AS `contact-addr`,
1901 `author`.`name` AS `contact-name`,
1902 `author`.`nick` AS `contact-nick`,
1903 `author`.`thumb` AS `contact-avatar`,
1904 `author`.`network` AS `contact-network`,
1905 `author`.`blocked` AS `contact-blocked`,
1906 `author`.`hidden` AS `contact-hidden`,
1907 `author`.`readonly` AS `contact-readonly`,
1908 `author`.`archive` AS `contact-archive`,
1909 `author`.`pending` AS `contact-pending`,
1910 `author`.`rel` AS `contact-rel`,
1911 `author`.`uid` AS `contact-uid`,
1912 `author`.`contact-type` AS `contact-contact-type`,
1913 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
1915 `author`.`id` AS `cid`,
1916 `author`.`alias` AS `alias`,
1917 `author`.`photo` AS `photo`,
1918 `author`.`name-date` AS `name-date`,
1919 `author`.`uri-date` AS `uri-date`,
1920 `author`.`avatar-date` AS `avatar-date`,
1921 `author`.`thumb` AS `thumb`,
1922 `post`.`author-id` AS `author-id`,
1923 `author`.`url` AS `author-link`,
1924 `author`.`addr` AS `author-addr`,
1925 `author`.`name` AS `author-name`,
1926 `author`.`nick` AS `author-nick`,
1927 `author`.`thumb` AS `author-avatar`,
1928 `author`.`network` AS `author-network`,
1929 `author`.`blocked` AS `author-blocked`,
1930 `author`.`hidden` AS `author-hidden`,
1931 `post`.`owner-id` AS `owner-id`,
1932 `owner`.`url` AS `owner-link`,
1933 `owner`.`addr` AS `owner-addr`,
1934 `owner`.`name` AS `owner-name`,
1935 `owner`.`nick` AS `owner-nick`,
1936 `owner`.`thumb` AS `owner-avatar`,
1937 `owner`.`network` AS `owner-network`,
1938 `owner`.`blocked` AS `owner-blocked`,
1939 `owner`.`hidden` AS `owner-hidden`,
1940 `owner`.`contact-type` AS `owner-contact-type`,
1941 `post`.`causer-id` AS `causer-id`,
1942 `causer`.`url` AS `causer-link`,
1943 `causer`.`addr` AS `causer-addr`,
1944 `causer`.`name` AS `causer-name`,
1945 `causer`.`nick` AS `causer-nick`,
1946 `causer`.`thumb` AS `causer-avatar`,
1947 `causer`.`network` AS `causer-network`,
1948 `causer`.`blocked` AS `causer-blocked`,
1949 `causer`.`hidden` AS `causer-hidden`,
1950 `causer`.`contact-type` AS `causer-contact-type`,
1951 `diaspora-interaction`.`interaction` AS `signed_text`,
1952 `parent-item-uri`.`guid` AS `parent-guid`,
1953 `parent-post`.`network` AS `parent-network`,
1954 `parent-post`.`author-id` AS `parent-author-id`,
1955 `parent-post-author`.`url` AS `parent-author-link`,
1956 `parent-post-author`.`name` AS `parent-author-name`,
1957 `parent-post-author`.`network` AS `parent-author-network`,
1958 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1959 `parent-post-author`.`hidden` AS `parent-author-hidden`
1961 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
1962 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
1963 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
1964 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
1965 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
1966 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
1967 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
1968 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
1969 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
1970 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
1971 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
1972 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
1973 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1976 -- VIEW post-thread-view
1978 DROP VIEW IF EXISTS `post-thread-view`;
1979 CREATE VIEW `post-thread-view` AS SELECT
1980 `item-uri`.`uri` AS `uri`,
1981 `post-thread`.`uri-id` AS `uri-id`,
1982 `parent-item-uri`.`uri` AS `parent-uri`,
1983 `post`.`parent-uri-id` AS `parent-uri-id`,
1984 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1985 `post`.`thr-parent-id` AS `thr-parent-id`,
1986 `item-uri`.`guid` AS `guid`,
1987 `post`.`gravity` AS `gravity`,
1988 `external-item-uri`.`uri` AS `extid`,
1989 `post`.`external-id` AS `external-id`,
1990 `post-thread`.`created` AS `created`,
1991 `post`.`edited` AS `edited`,
1992 `post-thread`.`commented` AS `commented`,
1993 `post-thread`.`received` AS `received`,
1994 `post-thread`.`changed` AS `changed`,
1995 `post`.`post-type` AS `post-type`,
1996 `post`.`private` AS `private`,
1997 `post`.`visible` AS `visible`,
1998 `post`.`deleted` AS `deleted`,
1999 `post`.`global` AS `global`,
2000 `post-thread`.`network` AS `network`,
2001 `post`.`vid` AS `vid`,
2002 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2003 `post-content`.`title` AS `title`,
2004 `post-content`.`content-warning` AS `content-warning`,
2005 `post-content`.`raw-body` AS `raw-body`,
2006 `post-content`.`body` AS `body`,
2007 `post-content`.`rendered-hash` AS `rendered-hash`,
2008 `post-content`.`rendered-html` AS `rendered-html`,
2009 `post-content`.`language` AS `language`,
2010 `post-content`.`plink` AS `plink`,
2011 `post-content`.`location` AS `location`,
2012 `post-content`.`coord` AS `coord`,
2013 `post-content`.`app` AS `app`,
2014 `post-content`.`object-type` AS `object-type`,
2015 `post-content`.`object` AS `object`,
2016 `post-content`.`target-type` AS `target-type`,
2017 `post-content`.`target` AS `target`,
2018 `post-content`.`resource-id` AS `resource-id`,
2019 `post-thread`.`author-id` AS `contact-id`,
2020 `author`.`url` AS `contact-link`,
2021 `author`.`addr` AS `contact-addr`,
2022 `author`.`name` AS `contact-name`,
2023 `author`.`nick` AS `contact-nick`,
2024 `author`.`thumb` AS `contact-avatar`,
2025 `author`.`network` AS `contact-network`,
2026 `author`.`blocked` AS `contact-blocked`,
2027 `author`.`hidden` AS `contact-hidden`,
2028 `author`.`readonly` AS `contact-readonly`,
2029 `author`.`archive` AS `contact-archive`,
2030 `author`.`pending` AS `contact-pending`,
2031 `author`.`rel` AS `contact-rel`,
2032 `author`.`uid` AS `contact-uid`,
2033 `author`.`contact-type` AS `contact-contact-type`,
2034 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2036 `author`.`id` AS `cid`,
2037 `author`.`alias` AS `alias`,
2038 `author`.`photo` AS `photo`,
2039 `author`.`name-date` AS `name-date`,
2040 `author`.`uri-date` AS `uri-date`,
2041 `author`.`avatar-date` AS `avatar-date`,
2042 `author`.`thumb` AS `thumb`,
2043 `post-thread`.`author-id` AS `author-id`,
2044 `author`.`url` AS `author-link`,
2045 `author`.`addr` AS `author-addr`,
2046 `author`.`name` AS `author-name`,
2047 `author`.`nick` AS `author-nick`,
2048 `author`.`thumb` AS `author-avatar`,
2049 `author`.`network` AS `author-network`,
2050 `author`.`blocked` AS `author-blocked`,
2051 `author`.`hidden` AS `author-hidden`,
2052 `post-thread`.`owner-id` AS `owner-id`,
2053 `owner`.`url` AS `owner-link`,
2054 `owner`.`addr` AS `owner-addr`,
2055 `owner`.`name` AS `owner-name`,
2056 `owner`.`nick` AS `owner-nick`,
2057 `owner`.`thumb` AS `owner-avatar`,
2058 `owner`.`network` AS `owner-network`,
2059 `owner`.`blocked` AS `owner-blocked`,
2060 `owner`.`hidden` AS `owner-hidden`,
2061 `owner`.`contact-type` AS `owner-contact-type`,
2062 `post-thread`.`causer-id` AS `causer-id`,
2063 `causer`.`url` AS `causer-link`,
2064 `causer`.`addr` AS `causer-addr`,
2065 `causer`.`name` AS `causer-name`,
2066 `causer`.`nick` AS `causer-nick`,
2067 `causer`.`thumb` AS `causer-avatar`,
2068 `causer`.`network` AS `causer-network`,
2069 `causer`.`blocked` AS `causer-blocked`,
2070 `causer`.`hidden` AS `causer-hidden`,
2071 `causer`.`contact-type` AS `causer-contact-type`,
2072 `diaspora-interaction`.`interaction` AS `signed_text`,
2073 `parent-item-uri`.`guid` AS `parent-guid`,
2074 `parent-post`.`network` AS `parent-network`,
2075 `parent-post`.`author-id` AS `parent-author-id`,
2076 `parent-post-author`.`url` AS `parent-author-link`,
2077 `parent-post-author`.`name` AS `parent-author-name`,
2078 `parent-post-author`.`network` AS `parent-author-network`,
2079 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2080 `parent-post-author`.`hidden` AS `parent-author-hidden`
2082 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
2083 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
2084 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
2085 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
2086 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
2087 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2088 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2089 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2090 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2091 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
2092 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
2093 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2094 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2097 -- VIEW category-view
2099 DROP VIEW IF EXISTS `category-view`;
2100 CREATE VIEW `category-view` AS SELECT
2101 `post-category`.`uri-id` AS `uri-id`,
2102 `post-category`.`uid` AS `uid`,
2103 `post-category`.`type` AS `type`,
2104 `post-category`.`tid` AS `tid`,
2105 `tag`.`name` AS `name`,
2106 `tag`.`url` AS `url`
2107 FROM `post-category`
2108 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2113 DROP VIEW IF EXISTS `tag-view`;
2114 CREATE VIEW `tag-view` AS SELECT
2115 `post-tag`.`uri-id` AS `uri-id`,
2116 `post-tag`.`type` AS `type`,
2117 `post-tag`.`tid` AS `tid`,
2118 `post-tag`.`cid` AS `cid`,
2119 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2120 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
2122 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2123 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2126 -- VIEW network-item-view
2128 DROP VIEW IF EXISTS `network-item-view`;
2129 CREATE VIEW `network-item-view` AS SELECT
2130 `post-user`.`uri-id` AS `uri-id`,
2131 `parent-post`.`id` AS `parent`,
2132 `post-user`.`received` AS `received`,
2133 `post-thread-user`.`commented` AS `commented`,
2134 `post-user`.`created` AS `created`,
2135 `post-user`.`uid` AS `uid`,
2136 `post-thread-user`.`starred` AS `starred`,
2137 `post-thread-user`.`mention` AS `mention`,
2138 `post-user`.`network` AS `network`,
2139 `post-user`.`unseen` AS `unseen`,
2140 `post-user`.`gravity` AS `gravity`,
2141 `post-user`.`contact-id` AS `contact-id`,
2142 `ownercontact`.`contact-type` AS `contact-type`
2144 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2145 INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2146 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2147 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2148 INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2149 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2150 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2151 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2152 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
2153 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2154 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2157 -- VIEW network-thread-view
2159 DROP VIEW IF EXISTS `network-thread-view`;
2160 CREATE VIEW `network-thread-view` AS SELECT
2161 `post-thread-user`.`uri-id` AS `uri-id`,
2162 `parent-post`.`id` AS `parent`,
2163 `post-thread-user`.`received` AS `received`,
2164 `post-thread-user`.`commented` AS `commented`,
2165 `post-thread-user`.`created` AS `created`,
2166 `post-thread-user`.`uid` AS `uid`,
2167 `post-thread-user`.`starred` AS `starred`,
2168 `post-thread-user`.`mention` AS `mention`,
2169 `post-thread-user`.`network` AS `network`,
2170 `post-thread-user`.`contact-id` AS `contact-id`,
2171 `ownercontact`.`contact-type` AS `contact-type`
2172 FROM `post-thread-user`
2173 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2174 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2175 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2176 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2177 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2178 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2179 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2180 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2181 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2182 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2183 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2188 DROP VIEW IF EXISTS `owner-view`;
2189 CREATE VIEW `owner-view` AS SELECT
2190 `contact`.`id` AS `id`,
2191 `contact`.`uid` AS `uid`,
2192 `contact`.`created` AS `created`,
2193 `contact`.`updated` AS `updated`,
2194 `contact`.`self` AS `self`,
2195 `contact`.`remote_self` AS `remote_self`,
2196 `contact`.`rel` AS `rel`,
2197 `contact`.`network` AS `network`,
2198 `contact`.`protocol` AS `protocol`,
2199 `contact`.`name` AS `name`,
2200 `contact`.`nick` AS `nick`,
2201 `contact`.`location` AS `location`,
2202 `contact`.`about` AS `about`,
2203 `contact`.`keywords` AS `keywords`,
2204 `contact`.`gender` AS `gender`,
2205 `contact`.`xmpp` AS `xmpp`,
2206 `contact`.`matrix` AS `matrix`,
2207 `contact`.`attag` AS `attag`,
2208 `contact`.`avatar` AS `avatar`,
2209 `contact`.`photo` AS `photo`,
2210 `contact`.`thumb` AS `thumb`,
2211 `contact`.`micro` AS `micro`,
2212 `contact`.`header` AS `header`,
2213 `contact`.`url` AS `url`,
2214 `contact`.`nurl` AS `nurl`,
2215 `contact`.`uri-id` AS `uri-id`,
2216 `contact`.`addr` AS `addr`,
2217 `contact`.`alias` AS `alias`,
2218 `contact`.`pubkey` AS `pubkey`,
2219 `contact`.`prvkey` AS `prvkey`,
2220 `contact`.`batch` AS `batch`,
2221 `contact`.`request` AS `request`,
2222 `contact`.`notify` AS `notify`,
2223 `contact`.`poll` AS `poll`,
2224 `contact`.`confirm` AS `confirm`,
2225 `contact`.`poco` AS `poco`,
2226 `contact`.`usehub` AS `usehub`,
2227 `contact`.`subhub` AS `subhub`,
2228 `contact`.`hub-verify` AS `hub-verify`,
2229 `contact`.`last-update` AS `last-update`,
2230 `contact`.`success_update` AS `success_update`,
2231 `contact`.`failure_update` AS `failure_update`,
2232 `contact`.`name-date` AS `name-date`,
2233 `contact`.`uri-date` AS `uri-date`,
2234 `contact`.`avatar-date` AS `avatar-date`,
2235 `contact`.`avatar-date` AS `picdate`,
2236 `contact`.`term-date` AS `term-date`,
2237 `contact`.`last-item` AS `last-item`,
2238 `contact`.`priority` AS `priority`,
2239 `user`.`blocked` AS `blocked`,
2240 `contact`.`block_reason` AS `block_reason`,
2241 `contact`.`readonly` AS `readonly`,
2242 `contact`.`writable` AS `writable`,
2243 `contact`.`forum` AS `forum`,
2244 `contact`.`prv` AS `prv`,
2245 `contact`.`contact-type` AS `contact-type`,
2246 `contact`.`manually-approve` AS `manually-approve`,
2247 `contact`.`hidden` AS `hidden`,
2248 `contact`.`archive` AS `archive`,
2249 `contact`.`pending` AS `pending`,
2250 `contact`.`deleted` AS `deleted`,
2251 `contact`.`unsearchable` AS `unsearchable`,
2252 `contact`.`sensitive` AS `sensitive`,
2253 `contact`.`baseurl` AS `baseurl`,
2254 `contact`.`reason` AS `reason`,
2255 `contact`.`closeness` AS `closeness`,
2256 `contact`.`info` AS `info`,
2257 `contact`.`profile-id` AS `profile-id`,
2258 `contact`.`bdyear` AS `bdyear`,
2259 `contact`.`bd` AS `bd`,
2260 `contact`.`notify_new_posts` AS `notify_new_posts`,
2261 `contact`.`fetch_further_information` AS `fetch_further_information`,
2262 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2263 `user`.`parent-uid` AS `parent-uid`,
2264 `user`.`guid` AS `guid`,
2265 `user`.`nickname` AS `nickname`,
2266 `user`.`email` AS `email`,
2267 `user`.`openid` AS `openid`,
2268 `user`.`timezone` AS `timezone`,
2269 `user`.`language` AS `language`,
2270 `user`.`register_date` AS `register_date`,
2271 `user`.`login_date` AS `login_date`,
2272 `user`.`default-location` AS `default-location`,
2273 `user`.`allow_location` AS `allow_location`,
2274 `user`.`theme` AS `theme`,
2275 `user`.`pubkey` AS `upubkey`,
2276 `user`.`prvkey` AS `uprvkey`,
2277 `user`.`sprvkey` AS `sprvkey`,
2278 `user`.`spubkey` AS `spubkey`,
2279 `user`.`verified` AS `verified`,
2280 `user`.`blockwall` AS `blockwall`,
2281 `user`.`hidewall` AS `hidewall`,
2282 `user`.`blocktags` AS `blocktags`,
2283 `user`.`unkmail` AS `unkmail`,
2284 `user`.`cntunkmail` AS `cntunkmail`,
2285 `user`.`notify-flags` AS `notify-flags`,
2286 `user`.`page-flags` AS `page-flags`,
2287 `user`.`account-type` AS `account-type`,
2288 `user`.`prvnets` AS `prvnets`,
2289 `user`.`maxreq` AS `maxreq`,
2290 `user`.`expire` AS `expire`,
2291 `user`.`account_removed` AS `account_removed`,
2292 `user`.`account_expired` AS `account_expired`,
2293 `user`.`account_expires_on` AS `account_expires_on`,
2294 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2295 `user`.`def_gid` AS `def_gid`,
2296 `user`.`allow_cid` AS `allow_cid`,
2297 `user`.`allow_gid` AS `allow_gid`,
2298 `user`.`deny_cid` AS `deny_cid`,
2299 `user`.`deny_gid` AS `deny_gid`,
2300 `user`.`openidserver` AS `openidserver`,
2301 `profile`.`publish` AS `publish`,
2302 `profile`.`net-publish` AS `net-publish`,
2303 `profile`.`hide-friends` AS `hide-friends`,
2304 `profile`.`prv_keywords` AS `prv_keywords`,
2305 `profile`.`pub_keywords` AS `pub_keywords`,
2306 `profile`.`address` AS `address`,
2307 `profile`.`locality` AS `locality`,
2308 `profile`.`region` AS `region`,
2309 `profile`.`postal-code` AS `postal-code`,
2310 `profile`.`country-name` AS `country-name`,
2311 `profile`.`homepage` AS `homepage`,
2312 `profile`.`dob` AS `dob`
2314 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2315 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2318 -- VIEW account-view
2320 DROP VIEW IF EXISTS `account-view`;
2321 CREATE VIEW `account-view` AS SELECT
2322 `contact`.`id` AS `id`,
2323 `contact`.`url` AS `url`,
2324 `contact`.`nurl` AS `nurl`,
2325 `contact`.`uri-id` AS `uri-id`,
2326 `contact`.`addr` AS `addr`,
2327 `contact`.`alias` AS `alias`,
2328 `contact`.`name` AS `name`,
2329 `contact`.`nick` AS `nick`,
2330 `contact`.`about` AS `about`,
2331 `contact`.`keywords` AS `keywords`,
2332 `contact`.`xmpp` AS `xmpp`,
2333 `contact`.`matrix` AS `matrix`,
2334 `contact`.`avatar` AS `avatar`,
2335 `contact`.`photo` AS `photo`,
2336 `contact`.`thumb` AS `thumb`,
2337 `contact`.`micro` AS `micro`,
2338 `contact`.`header` AS `header`,
2339 `contact`.`created` AS `created`,
2340 `contact`.`updated` AS `updated`,
2341 `contact`.`network` AS `network`,
2342 `contact`.`protocol` AS `protocol`,
2343 `contact`.`location` AS `location`,
2344 `contact`.`attag` AS `attag`,
2345 `contact`.`pubkey` AS `pubkey`,
2346 `contact`.`prvkey` AS `prvkey`,
2347 `contact`.`subscribe` AS `subscribe`,
2348 `contact`.`last-update` AS `last-update`,
2349 `contact`.`success_update` AS `success_update`,
2350 `contact`.`failure_update` AS `failure_update`,
2351 `contact`.`failed` AS `failed`,
2352 `contact`.`last-item` AS `last-item`,
2353 `contact`.`last-discovery` AS `last-discovery`,
2354 `contact`.`contact-type` AS `contact-type`,
2355 `contact`.`manually-approve` AS `manually-approve`,
2356 `contact`.`unsearchable` AS `unsearchable`,
2357 `contact`.`sensitive` AS `sensitive`,
2358 `contact`.`baseurl` AS `baseurl`,
2359 `contact`.`gsid` AS `gsid`,
2360 `contact`.`info` AS `info`,
2361 `contact`.`bdyear` AS `bdyear`,
2362 `contact`.`bd` AS `bd`,
2363 `contact`.`poco` AS `poco`,
2364 `contact`.`name-date` AS `name-date`,
2365 `contact`.`uri-date` AS `uri-date`,
2366 `contact`.`avatar-date` AS `avatar-date`,
2367 `contact`.`term-date` AS `term-date`,
2368 `contact`.`hidden` AS `global-ignored`,
2369 `contact`.`blocked` AS `global-blocked`,
2370 `contact`.`hidden` AS `hidden`,
2371 `contact`.`archive` AS `archive`,
2372 `contact`.`deleted` AS `deleted`,
2373 `contact`.`blocked` AS `blocked`,
2374 `contact`.`request` AS `dfrn-request`,
2375 `contact`.`notify` AS `dfrn-notify`,
2376 `contact`.`poll` AS `dfrn-poll`,
2377 `contact`.`confirm` AS `dfrn-confirm`,
2378 `fcontact`.`guid` AS `diaspora-guid`,
2379 `fcontact`.`batch` AS `diaspora-batch`,
2380 `fcontact`.`notify` AS `diaspora-notify`,
2381 `fcontact`.`poll` AS `diaspora-poll`,
2382 `fcontact`.`alias` AS `diaspora-alias`,
2383 `apcontact`.`uuid` AS `ap-uuid`,
2384 `apcontact`.`type` AS `ap-type`,
2385 `apcontact`.`following` AS `ap-following`,
2386 `apcontact`.`followers` AS `ap-followers`,
2387 `apcontact`.`inbox` AS `ap-inbox`,
2388 `apcontact`.`outbox` AS `ap-outbox`,
2389 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2390 `apcontact`.`generator` AS `ap-generator`,
2391 `apcontact`.`following_count` AS `ap-following_count`,
2392 `apcontact`.`followers_count` AS `ap-followers_count`,
2393 `apcontact`.`statuses_count` AS `ap-statuses_count`
2395 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
2396 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = contact.`uri-id`
2397 WHERE `contact`.`uid` = 0;
2400 -- VIEW account-user-view
2402 DROP VIEW IF EXISTS `account-user-view`;
2403 CREATE VIEW `account-user-view` AS SELECT
2404 `ucontact`.`id` AS `id`,
2405 `contact`.`id` AS `pid`,
2406 `ucontact`.`uid` AS `uid`,
2407 `contact`.`url` AS `url`,
2408 `contact`.`nurl` AS `nurl`,
2409 `contact`.`uri-id` AS `uri-id`,
2410 `contact`.`addr` AS `addr`,
2411 `contact`.`alias` AS `alias`,
2412 `contact`.`name` AS `name`,
2413 `contact`.`nick` AS `nick`,
2414 `contact`.`about` AS `about`,
2415 `contact`.`keywords` AS `keywords`,
2416 `contact`.`xmpp` AS `xmpp`,
2417 `contact`.`matrix` AS `matrix`,
2418 `contact`.`avatar` AS `avatar`,
2419 `contact`.`photo` AS `photo`,
2420 `contact`.`thumb` AS `thumb`,
2421 `contact`.`micro` AS `micro`,
2422 `contact`.`header` AS `header`,
2423 `contact`.`created` AS `created`,
2424 `contact`.`updated` AS `updated`,
2425 `ucontact`.`self` AS `self`,
2426 `ucontact`.`remote_self` AS `remote_self`,
2427 `ucontact`.`rel` AS `rel`,
2428 `contact`.`network` AS `network`,
2429 `ucontact`.`protocol` AS `protocol`,
2430 `contact`.`location` AS `location`,
2431 `contact`.`attag` AS `attag`,
2432 `contact`.`pubkey` AS `pubkey`,
2433 `contact`.`prvkey` AS `prvkey`,
2434 `contact`.`subscribe` AS `subscribe`,
2435 `contact`.`last-update` AS `last-update`,
2436 `contact`.`success_update` AS `success_update`,
2437 `contact`.`failure_update` AS `failure_update`,
2438 `contact`.`failed` AS `failed`,
2439 `contact`.`last-item` AS `last-item`,
2440 `contact`.`last-discovery` AS `last-discovery`,
2441 `contact`.`contact-type` AS `contact-type`,
2442 `contact`.`manually-approve` AS `manually-approve`,
2443 `contact`.`unsearchable` AS `unsearchable`,
2444 `contact`.`sensitive` AS `sensitive`,
2445 `contact`.`baseurl` AS `baseurl`,
2446 `contact`.`gsid` AS `gsid`,
2447 `contact`.`info` AS `info`,
2448 `contact`.`bdyear` AS `bdyear`,
2449 `contact`.`bd` AS `bd`,
2450 `contact`.`poco` AS `poco`,
2451 `contact`.`name-date` AS `name-date`,
2452 `contact`.`uri-date` AS `uri-date`,
2453 `contact`.`avatar-date` AS `avatar-date`,
2454 `contact`.`term-date` AS `term-date`,
2455 `contact`.`hidden` AS `global-ignored`,
2456 `contact`.`blocked` AS `global-blocked`,
2457 `ucontact`.`hidden` AS `hidden`,
2458 `ucontact`.`archive` AS `archive`,
2459 `ucontact`.`pending` AS `pending`,
2460 `ucontact`.`deleted` AS `deleted`,
2461 `ucontact`.`notify_new_posts` AS `notify_new_posts`,
2462 `ucontact`.`fetch_further_information` AS `fetch_further_information`,
2463 `ucontact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2464 `ucontact`.`rating` AS `rating`,
2465 `ucontact`.`readonly` AS `readonly`,
2466 `ucontact`.`blocked` AS `blocked`,
2467 `ucontact`.`block_reason` AS `block_reason`,
2468 `ucontact`.`subhub` AS `subhub`,
2469 `ucontact`.`hub-verify` AS `hub-verify`,
2470 `ucontact`.`reason` AS `reason`,
2471 `contact`.`request` AS `dfrn-request`,
2472 `contact`.`notify` AS `dfrn-notify`,
2473 `contact`.`poll` AS `dfrn-poll`,
2474 `contact`.`confirm` AS `dfrn-confirm`,
2475 `fcontact`.`guid` AS `diaspora-guid`,
2476 `fcontact`.`batch` AS `diaspora-batch`,
2477 `fcontact`.`notify` AS `diaspora-notify`,
2478 `fcontact`.`poll` AS `diaspora-poll`,
2479 `fcontact`.`alias` AS `diaspora-alias`,
2480 `apcontact`.`uuid` AS `ap-uuid`,
2481 `apcontact`.`type` AS `ap-type`,
2482 `apcontact`.`following` AS `ap-following`,
2483 `apcontact`.`followers` AS `ap-followers`,
2484 `apcontact`.`inbox` AS `ap-inbox`,
2485 `apcontact`.`outbox` AS `ap-outbox`,
2486 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2487 `apcontact`.`generator` AS `ap-generator`,
2488 `apcontact`.`following_count` AS `ap-following_count`,
2489 `apcontact`.`followers_count` AS `ap-followers_count`,
2490 `apcontact`.`statuses_count` AS `ap-statuses_count`
2491 FROM `contact` AS `ucontact`
2492 INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
2493 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
2494 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = `ucontact`.`uri-id` AND `fcontact`.`network` = 'dspr';
2497 -- VIEW pending-view
2499 DROP VIEW IF EXISTS `pending-view`;
2500 CREATE VIEW `pending-view` AS SELECT
2501 `register`.`id` AS `id`,
2502 `register`.`hash` AS `hash`,
2503 `register`.`created` AS `created`,
2504 `register`.`uid` AS `uid`,
2505 `register`.`password` AS `password`,
2506 `register`.`language` AS `language`,
2507 `register`.`note` AS `note`,
2508 `contact`.`self` AS `self`,
2509 `contact`.`name` AS `name`,
2510 `contact`.`url` AS `url`,
2511 `contact`.`micro` AS `micro`,
2512 `user`.`email` AS `email`,
2513 `contact`.`nick` AS `nick`
2515 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2516 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2519 -- VIEW tag-search-view
2521 DROP VIEW IF EXISTS `tag-search-view`;
2522 CREATE VIEW `tag-search-view` AS SELECT
2523 `post-tag`.`uri-id` AS `uri-id`,
2524 `post-user`.`uid` AS `uid`,
2525 `post-user`.`id` AS `iid`,
2526 `post-user`.`private` AS `private`,
2527 `post-user`.`wall` AS `wall`,
2528 `post-user`.`origin` AS `origin`,
2529 `post-user`.`global` AS `global`,
2530 `post-user`.`gravity` AS `gravity`,
2531 `post-user`.`received` AS `received`,
2532 `post-user`.`network` AS `network`,
2533 `post-user`.`author-id` AS `author-id`,
2534 `tag`.`name` AS `name`
2536 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
2537 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
2538 WHERE `post-tag`.`type` = 1;
2541 -- VIEW workerqueue-view
2543 DROP VIEW IF EXISTS `workerqueue-view`;
2544 CREATE VIEW `workerqueue-view` AS SELECT
2545 `process`.`pid` AS `pid`,
2546 `workerqueue`.`priority` AS `priority`
2548 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
2549 WHERE NOT `workerqueue`.`done`;