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