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