]> git.mxchange.org Git - friendica.git/blob - database.sql
Merge remote-tracking branch 'upstream/develop' into issue-8586
[friendica.git] / database.sql
1 -- ------------------------------------------
2 -- Friendica 2020.06-dev (Red Hot Poker)
3 -- DB_UPDATE_VERSION 1346
4 -- ------------------------------------------
5
6
7 --
8 -- TABLE 2fa_app_specific_password
9 --
10 CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
11         `id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
12         `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
13         `description` varchar(255) COMMENT 'Description of the usage of the password',
14         `hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
15         `generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
16         `last_used` datetime COMMENT 'Datetime the password was last used',
17          PRIMARY KEY(`id`),
18          INDEX `uid_description` (`uid`,`description`(190))
19 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
20
21 --
22 -- TABLE 2fa_recovery_codes
23 --
24 CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
25         `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
26         `code` varchar(50) NOT NULL COMMENT 'Recovery code string',
27         `generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
28         `used` datetime COMMENT 'Datetime the code was used',
29          PRIMARY KEY(`uid`,`code`)
30 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
31
32 --
33 -- TABLE addon
34 --
35 CREATE TABLE IF NOT EXISTS `addon` (
36         `id` int unsigned NOT NULL auto_increment COMMENT '',
37         `name` varchar(50) NOT NULL DEFAULT '' COMMENT 'addon base (file)name',
38         `version` varchar(50) NOT NULL DEFAULT '' COMMENT 'currently unused',
39         `installed` boolean NOT NULL DEFAULT '0' COMMENT 'currently always 1',
40         `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'currently unused',
41         `timestamp` int unsigned NOT NULL DEFAULT 0 COMMENT 'file timestamp to check for reloads',
42         `plugin_admin` boolean NOT NULL DEFAULT '0' COMMENT '1 = has admin config, 0 = has no admin config',
43          PRIMARY KEY(`id`),
44          UNIQUE INDEX `name` (`name`)
45 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registered addons';
46
47 --
48 -- TABLE apcontact
49 --
50 CREATE TABLE IF NOT EXISTS `apcontact` (
51         `url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
52         `uuid` varchar(255) COMMENT '',
53         `type` varchar(20) NOT NULL COMMENT '',
54         `following` varchar(255) COMMENT '',
55         `followers` varchar(255) COMMENT '',
56         `inbox` varchar(255) NOT NULL COMMENT '',
57         `outbox` varchar(255) COMMENT '',
58         `sharedinbox` varchar(255) COMMENT '',
59         `manually-approve` boolean COMMENT '',
60         `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
61         `name` varchar(255) COMMENT '',
62         `about` text COMMENT '',
63         `photo` varchar(255) COMMENT '',
64         `addr` varchar(255) COMMENT '',
65         `alias` varchar(255) COMMENT '',
66         `pubkey` text COMMENT '',
67         `baseurl` varchar(255) COMMENT 'baseurl of the ap contact',
68         `generator` varchar(255) COMMENT 'Name of the contact\'s system',
69         `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
70         `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
71         `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
72         `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
73          PRIMARY KEY(`url`),
74          INDEX `addr` (`addr`(32)),
75          INDEX `alias` (`alias`(190)),
76          INDEX `url` (`followers`(190))
77 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
78
79 --
80 -- TABLE attach
81 --
82 CREATE TABLE IF NOT EXISTS `attach` (
83         `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
84         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
85         `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
86         `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
87         `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
88         `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
89         `data` longblob NOT NULL COMMENT 'file data',
90         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
91         `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
92         `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
93         `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
94         `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
95         `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
96         `backend-class` tinytext COMMENT 'Storage backend class',
97         `backend-ref` text COMMENT 'Storage backend data reference',
98          PRIMARY KEY(`id`)
99 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
100
101 --
102 -- TABLE auth_codes
103 --
104 CREATE TABLE IF NOT EXISTS `auth_codes` (
105         `id` varchar(40) NOT NULL COMMENT '',
106         `client_id` varchar(20) NOT NULL DEFAULT '' COMMENT '',
107         `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
108         `expires` int NOT NULL DEFAULT 0 COMMENT '',
109         `scope` varchar(250) NOT NULL DEFAULT '' COMMENT '',
110          PRIMARY KEY(`id`)
111 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
112
113 --
114 -- TABLE cache
115 --
116 CREATE TABLE IF NOT EXISTS `cache` (
117         `k` varbinary(255) NOT NULL COMMENT 'cache key',
118         `v` mediumtext COMMENT 'cached serialized value',
119         `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
120         `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
121          PRIMARY KEY(`k`),
122          INDEX `k_expires` (`k`,`expires`)
123 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
124
125 --
126 -- TABLE challenge
127 --
128 CREATE TABLE IF NOT EXISTS `challenge` (
129         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
130         `challenge` varchar(255) NOT NULL DEFAULT '' COMMENT '',
131         `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
132         `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
133         `type` varchar(255) NOT NULL DEFAULT '' COMMENT '',
134         `last_update` varchar(255) NOT NULL DEFAULT '' COMMENT '',
135          PRIMARY KEY(`id`)
136 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
137
138 --
139 -- TABLE clients
140 --
141 CREATE TABLE IF NOT EXISTS `clients` (
142         `client_id` varchar(20) NOT NULL COMMENT '',
143         `pw` varchar(20) NOT NULL DEFAULT '' COMMENT '',
144         `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
145         `name` text COMMENT '',
146         `icon` text COMMENT '',
147         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
148          PRIMARY KEY(`client_id`)
149 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
150
151 --
152 -- TABLE config
153 --
154 CREATE TABLE IF NOT EXISTS `config` (
155         `id` int unsigned NOT NULL auto_increment COMMENT '',
156         `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
157         `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
158         `v` mediumtext COMMENT '',
159          PRIMARY KEY(`id`),
160          UNIQUE INDEX `cat_k` (`cat`,`k`)
161 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
162
163 --
164 -- TABLE contact
165 --
166 CREATE TABLE IF NOT EXISTS `contact` (
167         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
168         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
169         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
170         `updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last contact update',
171         `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
172         `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
173         `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
174         `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
175         `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network of the contact',
176         `protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
177         `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
178         `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
179         `location` varchar(255) DEFAULT '' COMMENT '',
180         `about` text COMMENT '',
181         `keywords` text COMMENT 'public keywords (interests) of the contact',
182         `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
183         `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
184         `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
185         `avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '',
186         `photo` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
187         `thumb` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
188         `micro` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
189         `site-pubkey` text COMMENT '',
190         `issued-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
191         `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
192         `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
193         `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
194         `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
195         `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
196         `pubkey` text COMMENT 'RSA public key 4096 bit',
197         `prvkey` text COMMENT 'RSA private key 4096 bit',
198         `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
199         `request` varchar(255) COMMENT '',
200         `notify` varchar(255) COMMENT '',
201         `poll` varchar(255) COMMENT '',
202         `confirm` varchar(255) COMMENT '',
203         `poco` varchar(255) COMMENT '',
204         `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT '',
205         `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT '',
206         `usehub` boolean NOT NULL DEFAULT '0' COMMENT '',
207         `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
208         `hub-verify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
209         `last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
210         `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
211         `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
212         `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
213         `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
214         `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
215         `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
216         `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
217         `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
218         `blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
219         `block_reason` text COMMENT 'Node-wide block reason',
220         `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
221         `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
222         `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum',
223         `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group',
224         `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT '',
225         `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
226         `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
227         `pending` boolean NOT NULL DEFAULT '1' COMMENT '',
228         `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
229         `rating` tinyint NOT NULL DEFAULT 0 COMMENT '',
230         `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
231         `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
232         `baseurl` varchar(255) DEFAULT '' COMMENT 'baseurl of the contact',
233         `reason` text COMMENT '',
234         `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT '',
235         `info` mediumtext COMMENT '',
236         `profile-id` int unsigned COMMENT 'Deprecated',
237         `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
238         `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
239         `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
240         `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
241         `ffi_keyword_blacklist` text COMMENT '',
242          PRIMARY KEY(`id`),
243          INDEX `uid_name` (`uid`,`name`(190)),
244          INDEX `self_uid` (`self`,`uid`),
245          INDEX `alias_uid` (`alias`(32),`uid`),
246          INDEX `pending_uid` (`pending`,`uid`),
247          INDEX `blocked_uid` (`blocked`,`uid`),
248          INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
249          INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
250          INDEX `addr_uid` (`addr`(32),`uid`),
251          INDEX `nurl_uid` (`nurl`(32),`uid`),
252          INDEX `nick_uid` (`nick`(32),`uid`),
253          INDEX `dfrn-id` (`dfrn-id`(64)),
254          INDEX `issued-id` (`issued-id`(64))
255 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
256
257 --
258 -- TABLE contact-relation
259 --
260 CREATE TABLE IF NOT EXISTS `contact-relation` (
261         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
262         `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
263         `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
264          PRIMARY KEY(`cid`,`relation-cid`),
265          INDEX `relation-cid` (`relation-cid`)
266 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
267
268 --
269 -- TABLE conv
270 --
271 CREATE TABLE IF NOT EXISTS `conv` (
272         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
273         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
274         `recips` text COMMENT 'sender_handle;recipient_handle',
275         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
276         `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
277         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
278         `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
279         `subject` text COMMENT 'subject of initial message',
280          PRIMARY KEY(`id`),
281          INDEX `uid` (`uid`)
282 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
283
284 --
285 -- TABLE conversation
286 --
287 CREATE TABLE IF NOT EXISTS `conversation` (
288         `item-uri` varbinary(255) NOT NULL COMMENT 'Original URI of the item - unrelated to the table with the same name',
289         `reply-to-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'URI to which this item is a reply',
290         `conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI',
291         `conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link',
292         `protocol` tinyint unsigned NOT NULL DEFAULT 255 COMMENT 'The protocol of the item',
293         `direction` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'How the message arrived here: 1=push, 2=pull',
294         `source` mediumtext COMMENT 'Original source',
295         `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Receiving date',
296          PRIMARY KEY(`item-uri`),
297          INDEX `conversation-uri` (`conversation-uri`),
298          INDEX `received` (`received`)
299 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Raw data and structure information for messages';
300
301 --
302 -- TABLE diaspora-interaction
303 --
304 CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
305         `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
306         `interaction` mediumtext COMMENT 'The Diaspora interaction',
307          PRIMARY KEY(`uri-id`)
308 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
309
310 --
311 -- TABLE event
312 --
313 CREATE TABLE IF NOT EXISTS `event` (
314         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
315         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
316         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
317         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
318         `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
319         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
320         `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
321         `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
322         `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
323         `summary` text COMMENT 'short description or title of the event',
324         `desc` text COMMENT 'event description',
325         `location` text COMMENT 'event location',
326         `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
327         `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
328         `adjust` boolean NOT NULL DEFAULT '1' COMMENT 'adjust to timezone of the recipient (0 or 1)',
329         `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
330         `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
331         `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
332         `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
333         `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
334          PRIMARY KEY(`id`),
335          INDEX `uid_start` (`uid`,`start`)
336 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
337
338 --
339 -- TABLE fcontact
340 --
341 CREATE TABLE IF NOT EXISTS `fcontact` (
342         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
343         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
344         `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
345         `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
346         `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
347         `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
348         `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
349         `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
350         `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
351         `notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
352         `poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
353         `confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
354         `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
355         `network` char(4) NOT NULL DEFAULT '' COMMENT '',
356         `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
357         `pubkey` text COMMENT '',
358         `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
359          PRIMARY KEY(`id`),
360          INDEX `addr` (`addr`(32)),
361          UNIQUE INDEX `url` (`url`(190))
362 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
363
364 --
365 -- TABLE fsuggest
366 --
367 CREATE TABLE IF NOT EXISTS `fsuggest` (
368         `id` int unsigned NOT NULL auto_increment COMMENT '',
369         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
370         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
371         `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
372         `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
373         `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
374         `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
375         `note` text COMMENT '',
376         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
377          PRIMARY KEY(`id`)
378 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
379
380 --
381 -- TABLE gcign
382 --
383 CREATE TABLE IF NOT EXISTS `gcign` (
384         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
385         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Local User id',
386         `gcid` int unsigned NOT NULL DEFAULT 0 COMMENT 'gcontact.id of ignored contact',
387          PRIMARY KEY(`id`),
388          INDEX `uid` (`uid`),
389          INDEX `gcid` (`gcid`)
390 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contacts ignored by friend suggestions';
391
392 --
393 -- TABLE gcontact
394 --
395 CREATE TABLE IF NOT EXISTS `gcontact` (
396         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
397         `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
398         `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
399         `url` varchar(255) NOT NULL DEFAULT '' COMMENT 'Link to the contacts profile page',
400         `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
401         `photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'Link to the profile photo',
402         `connect` varchar(255) NOT NULL DEFAULT '' COMMENT '',
403         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
404         `updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
405         `last_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
406         `last_failure` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
407         `last_discovery` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last contact discovery',
408         `archive_date` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
409         `archived` boolean NOT NULL DEFAULT '0' COMMENT '',
410         `location` varchar(255) NOT NULL DEFAULT '' COMMENT '',
411         `about` text COMMENT '',
412         `keywords` text COMMENT 'puplic keywords (interests)',
413         `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
414         `birthday` varchar(32) NOT NULL DEFAULT '0001-01-01' COMMENT '',
415         `community` boolean NOT NULL DEFAULT '0' COMMENT '1 if contact is forum account',
416         `contact-type` tinyint NOT NULL DEFAULT -1 COMMENT '',
417         `hide` boolean NOT NULL DEFAULT '0' COMMENT '1 = should be hidden from search',
418         `nsfw` boolean NOT NULL DEFAULT '0' COMMENT '1 = contact posts nsfw content',
419         `network` char(4) NOT NULL DEFAULT '' COMMENT 'social network protocol',
420         `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
421         `notify` varchar(255) COMMENT '',
422         `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
423         `generation` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
424         `server_url` varchar(255) NOT NULL DEFAULT '' COMMENT 'baseurl of the contacts server',
425          PRIMARY KEY(`id`),
426          UNIQUE INDEX `nurl` (`nurl`(190)),
427          INDEX `name` (`name`(64)),
428          INDEX `nick` (`nick`(32)),
429          INDEX `addr` (`addr`(64)),
430          INDEX `hide_network_updated` (`hide`,`network`,`updated`),
431          INDEX `updated` (`updated`)
432 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='global contacts';
433
434 --
435 -- TABLE gfollower
436 --
437 CREATE TABLE IF NOT EXISTS `gfollower` (
438         `gcid` int unsigned NOT NULL DEFAULT 0 COMMENT 'global contact',
439         `follower-gcid` int unsigned NOT NULL DEFAULT 0 COMMENT 'global contact of the follower',
440         `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates that the connection has been deleted',
441          PRIMARY KEY(`gcid`,`follower-gcid`),
442          INDEX `follower-gcid` (`follower-gcid`)
443 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Followers of global contacts';
444
445 --
446 -- TABLE glink
447 --
448 CREATE TABLE IF NOT EXISTS `glink` (
449         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
450         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
451         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
452         `gcid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
453         `zcid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
454         `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
455          PRIMARY KEY(`id`),
456          UNIQUE INDEX `cid_uid_gcid_zcid` (`cid`,`uid`,`gcid`,`zcid`),
457          INDEX `gcid` (`gcid`)
458 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='\'friends of friends\' linkages derived from poco';
459
460 --
461 -- TABLE group
462 --
463 CREATE TABLE IF NOT EXISTS `group` (
464         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
465         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
466         `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
467         `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
468         `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
469          PRIMARY KEY(`id`),
470          INDEX `uid` (`uid`)
471 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
472
473 --
474 -- TABLE group_member
475 --
476 CREATE TABLE IF NOT EXISTS `group_member` (
477         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
478         `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
479         `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
480          PRIMARY KEY(`id`),
481          INDEX `contactid` (`contact-id`),
482          UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`)
483 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
484
485 --
486 -- TABLE gserver
487 --
488 CREATE TABLE IF NOT EXISTS `gserver` (
489         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
490         `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
491         `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
492         `version` varchar(255) NOT NULL DEFAULT '' COMMENT '',
493         `site_name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
494         `info` text COMMENT '',
495         `register_policy` tinyint NOT NULL DEFAULT 0 COMMENT '',
496         `registered-users` int unsigned NOT NULL DEFAULT 0 COMMENT 'Number of registered users',
497         `directory-type` tinyint DEFAULT 0 COMMENT 'Type of directory service (Poco, Mastodon)',
498         `poco` varchar(255) NOT NULL DEFAULT '' COMMENT '',
499         `noscrape` varchar(255) NOT NULL DEFAULT '' COMMENT '',
500         `network` char(4) NOT NULL DEFAULT '' COMMENT '',
501         `platform` varchar(255) NOT NULL DEFAULT '' COMMENT '',
502         `relay-subscribe` boolean NOT NULL DEFAULT '0' COMMENT 'Has the server subscribed to the relay system',
503         `relay-scope` varchar(10) NOT NULL DEFAULT '' COMMENT 'The scope of messages that the server wants to get',
504         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
505         `last_poco_query` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
506         `last_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
507         `last_failure` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
508          PRIMARY KEY(`id`),
509          UNIQUE INDEX `nurl` (`nurl`(190))
510 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Global servers';
511
512 --
513 -- TABLE gserver-tag
514 --
515 CREATE TABLE IF NOT EXISTS `gserver-tag` (
516         `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
517         `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
518          PRIMARY KEY(`gserver-id`,`tag`),
519          INDEX `tag` (`tag`)
520 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
521
522 --
523 -- TABLE hook
524 --
525 CREATE TABLE IF NOT EXISTS `hook` (
526         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
527         `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
528         `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
529         `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
530         `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',
531          PRIMARY KEY(`id`),
532          UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
533 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
534
535 --
536 -- TABLE inbox-status
537 --
538 CREATE TABLE IF NOT EXISTS `inbox-status` (
539         `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
540         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
541         `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
542         `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
543         `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
544         `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
545         `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
546          PRIMARY KEY(`url`)
547 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
548
549 --
550 -- TABLE intro
551 --
552 CREATE TABLE IF NOT EXISTS `intro` (
553         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
554         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
555         `fid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
556         `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
557         `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
558         `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
559         `note` text COMMENT '',
560         `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
561         `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
562         `blocked` boolean NOT NULL DEFAULT '1' COMMENT '',
563         `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
564          PRIMARY KEY(`id`)
565 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
566
567 --
568 -- TABLE item
569 --
570 CREATE TABLE IF NOT EXISTS `item` (
571         `id` int unsigned NOT NULL auto_increment,
572         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this item',
573         `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
574         `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
575         `uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
576         `parent` int unsigned NOT NULL DEFAULT 0 COMMENT 'item.id of the parent to this item if it is a reply of some form; otherwise this must be set to the id of this item',
577         `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT 'uri of the parent to this item',
578         `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
579         `thr-parent` varchar(255) NOT NULL DEFAULT '' COMMENT 'If the parent of this item is not the top-level item in the conversation, the uri of the immediate parent; otherwise set to parent-uri',
580         `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
581         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
582         `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
583         `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last comment/reply to this item',
584         `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
585         `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',
586         `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
587         `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
588         `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
589         `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
590         `icid` int unsigned COMMENT 'Id of the item-content table entry that contains the whole item content',
591         `iaid` int unsigned COMMENT 'Id of the item-activity table entry that contains the activity data',
592         `extid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
593         `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
594         `global` boolean NOT NULL DEFAULT '0' COMMENT '',
595         `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
596         `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
597         `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
598         `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been deleted',
599         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
600         `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
601         `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
602         `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
603         `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
604         `starred` boolean NOT NULL DEFAULT '0' COMMENT 'item has been favourited',
605         `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'item has not been seen',
606         `mention` boolean NOT NULL DEFAULT '0' COMMENT 'The owner of this item was mentioned in it',
607         `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
608         `psid` int unsigned COMMENT 'ID of the permission set of this post',
609         `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',
610         `event-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Used to link to the event.id',
611         `attach` mediumtext COMMENT 'JSON structure representing attachments to this item',
612         `allow_cid` mediumtext COMMENT 'Deprecated',
613         `allow_gid` mediumtext COMMENT 'Deprecated',
614         `deny_cid` mediumtext COMMENT 'Deprecated',
615         `deny_gid` mediumtext COMMENT 'Deprecated',
616         `postopts` text COMMENT 'Deprecated',
617         `inform` mediumtext COMMENT 'Deprecated',
618         `type` varchar(20) COMMENT 'Deprecated',
619         `bookmark` boolean COMMENT 'Deprecated',
620         `file` mediumtext COMMENT 'Deprecated',
621         `location` varchar(255) COMMENT 'Deprecated',
622         `coord` varchar(255) COMMENT 'Deprecated',
623         `tag` mediumtext COMMENT 'Deprecated',
624         `plink` varchar(255) COMMENT 'Deprecated',
625         `title` varchar(255) COMMENT 'Deprecated',
626         `content-warning` varchar(255) COMMENT 'Deprecated',
627         `body` mediumtext COMMENT 'Deprecated',
628         `app` varchar(255) COMMENT 'Deprecated',
629         `verb` varchar(100) COMMENT 'Deprecated',
630         `object-type` varchar(100) COMMENT 'Deprecated',
631         `object` text COMMENT 'Deprecated',
632         `target-type` varchar(100) COMMENT 'Deprecated',
633         `target` text COMMENT 'Deprecated',
634         `author-name` varchar(255) COMMENT 'Deprecated',
635         `author-link` varchar(255) COMMENT 'Deprecated',
636         `author-avatar` varchar(255) COMMENT 'Deprecated',
637         `owner-name` varchar(255) COMMENT 'Deprecated',
638         `owner-link` varchar(255) COMMENT 'Deprecated',
639         `owner-avatar` varchar(255) COMMENT 'Deprecated',
640         `rendered-hash` varchar(32) COMMENT 'Deprecated',
641         `rendered-html` mediumtext COMMENT 'Deprecated',
642          PRIMARY KEY(`id`),
643          INDEX `guid` (`guid`(191)),
644          INDEX `uri` (`uri`(191)),
645          INDEX `parent` (`parent`),
646          INDEX `parent-uri` (`parent-uri`(191)),
647          INDEX `extid` (`extid`(191)),
648          INDEX `uid_id` (`uid`,`id`),
649          INDEX `uid_contactid_id` (`uid`,`contact-id`,`id`),
650          INDEX `uid_received` (`uid`,`received`),
651          INDEX `uid_commented` (`uid`,`commented`),
652          INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
653          INDEX `uid_network_received` (`uid`,`network`,`received`),
654          INDEX `uid_network_commented` (`uid`,`network`,`commented`),
655          INDEX `uid_thrparent` (`uid`,`thr-parent`(190)),
656          INDEX `uid_parenturi` (`uid`,`parent-uri`(190)),
657          INDEX `uid_contactid_received` (`uid`,`contact-id`,`received`),
658          INDEX `authorid_received` (`author-id`,`received`),
659          INDEX `ownerid` (`owner-id`),
660          INDEX `contact-id` (`contact-id`),
661          INDEX `uid_uri` (`uid`,`uri`(190)),
662          INDEX `resource-id` (`resource-id`),
663          INDEX `deleted_changed` (`deleted`,`changed`),
664          INDEX `uid_wall_changed` (`uid`,`wall`,`changed`),
665          INDEX `mention_uid_id` (`mention`,`uid`,`id`),
666          INDEX `uid_eventid` (`uid`,`event-id`),
667          INDEX `icid` (`icid`),
668          INDEX `iaid` (`iaid`),
669          INDEX `psid_wall` (`psid`,`wall`),
670          INDEX `uri-id` (`uri-id`)
671 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
672
673 --
674 -- TABLE item-activity
675 --
676 CREATE TABLE IF NOT EXISTS `item-activity` (
677         `id` int unsigned NOT NULL auto_increment,
678         `uri` varchar(255) COMMENT '',
679         `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
680         `uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
681         `activity` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
682          PRIMARY KEY(`id`),
683          UNIQUE INDEX `uri-hash` (`uri-hash`),
684          INDEX `uri` (`uri`(191)),
685          INDEX `uri-id` (`uri-id`)
686 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activities for items';
687
688 --
689 -- TABLE item-content
690 --
691 CREATE TABLE IF NOT EXISTS `item-content` (
692         `id` int unsigned NOT NULL auto_increment,
693         `uri` varchar(255) COMMENT '',
694         `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
695         `uri-plink-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
696         `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
697         `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
698         `body` mediumtext COMMENT 'item body content',
699         `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
700         `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
701         `language` text COMMENT 'Language information about this post',
702         `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
703         `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
704         `rendered-html` mediumtext COMMENT 'item.body converted to html',
705         `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
706         `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
707         `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
708         `target` text COMMENT 'JSON encoded target structure if used',
709         `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
710         `verb` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams verb',
711          PRIMARY KEY(`id`),
712          UNIQUE INDEX `uri-plink-hash` (`uri-plink-hash`),
713          INDEX `uri` (`uri`(191)),
714          INDEX `plink` (`plink`(191)),
715          INDEX `uri-id` (`uri-id`)
716 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
717
718 --
719 -- TABLE item-uri
720 --
721 CREATE TABLE IF NOT EXISTS `item-uri` (
722         `id` int unsigned NOT NULL auto_increment,
723         `uri` varbinary(255) NOT NULL COMMENT 'URI of an item',
724         `guid` varbinary(255) COMMENT 'A unique identifier for an item',
725          PRIMARY KEY(`id`),
726          UNIQUE INDEX `uri` (`uri`),
727          INDEX `guid` (`guid`)
728 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
729
730 --
731 -- TABLE locks
732 --
733 CREATE TABLE IF NOT EXISTS `locks` (
734         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
735         `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
736         `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
737         `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
738         `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
739          PRIMARY KEY(`id`),
740          INDEX `name_expires` (`name`,`expires`)
741 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
742
743 --
744 -- TABLE mail
745 --
746 CREATE TABLE IF NOT EXISTS `mail` (
747         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
748         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
749         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
750         `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
751         `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
752         `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
753         `contact-id` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact.id',
754         `convid` int unsigned NOT NULL DEFAULT 0 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         `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
763         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
764          PRIMARY KEY(`id`),
765          INDEX `uid_seen` (`uid`,`seen`),
766          INDEX `convid` (`convid`),
767          INDEX `uri` (`uri`(64)),
768          INDEX `parent-uri` (`parent-uri`(64)),
769          INDEX `contactid` (`contact-id`(32))
770 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
771
772 --
773 -- TABLE mailacct
774 --
775 CREATE TABLE IF NOT EXISTS `mailacct` (
776         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
777         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
778         `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
779         `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
780         `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
781         `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
782         `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
783         `pass` text COMMENT '',
784         `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
785         `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
786         `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
787         `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
788         `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
789          PRIMARY KEY(`id`)
790 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
791
792 --
793 -- TABLE manage
794 --
795 CREATE TABLE IF NOT EXISTS `manage` (
796         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
797         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
798         `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
799          PRIMARY KEY(`id`),
800          UNIQUE INDEX `uid_mid` (`uid`,`mid`)
801 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
802
803 --
804 -- TABLE notify
805 --
806 CREATE TABLE IF NOT EXISTS `notify` (
807         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
808         `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
809         `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
810         `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
811         `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
812         `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
813         `msg` mediumtext COMMENT '',
814         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
815         `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
816         `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'item.id',
817         `parent` int unsigned NOT NULL DEFAULT 0 COMMENT '',
818         `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
819         `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
820         `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
821         `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
822         `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
823         `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
824         `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
825          PRIMARY KEY(`id`),
826          INDEX `seen_uid_date` (`seen`,`uid`,`date`),
827          INDEX `uid_date` (`uid`,`date`),
828          INDEX `uid_type_link` (`uid`,`type`,`link`(190))
829 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
830
831 --
832 -- TABLE notify-threads
833 --
834 CREATE TABLE IF NOT EXISTS `notify-threads` (
835         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
836         `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
837         `master-parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
838         `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
839         `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
840         `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
841          PRIMARY KEY(`id`)
842 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
843
844 --
845 -- TABLE oembed
846 --
847 CREATE TABLE IF NOT EXISTS `oembed` (
848         `url` varbinary(255) NOT NULL COMMENT 'page url',
849         `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
850         `content` mediumtext COMMENT 'OEmbed data of the page',
851         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
852          PRIMARY KEY(`url`,`maxwidth`),
853          INDEX `created` (`created`)
854 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
855
856 --
857 -- TABLE openwebauth-token
858 --
859 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
860         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
861         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
862         `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
863         `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
864         `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
865         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
866          PRIMARY KEY(`id`)
867 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
868
869 --
870 -- TABLE parsed_url
871 --
872 CREATE TABLE IF NOT EXISTS `parsed_url` (
873         `url` varbinary(255) NOT NULL COMMENT 'page url',
874         `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
875         `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
876         `content` mediumtext COMMENT 'page data',
877         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
878          PRIMARY KEY(`url`,`guessing`,`oembed`),
879          INDEX `created` (`created`)
880 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
881
882 --
883 -- TABLE participation
884 --
885 CREATE TABLE IF NOT EXISTS `participation` (
886         `iid` int unsigned NOT NULL COMMENT '',
887         `server` varchar(60) NOT NULL COMMENT '',
888         `cid` int unsigned NOT NULL COMMENT '',
889         `fid` int unsigned NOT NULL COMMENT '',
890          PRIMARY KEY(`iid`,`server`),
891          INDEX `cid` (`cid`),
892          INDEX `fid` (`fid`)
893 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Storage for participation messages from Diaspora';
894
895 --
896 -- TABLE pconfig
897 --
898 CREATE TABLE IF NOT EXISTS `pconfig` (
899         `id` int unsigned NOT NULL auto_increment COMMENT '',
900         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
901         `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
902         `k` varbinary(100) NOT NULL DEFAULT '' COMMENT '',
903         `v` mediumtext COMMENT '',
904          PRIMARY KEY(`id`),
905          UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`)
906 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
907
908 --
909 -- TABLE permissionset
910 --
911 CREATE TABLE IF NOT EXISTS `permissionset` (
912         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
913         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
914         `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
915         `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
916         `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
917         `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
918          PRIMARY KEY(`id`),
919          INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30))
920 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
921
922 --
923 -- TABLE photo
924 --
925 CREATE TABLE IF NOT EXISTS `photo` (
926         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
927         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
928         `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
929         `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
930         `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
931         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
932         `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
933         `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
934         `desc` text COMMENT '',
935         `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
936         `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
937         `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
938         `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
939         `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
940         `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
941         `data` mediumblob NOT NULL COMMENT '',
942         `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
943         `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
944         `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
945         `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
946         `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
947         `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
948         `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
949         `backend-class` tinytext COMMENT 'Storage backend class',
950         `backend-ref` text COMMENT 'Storage backend data reference',
951         `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
952          PRIMARY KEY(`id`),
953          INDEX `contactid` (`contact-id`),
954          INDEX `uid_contactid` (`uid`,`contact-id`),
955          INDEX `uid_profile` (`uid`,`profile`),
956          INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
957          INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
958          INDEX `resource-id` (`resource-id`)
959 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
960
961 --
962 -- TABLE poll
963 --
964 CREATE TABLE IF NOT EXISTS `poll` (
965         `id` int unsigned NOT NULL auto_increment COMMENT '',
966         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
967         `q0` text COMMENT '',
968         `q1` text COMMENT '',
969         `q2` text COMMENT '',
970         `q3` text COMMENT '',
971         `q4` text COMMENT '',
972         `q5` text COMMENT '',
973         `q6` text COMMENT '',
974         `q7` text COMMENT '',
975         `q8` text COMMENT '',
976         `q9` text COMMENT '',
977          PRIMARY KEY(`id`),
978          INDEX `uid` (`uid`)
979 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently unused table for storing poll results';
980
981 --
982 -- TABLE poll_result
983 --
984 CREATE TABLE IF NOT EXISTS `poll_result` (
985         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
986         `poll_id` int unsigned NOT NULL DEFAULT 0,
987         `choice` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
988          PRIMARY KEY(`id`),
989          INDEX `poll_id` (`poll_id`)
990 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='data for polls - currently unused';
991
992 --
993 -- TABLE process
994 --
995 CREATE TABLE IF NOT EXISTS `process` (
996         `pid` int unsigned NOT NULL COMMENT '',
997         `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
998         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
999          PRIMARY KEY(`pid`),
1000          INDEX `command` (`command`)
1001 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
1002
1003 --
1004 -- TABLE profile
1005 --
1006 CREATE TABLE IF NOT EXISTS `profile` (
1007         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1008         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1009         `profile-name` varchar(255) COMMENT 'Deprecated',
1010         `is-default` boolean COMMENT 'Deprecated',
1011         `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1012         `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1013         `pdesc` varchar(255) COMMENT 'Deprecated',
1014         `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1015         `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1016         `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1017         `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1018         `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1019         `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1020         `hometown` varchar(255) COMMENT 'Deprecated',
1021         `gender` varchar(32) COMMENT 'Deprecated',
1022         `marital` varchar(255) COMMENT 'Deprecated',
1023         `with` text COMMENT 'Deprecated',
1024         `howlong` datetime COMMENT 'Deprecated',
1025         `sexual` varchar(255) COMMENT 'Deprecated',
1026         `politic` varchar(255) COMMENT 'Deprecated',
1027         `religion` varchar(255) COMMENT 'Deprecated',
1028         `pub_keywords` text COMMENT '',
1029         `prv_keywords` text COMMENT '',
1030         `likes` text COMMENT 'Deprecated',
1031         `dislikes` text COMMENT 'Deprecated',
1032         `about` text COMMENT 'Profile description',
1033         `summary` varchar(255) COMMENT 'Deprecated',
1034         `music` text COMMENT 'Deprecated',
1035         `book` text COMMENT 'Deprecated',
1036         `tv` text COMMENT 'Deprecated',
1037         `film` text COMMENT 'Deprecated',
1038         `interest` text COMMENT 'Deprecated',
1039         `romance` text COMMENT 'Deprecated',
1040         `work` text COMMENT 'Deprecated',
1041         `education` text COMMENT 'Deprecated',
1042         `contact` text COMMENT 'Deprecated',
1043         `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1044         `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1045         `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1046         `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1047         `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1048         `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1049          PRIMARY KEY(`id`),
1050          INDEX `uid_is-default` (`uid`,`is-default`),
1051          FULLTEXT INDEX `pub_keywords` (`pub_keywords`)
1052 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1053
1054 --
1055 -- TABLE profile_check
1056 --
1057 CREATE TABLE IF NOT EXISTS `profile_check` (
1058         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1059         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1060         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1061         `dfrn_id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1062         `sec` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1063         `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1064          PRIMARY KEY(`id`)
1065 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='DFRN remote auth use';
1066
1067 --
1068 -- TABLE profile_field
1069 --
1070 CREATE TABLE IF NOT EXISTS `profile_field` (
1071         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1072         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1073         `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1074         `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1075         `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1076         `value` text COMMENT 'Value of the field',
1077         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1078         `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1079          PRIMARY KEY(`id`),
1080          INDEX `uid` (`uid`),
1081          INDEX `order` (`order`),
1082          INDEX `psid` (`psid`)
1083 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1084
1085 --
1086 -- TABLE push_subscriber
1087 --
1088 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1089         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1090         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1091         `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1092         `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1093         `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1094         `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1095         `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1096         `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1097         `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1098         `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1099          PRIMARY KEY(`id`),
1100          INDEX `next_try` (`next_try`)
1101 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1102
1103 --
1104 -- TABLE register
1105 --
1106 CREATE TABLE IF NOT EXISTS `register` (
1107         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1108         `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1109         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1110         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1111         `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1112         `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1113         `note` text COMMENT '',
1114          PRIMARY KEY(`id`)
1115 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1116
1117 --
1118 -- TABLE search
1119 --
1120 CREATE TABLE IF NOT EXISTS `search` (
1121         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1122         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1123         `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1124          PRIMARY KEY(`id`),
1125          INDEX `uid` (`uid`)
1126 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1127
1128 --
1129 -- TABLE session
1130 --
1131 CREATE TABLE IF NOT EXISTS `session` (
1132         `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1133         `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1134         `data` text COMMENT '',
1135         `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1136          PRIMARY KEY(`id`),
1137          INDEX `sid` (`sid`(64)),
1138          INDEX `expire` (`expire`)
1139 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1140
1141 --
1142 -- TABLE term
1143 --
1144 CREATE TABLE IF NOT EXISTS `term` (
1145         `tid` int unsigned NOT NULL auto_increment COMMENT '',
1146         `oid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1147         `otype` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1148         `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1149         `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1150         `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1151         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1152         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1153         `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1154         `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1155         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1156          PRIMARY KEY(`tid`),
1157          INDEX `term_type` (`term`(64),`type`),
1158          INDEX `oid_otype_type_term` (`oid`,`otype`,`type`,`term`(32)),
1159          INDEX `uid_otype_type_term_global_created` (`uid`,`otype`,`type`,`term`(32),`global`,`created`),
1160          INDEX `uid_otype_type_url` (`uid`,`otype`,`type`,`url`(64)),
1161          INDEX `guid` (`guid`(64))
1162 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='item taxonomy (categories, tags, etc.) table';
1163
1164 --
1165 -- TABLE tag
1166 --
1167 CREATE TABLE IF NOT EXISTS `tag` (
1168         `id` int unsigned NOT NULL auto_increment COMMENT '',
1169         `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
1170         `url` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1171          PRIMARY KEY(`id`),
1172          UNIQUE INDEX `type_name_url` (`name`,`url`),
1173          INDEX `url` (`url`)
1174 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
1175
1176 --
1177 -- TABLE post-category
1178 --
1179 CREATE TABLE IF NOT EXISTS `post-category` (
1180         `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1181         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1182         `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1183         `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1184          PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
1185          INDEX `uri-id` (`tid`)
1186 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
1187
1188 --
1189 -- TABLE post-delivery-data
1190 --
1191 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1192         `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1193         `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',
1194         `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1195         `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1196         `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1197         `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1198         `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1199         `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1200         `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1201         `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1202         `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1203          PRIMARY KEY(`uri-id`)
1204 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1205
1206 --
1207 -- TABLE post-tag
1208 --
1209 CREATE TABLE IF NOT EXISTS `post-tag` (
1210         `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1211         `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1212         `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1213         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1214          PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1215          INDEX `uri-id` (`tid`),
1216          INDEX `cid` (`tid`)
1217 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1218
1219 --
1220 -- TABLE thread
1221 --
1222 CREATE TABLE IF NOT EXISTS `thread` (
1223         `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'sequential ID',
1224         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1225         `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1226         `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1227         `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1228         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1229         `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1230         `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1231         `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1232         `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1233         `wall` boolean NOT NULL DEFAULT '0' COMMENT '',
1234         `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1235         `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1236         `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
1237         `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1238         `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1239         `ignored` boolean NOT NULL DEFAULT '0' COMMENT '',
1240         `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
1241         `unseen` boolean NOT NULL DEFAULT '1' COMMENT '',
1242         `deleted` boolean NOT NULL DEFAULT '0' COMMENT '',
1243         `origin` boolean NOT NULL DEFAULT '0' COMMENT '',
1244         `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1245         `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1246         `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1247         `bookmark` boolean COMMENT '',
1248          PRIMARY KEY(`iid`),
1249          INDEX `uid_network_commented` (`uid`,`network`,`commented`),
1250          INDEX `uid_network_received` (`uid`,`network`,`received`),
1251          INDEX `uid_contactid_commented` (`uid`,`contact-id`,`commented`),
1252          INDEX `uid_contactid_received` (`uid`,`contact-id`,`received`),
1253          INDEX `contactid` (`contact-id`),
1254          INDEX `ownerid` (`owner-id`),
1255          INDEX `authorid` (`author-id`),
1256          INDEX `uid_received` (`uid`,`received`),
1257          INDEX `uid_commented` (`uid`,`commented`),
1258          INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1259          INDEX `private_wall_origin_commented` (`private`,`wall`,`origin`,`commented`)
1260 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1261
1262 --
1263 -- TABLE tokens
1264 --
1265 CREATE TABLE IF NOT EXISTS `tokens` (
1266         `id` varchar(40) NOT NULL COMMENT '',
1267         `secret` text COMMENT '',
1268         `client_id` varchar(20) NOT NULL DEFAULT '',
1269         `expires` int NOT NULL DEFAULT 0 COMMENT '',
1270         `scope` varchar(200) NOT NULL DEFAULT '' COMMENT '',
1271         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1272          PRIMARY KEY(`id`)
1273 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
1274
1275 --
1276 -- TABLE user
1277 --
1278 CREATE TABLE IF NOT EXISTS `user` (
1279         `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1280         `parent-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'The parent user that has full control about this user',
1281         `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
1282         `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
1283         `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
1284         `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
1285         `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
1286         `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
1287         `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1288         `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
1289         `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
1290         `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
1291         `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
1292         `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
1293         `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
1294         `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
1295         `pubkey` text COMMENT 'RSA public key 4096 bit',
1296         `prvkey` text COMMENT 'RSA private key 4096 bit',
1297         `spubkey` text COMMENT '',
1298         `sprvkey` text COMMENT '',
1299         `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
1300         `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
1301         `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
1302         `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unkown viewers',
1303         `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
1304         `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
1305         `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
1306         `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
1307         `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
1308         `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1309         `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
1310         `pwdreset` varchar(255) COMMENT 'Password reset request token',
1311         `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
1312         `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
1313         `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1314         `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
1315         `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
1316         `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
1317         `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
1318         `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1319         `allow_cid` mediumtext COMMENT 'default permission for this user',
1320         `allow_gid` mediumtext COMMENT 'default permission for this user',
1321         `deny_cid` mediumtext COMMENT 'default permission for this user',
1322         `deny_gid` mediumtext COMMENT 'default permission for this user',
1323         `openidserver` text COMMENT '',
1324          PRIMARY KEY(`uid`),
1325          INDEX `nickname` (`nickname`(32))
1326 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
1327
1328 --
1329 -- TABLE userd
1330 --
1331 CREATE TABLE IF NOT EXISTS `userd` (
1332         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1333         `username` varchar(255) NOT NULL COMMENT '',
1334          PRIMARY KEY(`id`),
1335          INDEX `username` (`username`(32))
1336 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1337
1338 --
1339 -- TABLE user-contact
1340 --
1341 CREATE TABLE IF NOT EXISTS `user-contact` (
1342         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1343         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1344         `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1345         `ignored` boolean COMMENT 'Posts from this contact are ignored',
1346         `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1347          PRIMARY KEY(`uid`,`cid`)
1348 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1349
1350 --
1351 -- TABLE user-item
1352 --
1353 CREATE TABLE IF NOT EXISTS `user-item` (
1354         `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item id',
1355         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1356         `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide an item from the user',
1357         `ignored` boolean COMMENT 'Ignore this thread if set',
1358         `pinned` boolean COMMENT 'The item is pinned on the profile page',
1359         `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1360          PRIMARY KEY(`uid`,`iid`),
1361          INDEX `uid_pinned` (`uid`,`pinned`),
1362          INDEX `iid_uid` (`iid`,`uid`)
1363 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific item data';
1364
1365 --
1366 -- TABLE worker-ipc
1367 --
1368 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1369         `key` int NOT NULL COMMENT '',
1370         `jobs` boolean COMMENT 'Flag for outstanding jobs',
1371          PRIMARY KEY(`key`)
1372 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1373
1374 --
1375 -- TABLE workerqueue
1376 --
1377 CREATE TABLE IF NOT EXISTS `workerqueue` (
1378         `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
1379         `parameter` mediumtext COMMENT 'Task command',
1380         `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
1381         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
1382         `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
1383         `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
1384         `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1385         `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1386         `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
1387          PRIMARY KEY(`id`),
1388          INDEX `done_parameter` (`done`,`parameter`(64)),
1389          INDEX `done_executed` (`done`,`executed`),
1390          INDEX `done_priority_created` (`done`,`priority`,`created`),
1391          INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
1392          INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
1393          INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
1394 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
1395
1396 --
1397 -- TABLE storage
1398 --
1399 CREATE TABLE IF NOT EXISTS `storage` (
1400         `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1401         `data` longblob NOT NULL COMMENT 'file data',
1402          PRIMARY KEY(`id`)
1403 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1404
1405 --
1406 -- VIEW category-view
1407 --
1408 DROP VIEW IF EXISTS `category-view`;
1409 CREATE VIEW `category-view` AS SELECT 
1410         `post-category`.`uri-id` AS `uri-id`,
1411         `post-category`.`uid` AS `uid`,
1412         `item-uri`.`uri` AS `uri`,
1413         `item-uri`.`guid` AS `guid`,
1414         `post-category`.`type` AS `type`,
1415         `post-category`.`tid` AS `tid`,
1416         `tag`.`name` AS `name`,
1417         `tag`.`url` AS `url`
1418         FROM `post-category`
1419                         INNER JOIN `item-uri` ON `item-uri`.id = `post-category`.`uri-id`
1420                         LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
1421
1422 --
1423 -- VIEW tag-view
1424 --
1425 DROP VIEW IF EXISTS `tag-view`;
1426 CREATE VIEW `tag-view` AS SELECT 
1427         `post-tag`.`uri-id` AS `uri-id`,
1428         `item-uri`.`uri` AS `uri`,
1429         `item-uri`.`guid` AS `guid`,
1430         `post-tag`.`type` AS `type`,
1431         `post-tag`.`tid` AS `tid`,
1432         `post-tag`.`cid` AS `cid`,
1433         CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
1434         CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
1435         FROM `post-tag`
1436                         INNER JOIN `item-uri` ON `item-uri`.id = `post-tag`.`uri-id`
1437                         LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
1438                         LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
1439
1440 --
1441 -- VIEW owner-view
1442 --
1443 DROP VIEW IF EXISTS `owner-view`;
1444 CREATE VIEW `owner-view` AS SELECT 
1445         `contact`.`id` AS `id`,
1446         `contact`.`uid` AS `uid`,
1447         `contact`.`created` AS `created`,
1448         `contact`.`updated` AS `updated`,
1449         `contact`.`self` AS `self`,
1450         `contact`.`remote_self` AS `remote_self`,
1451         `contact`.`rel` AS `rel`,
1452         `contact`.`duplex` AS `duplex`,
1453         `contact`.`network` AS `network`,
1454         `contact`.`protocol` AS `protocol`,
1455         `contact`.`name` AS `name`,
1456         `contact`.`nick` AS `nick`,
1457         `contact`.`location` AS `location`,
1458         `contact`.`about` AS `about`,
1459         `contact`.`keywords` AS `keywords`,
1460         `contact`.`gender` AS `gender`,
1461         `contact`.`xmpp` AS `xmpp`,
1462         `contact`.`attag` AS `attag`,
1463         `contact`.`avatar` AS `avatar`,
1464         `contact`.`photo` AS `photo`,
1465         `contact`.`thumb` AS `thumb`,
1466         `contact`.`micro` AS `micro`,
1467         `contact`.`site-pubkey` AS `site-pubkey`,
1468         `contact`.`issued-id` AS `issued-id`,
1469         `contact`.`dfrn-id` AS `dfrn-id`,
1470         `contact`.`url` AS `url`,
1471         `contact`.`nurl` AS `nurl`,
1472         `contact`.`addr` AS `addr`,
1473         `contact`.`alias` AS `alias`,
1474         `contact`.`pubkey` AS `pubkey`,
1475         `contact`.`prvkey` AS `prvkey`,
1476         `contact`.`batch` AS `batch`,
1477         `contact`.`request` AS `request`,
1478         `contact`.`notify` AS `notify`,
1479         `contact`.`poll` AS `poll`,
1480         `contact`.`confirm` AS `confirm`,
1481         `contact`.`poco` AS `poco`,
1482         `contact`.`aes_allow` AS `aes_allow`,
1483         `contact`.`ret-aes` AS `ret-aes`,
1484         `contact`.`usehub` AS `usehub`,
1485         `contact`.`subhub` AS `subhub`,
1486         `contact`.`hub-verify` AS `hub-verify`,
1487         `contact`.`last-update` AS `last-update`,
1488         `contact`.`success_update` AS `success_update`,
1489         `contact`.`failure_update` AS `failure_update`,
1490         `contact`.`name-date` AS `name-date`,
1491         `contact`.`uri-date` AS `uri-date`,
1492         `contact`.`avatar-date` AS `avatar-date`,
1493         `contact`.`avatar-date` AS `picdate`,
1494         `contact`.`term-date` AS `term-date`,
1495         `contact`.`last-item` AS `last-item`,
1496         `contact`.`priority` AS `priority`,
1497         `contact`.`blocked` AS `blocked`,
1498         `contact`.`block_reason` AS `block_reason`,
1499         `contact`.`readonly` AS `readonly`,
1500         `contact`.`writable` AS `writable`,
1501         `contact`.`forum` AS `forum`,
1502         `contact`.`prv` AS `prv`,
1503         `contact`.`contact-type` AS `contact-type`,
1504         `contact`.`hidden` AS `hidden`,
1505         `contact`.`archive` AS `archive`,
1506         `contact`.`pending` AS `pending`,
1507         `contact`.`deleted` AS `deleted`,
1508         `contact`.`rating` AS `rating`,
1509         `contact`.`unsearchable` AS `unsearchable`,
1510         `contact`.`sensitive` AS `sensitive`,
1511         `contact`.`baseurl` AS `baseurl`,
1512         `contact`.`reason` AS `reason`,
1513         `contact`.`closeness` AS `closeness`,
1514         `contact`.`info` AS `info`,
1515         `contact`.`profile-id` AS `profile-id`,
1516         `contact`.`bdyear` AS `bdyear`,
1517         `contact`.`bd` AS `bd`,
1518         `contact`.`notify_new_posts` AS `notify_new_posts`,
1519         `contact`.`fetch_further_information` AS `fetch_further_information`,
1520         `contact`.`ffi_keyword_blacklist` AS `ffi_keyword_blacklist`,
1521         `user`.`parent-uid` AS `parent-uid`,
1522         `user`.`guid` AS `guid`,
1523         `user`.`nickname` AS `nickname`,
1524         `user`.`email` AS `email`,
1525         `user`.`openid` AS `openid`,
1526         `user`.`timezone` AS `timezone`,
1527         `user`.`language` AS `language`,
1528         `user`.`register_date` AS `register_date`,
1529         `user`.`login_date` AS `login_date`,
1530         `user`.`default-location` AS `default-location`,
1531         `user`.`allow_location` AS `allow_location`,
1532         `user`.`theme` AS `theme`,
1533         `user`.`pubkey` AS `upubkey`,
1534         `user`.`prvkey` AS `uprvkey`,
1535         `user`.`sprvkey` AS `sprvkey`,
1536         `user`.`spubkey` AS `spubkey`,
1537         `user`.`verified` AS `verified`,
1538         `user`.`blockwall` AS `blockwall`,
1539         `user`.`hidewall` AS `hidewall`,
1540         `user`.`blocktags` AS `blocktags`,
1541         `user`.`unkmail` AS `unkmail`,
1542         `user`.`cntunkmail` AS `cntunkmail`,
1543         `user`.`notify-flags` AS `notify-flags`,
1544         `user`.`page-flags` AS `page-flags`,
1545         `user`.`account-type` AS `account-type`,
1546         `user`.`prvnets` AS `prvnets`,
1547         `user`.`maxreq` AS `maxreq`,
1548         `user`.`expire` AS `expire`,
1549         `user`.`account_removed` AS `account_removed`,
1550         `user`.`account_expired` AS `account_expired`,
1551         `user`.`account_expires_on` AS `account_expires_on`,
1552         `user`.`expire_notification_sent` AS `expire_notification_sent`,
1553         `user`.`def_gid` AS `def_gid`,
1554         `user`.`allow_cid` AS `allow_cid`,
1555         `user`.`allow_gid` AS `allow_gid`,
1556         `user`.`deny_cid` AS `deny_cid`,
1557         `user`.`deny_gid` AS `deny_gid`,
1558         `user`.`openidserver` AS `openidserver`,
1559         `profile`.`publish` AS `publish`,
1560         `profile`.`net-publish` AS `net-publish`,
1561         `profile`.`hide-friends` AS `hide-friends`,
1562         `profile`.`prv_keywords` AS `prv_keywords`,
1563         `profile`.`pub_keywords` AS `pub_keywords`,
1564         `profile`.`address` AS `address`,
1565         `profile`.`locality` AS `locality`,
1566         `profile`.`region` AS `region`,
1567         `profile`.`postal-code` AS `postal-code`,
1568         `profile`.`country-name` AS `country-name`,
1569         `profile`.`homepage` AS `homepage`,
1570         `profile`.`dob` AS `dob`
1571         FROM `user`
1572                         INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
1573                         INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
1574
1575 --
1576 -- VIEW pending-view
1577 --
1578 DROP VIEW IF EXISTS `pending-view`;
1579 CREATE VIEW `pending-view` AS SELECT 
1580         `register`.`id` AS `id`,
1581         `register`.`hash` AS `hash`,
1582         `register`.`created` AS `created`,
1583         `register`.`uid` AS `uid`,
1584         `register`.`password` AS `password`,
1585         `register`.`language` AS `language`,
1586         `register`.`note` AS `note`,
1587         `contact`.`self` AS `self`,
1588         `contact`.`name` AS `name`,
1589         `contact`.`url` AS `url`,
1590         `contact`.`micro` AS `micro`,
1591         `user`.`email` AS `email`,
1592         `contact`.`nick` AS `nick`
1593         FROM `register`
1594                         INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
1595                         INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
1596
1597 --
1598 -- VIEW tag-search-view
1599 --
1600 DROP VIEW IF EXISTS `tag-search-view`;
1601 CREATE VIEW `tag-search-view` AS SELECT 
1602         `post-tag`.`uri-id` AS `uri-id`,
1603         `item`.`id` AS `iid`,
1604         `item`.`uri` AS `uri`,
1605         `item`.`guid` AS `guid`,
1606         `item`.`uid` AS `uid`,
1607         `item`.`private` AS `private`,
1608         `item`.`wall` AS `wall`,
1609         `item`.`origin` AS `origin`,
1610         `item`.`gravity` AS `gravity`,
1611         `item`.`received` AS `received`,
1612         `tag`.`name` AS `name`
1613         FROM `post-tag`
1614                         INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
1615                         INNER JOIN `item` ON `item`.`uri-id` = `post-tag`.`uri-id`
1616                         WHERE `post-tag`.`type` = 1;
1617
1618 --
1619 -- VIEW workerqueue-view
1620 --
1621 DROP VIEW IF EXISTS `workerqueue-view`;
1622 CREATE VIEW `workerqueue-view` AS SELECT 
1623         `process`.`pid` AS `pid`,
1624         `workerqueue`.`priority` AS `priority`
1625         FROM `process`
1626                         INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
1627                         WHERE NOT `workerqueue`.`done`;
1628
1629