1 -- ------------------------------------------
2 -- Friendica 2021.09-dev (Siberian Iris)
3 -- DB_UPDATE_VERSION 1432
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 `photo` varchar(255) COMMENT '',
336 `header` varchar(255) COMMENT 'Header picture',
337 `addr` varchar(255) COMMENT '',
338 `alias` varchar(255) COMMENT '',
339 `pubkey` text COMMENT '',
340 `subscribe` varchar(255) COMMENT '',
341 `baseurl` varchar(255) COMMENT 'baseurl of the ap contact',
342 `gsid` int unsigned COMMENT 'Global Server ID',
343 `generator` varchar(255) COMMENT 'Name of the contact\'s system',
344 `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
345 `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
346 `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
347 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
349 INDEX `addr` (`addr`(32)),
350 INDEX `alias` (`alias`(190)),
351 INDEX `followers` (`followers`(190)),
352 INDEX `baseurl` (`baseurl`(190)),
353 INDEX `sharedinbox` (`sharedinbox`(190)),
354 INDEX `gsid` (`gsid`),
355 UNIQUE INDEX `uri-id` (`uri-id`),
356 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
357 FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
358 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
363 CREATE TABLE IF NOT EXISTS `application` (
364 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
365 `client_id` varchar(64) NOT NULL COMMENT '',
366 `client_secret` varchar(64) NOT NULL COMMENT '',
367 `name` varchar(255) NOT NULL COMMENT '',
368 `redirect_uri` varchar(255) NOT NULL COMMENT '',
369 `website` varchar(255) COMMENT '',
370 `scopes` varchar(255) COMMENT '',
371 `read` boolean COMMENT 'Read scope',
372 `write` boolean COMMENT 'Write scope',
373 `follow` boolean COMMENT 'Follow scope',
374 `push` boolean COMMENT 'Push scope',
376 UNIQUE INDEX `client_id` (`client_id`)
377 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth application';
380 -- TABLE application-token
382 CREATE TABLE IF NOT EXISTS `application-token` (
383 `application-id` int unsigned NOT NULL COMMENT '',
384 `uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
385 `code` varchar(64) NOT NULL COMMENT '',
386 `access_token` varchar(64) NOT NULL COMMENT '',
387 `created_at` datetime NOT NULL COMMENT 'creation time',
388 `scopes` varchar(255) COMMENT '',
389 `read` boolean COMMENT 'Read scope',
390 `write` boolean COMMENT 'Write scope',
391 `follow` boolean COMMENT 'Follow scope',
392 `push` boolean COMMENT 'Push scope',
393 PRIMARY KEY(`application-id`,`uid`),
394 INDEX `uid_id` (`uid`,`application-id`),
395 FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
396 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
397 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth user token';
402 CREATE TABLE IF NOT EXISTS `attach` (
403 `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
404 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
405 `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
406 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
407 `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
408 `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
409 `data` longblob NOT NULL COMMENT 'file data',
410 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
411 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
412 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
413 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
414 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
415 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
416 `backend-class` tinytext COMMENT 'Storage backend class',
417 `backend-ref` text COMMENT 'Storage backend data reference',
420 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
421 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
426 CREATE TABLE IF NOT EXISTS `cache` (
427 `k` varbinary(255) NOT NULL COMMENT 'cache key',
428 `v` mediumtext COMMENT 'cached serialized value',
429 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
430 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
432 INDEX `k_expires` (`k`,`expires`)
433 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
438 CREATE TABLE IF NOT EXISTS `config` (
439 `id` int unsigned NOT NULL auto_increment COMMENT '',
440 `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
441 `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
442 `v` mediumtext COMMENT '',
444 UNIQUE INDEX `cat_k` (`cat`,`k`)
445 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
448 -- TABLE contact-relation
450 CREATE TABLE IF NOT EXISTS `contact-relation` (
451 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
452 `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
453 `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
454 `follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
455 `follows` boolean NOT NULL DEFAULT '0' COMMENT '',
456 PRIMARY KEY(`cid`,`relation-cid`),
457 INDEX `relation-cid` (`relation-cid`),
458 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
459 FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
460 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
465 CREATE TABLE IF NOT EXISTS `conv` (
466 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
467 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
468 `recips` text COMMENT 'sender_handle;recipient_handle',
469 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
470 `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
471 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
472 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
473 `subject` text COMMENT 'subject of initial message',
476 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
477 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
480 -- TABLE conversation
482 CREATE TABLE IF NOT EXISTS `conversation` (
483 `item-uri` varbinary(255) NOT NULL COMMENT 'Original URI of the item - unrelated to the table with the same name',
484 `reply-to-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'URI to which this item is a reply',
485 `conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI',
486 `conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link',
487 `protocol` tinyint unsigned NOT NULL DEFAULT 255 COMMENT 'The protocol of the item',
488 `direction` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'How the message arrived here: 1=push, 2=pull',
489 `source` mediumtext COMMENT 'Original source',
490 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Receiving date',
491 PRIMARY KEY(`item-uri`),
492 INDEX `conversation-uri` (`conversation-uri`),
493 INDEX `received` (`received`)
494 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Raw data and structure information for messages';
499 CREATE TABLE IF NOT EXISTS `workerqueue` (
500 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
501 `command` varchar(100) COMMENT 'Task command',
502 `parameter` mediumtext COMMENT 'Task parameter',
503 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
504 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
505 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
506 `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
507 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
508 `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
509 `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
511 INDEX `command` (`command`),
512 INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
513 INDEX `done_executed` (`done`,`executed`),
514 INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
515 INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
516 INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
517 INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
518 INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
519 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
522 -- TABLE delayed-post
524 CREATE TABLE IF NOT EXISTS `delayed-post` (
525 `id` int unsigned NOT NULL auto_increment,
526 `uri` varchar(255) COMMENT 'URI of the post that will be distributed later',
527 `uid` mediumint unsigned COMMENT 'Owner User id',
528 `delayed` datetime COMMENT 'delay time',
529 `wid` int unsigned COMMENT 'Workerqueue id',
531 UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
533 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
534 FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
535 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
538 -- TABLE diaspora-interaction
540 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
541 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
542 `interaction` mediumtext COMMENT 'The Diaspora interaction',
543 PRIMARY KEY(`uri-id`),
544 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
545 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
550 CREATE TABLE IF NOT EXISTS `event` (
551 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
552 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
553 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
554 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
555 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
556 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the event uri',
557 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
558 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
559 `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
560 `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
561 `summary` text COMMENT 'short description or title of the event',
562 `desc` text COMMENT 'event description',
563 `location` text COMMENT 'event location',
564 `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
565 `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
566 `adjust` boolean NOT NULL DEFAULT '1' COMMENT 'adjust to timezone of the recipient (0 or 1)',
567 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
568 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
569 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
570 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
571 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
573 INDEX `uid_start` (`uid`,`start`),
575 INDEX `uri-id` (`uri-id`),
576 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
577 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
578 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
579 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
584 CREATE TABLE IF NOT EXISTS `fcontact` (
585 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
586 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
587 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
588 `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the fcontact url',
589 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
590 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
591 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
592 `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
593 `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
594 `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
595 `notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
596 `poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
597 `confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
598 `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
599 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
600 `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
601 `pubkey` text COMMENT '',
602 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
604 INDEX `addr` (`addr`(32)),
605 UNIQUE INDEX `url` (`url`(190)),
606 UNIQUE INDEX `uri-id` (`uri-id`),
607 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
608 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
613 CREATE TABLE IF NOT EXISTS `fsuggest` (
614 `id` int unsigned NOT NULL auto_increment COMMENT '',
615 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
616 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
617 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
618 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
619 `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
620 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
621 `note` text COMMENT '',
622 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
626 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
627 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
628 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
633 CREATE TABLE IF NOT EXISTS `group` (
634 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
635 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
636 `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
637 `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
638 `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
641 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
642 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
645 -- TABLE group_member
647 CREATE TABLE IF NOT EXISTS `group_member` (
648 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
649 `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
650 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
652 INDEX `contactid` (`contact-id`),
653 UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
654 FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
655 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
656 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
661 CREATE TABLE IF NOT EXISTS `gserver-tag` (
662 `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
663 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
664 PRIMARY KEY(`gserver-id`,`tag`),
666 FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
667 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
672 CREATE TABLE IF NOT EXISTS `hook` (
673 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
674 `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
675 `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
676 `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
677 `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',
679 INDEX `priority` (`priority`),
680 UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
681 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
686 CREATE TABLE IF NOT EXISTS `host` (
687 `id` tinyint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
688 `name` varchar(128) NOT NULL DEFAULT '' COMMENT 'The hostname',
690 UNIQUE INDEX `name` (`name`)
691 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Hostname';
694 -- TABLE inbox-status
696 CREATE TABLE IF NOT EXISTS `inbox-status` (
697 `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
698 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
699 `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
700 `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
701 `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
702 `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
703 `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
705 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
710 CREATE TABLE IF NOT EXISTS `intro` (
711 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
712 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
713 `fid` int unsigned COMMENT '',
714 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
715 `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
716 `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
717 `note` text COMMENT '',
718 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
719 `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
720 `blocked` boolean NOT NULL DEFAULT '1' COMMENT '',
721 `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
723 INDEX `contact-id` (`contact-id`),
725 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
726 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
727 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
732 CREATE TABLE IF NOT EXISTS `locks` (
733 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
734 `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
735 `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
736 `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
737 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
739 INDEX `name_expires` (`name`,`expires`)
740 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
745 CREATE TABLE IF NOT EXISTS `mail` (
746 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
747 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
748 `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
749 `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
750 `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
751 `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
752 `contact-id` varchar(255) COMMENT 'contact.id',
753 `author-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the author of the mail',
754 `convid` int unsigned COMMENT 'conv.id',
755 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
756 `body` mediumtext COMMENT '',
757 `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
758 `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
759 `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
760 `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
761 `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
762 `uri-id` int unsigned COMMENT 'Item-uri id of the related mail',
763 `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
764 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related mail',
765 `thr-parent` varchar(255) COMMENT '',
766 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
767 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
769 INDEX `uid_seen` (`uid`,`seen`),
770 INDEX `convid` (`convid`),
771 INDEX `uri` (`uri`(64)),
772 INDEX `parent-uri` (`parent-uri`(64)),
773 INDEX `contactid` (`contact-id`(32)),
774 INDEX `author-id` (`author-id`),
775 INDEX `uri-id` (`uri-id`),
776 INDEX `parent-uri-id` (`parent-uri-id`),
777 INDEX `thr-parent-id` (`thr-parent-id`),
778 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
779 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
780 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
781 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
782 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
783 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
788 CREATE TABLE IF NOT EXISTS `mailacct` (
789 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
790 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
791 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
792 `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
793 `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
794 `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
795 `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
796 `pass` text COMMENT '',
797 `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
798 `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
799 `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
800 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
801 `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
804 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
805 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
810 CREATE TABLE IF NOT EXISTS `manage` (
811 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
812 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
813 `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
815 UNIQUE INDEX `uid_mid` (`uid`,`mid`),
817 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
818 FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
819 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
822 -- TABLE notification
824 CREATE TABLE IF NOT EXISTS `notification` (
825 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
826 `uid` mediumint unsigned COMMENT 'Owner User id',
827 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
828 `type` tinyint unsigned COMMENT '',
829 `actor-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the actor that caused the notification',
830 `target-uri-id` int unsigned COMMENT 'Item-uri id of the related post',
831 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
832 `created` datetime COMMENT '',
833 `seen` boolean DEFAULT '0' COMMENT '',
835 UNIQUE INDEX `uid_vid_type_actor-id_target-uri-id` (`uid`,`vid`,`type`,`actor-id`,`target-uri-id`),
837 INDEX `actor-id` (`actor-id`),
838 INDEX `target-uri-id` (`target-uri-id`),
839 INDEX `parent-uri-id` (`parent-uri-id`),
840 INDEX `seen_uid` (`seen`,`uid`),
841 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
842 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
843 FOREIGN KEY (`actor-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
844 FOREIGN KEY (`target-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
845 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
846 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
851 CREATE TABLE IF NOT EXISTS `notify` (
852 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
853 `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
854 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
855 `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
856 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
857 `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
858 `msg` mediumtext COMMENT '',
859 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
860 `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
861 `iid` int unsigned COMMENT '',
862 `parent` int unsigned COMMENT '',
863 `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
864 `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
865 `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
866 `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
867 `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
868 `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
869 `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
871 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
872 INDEX `uid_date` (`uid`,`date`),
873 INDEX `uid_type_link` (`uid`,`type`,`link`(190)),
874 INDEX `uri-id` (`uri-id`),
875 INDEX `parent-uri-id` (`parent-uri-id`),
876 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
877 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
878 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
879 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
882 -- TABLE notify-threads
884 CREATE TABLE IF NOT EXISTS `notify-threads` (
885 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
886 `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
887 `master-parent-item` int unsigned COMMENT 'Deprecated',
888 `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
889 `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
890 `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
892 INDEX `master-parent-uri-id` (`master-parent-uri-id`),
893 INDEX `receiver-uid` (`receiver-uid`),
894 INDEX `notify-id` (`notify-id`),
895 FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
896 FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
897 FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
898 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
903 CREATE TABLE IF NOT EXISTS `oembed` (
904 `url` varbinary(255) NOT NULL COMMENT 'page url',
905 `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
906 `content` mediumtext COMMENT 'OEmbed data of the page',
907 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
908 PRIMARY KEY(`url`,`maxwidth`),
909 INDEX `created` (`created`)
910 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
913 -- TABLE openwebauth-token
915 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
916 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
917 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id - currently unused',
918 `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
919 `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
920 `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
921 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
924 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
925 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
930 CREATE TABLE IF NOT EXISTS `parsed_url` (
931 `url_hash` binary(64) NOT NULL COMMENT 'page url hash',
932 `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
933 `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
934 `url` text NOT NULL COMMENT 'page url',
935 `content` mediumtext COMMENT 'page data',
936 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
937 `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration',
938 PRIMARY KEY(`url_hash`,`guessing`,`oembed`),
939 INDEX `created` (`created`),
940 INDEX `expires` (`expires`)
941 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
946 CREATE TABLE IF NOT EXISTS `pconfig` (
947 `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key',
948 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
949 `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category',
950 `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key',
951 `v` mediumtext COMMENT 'Value',
953 UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`),
954 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
955 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
960 CREATE TABLE IF NOT EXISTS `photo` (
961 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
962 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
963 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
964 `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
965 `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
966 `hash` char(32) COMMENT 'hash value of the photo',
967 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
968 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
969 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
970 `desc` text COMMENT '',
971 `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
972 `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
973 `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
974 `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
975 `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
976 `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
977 `data` mediumblob NOT NULL COMMENT '',
978 `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
979 `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
980 `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
981 `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
982 `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
983 `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
984 `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
985 `backend-class` tinytext COMMENT 'Storage backend class',
986 `backend-ref` text COMMENT 'Storage backend data reference',
987 `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
989 INDEX `contactid` (`contact-id`),
990 INDEX `uid_contactid` (`uid`,`contact-id`),
991 INDEX `uid_profile` (`uid`,`profile`),
992 INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
993 INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
994 INDEX `resource-id` (`resource-id`),
995 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE RESTRICT,
996 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
997 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
1002 CREATE TABLE IF NOT EXISTS `post` (
1003 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1004 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1005 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1006 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1007 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1008 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1009 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1010 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1011 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1012 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1013 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1014 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1015 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1016 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1017 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1018 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1019 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1020 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1021 PRIMARY KEY(`uri-id`),
1022 INDEX `parent-uri-id` (`parent-uri-id`),
1023 INDEX `thr-parent-id` (`thr-parent-id`),
1024 INDEX `external-id` (`external-id`),
1025 INDEX `owner-id` (`owner-id`),
1026 INDEX `author-id` (`author-id`),
1027 INDEX `causer-id` (`causer-id`),
1028 INDEX `vid` (`vid`),
1029 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1030 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1031 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1032 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1033 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1034 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1035 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1036 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1037 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
1040 -- TABLE post-category
1042 CREATE TABLE IF NOT EXISTS `post-category` (
1043 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1044 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1045 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1046 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1047 PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1048 INDEX `uri-id` (`tid`),
1049 INDEX `uid` (`uid`),
1050 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1051 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1052 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1053 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1056 -- TABLE post-content
1058 CREATE TABLE IF NOT EXISTS `post-content` (
1059 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1060 `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
1061 `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1062 `body` mediumtext COMMENT 'item body content',
1063 `raw-body` mediumtext COMMENT 'Body without embedded media links',
1064 `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
1065 `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
1066 `language` text COMMENT 'Language information about this post',
1067 `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
1068 `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1069 `rendered-html` mediumtext COMMENT 'item.body converted to html',
1070 `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
1071 `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
1072 `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
1073 `target` text COMMENT 'JSON encoded target structure if used',
1074 `resource-id` varchar(32) NOT NULL DEFAULT '' COMMENT 'Used to link other tables to items, it identifies the linked resource (e.g. photo) and if set must also set resource_type',
1075 `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
1076 PRIMARY KEY(`uri-id`),
1077 INDEX `plink` (`plink`(191)),
1078 INDEX `resource-id` (`resource-id`),
1079 FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
1080 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1081 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
1084 -- TABLE post-delivery-data
1086 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1087 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1088 `postopts` text COMMENT 'External post connectors add their network name to this comma-separated string to identify that they should be delivered to these networks during delivery',
1089 `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1090 `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1091 `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1092 `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1093 `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1094 `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1095 `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1096 `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1097 `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1098 PRIMARY KEY(`uri-id`),
1099 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1100 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1105 CREATE TABLE IF NOT EXISTS `post-link` (
1106 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1107 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1108 `url` varbinary(511) NOT NULL COMMENT 'External URL',
1109 `mimetype` varchar(60) COMMENT '',
1111 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1112 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1113 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post related external links';
1118 CREATE TABLE IF NOT EXISTS `post-media` (
1119 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1120 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1121 `url` varbinary(511) NOT NULL COMMENT 'Media URL',
1122 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
1123 `mimetype` varchar(60) COMMENT '',
1124 `height` smallint unsigned COMMENT 'Height of the media',
1125 `width` smallint unsigned COMMENT 'Width of the media',
1126 `size` int unsigned COMMENT 'Media size',
1127 `preview` varbinary(255) COMMENT 'Preview URL',
1128 `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
1129 `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
1130 `description` text COMMENT '',
1131 `name` varchar(255) COMMENT 'Name of the media',
1132 `author-url` varbinary(255) COMMENT 'URL of the author of the media',
1133 `author-name` varchar(255) COMMENT 'Name of the author of the media',
1134 `author-image` varbinary(255) COMMENT 'Image of the author of the media',
1135 `publisher-url` varbinary(255) COMMENT 'URL of the publisher of the media',
1136 `publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
1137 `publisher-image` varbinary(255) COMMENT 'Image of the publisher of the media',
1139 UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
1140 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1141 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
1146 CREATE TABLE IF NOT EXISTS `post-tag` (
1147 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1148 `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1149 `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1150 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1151 PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1152 INDEX `tid` (`tid`),
1153 INDEX `cid` (`cid`),
1154 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1155 FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1156 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1157 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1160 -- TABLE post-thread
1162 CREATE TABLE IF NOT EXISTS `post-thread` (
1163 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1164 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1165 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1166 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1167 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1168 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1169 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1170 `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date that something in the conversation changed, indicating clients should fetch the conversation again',
1171 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1172 PRIMARY KEY(`uri-id`),
1173 INDEX `owner-id` (`owner-id`),
1174 INDEX `author-id` (`author-id`),
1175 INDEX `causer-id` (`causer-id`),
1176 INDEX `received` (`received`),
1177 INDEX `commented` (`commented`),
1178 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1179 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1180 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1181 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1182 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1187 CREATE TABLE IF NOT EXISTS `post-user` (
1188 `id` int unsigned NOT NULL auto_increment,
1189 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1190 `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
1191 `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
1192 `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
1193 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
1194 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
1195 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
1196 `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1197 `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
1198 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
1199 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
1200 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1201 `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
1202 `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
1203 `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
1204 `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1205 `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1206 `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1207 `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
1208 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1209 `protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
1210 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1211 `event-id` int unsigned COMMENT 'Used to link to the event.id',
1212 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1213 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1214 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1215 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1216 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1217 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1219 UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
1220 INDEX `uri-id` (`uri-id`),
1221 INDEX `parent-uri-id` (`parent-uri-id`),
1222 INDEX `thr-parent-id` (`thr-parent-id`),
1223 INDEX `external-id` (`external-id`),
1224 INDEX `owner-id` (`owner-id`),
1225 INDEX `author-id` (`author-id`),
1226 INDEX `causer-id` (`causer-id`),
1227 INDEX `vid` (`vid`),
1228 INDEX `contact-id` (`contact-id`),
1229 INDEX `event-id` (`event-id`),
1230 INDEX `psid` (`psid`),
1231 INDEX `author-id_uid` (`author-id`,`uid`),
1232 INDEX `author-id_received` (`author-id`,`received`),
1233 INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
1234 INDEX `uid_contactid` (`uid`,`contact-id`),
1235 INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
1236 INDEX `uid_unseen` (`uid`,`unseen`),
1237 INDEX `uid_hidden_uri-id` (`uid`,`hidden`,`uri-id`),
1238 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1239 FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1240 FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1241 FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1242 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1243 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1244 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1245 FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1246 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1247 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1248 FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1249 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1250 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
1253 -- TABLE post-thread-user
1255 CREATE TABLE IF NOT EXISTS `post-thread-user` (
1256 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1257 `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1258 `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1259 `causer-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
1260 `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1261 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1262 `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1263 `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date that something in the conversation changed, indicating clients should fetch the conversation again',
1264 `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1265 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
1266 `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'The thread is pinned on the profile page',
1267 `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1268 `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
1269 `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
1270 `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1271 `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1272 `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1273 `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1274 `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
1275 `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
1276 `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
1277 `psid` int unsigned COMMENT 'ID of the permission set of this post',
1278 `post-user-id` int unsigned COMMENT 'Id of the post-user table',
1279 PRIMARY KEY(`uid`,`uri-id`),
1280 INDEX `uri-id` (`uri-id`),
1281 INDEX `owner-id` (`owner-id`),
1282 INDEX `author-id` (`author-id`),
1283 INDEX `causer-id` (`causer-id`),
1284 INDEX `uid` (`uid`),
1285 INDEX `contact-id` (`contact-id`),
1286 INDEX `psid` (`psid`),
1287 INDEX `post-user-id` (`post-user-id`),
1288 INDEX `commented` (`commented`),
1289 INDEX `uid_received` (`uid`,`received`),
1290 INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1291 INDEX `uid_pinned` (`uid`,`pinned`),
1292 INDEX `uid_commented` (`uid`,`commented`),
1293 INDEX `uid_starred` (`uid`,`starred`),
1294 INDEX `uid_mention` (`uid`,`mention`),
1295 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1296 FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1297 FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1298 FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1299 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1300 FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1301 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
1302 FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
1303 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
1306 -- TABLE post-user-notification
1308 CREATE TABLE IF NOT EXISTS `post-user-notification` (
1309 `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1310 `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
1311 `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1312 PRIMARY KEY(`uid`,`uri-id`),
1313 INDEX `uri-id` (`uri-id`),
1314 FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1315 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1316 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User post notifications';
1321 CREATE TABLE IF NOT EXISTS `process` (
1322 `pid` int unsigned NOT NULL COMMENT '',
1323 `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
1324 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1326 INDEX `command` (`command`)
1327 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1332 CREATE TABLE IF NOT EXISTS `profile` (
1333 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1334 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1335 `profile-name` varchar(255) COMMENT 'Deprecated',
1336 `is-default` boolean COMMENT 'Deprecated',
1337 `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1338 `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1339 `pdesc` varchar(255) COMMENT 'Deprecated',
1340 `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1341 `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1342 `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1343 `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1344 `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1345 `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1346 `hometown` varchar(255) COMMENT 'Deprecated',
1347 `gender` varchar(32) COMMENT 'Deprecated',
1348 `marital` varchar(255) COMMENT 'Deprecated',
1349 `with` text COMMENT 'Deprecated',
1350 `howlong` datetime COMMENT 'Deprecated',
1351 `sexual` varchar(255) COMMENT 'Deprecated',
1352 `politic` varchar(255) COMMENT 'Deprecated',
1353 `religion` varchar(255) COMMENT 'Deprecated',
1354 `pub_keywords` text COMMENT '',
1355 `prv_keywords` text COMMENT '',
1356 `likes` text COMMENT 'Deprecated',
1357 `dislikes` text COMMENT 'Deprecated',
1358 `about` text COMMENT 'Profile description',
1359 `summary` varchar(255) COMMENT 'Deprecated',
1360 `music` text COMMENT 'Deprecated',
1361 `book` text COMMENT 'Deprecated',
1362 `tv` text COMMENT 'Deprecated',
1363 `film` text COMMENT 'Deprecated',
1364 `interest` text COMMENT 'Deprecated',
1365 `romance` text COMMENT 'Deprecated',
1366 `work` text COMMENT 'Deprecated',
1367 `education` text COMMENT 'Deprecated',
1368 `contact` text COMMENT 'Deprecated',
1369 `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1370 `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
1371 `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
1372 `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1373 `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1374 `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1375 `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1377 INDEX `uid_is-default` (`uid`,`is-default`),
1378 FULLTEXT INDEX `pub_keywords` (`pub_keywords`),
1379 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1380 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1383 -- TABLE profile_field
1385 CREATE TABLE IF NOT EXISTS `profile_field` (
1386 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1387 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1388 `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1389 `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1390 `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1391 `value` text COMMENT 'Value of the field',
1392 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1393 `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1395 INDEX `uid` (`uid`),
1396 INDEX `order` (`order`),
1397 INDEX `psid` (`psid`),
1398 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
1399 FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
1400 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1403 -- TABLE push_subscriber
1405 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1406 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1407 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1408 `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1409 `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1410 `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1411 `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1412 `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1413 `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1414 `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1415 `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1417 INDEX `next_try` (`next_try`),
1418 INDEX `uid` (`uid`),
1419 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1420 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1425 CREATE TABLE IF NOT EXISTS `register` (
1426 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1427 `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1428 `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1429 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1430 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1431 `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1432 `note` text COMMENT '',
1434 INDEX `uid` (`uid`),
1435 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1436 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1441 CREATE TABLE IF NOT EXISTS `search` (
1442 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1443 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1444 `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1446 INDEX `uid_term` (`uid`,`term`(64)),
1447 INDEX `term` (`term`(64)),
1448 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1449 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1454 CREATE TABLE IF NOT EXISTS `session` (
1455 `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1456 `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1457 `data` text COMMENT '',
1458 `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1460 INDEX `sid` (`sid`(64)),
1461 INDEX `expire` (`expire`)
1462 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1467 CREATE TABLE IF NOT EXISTS `storage` (
1468 `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1469 `data` longblob NOT NULL COMMENT 'file data',
1471 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1476 CREATE TABLE IF NOT EXISTS `userd` (
1477 `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1478 `username` varchar(255) NOT NULL COMMENT '',
1480 INDEX `username` (`username`(32))
1481 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1484 -- TABLE user-contact
1486 CREATE TABLE IF NOT EXISTS `user-contact` (
1487 `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1488 `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1489 `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1490 `ignored` boolean COMMENT 'Posts from this contact are ignored',
1491 `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1492 PRIMARY KEY(`uid`,`cid`),
1493 INDEX `cid` (`cid`),
1494 FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
1495 FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
1496 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1501 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1502 `key` int NOT NULL COMMENT '',
1503 `jobs` boolean COMMENT 'Flag for outstanding jobs',
1505 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1508 -- VIEW application-view
1510 DROP VIEW IF EXISTS `application-view`;
1511 CREATE VIEW `application-view` AS SELECT
1512 `application`.`id` AS `id`,
1513 `application-token`.`uid` AS `uid`,
1514 `application`.`name` AS `name`,
1515 `application`.`redirect_uri` AS `redirect_uri`,
1516 `application`.`website` AS `website`,
1517 `application`.`client_id` AS `client_id`,
1518 `application`.`client_secret` AS `client_secret`,
1519 `application-token`.`code` AS `code`,
1520 `application-token`.`access_token` AS `access_token`,
1521 `application-token`.`created_at` AS `created_at`,
1522 `application-token`.`scopes` AS `scopes`,
1523 `application-token`.`read` AS `read`,
1524 `application-token`.`write` AS `write`,
1525 `application-token`.`follow` AS `follow`,
1526 `application-token`.`push` AS `push`
1527 FROM `application-token`
1528 INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`;
1531 -- VIEW post-user-view
1533 DROP VIEW IF EXISTS `post-user-view`;
1534 CREATE VIEW `post-user-view` AS SELECT
1535 `post-user`.`id` AS `id`,
1536 `post-user`.`id` AS `post-user-id`,
1537 `post-user`.`uid` AS `uid`,
1538 `parent-post`.`id` AS `parent`,
1539 `item-uri`.`uri` AS `uri`,
1540 `post-user`.`uri-id` AS `uri-id`,
1541 `parent-item-uri`.`uri` AS `parent-uri`,
1542 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1543 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1544 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1545 `item-uri`.`guid` AS `guid`,
1546 `post-user`.`wall` AS `wall`,
1547 `post-user`.`gravity` AS `gravity`,
1548 `external-item-uri`.`uri` AS `extid`,
1549 `post-user`.`external-id` AS `external-id`,
1550 `post-user`.`created` AS `created`,
1551 `post-user`.`edited` AS `edited`,
1552 `post-thread-user`.`commented` AS `commented`,
1553 `post-user`.`received` AS `received`,
1554 `post-thread-user`.`changed` AS `changed`,
1555 `post-user`.`post-type` AS `post-type`,
1556 `post-user`.`post-reason` AS `post-reason`,
1557 `post-user`.`private` AS `private`,
1558 `post-thread-user`.`pubmail` AS `pubmail`,
1559 `post-user`.`visible` AS `visible`,
1560 `post-thread-user`.`starred` AS `starred`,
1561 `post-thread-user`.`pinned` AS `pinned`,
1562 `post-user`.`unseen` AS `unseen`,
1563 `post-user`.`deleted` AS `deleted`,
1564 `post-user`.`origin` AS `origin`,
1565 `post-thread-user`.`origin` AS `parent-origin`,
1566 `post-thread-user`.`forum_mode` AS `forum_mode`,
1567 `post-thread-user`.`mention` AS `mention`,
1568 `post-user`.`global` AS `global`,
1569 `post-user`.`network` AS `network`,
1570 `post-user`.`vid` AS `vid`,
1571 `post-user`.`psid` AS `psid`,
1572 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1573 `post-content`.`title` AS `title`,
1574 `post-content`.`content-warning` AS `content-warning`,
1575 `post-content`.`raw-body` AS `raw-body`,
1576 `post-content`.`body` AS `body`,
1577 `post-content`.`rendered-hash` AS `rendered-hash`,
1578 `post-content`.`rendered-html` AS `rendered-html`,
1579 `post-content`.`language` AS `language`,
1580 `post-content`.`plink` AS `plink`,
1581 `post-content`.`location` AS `location`,
1582 `post-content`.`coord` AS `coord`,
1583 `post-content`.`app` AS `app`,
1584 `post-content`.`object-type` AS `object-type`,
1585 `post-content`.`object` AS `object`,
1586 `post-content`.`target-type` AS `target-type`,
1587 `post-content`.`target` AS `target`,
1588 `post-content`.`resource-id` AS `resource-id`,
1589 `post-user`.`contact-id` AS `contact-id`,
1590 `contact`.`url` AS `contact-link`,
1591 `contact`.`addr` AS `contact-addr`,
1592 `contact`.`name` AS `contact-name`,
1593 `contact`.`nick` AS `contact-nick`,
1594 `contact`.`thumb` AS `contact-avatar`,
1595 `contact`.`network` AS `contact-network`,
1596 `contact`.`blocked` AS `contact-blocked`,
1597 `contact`.`hidden` AS `contact-hidden`,
1598 `contact`.`readonly` AS `contact-readonly`,
1599 `contact`.`archive` AS `contact-archive`,
1600 `contact`.`pending` AS `contact-pending`,
1601 `contact`.`rel` AS `contact-rel`,
1602 `contact`.`uid` AS `contact-uid`,
1603 `contact`.`contact-type` AS `contact-contact-type`,
1604 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1605 `contact`.`self` AS `self`,
1606 `contact`.`id` AS `cid`,
1607 `contact`.`alias` AS `alias`,
1608 `contact`.`photo` AS `photo`,
1609 `contact`.`name-date` AS `name-date`,
1610 `contact`.`uri-date` AS `uri-date`,
1611 `contact`.`avatar-date` AS `avatar-date`,
1612 `contact`.`thumb` AS `thumb`,
1613 `post-user`.`author-id` AS `author-id`,
1614 `author`.`url` AS `author-link`,
1615 `author`.`addr` AS `author-addr`,
1616 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1617 `author`.`nick` AS `author-nick`,
1618 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1619 `author`.`network` AS `author-network`,
1620 `author`.`blocked` AS `author-blocked`,
1621 `author`.`hidden` AS `author-hidden`,
1622 `post-user`.`owner-id` AS `owner-id`,
1623 `owner`.`url` AS `owner-link`,
1624 `owner`.`addr` AS `owner-addr`,
1625 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1626 `owner`.`nick` AS `owner-nick`,
1627 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1628 `owner`.`network` AS `owner-network`,
1629 `owner`.`blocked` AS `owner-blocked`,
1630 `owner`.`hidden` AS `owner-hidden`,
1631 `owner`.`contact-type` AS `owner-contact-type`,
1632 `post-user`.`causer-id` AS `causer-id`,
1633 `causer`.`url` AS `causer-link`,
1634 `causer`.`addr` AS `causer-addr`,
1635 `causer`.`name` AS `causer-name`,
1636 `causer`.`nick` AS `causer-nick`,
1637 `causer`.`thumb` AS `causer-avatar`,
1638 `causer`.`network` AS `causer-network`,
1639 `causer`.`blocked` AS `causer-blocked`,
1640 `causer`.`hidden` AS `causer-hidden`,
1641 `causer`.`contact-type` AS `causer-contact-type`,
1642 `post-delivery-data`.`postopts` AS `postopts`,
1643 `post-delivery-data`.`inform` AS `inform`,
1644 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1645 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1646 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1647 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1648 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1649 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1650 IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1651 `post-user`.`event-id` AS `event-id`,
1652 `event`.`created` AS `event-created`,
1653 `event`.`edited` AS `event-edited`,
1654 `event`.`start` AS `event-start`,
1655 `event`.`finish` AS `event-finish`,
1656 `event`.`summary` AS `event-summary`,
1657 `event`.`desc` AS `event-desc`,
1658 `event`.`location` AS `event-location`,
1659 `event`.`type` AS `event-type`,
1660 `event`.`nofinish` AS `event-nofinish`,
1661 `event`.`adjust` AS `event-adjust`,
1662 `event`.`ignore` AS `event-ignore`,
1663 `diaspora-interaction`.`interaction` AS `signed_text`,
1664 `parent-item-uri`.`guid` AS `parent-guid`,
1665 `parent-post`.`network` AS `parent-network`,
1666 `parent-post`.`author-id` AS `parent-author-id`,
1667 `parent-post-author`.`url` AS `parent-author-link`,
1668 `parent-post-author`.`name` AS `parent-author-name`,
1669 `parent-post-author`.`network` AS `parent-author-network`,
1670 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1671 `parent-post-author`.`hidden` AS `parent-author-hidden`
1673 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
1674 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
1675 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
1676 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
1677 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
1678 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
1679 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1680 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1681 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1682 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1683 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1684 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
1685 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
1686 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
1687 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
1688 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
1689 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1692 -- VIEW post-thread-user-view
1694 DROP VIEW IF EXISTS `post-thread-user-view`;
1695 CREATE VIEW `post-thread-user-view` AS SELECT
1696 `post-user`.`id` AS `id`,
1697 `post-user`.`id` AS `post-user-id`,
1698 `post-thread-user`.`uid` AS `uid`,
1699 `parent-post`.`id` AS `parent`,
1700 `item-uri`.`uri` AS `uri`,
1701 `post-thread-user`.`uri-id` AS `uri-id`,
1702 `parent-item-uri`.`uri` AS `parent-uri`,
1703 `post-user`.`parent-uri-id` AS `parent-uri-id`,
1704 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1705 `post-user`.`thr-parent-id` AS `thr-parent-id`,
1706 `item-uri`.`guid` AS `guid`,
1707 `post-thread-user`.`wall` AS `wall`,
1708 `post-user`.`gravity` AS `gravity`,
1709 `external-item-uri`.`uri` AS `extid`,
1710 `post-user`.`external-id` AS `external-id`,
1711 `post-thread-user`.`created` AS `created`,
1712 `post-user`.`edited` AS `edited`,
1713 `post-thread-user`.`commented` AS `commented`,
1714 `post-thread-user`.`received` AS `received`,
1715 `post-thread-user`.`changed` AS `changed`,
1716 `post-user`.`post-type` AS `post-type`,
1717 `post-user`.`post-reason` AS `post-reason`,
1718 `post-user`.`private` AS `private`,
1719 `post-thread-user`.`pubmail` AS `pubmail`,
1720 `post-thread-user`.`ignored` AS `ignored`,
1721 `post-user`.`visible` AS `visible`,
1722 `post-thread-user`.`starred` AS `starred`,
1723 `post-thread-user`.`pinned` AS `pinned`,
1724 `post-thread-user`.`unseen` AS `unseen`,
1725 `post-user`.`deleted` AS `deleted`,
1726 `post-thread-user`.`origin` AS `origin`,
1727 `post-thread-user`.`forum_mode` AS `forum_mode`,
1728 `post-thread-user`.`mention` AS `mention`,
1729 `post-user`.`global` AS `global`,
1730 `post-thread-user`.`network` AS `network`,
1731 `post-user`.`vid` AS `vid`,
1732 `post-thread-user`.`psid` AS `psid`,
1733 IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1734 `post-content`.`title` AS `title`,
1735 `post-content`.`content-warning` AS `content-warning`,
1736 `post-content`.`raw-body` AS `raw-body`,
1737 `post-content`.`body` AS `body`,
1738 `post-content`.`rendered-hash` AS `rendered-hash`,
1739 `post-content`.`rendered-html` AS `rendered-html`,
1740 `post-content`.`language` AS `language`,
1741 `post-content`.`plink` AS `plink`,
1742 `post-content`.`location` AS `location`,
1743 `post-content`.`coord` AS `coord`,
1744 `post-content`.`app` AS `app`,
1745 `post-content`.`object-type` AS `object-type`,
1746 `post-content`.`object` AS `object`,
1747 `post-content`.`target-type` AS `target-type`,
1748 `post-content`.`target` AS `target`,
1749 `post-content`.`resource-id` AS `resource-id`,
1750 `post-thread-user`.`contact-id` AS `contact-id`,
1751 `contact`.`url` AS `contact-link`,
1752 `contact`.`addr` AS `contact-addr`,
1753 `contact`.`name` AS `contact-name`,
1754 `contact`.`nick` AS `contact-nick`,
1755 `contact`.`thumb` AS `contact-avatar`,
1756 `contact`.`network` AS `contact-network`,
1757 `contact`.`blocked` AS `contact-blocked`,
1758 `contact`.`hidden` AS `contact-hidden`,
1759 `contact`.`readonly` AS `contact-readonly`,
1760 `contact`.`archive` AS `contact-archive`,
1761 `contact`.`pending` AS `contact-pending`,
1762 `contact`.`rel` AS `contact-rel`,
1763 `contact`.`uid` AS `contact-uid`,
1764 `contact`.`contact-type` AS `contact-contact-type`,
1765 IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
1766 `contact`.`self` AS `self`,
1767 `contact`.`id` AS `cid`,
1768 `contact`.`alias` AS `alias`,
1769 `contact`.`photo` AS `photo`,
1770 `contact`.`name-date` AS `name-date`,
1771 `contact`.`uri-date` AS `uri-date`,
1772 `contact`.`avatar-date` AS `avatar-date`,
1773 `contact`.`thumb` AS `thumb`,
1774 `post-thread-user`.`author-id` AS `author-id`,
1775 `author`.`url` AS `author-link`,
1776 `author`.`addr` AS `author-addr`,
1777 IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
1778 `author`.`nick` AS `author-nick`,
1779 IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`) AS `author-avatar`,
1780 `author`.`network` AS `author-network`,
1781 `author`.`blocked` AS `author-blocked`,
1782 `author`.`hidden` AS `author-hidden`,
1783 `post-thread-user`.`owner-id` AS `owner-id`,
1784 `owner`.`url` AS `owner-link`,
1785 `owner`.`addr` AS `owner-addr`,
1786 IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
1787 `owner`.`nick` AS `owner-nick`,
1788 IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`) AS `owner-avatar`,
1789 `owner`.`network` AS `owner-network`,
1790 `owner`.`blocked` AS `owner-blocked`,
1791 `owner`.`hidden` AS `owner-hidden`,
1792 `owner`.`contact-type` AS `owner-contact-type`,
1793 `post-thread-user`.`causer-id` AS `causer-id`,
1794 `causer`.`url` AS `causer-link`,
1795 `causer`.`addr` AS `causer-addr`,
1796 `causer`.`name` AS `causer-name`,
1797 `causer`.`nick` AS `causer-nick`,
1798 `causer`.`thumb` AS `causer-avatar`,
1799 `causer`.`network` AS `causer-network`,
1800 `causer`.`blocked` AS `causer-blocked`,
1801 `causer`.`hidden` AS `causer-hidden`,
1802 `causer`.`contact-type` AS `causer-contact-type`,
1803 `post-delivery-data`.`postopts` AS `postopts`,
1804 `post-delivery-data`.`inform` AS `inform`,
1805 `post-delivery-data`.`queue_count` AS `delivery_queue_count`,
1806 `post-delivery-data`.`queue_done` AS `delivery_queue_done`,
1807 `post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
1808 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
1809 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
1810 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
1811 IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
1812 `post-user`.`event-id` AS `event-id`,
1813 `event`.`created` AS `event-created`,
1814 `event`.`edited` AS `event-edited`,
1815 `event`.`start` AS `event-start`,
1816 `event`.`finish` AS `event-finish`,
1817 `event`.`summary` AS `event-summary`,
1818 `event`.`desc` AS `event-desc`,
1819 `event`.`location` AS `event-location`,
1820 `event`.`type` AS `event-type`,
1821 `event`.`nofinish` AS `event-nofinish`,
1822 `event`.`adjust` AS `event-adjust`,
1823 `event`.`ignore` AS `event-ignore`,
1824 `diaspora-interaction`.`interaction` AS `signed_text`,
1825 `parent-item-uri`.`guid` AS `parent-guid`,
1826 `parent-post`.`network` AS `parent-network`,
1827 `parent-post`.`author-id` AS `parent-author-id`,
1828 `parent-post-author`.`url` AS `parent-author-link`,
1829 `parent-post-author`.`name` AS `parent-author-name`,
1830 `parent-post-author`.`network` AS `parent-author-network`,
1831 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1832 `parent-post-author`.`hidden` AS `parent-author-hidden`
1833 FROM `post-thread-user`
1834 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
1835 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
1836 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
1837 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
1838 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
1839 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
1840 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
1841 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
1842 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
1843 LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
1844 LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
1845 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
1846 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
1847 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
1848 LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
1849 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`
1850 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1855 DROP VIEW IF EXISTS `post-view`;
1856 CREATE VIEW `post-view` AS SELECT
1857 `item-uri`.`uri` AS `uri`,
1858 `post`.`uri-id` AS `uri-id`,
1859 `parent-item-uri`.`uri` AS `parent-uri`,
1860 `post`.`parent-uri-id` AS `parent-uri-id`,
1861 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1862 `post`.`thr-parent-id` AS `thr-parent-id`,
1863 `item-uri`.`guid` AS `guid`,
1864 `post`.`gravity` AS `gravity`,
1865 `external-item-uri`.`uri` AS `extid`,
1866 `post`.`external-id` AS `external-id`,
1867 `post`.`created` AS `created`,
1868 `post`.`edited` AS `edited`,
1869 `post-thread`.`commented` AS `commented`,
1870 `post`.`received` AS `received`,
1871 `post-thread`.`changed` AS `changed`,
1872 `post`.`post-type` AS `post-type`,
1873 `post`.`private` AS `private`,
1874 `post`.`visible` AS `visible`,
1875 `post`.`deleted` AS `deleted`,
1876 `post`.`global` AS `global`,
1877 `post`.`network` AS `network`,
1878 `post`.`vid` AS `vid`,
1879 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
1880 `post-content`.`title` AS `title`,
1881 `post-content`.`content-warning` AS `content-warning`,
1882 `post-content`.`raw-body` AS `raw-body`,
1883 `post-content`.`body` AS `body`,
1884 `post-content`.`rendered-hash` AS `rendered-hash`,
1885 `post-content`.`rendered-html` AS `rendered-html`,
1886 `post-content`.`language` AS `language`,
1887 `post-content`.`plink` AS `plink`,
1888 `post-content`.`location` AS `location`,
1889 `post-content`.`coord` AS `coord`,
1890 `post-content`.`app` AS `app`,
1891 `post-content`.`object-type` AS `object-type`,
1892 `post-content`.`object` AS `object`,
1893 `post-content`.`target-type` AS `target-type`,
1894 `post-content`.`target` AS `target`,
1895 `post-content`.`resource-id` AS `resource-id`,
1896 `post`.`author-id` AS `contact-id`,
1897 `author`.`url` AS `contact-link`,
1898 `author`.`addr` AS `contact-addr`,
1899 `author`.`name` AS `contact-name`,
1900 `author`.`nick` AS `contact-nick`,
1901 `author`.`thumb` AS `contact-avatar`,
1902 `author`.`network` AS `contact-network`,
1903 `author`.`blocked` AS `contact-blocked`,
1904 `author`.`hidden` AS `contact-hidden`,
1905 `author`.`readonly` AS `contact-readonly`,
1906 `author`.`archive` AS `contact-archive`,
1907 `author`.`pending` AS `contact-pending`,
1908 `author`.`rel` AS `contact-rel`,
1909 `author`.`uid` AS `contact-uid`,
1910 `author`.`contact-type` AS `contact-contact-type`,
1911 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
1913 `author`.`id` AS `cid`,
1914 `author`.`alias` AS `alias`,
1915 `author`.`photo` AS `photo`,
1916 `author`.`name-date` AS `name-date`,
1917 `author`.`uri-date` AS `uri-date`,
1918 `author`.`avatar-date` AS `avatar-date`,
1919 `author`.`thumb` AS `thumb`,
1920 `post`.`author-id` AS `author-id`,
1921 `author`.`url` AS `author-link`,
1922 `author`.`addr` AS `author-addr`,
1923 `author`.`name` AS `author-name`,
1924 `author`.`nick` AS `author-nick`,
1925 `author`.`thumb` AS `author-avatar`,
1926 `author`.`network` AS `author-network`,
1927 `author`.`blocked` AS `author-blocked`,
1928 `author`.`hidden` AS `author-hidden`,
1929 `post`.`owner-id` AS `owner-id`,
1930 `owner`.`url` AS `owner-link`,
1931 `owner`.`addr` AS `owner-addr`,
1932 `owner`.`name` AS `owner-name`,
1933 `owner`.`nick` AS `owner-nick`,
1934 `owner`.`thumb` AS `owner-avatar`,
1935 `owner`.`network` AS `owner-network`,
1936 `owner`.`blocked` AS `owner-blocked`,
1937 `owner`.`hidden` AS `owner-hidden`,
1938 `owner`.`contact-type` AS `owner-contact-type`,
1939 `post`.`causer-id` AS `causer-id`,
1940 `causer`.`url` AS `causer-link`,
1941 `causer`.`addr` AS `causer-addr`,
1942 `causer`.`name` AS `causer-name`,
1943 `causer`.`nick` AS `causer-nick`,
1944 `causer`.`thumb` AS `causer-avatar`,
1945 `causer`.`network` AS `causer-network`,
1946 `causer`.`blocked` AS `causer-blocked`,
1947 `causer`.`hidden` AS `causer-hidden`,
1948 `causer`.`contact-type` AS `causer-contact-type`,
1949 `diaspora-interaction`.`interaction` AS `signed_text`,
1950 `parent-item-uri`.`guid` AS `parent-guid`,
1951 `parent-post`.`network` AS `parent-network`,
1952 `parent-post`.`author-id` AS `parent-author-id`,
1953 `parent-post-author`.`url` AS `parent-author-link`,
1954 `parent-post-author`.`name` AS `parent-author-name`,
1955 `parent-post-author`.`network` AS `parent-author-network`,
1956 `parent-post-author`.`blocked` AS `parent-author-blocked`,
1957 `parent-post-author`.`hidden` AS `parent-author-hidden`
1959 STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
1960 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
1961 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
1962 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
1963 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
1964 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
1965 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
1966 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
1967 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
1968 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
1969 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
1970 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
1971 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
1974 -- VIEW post-thread-view
1976 DROP VIEW IF EXISTS `post-thread-view`;
1977 CREATE VIEW `post-thread-view` AS SELECT
1978 `item-uri`.`uri` AS `uri`,
1979 `post-thread`.`uri-id` AS `uri-id`,
1980 `parent-item-uri`.`uri` AS `parent-uri`,
1981 `post`.`parent-uri-id` AS `parent-uri-id`,
1982 `thr-parent-item-uri`.`uri` AS `thr-parent`,
1983 `post`.`thr-parent-id` AS `thr-parent-id`,
1984 `item-uri`.`guid` AS `guid`,
1985 `post`.`gravity` AS `gravity`,
1986 `external-item-uri`.`uri` AS `extid`,
1987 `post`.`external-id` AS `external-id`,
1988 `post-thread`.`created` AS `created`,
1989 `post`.`edited` AS `edited`,
1990 `post-thread`.`commented` AS `commented`,
1991 `post-thread`.`received` AS `received`,
1992 `post-thread`.`changed` AS `changed`,
1993 `post`.`post-type` AS `post-type`,
1994 `post`.`private` AS `private`,
1995 `post`.`visible` AS `visible`,
1996 `post`.`deleted` AS `deleted`,
1997 `post`.`global` AS `global`,
1998 `post-thread`.`network` AS `network`,
1999 `post`.`vid` AS `vid`,
2000 IF (`post`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
2001 `post-content`.`title` AS `title`,
2002 `post-content`.`content-warning` AS `content-warning`,
2003 `post-content`.`raw-body` AS `raw-body`,
2004 `post-content`.`body` AS `body`,
2005 `post-content`.`rendered-hash` AS `rendered-hash`,
2006 `post-content`.`rendered-html` AS `rendered-html`,
2007 `post-content`.`language` AS `language`,
2008 `post-content`.`plink` AS `plink`,
2009 `post-content`.`location` AS `location`,
2010 `post-content`.`coord` AS `coord`,
2011 `post-content`.`app` AS `app`,
2012 `post-content`.`object-type` AS `object-type`,
2013 `post-content`.`object` AS `object`,
2014 `post-content`.`target-type` AS `target-type`,
2015 `post-content`.`target` AS `target`,
2016 `post-content`.`resource-id` AS `resource-id`,
2017 `post-thread`.`author-id` AS `contact-id`,
2018 `author`.`url` AS `contact-link`,
2019 `author`.`addr` AS `contact-addr`,
2020 `author`.`name` AS `contact-name`,
2021 `author`.`nick` AS `contact-nick`,
2022 `author`.`thumb` AS `contact-avatar`,
2023 `author`.`network` AS `contact-network`,
2024 `author`.`blocked` AS `contact-blocked`,
2025 `author`.`hidden` AS `contact-hidden`,
2026 `author`.`readonly` AS `contact-readonly`,
2027 `author`.`archive` AS `contact-archive`,
2028 `author`.`pending` AS `contact-pending`,
2029 `author`.`rel` AS `contact-rel`,
2030 `author`.`uid` AS `contact-uid`,
2031 `author`.`contact-type` AS `contact-contact-type`,
2032 IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`) AS `writable`,
2034 `author`.`id` AS `cid`,
2035 `author`.`alias` AS `alias`,
2036 `author`.`photo` AS `photo`,
2037 `author`.`name-date` AS `name-date`,
2038 `author`.`uri-date` AS `uri-date`,
2039 `author`.`avatar-date` AS `avatar-date`,
2040 `author`.`thumb` AS `thumb`,
2041 `post-thread`.`author-id` AS `author-id`,
2042 `author`.`url` AS `author-link`,
2043 `author`.`addr` AS `author-addr`,
2044 `author`.`name` AS `author-name`,
2045 `author`.`nick` AS `author-nick`,
2046 `author`.`thumb` AS `author-avatar`,
2047 `author`.`network` AS `author-network`,
2048 `author`.`blocked` AS `author-blocked`,
2049 `author`.`hidden` AS `author-hidden`,
2050 `post-thread`.`owner-id` AS `owner-id`,
2051 `owner`.`url` AS `owner-link`,
2052 `owner`.`addr` AS `owner-addr`,
2053 `owner`.`name` AS `owner-name`,
2054 `owner`.`nick` AS `owner-nick`,
2055 `owner`.`thumb` AS `owner-avatar`,
2056 `owner`.`network` AS `owner-network`,
2057 `owner`.`blocked` AS `owner-blocked`,
2058 `owner`.`hidden` AS `owner-hidden`,
2059 `owner`.`contact-type` AS `owner-contact-type`,
2060 `post-thread`.`causer-id` AS `causer-id`,
2061 `causer`.`url` AS `causer-link`,
2062 `causer`.`addr` AS `causer-addr`,
2063 `causer`.`name` AS `causer-name`,
2064 `causer`.`nick` AS `causer-nick`,
2065 `causer`.`thumb` AS `causer-avatar`,
2066 `causer`.`network` AS `causer-network`,
2067 `causer`.`blocked` AS `causer-blocked`,
2068 `causer`.`hidden` AS `causer-hidden`,
2069 `causer`.`contact-type` AS `causer-contact-type`,
2070 `diaspora-interaction`.`interaction` AS `signed_text`,
2071 `parent-item-uri`.`guid` AS `parent-guid`,
2072 `parent-post`.`network` AS `parent-network`,
2073 `parent-post`.`author-id` AS `parent-author-id`,
2074 `parent-post-author`.`url` AS `parent-author-link`,
2075 `parent-post-author`.`name` AS `parent-author-name`,
2076 `parent-post-author`.`network` AS `parent-author-network`,
2077 `parent-post-author`.`blocked` AS `parent-author-blocked`,
2078 `parent-post-author`.`hidden` AS `parent-author-hidden`
2080 INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
2081 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
2082 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
2083 LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
2084 LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
2085 LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
2086 LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
2087 LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
2088 LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
2089 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
2090 LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
2091 LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
2092 LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
2095 -- VIEW category-view
2097 DROP VIEW IF EXISTS `category-view`;
2098 CREATE VIEW `category-view` AS SELECT
2099 `post-category`.`uri-id` AS `uri-id`,
2100 `post-category`.`uid` AS `uid`,
2101 `post-category`.`type` AS `type`,
2102 `post-category`.`tid` AS `tid`,
2103 `tag`.`name` AS `name`,
2104 `tag`.`url` AS `url`
2105 FROM `post-category`
2106 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
2111 DROP VIEW IF EXISTS `tag-view`;
2112 CREATE VIEW `tag-view` AS SELECT
2113 `post-tag`.`uri-id` AS `uri-id`,
2114 `post-tag`.`type` AS `type`,
2115 `post-tag`.`tid` AS `tid`,
2116 `post-tag`.`cid` AS `cid`,
2117 CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
2118 CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
2120 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
2121 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
2124 -- VIEW network-item-view
2126 DROP VIEW IF EXISTS `network-item-view`;
2127 CREATE VIEW `network-item-view` AS SELECT
2128 `post-user`.`uri-id` AS `uri-id`,
2129 `parent-post`.`id` AS `parent`,
2130 `post-user`.`received` AS `received`,
2131 `post-thread-user`.`commented` AS `commented`,
2132 `post-user`.`created` AS `created`,
2133 `post-user`.`uid` AS `uid`,
2134 `post-thread-user`.`starred` AS `starred`,
2135 `post-thread-user`.`mention` AS `mention`,
2136 `post-user`.`network` AS `network`,
2137 `post-user`.`unseen` AS `unseen`,
2138 `post-user`.`gravity` AS `gravity`,
2139 `post-user`.`contact-id` AS `contact-id`,
2140 `ownercontact`.`contact-type` AS `contact-type`
2142 STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
2143 INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2144 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2145 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2146 INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2147 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2148 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2149 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2150 AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
2151 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2152 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2155 -- VIEW network-thread-view
2157 DROP VIEW IF EXISTS `network-thread-view`;
2158 CREATE VIEW `network-thread-view` AS SELECT
2159 `post-thread-user`.`uri-id` AS `uri-id`,
2160 `parent-post`.`id` AS `parent`,
2161 `post-thread-user`.`received` AS `received`,
2162 `post-thread-user`.`commented` AS `commented`,
2163 `post-thread-user`.`created` AS `created`,
2164 `post-thread-user`.`uid` AS `uid`,
2165 `post-thread-user`.`starred` AS `starred`,
2166 `post-thread-user`.`mention` AS `mention`,
2167 `post-thread-user`.`network` AS `network`,
2168 `post-thread-user`.`contact-id` AS `contact-id`,
2169 `ownercontact`.`contact-type` AS `contact-type`
2170 FROM `post-thread-user`
2171 INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
2172 STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
2173 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
2174 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
2175 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
2176 LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
2177 WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
2178 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
2179 AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
2180 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
2181 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
2186 DROP VIEW IF EXISTS `owner-view`;
2187 CREATE VIEW `owner-view` AS SELECT
2188 `contact`.`id` AS `id`,
2189 `contact`.`uid` AS `uid`,
2190 `contact`.`created` AS `created`,
2191 `contact`.`updated` AS `updated`,
2192 `contact`.`self` AS `self`,
2193 `contact`.`remote_self` AS `remote_self`,
2194 `contact`.`rel` AS `rel`,
2195 `contact`.`network` AS `network`,
2196 `contact`.`protocol` AS `protocol`,
2197 `contact`.`name` AS `name`,
2198 `contact`.`nick` AS `nick`,
2199 `contact`.`location` AS `location`,
2200 `contact`.`about` AS `about`,
2201 `contact`.`keywords` AS `keywords`,
2202 `contact`.`gender` AS `gender`,
2203 `contact`.`xmpp` AS `xmpp`,
2204 `contact`.`matrix` AS `matrix`,
2205 `contact`.`attag` AS `attag`,
2206 `contact`.`avatar` AS `avatar`,
2207 `contact`.`photo` AS `photo`,
2208 `contact`.`thumb` AS `thumb`,
2209 `contact`.`micro` AS `micro`,
2210 `contact`.`header` AS `header`,
2211 `contact`.`url` AS `url`,
2212 `contact`.`nurl` AS `nurl`,
2213 `contact`.`uri-id` AS `uri-id`,
2214 `contact`.`addr` AS `addr`,
2215 `contact`.`alias` AS `alias`,
2216 `contact`.`pubkey` AS `pubkey`,
2217 `contact`.`prvkey` AS `prvkey`,
2218 `contact`.`batch` AS `batch`,
2219 `contact`.`request` AS `request`,
2220 `contact`.`notify` AS `notify`,
2221 `contact`.`poll` AS `poll`,
2222 `contact`.`confirm` AS `confirm`,
2223 `contact`.`poco` AS `poco`,
2224 `contact`.`usehub` AS `usehub`,
2225 `contact`.`subhub` AS `subhub`,
2226 `contact`.`hub-verify` AS `hub-verify`,
2227 `contact`.`last-update` AS `last-update`,
2228 `contact`.`success_update` AS `success_update`,
2229 `contact`.`failure_update` AS `failure_update`,
2230 `contact`.`name-date` AS `name-date`,
2231 `contact`.`uri-date` AS `uri-date`,
2232 `contact`.`avatar-date` AS `avatar-date`,
2233 `contact`.`avatar-date` AS `picdate`,
2234 `contact`.`term-date` AS `term-date`,
2235 `contact`.`last-item` AS `last-item`,
2236 `contact`.`priority` AS `priority`,
2237 `user`.`blocked` AS `blocked`,
2238 `contact`.`block_reason` AS `block_reason`,
2239 `contact`.`readonly` AS `readonly`,
2240 `contact`.`writable` AS `writable`,
2241 `contact`.`forum` AS `forum`,
2242 `contact`.`prv` AS `prv`,
2243 `contact`.`contact-type` AS `contact-type`,
2244 `contact`.`manually-approve` AS `manually-approve`,
2245 `contact`.`hidden` AS `hidden`,
2246 `contact`.`archive` AS `archive`,
2247 `contact`.`pending` AS `pending`,
2248 `contact`.`deleted` AS `deleted`,
2249 `contact`.`unsearchable` AS `unsearchable`,
2250 `contact`.`sensitive` AS `sensitive`,
2251 `contact`.`baseurl` AS `baseurl`,
2252 `contact`.`reason` AS `reason`,
2253 `contact`.`closeness` AS `closeness`,
2254 `contact`.`info` AS `info`,
2255 `contact`.`profile-id` AS `profile-id`,
2256 `contact`.`bdyear` AS `bdyear`,
2257 `contact`.`bd` AS `bd`,
2258 `contact`.`notify_new_posts` AS `notify_new_posts`,
2259 `contact`.`fetch_further_information` AS `fetch_further_information`,
2260 `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2261 `user`.`parent-uid` AS `parent-uid`,
2262 `user`.`guid` AS `guid`,
2263 `user`.`nickname` AS `nickname`,
2264 `user`.`email` AS `email`,
2265 `user`.`openid` AS `openid`,
2266 `user`.`timezone` AS `timezone`,
2267 `user`.`language` AS `language`,
2268 `user`.`register_date` AS `register_date`,
2269 `user`.`login_date` AS `login_date`,
2270 `user`.`default-location` AS `default-location`,
2271 `user`.`allow_location` AS `allow_location`,
2272 `user`.`theme` AS `theme`,
2273 `user`.`pubkey` AS `upubkey`,
2274 `user`.`prvkey` AS `uprvkey`,
2275 `user`.`sprvkey` AS `sprvkey`,
2276 `user`.`spubkey` AS `spubkey`,
2277 `user`.`verified` AS `verified`,
2278 `user`.`blockwall` AS `blockwall`,
2279 `user`.`hidewall` AS `hidewall`,
2280 `user`.`blocktags` AS `blocktags`,
2281 `user`.`unkmail` AS `unkmail`,
2282 `user`.`cntunkmail` AS `cntunkmail`,
2283 `user`.`notify-flags` AS `notify-flags`,
2284 `user`.`page-flags` AS `page-flags`,
2285 `user`.`account-type` AS `account-type`,
2286 `user`.`prvnets` AS `prvnets`,
2287 `user`.`maxreq` AS `maxreq`,
2288 `user`.`expire` AS `expire`,
2289 `user`.`account_removed` AS `account_removed`,
2290 `user`.`account_expired` AS `account_expired`,
2291 `user`.`account_expires_on` AS `account_expires_on`,
2292 `user`.`expire_notification_sent` AS `expire_notification_sent`,
2293 `user`.`def_gid` AS `def_gid`,
2294 `user`.`allow_cid` AS `allow_cid`,
2295 `user`.`allow_gid` AS `allow_gid`,
2296 `user`.`deny_cid` AS `deny_cid`,
2297 `user`.`deny_gid` AS `deny_gid`,
2298 `user`.`openidserver` AS `openidserver`,
2299 `profile`.`publish` AS `publish`,
2300 `profile`.`net-publish` AS `net-publish`,
2301 `profile`.`hide-friends` AS `hide-friends`,
2302 `profile`.`prv_keywords` AS `prv_keywords`,
2303 `profile`.`pub_keywords` AS `pub_keywords`,
2304 `profile`.`address` AS `address`,
2305 `profile`.`locality` AS `locality`,
2306 `profile`.`region` AS `region`,
2307 `profile`.`postal-code` AS `postal-code`,
2308 `profile`.`country-name` AS `country-name`,
2309 `profile`.`homepage` AS `homepage`,
2310 `profile`.`dob` AS `dob`
2312 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
2313 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
2316 -- VIEW account-view
2318 DROP VIEW IF EXISTS `account-view`;
2319 CREATE VIEW `account-view` AS SELECT
2320 `contact`.`id` AS `id`,
2321 `contact`.`url` AS `url`,
2322 `contact`.`nurl` AS `nurl`,
2323 `contact`.`uri-id` AS `uri-id`,
2324 `contact`.`addr` AS `addr`,
2325 `contact`.`alias` AS `alias`,
2326 `contact`.`name` AS `name`,
2327 `contact`.`nick` AS `nick`,
2328 `contact`.`about` AS `about`,
2329 `contact`.`keywords` AS `keywords`,
2330 `contact`.`xmpp` AS `xmpp`,
2331 `contact`.`matrix` AS `matrix`,
2332 `contact`.`avatar` AS `avatar`,
2333 `contact`.`photo` AS `photo`,
2334 `contact`.`thumb` AS `thumb`,
2335 `contact`.`micro` AS `micro`,
2336 `contact`.`header` AS `header`,
2337 `contact`.`created` AS `created`,
2338 `contact`.`updated` AS `updated`,
2339 `contact`.`network` AS `network`,
2340 `contact`.`protocol` AS `protocol`,
2341 `contact`.`location` AS `location`,
2342 `contact`.`attag` AS `attag`,
2343 `contact`.`pubkey` AS `pubkey`,
2344 `contact`.`prvkey` AS `prvkey`,
2345 `contact`.`subscribe` AS `subscribe`,
2346 `contact`.`last-update` AS `last-update`,
2347 `contact`.`success_update` AS `success_update`,
2348 `contact`.`failure_update` AS `failure_update`,
2349 `contact`.`failed` AS `failed`,
2350 `contact`.`last-item` AS `last-item`,
2351 `contact`.`last-discovery` AS `last-discovery`,
2352 `contact`.`contact-type` AS `contact-type`,
2353 `contact`.`manually-approve` AS `manually-approve`,
2354 `contact`.`unsearchable` AS `unsearchable`,
2355 `contact`.`sensitive` AS `sensitive`,
2356 `contact`.`baseurl` AS `baseurl`,
2357 `contact`.`gsid` AS `gsid`,
2358 `contact`.`info` AS `info`,
2359 `contact`.`bdyear` AS `bdyear`,
2360 `contact`.`bd` AS `bd`,
2361 `contact`.`poco` AS `poco`,
2362 `contact`.`name-date` AS `name-date`,
2363 `contact`.`uri-date` AS `uri-date`,
2364 `contact`.`avatar-date` AS `avatar-date`,
2365 `contact`.`term-date` AS `term-date`,
2366 `contact`.`hidden` AS `global-ignored`,
2367 `contact`.`blocked` AS `global-blocked`,
2368 `contact`.`hidden` AS `hidden`,
2369 `contact`.`archive` AS `archive`,
2370 `contact`.`deleted` AS `deleted`,
2371 `contact`.`blocked` AS `blocked`,
2372 `contact`.`request` AS `dfrn-request`,
2373 `contact`.`notify` AS `dfrn-notify`,
2374 `contact`.`poll` AS `dfrn-poll`,
2375 `contact`.`confirm` AS `dfrn-confirm`,
2376 `fcontact`.`guid` AS `diaspora-guid`,
2377 `fcontact`.`batch` AS `diaspora-batch`,
2378 `fcontact`.`notify` AS `diaspora-notify`,
2379 `fcontact`.`poll` AS `diaspora-poll`,
2380 `fcontact`.`alias` AS `diaspora-alias`,
2381 `apcontact`.`uuid` AS `ap-uuid`,
2382 `apcontact`.`type` AS `ap-type`,
2383 `apcontact`.`following` AS `ap-following`,
2384 `apcontact`.`followers` AS `ap-followers`,
2385 `apcontact`.`inbox` AS `ap-inbox`,
2386 `apcontact`.`outbox` AS `ap-outbox`,
2387 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2388 `apcontact`.`generator` AS `ap-generator`,
2389 `apcontact`.`following_count` AS `ap-following_count`,
2390 `apcontact`.`followers_count` AS `ap-followers_count`,
2391 `apcontact`.`statuses_count` AS `ap-statuses_count`
2393 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
2394 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = contact.`uri-id`
2395 WHERE `contact`.`uid` = 0;
2398 -- VIEW account-user-view
2400 DROP VIEW IF EXISTS `account-user-view`;
2401 CREATE VIEW `account-user-view` AS SELECT
2402 `ucontact`.`id` AS `id`,
2403 `contact`.`id` AS `pid`,
2404 `ucontact`.`uid` AS `uid`,
2405 `contact`.`url` AS `url`,
2406 `contact`.`nurl` AS `nurl`,
2407 `contact`.`uri-id` AS `uri-id`,
2408 `contact`.`addr` AS `addr`,
2409 `contact`.`alias` AS `alias`,
2410 `contact`.`name` AS `name`,
2411 `contact`.`nick` AS `nick`,
2412 `contact`.`about` AS `about`,
2413 `contact`.`keywords` AS `keywords`,
2414 `contact`.`xmpp` AS `xmpp`,
2415 `contact`.`matrix` AS `matrix`,
2416 `contact`.`avatar` AS `avatar`,
2417 `contact`.`photo` AS `photo`,
2418 `contact`.`thumb` AS `thumb`,
2419 `contact`.`micro` AS `micro`,
2420 `contact`.`header` AS `header`,
2421 `contact`.`created` AS `created`,
2422 `contact`.`updated` AS `updated`,
2423 `ucontact`.`self` AS `self`,
2424 `ucontact`.`remote_self` AS `remote_self`,
2425 `ucontact`.`rel` AS `rel`,
2426 `contact`.`network` AS `network`,
2427 `ucontact`.`protocol` AS `protocol`,
2428 `contact`.`location` AS `location`,
2429 `contact`.`attag` AS `attag`,
2430 `contact`.`pubkey` AS `pubkey`,
2431 `contact`.`prvkey` AS `prvkey`,
2432 `contact`.`subscribe` AS `subscribe`,
2433 `contact`.`last-update` AS `last-update`,
2434 `contact`.`success_update` AS `success_update`,
2435 `contact`.`failure_update` AS `failure_update`,
2436 `contact`.`failed` AS `failed`,
2437 `contact`.`last-item` AS `last-item`,
2438 `contact`.`last-discovery` AS `last-discovery`,
2439 `contact`.`contact-type` AS `contact-type`,
2440 `contact`.`manually-approve` AS `manually-approve`,
2441 `contact`.`unsearchable` AS `unsearchable`,
2442 `contact`.`sensitive` AS `sensitive`,
2443 `contact`.`baseurl` AS `baseurl`,
2444 `contact`.`gsid` AS `gsid`,
2445 `contact`.`info` AS `info`,
2446 `contact`.`bdyear` AS `bdyear`,
2447 `contact`.`bd` AS `bd`,
2448 `contact`.`poco` AS `poco`,
2449 `contact`.`name-date` AS `name-date`,
2450 `contact`.`uri-date` AS `uri-date`,
2451 `contact`.`avatar-date` AS `avatar-date`,
2452 `contact`.`term-date` AS `term-date`,
2453 `contact`.`hidden` AS `global-ignored`,
2454 `contact`.`blocked` AS `global-blocked`,
2455 `ucontact`.`hidden` AS `hidden`,
2456 `ucontact`.`archive` AS `archive`,
2457 `ucontact`.`pending` AS `pending`,
2458 `ucontact`.`deleted` AS `deleted`,
2459 `ucontact`.`notify_new_posts` AS `notify_new_posts`,
2460 `ucontact`.`fetch_further_information` AS `fetch_further_information`,
2461 `ucontact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
2462 `ucontact`.`rating` AS `rating`,
2463 `ucontact`.`readonly` AS `readonly`,
2464 `ucontact`.`blocked` AS `blocked`,
2465 `ucontact`.`block_reason` AS `block_reason`,
2466 `ucontact`.`subhub` AS `subhub`,
2467 `ucontact`.`hub-verify` AS `hub-verify`,
2468 `ucontact`.`reason` AS `reason`,
2469 `contact`.`request` AS `dfrn-request`,
2470 `contact`.`notify` AS `dfrn-notify`,
2471 `contact`.`poll` AS `dfrn-poll`,
2472 `contact`.`confirm` AS `dfrn-confirm`,
2473 `fcontact`.`guid` AS `diaspora-guid`,
2474 `fcontact`.`batch` AS `diaspora-batch`,
2475 `fcontact`.`notify` AS `diaspora-notify`,
2476 `fcontact`.`poll` AS `diaspora-poll`,
2477 `fcontact`.`alias` AS `diaspora-alias`,
2478 `apcontact`.`uuid` AS `ap-uuid`,
2479 `apcontact`.`type` AS `ap-type`,
2480 `apcontact`.`following` AS `ap-following`,
2481 `apcontact`.`followers` AS `ap-followers`,
2482 `apcontact`.`inbox` AS `ap-inbox`,
2483 `apcontact`.`outbox` AS `ap-outbox`,
2484 `apcontact`.`sharedinbox` AS `ap-sharedinbox`,
2485 `apcontact`.`generator` AS `ap-generator`,
2486 `apcontact`.`following_count` AS `ap-following_count`,
2487 `apcontact`.`followers_count` AS `ap-followers_count`,
2488 `apcontact`.`statuses_count` AS `ap-statuses_count`
2489 FROM `contact` AS `ucontact`
2490 INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
2491 LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
2492 LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = `ucontact`.`uri-id` AND `fcontact`.`network` = 'dspr';
2495 -- VIEW pending-view
2497 DROP VIEW IF EXISTS `pending-view`;
2498 CREATE VIEW `pending-view` AS SELECT
2499 `register`.`id` AS `id`,
2500 `register`.`hash` AS `hash`,
2501 `register`.`created` AS `created`,
2502 `register`.`uid` AS `uid`,
2503 `register`.`password` AS `password`,
2504 `register`.`language` AS `language`,
2505 `register`.`note` AS `note`,
2506 `contact`.`self` AS `self`,
2507 `contact`.`name` AS `name`,
2508 `contact`.`url` AS `url`,
2509 `contact`.`micro` AS `micro`,
2510 `user`.`email` AS `email`,
2511 `contact`.`nick` AS `nick`
2513 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
2514 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
2517 -- VIEW tag-search-view
2519 DROP VIEW IF EXISTS `tag-search-view`;
2520 CREATE VIEW `tag-search-view` AS SELECT
2521 `post-tag`.`uri-id` AS `uri-id`,
2522 `post-user`.`uid` AS `uid`,
2523 `post-user`.`id` AS `iid`,
2524 `post-user`.`private` AS `private`,
2525 `post-user`.`wall` AS `wall`,
2526 `post-user`.`origin` AS `origin`,
2527 `post-user`.`global` AS `global`,
2528 `post-user`.`gravity` AS `gravity`,
2529 `post-user`.`received` AS `received`,
2530 `post-user`.`network` AS `network`,
2531 `post-user`.`author-id` AS `author-id`,
2532 `tag`.`name` AS `name`
2534 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
2535 STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
2536 WHERE `post-tag`.`type` = 1;
2539 -- VIEW workerqueue-view
2541 DROP VIEW IF EXISTS `workerqueue-view`;
2542 CREATE VIEW `workerqueue-view` AS SELECT
2543 `process`.`pid` AS `pid`,
2544 `workerqueue`.`priority` AS `priority`
2546 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
2547 WHERE NOT `workerqueue`.`done`;