]> git.mxchange.org Git - friendica.git/blob - database.sql
df3894e8b4ce84945f6c47a6c7d9b9ce10629bb3
[friendica.git] / database.sql
1 -- ------------------------------------------
2 -- Friendica 2020.06-dev (Red Hot Poker)
3 -- DB_UPDATE_VERSION 1345
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         `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
819         `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
820         `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
821         `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
822         `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
823          PRIMARY KEY(`id`),
824          INDEX `seen_uid_date` (`seen`,`uid`,`date`),
825          INDEX `uid_date` (`uid`,`date`),
826          INDEX `uid_type_link` (`uid`,`type`,`link`(190))
827 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
828
829 --
830 -- TABLE notify-threads
831 --
832 CREATE TABLE IF NOT EXISTS `notify-threads` (
833         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
834         `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
835         `master-parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
836         `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
837         `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
838          PRIMARY KEY(`id`)
839 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
840
841 --
842 -- TABLE oembed
843 --
844 CREATE TABLE IF NOT EXISTS `oembed` (
845         `url` varbinary(255) NOT NULL COMMENT 'page url',
846         `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
847         `content` mediumtext COMMENT 'OEmbed data of the page',
848         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
849          PRIMARY KEY(`url`,`maxwidth`),
850          INDEX `created` (`created`)
851 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
852
853 --
854 -- TABLE openwebauth-token
855 --
856 CREATE TABLE IF NOT EXISTS `openwebauth-token` (
857         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
858         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
859         `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
860         `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
861         `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
862         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
863          PRIMARY KEY(`id`)
864 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
865
866 --
867 -- TABLE parsed_url
868 --
869 CREATE TABLE IF NOT EXISTS `parsed_url` (
870         `url` varbinary(255) NOT NULL COMMENT 'page url',
871         `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
872         `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
873         `content` mediumtext COMMENT 'page data',
874         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
875          PRIMARY KEY(`url`,`guessing`,`oembed`),
876          INDEX `created` (`created`)
877 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
878
879 --
880 -- TABLE participation
881 --
882 CREATE TABLE IF NOT EXISTS `participation` (
883         `iid` int unsigned NOT NULL COMMENT '',
884         `server` varchar(60) NOT NULL COMMENT '',
885         `cid` int unsigned NOT NULL COMMENT '',
886         `fid` int unsigned NOT NULL COMMENT '',
887          PRIMARY KEY(`iid`,`server`),
888          INDEX `cid` (`cid`),
889          INDEX `fid` (`fid`)
890 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Storage for participation messages from Diaspora';
891
892 --
893 -- TABLE pconfig
894 --
895 CREATE TABLE IF NOT EXISTS `pconfig` (
896         `id` int unsigned NOT NULL auto_increment COMMENT '',
897         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
898         `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
899         `k` varbinary(100) NOT NULL DEFAULT '' COMMENT '',
900         `v` mediumtext COMMENT '',
901          PRIMARY KEY(`id`),
902          UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`)
903 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
904
905 --
906 -- TABLE permissionset
907 --
908 CREATE TABLE IF NOT EXISTS `permissionset` (
909         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
910         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
911         `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
912         `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
913         `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
914         `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
915          PRIMARY KEY(`id`),
916          INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30))
917 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
918
919 --
920 -- TABLE photo
921 --
922 CREATE TABLE IF NOT EXISTS `photo` (
923         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
924         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
925         `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
926         `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
927         `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
928         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
929         `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
930         `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
931         `desc` text COMMENT '',
932         `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
933         `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
934         `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
935         `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
936         `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
937         `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
938         `data` mediumblob NOT NULL COMMENT '',
939         `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
940         `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
941         `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
942         `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
943         `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
944         `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
945         `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
946         `backend-class` tinytext COMMENT 'Storage backend class',
947         `backend-ref` text COMMENT 'Storage backend data reference',
948         `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
949          PRIMARY KEY(`id`),
950          INDEX `contactid` (`contact-id`),
951          INDEX `uid_contactid` (`uid`,`contact-id`),
952          INDEX `uid_profile` (`uid`,`profile`),
953          INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
954          INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
955          INDEX `resource-id` (`resource-id`)
956 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
957
958 --
959 -- TABLE poll
960 --
961 CREATE TABLE IF NOT EXISTS `poll` (
962         `id` int unsigned NOT NULL auto_increment COMMENT '',
963         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
964         `q0` text COMMENT '',
965         `q1` text COMMENT '',
966         `q2` text COMMENT '',
967         `q3` text COMMENT '',
968         `q4` text COMMENT '',
969         `q5` text COMMENT '',
970         `q6` text COMMENT '',
971         `q7` text COMMENT '',
972         `q8` text COMMENT '',
973         `q9` text COMMENT '',
974          PRIMARY KEY(`id`),
975          INDEX `uid` (`uid`)
976 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently unused table for storing poll results';
977
978 --
979 -- TABLE poll_result
980 --
981 CREATE TABLE IF NOT EXISTS `poll_result` (
982         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
983         `poll_id` int unsigned NOT NULL DEFAULT 0,
984         `choice` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
985          PRIMARY KEY(`id`),
986          INDEX `poll_id` (`poll_id`)
987 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='data for polls - currently unused';
988
989 --
990 -- TABLE process
991 --
992 CREATE TABLE IF NOT EXISTS `process` (
993         `pid` int unsigned NOT NULL COMMENT '',
994         `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
995         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
996          PRIMARY KEY(`pid`),
997          INDEX `command` (`command`)
998 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
999
1000 --
1001 -- TABLE profile
1002 --
1003 CREATE TABLE IF NOT EXISTS `profile` (
1004         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1005         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
1006         `profile-name` varchar(255) COMMENT 'Deprecated',
1007         `is-default` boolean COMMENT 'Deprecated',
1008         `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
1009         `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1010         `pdesc` varchar(255) COMMENT 'Deprecated',
1011         `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
1012         `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1013         `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1014         `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1015         `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
1016         `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1017         `hometown` varchar(255) COMMENT 'Deprecated',
1018         `gender` varchar(32) COMMENT 'Deprecated',
1019         `marital` varchar(255) COMMENT 'Deprecated',
1020         `with` text COMMENT 'Deprecated',
1021         `howlong` datetime COMMENT 'Deprecated',
1022         `sexual` varchar(255) COMMENT 'Deprecated',
1023         `politic` varchar(255) COMMENT 'Deprecated',
1024         `religion` varchar(255) COMMENT 'Deprecated',
1025         `pub_keywords` text COMMENT '',
1026         `prv_keywords` text COMMENT '',
1027         `likes` text COMMENT 'Deprecated',
1028         `dislikes` text COMMENT 'Deprecated',
1029         `about` text COMMENT 'Profile description',
1030         `summary` varchar(255) COMMENT 'Deprecated',
1031         `music` text COMMENT 'Deprecated',
1032         `book` text COMMENT 'Deprecated',
1033         `tv` text COMMENT 'Deprecated',
1034         `film` text COMMENT 'Deprecated',
1035         `interest` text COMMENT 'Deprecated',
1036         `romance` text COMMENT 'Deprecated',
1037         `work` text COMMENT 'Deprecated',
1038         `education` text COMMENT 'Deprecated',
1039         `contact` text COMMENT 'Deprecated',
1040         `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1041         `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1042         `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1043         `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1044         `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
1045         `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
1046          PRIMARY KEY(`id`),
1047          INDEX `uid_is-default` (`uid`,`is-default`),
1048          FULLTEXT INDEX `pub_keywords` (`pub_keywords`)
1049 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
1050
1051 --
1052 -- TABLE profile_check
1053 --
1054 CREATE TABLE IF NOT EXISTS `profile_check` (
1055         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1056         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1057         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
1058         `dfrn_id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1059         `sec` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1060         `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1061          PRIMARY KEY(`id`)
1062 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='DFRN remote auth use';
1063
1064 --
1065 -- TABLE profile_field
1066 --
1067 CREATE TABLE IF NOT EXISTS `profile_field` (
1068         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1069         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
1070         `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
1071         `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
1072         `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
1073         `value` text COMMENT 'Value of the field',
1074         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
1075         `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
1076          PRIMARY KEY(`id`),
1077          INDEX `uid` (`uid`),
1078          INDEX `order` (`order`),
1079          INDEX `psid` (`psid`)
1080 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
1081
1082 --
1083 -- TABLE push_subscriber
1084 --
1085 CREATE TABLE IF NOT EXISTS `push_subscriber` (
1086         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1087         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1088         `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1089         `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1090         `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1091         `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1092         `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
1093         `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1094         `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
1095         `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1096          PRIMARY KEY(`id`),
1097          INDEX `next_try` (`next_try`)
1098 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
1099
1100 --
1101 -- TABLE register
1102 --
1103 CREATE TABLE IF NOT EXISTS `register` (
1104         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1105         `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1106         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1107         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1108         `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1109         `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
1110         `note` text COMMENT '',
1111          PRIMARY KEY(`id`)
1112 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
1113
1114 --
1115 -- TABLE search
1116 --
1117 CREATE TABLE IF NOT EXISTS `search` (
1118         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1119         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1120         `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1121          PRIMARY KEY(`id`),
1122          INDEX `uid` (`uid`)
1123 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
1124
1125 --
1126 -- TABLE session
1127 --
1128 CREATE TABLE IF NOT EXISTS `session` (
1129         `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1130         `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1131         `data` text COMMENT '',
1132         `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1133          PRIMARY KEY(`id`),
1134          INDEX `sid` (`sid`(64)),
1135          INDEX `expire` (`expire`)
1136 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
1137
1138 --
1139 -- TABLE term
1140 --
1141 CREATE TABLE IF NOT EXISTS `term` (
1142         `tid` int unsigned NOT NULL auto_increment COMMENT '',
1143         `oid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1144         `otype` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1145         `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1146         `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1147         `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1148         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1149         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1150         `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1151         `global` boolean NOT NULL DEFAULT '0' COMMENT '',
1152         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1153          PRIMARY KEY(`tid`),
1154          INDEX `term_type` (`term`(64),`type`),
1155          INDEX `oid_otype_type_term` (`oid`,`otype`,`type`,`term`(32)),
1156          INDEX `uid_otype_type_term_global_created` (`uid`,`otype`,`type`,`term`(32),`global`,`created`),
1157          INDEX `uid_otype_type_url` (`uid`,`otype`,`type`,`url`(64)),
1158          INDEX `guid` (`guid`(64))
1159 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='item taxonomy (categories, tags, etc.) table';
1160
1161 --
1162 -- TABLE tag
1163 --
1164 CREATE TABLE IF NOT EXISTS `tag` (
1165         `id` int unsigned NOT NULL auto_increment COMMENT '',
1166         `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
1167         `url` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
1168          PRIMARY KEY(`id`),
1169          UNIQUE INDEX `type_name_url` (`name`,`url`),
1170          INDEX `url` (`url`)
1171 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
1172
1173 --
1174 -- TABLE post-delivery-data
1175 --
1176 CREATE TABLE IF NOT EXISTS `post-delivery-data` (
1177         `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1178         `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',
1179         `inform` mediumtext COMMENT 'Additional receivers of the linked item',
1180         `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
1181         `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
1182         `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
1183         `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
1184         `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
1185         `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
1186         `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
1187         `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
1188          PRIMARY KEY(`uri-id`)
1189 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
1190
1191 --
1192 -- TABLE post-tag
1193 --
1194 CREATE TABLE IF NOT EXISTS `post-tag` (
1195         `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
1196         `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1197         `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1198         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
1199          PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
1200          INDEX `uri-id` (`tid`),
1201          INDEX `cid` (`tid`)
1202 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
1203
1204 --
1205 -- TABLE thread
1206 --
1207 CREATE TABLE IF NOT EXISTS `thread` (
1208         `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'sequential ID',
1209         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1210         `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1211         `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
1212         `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
1213         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1214         `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1215         `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1216         `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1217         `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
1218         `wall` boolean NOT NULL DEFAULT '0' COMMENT '',
1219         `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
1220         `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
1221         `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
1222         `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
1223         `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
1224         `ignored` boolean NOT NULL DEFAULT '0' COMMENT '',
1225         `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
1226         `unseen` boolean NOT NULL DEFAULT '1' COMMENT '',
1227         `deleted` boolean NOT NULL DEFAULT '0' COMMENT '',
1228         `origin` boolean NOT NULL DEFAULT '0' COMMENT '',
1229         `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1230         `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
1231         `network` char(4) NOT NULL DEFAULT '' COMMENT '',
1232         `bookmark` boolean COMMENT '',
1233          PRIMARY KEY(`iid`),
1234          INDEX `uid_network_commented` (`uid`,`network`,`commented`),
1235          INDEX `uid_network_received` (`uid`,`network`,`received`),
1236          INDEX `uid_contactid_commented` (`uid`,`contact-id`,`commented`),
1237          INDEX `uid_contactid_received` (`uid`,`contact-id`,`received`),
1238          INDEX `contactid` (`contact-id`),
1239          INDEX `ownerid` (`owner-id`),
1240          INDEX `authorid` (`author-id`),
1241          INDEX `uid_received` (`uid`,`received`),
1242          INDEX `uid_commented` (`uid`,`commented`),
1243          INDEX `uid_wall_received` (`uid`,`wall`,`received`),
1244          INDEX `private_wall_origin_commented` (`private`,`wall`,`origin`,`commented`)
1245 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
1246
1247 --
1248 -- TABLE tokens
1249 --
1250 CREATE TABLE IF NOT EXISTS `tokens` (
1251         `id` varchar(40) NOT NULL COMMENT '',
1252         `secret` text COMMENT '',
1253         `client_id` varchar(20) NOT NULL DEFAULT '',
1254         `expires` int NOT NULL DEFAULT 0 COMMENT '',
1255         `scope` varchar(200) NOT NULL DEFAULT '' COMMENT '',
1256         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1257          PRIMARY KEY(`id`)
1258 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
1259
1260 --
1261 -- TABLE user
1262 --
1263 CREATE TABLE IF NOT EXISTS `user` (
1264         `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1265         `parent-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'The parent user that has full control about this user',
1266         `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
1267         `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
1268         `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
1269         `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
1270         `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
1271         `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
1272         `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1273         `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
1274         `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
1275         `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
1276         `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
1277         `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
1278         `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
1279         `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
1280         `pubkey` text COMMENT 'RSA public key 4096 bit',
1281         `prvkey` text COMMENT 'RSA private key 4096 bit',
1282         `spubkey` text COMMENT '',
1283         `sprvkey` text COMMENT '',
1284         `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
1285         `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
1286         `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
1287         `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unkown viewers',
1288         `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
1289         `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
1290         `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
1291         `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
1292         `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
1293         `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1294         `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
1295         `pwdreset` varchar(255) COMMENT 'Password reset request token',
1296         `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
1297         `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
1298         `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1299         `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
1300         `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
1301         `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
1302         `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
1303         `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1304         `allow_cid` mediumtext COMMENT 'default permission for this user',
1305         `allow_gid` mediumtext COMMENT 'default permission for this user',
1306         `deny_cid` mediumtext COMMENT 'default permission for this user',
1307         `deny_gid` mediumtext COMMENT 'default permission for this user',
1308         `openidserver` text COMMENT '',
1309          PRIMARY KEY(`uid`),
1310          INDEX `nickname` (`nickname`(32))
1311 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
1312
1313 --
1314 -- TABLE userd
1315 --
1316 CREATE TABLE IF NOT EXISTS `userd` (
1317         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1318         `username` varchar(255) NOT NULL COMMENT '',
1319          PRIMARY KEY(`id`),
1320          INDEX `username` (`username`(32))
1321 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
1322
1323 --
1324 -- TABLE user-contact
1325 --
1326 CREATE TABLE IF NOT EXISTS `user-contact` (
1327         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
1328         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1329         `blocked` boolean COMMENT 'Contact is completely blocked for this user',
1330         `ignored` boolean COMMENT 'Posts from this contact are ignored',
1331         `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
1332          PRIMARY KEY(`uid`,`cid`)
1333 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
1334
1335 --
1336 -- TABLE user-item
1337 --
1338 CREATE TABLE IF NOT EXISTS `user-item` (
1339         `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item id',
1340         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1341         `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide an item from the user',
1342         `ignored` boolean COMMENT 'Ignore this thread if set',
1343         `pinned` boolean COMMENT 'The item is pinned on the profile page',
1344         `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1345          PRIMARY KEY(`uid`,`iid`),
1346          INDEX `uid_pinned` (`uid`,`pinned`),
1347          INDEX `iid_uid` (`iid`,`uid`)
1348 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific item data';
1349
1350 --
1351 -- TABLE worker-ipc
1352 --
1353 CREATE TABLE IF NOT EXISTS `worker-ipc` (
1354         `key` int NOT NULL COMMENT '',
1355         `jobs` boolean COMMENT 'Flag for outstanding jobs',
1356          PRIMARY KEY(`key`)
1357 ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
1358
1359 --
1360 -- TABLE workerqueue
1361 --
1362 CREATE TABLE IF NOT EXISTS `workerqueue` (
1363         `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
1364         `parameter` mediumtext COMMENT 'Task command',
1365         `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
1366         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
1367         `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
1368         `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
1369         `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
1370         `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
1371         `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
1372          PRIMARY KEY(`id`),
1373          INDEX `done_parameter` (`done`,`parameter`(64)),
1374          INDEX `done_executed` (`done`,`executed`),
1375          INDEX `done_priority_created` (`done`,`priority`,`created`),
1376          INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
1377          INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
1378          INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
1379 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
1380
1381 --
1382 -- TABLE storage
1383 --
1384 CREATE TABLE IF NOT EXISTS `storage` (
1385         `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
1386         `data` longblob NOT NULL COMMENT 'file data',
1387          PRIMARY KEY(`id`)
1388 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
1389
1390 --
1391 -- VIEW tag-view
1392 --
1393 DROP VIEW IF EXISTS `tag-view`;
1394 CREATE VIEW `tag-view` AS SELECT 
1395         `post-tag`.`uri-id` AS `uri-id`,
1396         `item-uri`.`uri` AS `uri`,
1397         `item-uri`.`guid` AS `guid`,
1398         `post-tag`.`type` AS `type`,
1399         `post-tag`.`tid` AS `tid`,
1400         `post-tag`.`cid` AS `cid`,
1401         CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
1402         CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
1403         FROM `post-tag`
1404                         INNER JOIN `item-uri` ON `item-uri`.id = `post-tag`.`uri-id`
1405                         LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
1406                         LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
1407
1408 --
1409 -- VIEW owner-view
1410 --
1411 DROP VIEW IF EXISTS `owner-view`;
1412 CREATE VIEW `owner-view` AS SELECT 
1413         `contact`.`id` AS `id`,
1414         `contact`.`uid` AS `uid`,
1415         `contact`.`created` AS `created`,
1416         `contact`.`updated` AS `updated`,
1417         `contact`.`self` AS `self`,
1418         `contact`.`remote_self` AS `remote_self`,
1419         `contact`.`rel` AS `rel`,
1420         `contact`.`duplex` AS `duplex`,
1421         `contact`.`network` AS `network`,
1422         `contact`.`protocol` AS `protocol`,
1423         `contact`.`name` AS `name`,
1424         `contact`.`nick` AS `nick`,
1425         `contact`.`location` AS `location`,
1426         `contact`.`about` AS `about`,
1427         `contact`.`keywords` AS `keywords`,
1428         `contact`.`gender` AS `gender`,
1429         `contact`.`xmpp` AS `xmpp`,
1430         `contact`.`attag` AS `attag`,
1431         `contact`.`avatar` AS `avatar`,
1432         `contact`.`photo` AS `photo`,
1433         `contact`.`thumb` AS `thumb`,
1434         `contact`.`micro` AS `micro`,
1435         `contact`.`site-pubkey` AS `site-pubkey`,
1436         `contact`.`issued-id` AS `issued-id`,
1437         `contact`.`dfrn-id` AS `dfrn-id`,
1438         `contact`.`url` AS `url`,
1439         `contact`.`nurl` AS `nurl`,
1440         `contact`.`addr` AS `addr`,
1441         `contact`.`alias` AS `alias`,
1442         `contact`.`pubkey` AS `pubkey`,
1443         `contact`.`prvkey` AS `prvkey`,
1444         `contact`.`batch` AS `batch`,
1445         `contact`.`request` AS `request`,
1446         `contact`.`notify` AS `notify`,
1447         `contact`.`poll` AS `poll`,
1448         `contact`.`confirm` AS `confirm`,
1449         `contact`.`poco` AS `poco`,
1450         `contact`.`aes_allow` AS `aes_allow`,
1451         `contact`.`ret-aes` AS `ret-aes`,
1452         `contact`.`usehub` AS `usehub`,
1453         `contact`.`subhub` AS `subhub`,
1454         `contact`.`hub-verify` AS `hub-verify`,
1455         `contact`.`last-update` AS `last-update`,
1456         `contact`.`success_update` AS `success_update`,
1457         `contact`.`failure_update` AS `failure_update`,
1458         `contact`.`name-date` AS `name-date`,
1459         `contact`.`uri-date` AS `uri-date`,
1460         `contact`.`avatar-date` AS `avatar-date`,
1461         `contact`.`avatar-date` AS `picdate`,
1462         `contact`.`term-date` AS `term-date`,
1463         `contact`.`last-item` AS `last-item`,
1464         `contact`.`priority` AS `priority`,
1465         `contact`.`blocked` AS `blocked`,
1466         `contact`.`block_reason` AS `block_reason`,
1467         `contact`.`readonly` AS `readonly`,
1468         `contact`.`writable` AS `writable`,
1469         `contact`.`forum` AS `forum`,
1470         `contact`.`prv` AS `prv`,
1471         `contact`.`contact-type` AS `contact-type`,
1472         `contact`.`hidden` AS `hidden`,
1473         `contact`.`archive` AS `archive`,
1474         `contact`.`pending` AS `pending`,
1475         `contact`.`deleted` AS `deleted`,
1476         `contact`.`rating` AS `rating`,
1477         `contact`.`unsearchable` AS `unsearchable`,
1478         `contact`.`sensitive` AS `sensitive`,
1479         `contact`.`baseurl` AS `baseurl`,
1480         `contact`.`reason` AS `reason`,
1481         `contact`.`closeness` AS `closeness`,
1482         `contact`.`info` AS `info`,
1483         `contact`.`profile-id` AS `profile-id`,
1484         `contact`.`bdyear` AS `bdyear`,
1485         `contact`.`bd` AS `bd`,
1486         `contact`.`notify_new_posts` AS `notify_new_posts`,
1487         `contact`.`fetch_further_information` AS `fetch_further_information`,
1488         `contact`.`ffi_keyword_blacklist` AS `ffi_keyword_blacklist`,
1489         `user`.`parent-uid` AS `parent-uid`,
1490         `user`.`guid` AS `guid`,
1491         `user`.`nickname` AS `nickname`,
1492         `user`.`email` AS `email`,
1493         `user`.`openid` AS `openid`,
1494         `user`.`timezone` AS `timezone`,
1495         `user`.`language` AS `language`,
1496         `user`.`register_date` AS `register_date`,
1497         `user`.`login_date` AS `login_date`,
1498         `user`.`default-location` AS `default-location`,
1499         `user`.`allow_location` AS `allow_location`,
1500         `user`.`theme` AS `theme`,
1501         `user`.`pubkey` AS `upubkey`,
1502         `user`.`prvkey` AS `uprvkey`,
1503         `user`.`sprvkey` AS `sprvkey`,
1504         `user`.`spubkey` AS `spubkey`,
1505         `user`.`verified` AS `verified`,
1506         `user`.`blockwall` AS `blockwall`,
1507         `user`.`hidewall` AS `hidewall`,
1508         `user`.`blocktags` AS `blocktags`,
1509         `user`.`unkmail` AS `unkmail`,
1510         `user`.`cntunkmail` AS `cntunkmail`,
1511         `user`.`notify-flags` AS `notify-flags`,
1512         `user`.`page-flags` AS `page-flags`,
1513         `user`.`account-type` AS `account-type`,
1514         `user`.`prvnets` AS `prvnets`,
1515         `user`.`maxreq` AS `maxreq`,
1516         `user`.`expire` AS `expire`,
1517         `user`.`account_removed` AS `account_removed`,
1518         `user`.`account_expired` AS `account_expired`,
1519         `user`.`account_expires_on` AS `account_expires_on`,
1520         `user`.`expire_notification_sent` AS `expire_notification_sent`,
1521         `user`.`def_gid` AS `def_gid`,
1522         `user`.`allow_cid` AS `allow_cid`,
1523         `user`.`allow_gid` AS `allow_gid`,
1524         `user`.`deny_cid` AS `deny_cid`,
1525         `user`.`deny_gid` AS `deny_gid`,
1526         `user`.`openidserver` AS `openidserver`,
1527         `profile`.`publish` AS `publish`,
1528         `profile`.`net-publish` AS `net-publish`,
1529         `profile`.`hide-friends` AS `hide-friends`,
1530         `profile`.`prv_keywords` AS `prv_keywords`,
1531         `profile`.`pub_keywords` AS `pub_keywords`,
1532         `profile`.`address` AS `address`,
1533         `profile`.`locality` AS `locality`,
1534         `profile`.`region` AS `region`,
1535         `profile`.`postal-code` AS `postal-code`,
1536         `profile`.`country-name` AS `country-name`,
1537         `profile`.`homepage` AS `homepage`,
1538         `profile`.`dob` AS `dob`
1539         FROM `user`
1540                         INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
1541                         INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
1542
1543 --
1544 -- VIEW pending-view
1545 --
1546 DROP VIEW IF EXISTS `pending-view`;
1547 CREATE VIEW `pending-view` AS SELECT 
1548         `register`.`id` AS `id`,
1549         `register`.`hash` AS `hash`,
1550         `register`.`created` AS `created`,
1551         `register`.`uid` AS `uid`,
1552         `register`.`password` AS `password`,
1553         `register`.`language` AS `language`,
1554         `register`.`note` AS `note`,
1555         `contact`.`self` AS `self`,
1556         `contact`.`name` AS `name`,
1557         `contact`.`url` AS `url`,
1558         `contact`.`micro` AS `micro`,
1559         `user`.`email` AS `email`,
1560         `contact`.`nick` AS `nick`
1561         FROM `register`
1562                         INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
1563                         INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
1564
1565 --
1566 -- VIEW tag-search-view
1567 --
1568 DROP VIEW IF EXISTS `tag-search-view`;
1569 CREATE VIEW `tag-search-view` AS SELECT 
1570         `post-tag`.`uri-id` AS `uri-id`,
1571         `item`.`id` AS `iid`,
1572         `item`.`uri` AS `uri`,
1573         `item`.`guid` AS `guid`,
1574         `item`.`uid` AS `uid`,
1575         `item`.`private` AS `private`,
1576         `item`.`wall` AS `wall`,
1577         `item`.`origin` AS `origin`,
1578         `item`.`gravity` AS `gravity`,
1579         `item`.`received` AS `received`,
1580         `tag`.`name` AS `name`
1581         FROM `post-tag`
1582                         INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
1583                         INNER JOIN `item` ON `item`.`uri-id` = `post-tag`.`uri-id`
1584                         WHERE `post-tag`.`type` = 1;
1585
1586 --
1587 -- VIEW workerqueue-view
1588 --
1589 DROP VIEW IF EXISTS `workerqueue-view`;
1590 CREATE VIEW `workerqueue-view` AS SELECT 
1591         `process`.`pid` AS `pid`,
1592         `workerqueue`.`priority` AS `priority`
1593         FROM `process`
1594                         INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
1595                         WHERE NOT `workerqueue`.`done`;
1596
1597