]> git.mxchange.org Git - friendica.git/blob - database.sql
Updated sql file
[friendica.git] / database.sql
1 -- ------------------------------------------
2 -- Friendica 2018.08-dev (The Tazmans Flax-lily)
3 -- DB_UPDATE_VERSION 1267
4 -- ------------------------------------------
5
6
7 --
8 -- TABLE addon
9 --
10 CREATE TABLE IF NOT EXISTS `addon` (
11         `id` int unsigned NOT NULL auto_increment COMMENT '',
12         `name` varchar(50) NOT NULL DEFAULT '' COMMENT 'addon base (file)name',
13         `version` varchar(50) NOT NULL DEFAULT '' COMMENT 'currently unused',
14         `installed` boolean NOT NULL DEFAULT '0' COMMENT 'currently always 1',
15         `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'currently unused',
16         `timestamp` int unsigned NOT NULL DEFAULT 0 COMMENT 'file timestamp to check for reloads',
17         `plugin_admin` boolean NOT NULL DEFAULT '0' COMMENT '1 = has admin config, 0 = has no admin config',
18          PRIMARY KEY(`id`),
19          UNIQUE INDEX `name` (`name`)
20 ) DEFAULT COLLATE utf8mb4_general_ci;
21
22 --
23 -- TABLE attach
24 --
25 CREATE TABLE IF NOT EXISTS `attach` (
26         `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
27         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
28         `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
29         `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
30         `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
31         `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
32         `data` longblob NOT NULL COMMENT 'file data',
33         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
34         `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
35         `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
36         `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
37         `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
38         `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
39          PRIMARY KEY(`id`)
40 ) DEFAULT COLLATE utf8mb4_general_ci;
41
42 --
43 -- TABLE auth_codes
44 --
45 CREATE TABLE IF NOT EXISTS `auth_codes` (
46         `id` varchar(40) NOT NULL COMMENT '',
47         `client_id` varchar(20) NOT NULL DEFAULT '' COMMENT '',
48         `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
49         `expires` int NOT NULL DEFAULT 0 COMMENT '',
50         `scope` varchar(250) NOT NULL DEFAULT '' COMMENT '',
51          PRIMARY KEY(`id`)
52 ) DEFAULT COLLATE utf8mb4_general_ci;
53
54 --
55 -- TABLE cache
56 --
57 CREATE TABLE IF NOT EXISTS `cache` (
58         `k` varbinary(255) NOT NULL COMMENT 'cache key',
59         `v` mediumtext COMMENT 'cached serialized value',
60         `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
61         `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
62          PRIMARY KEY(`k`),
63          INDEX `k_expires` (`k`,`expires`)
64 ) DEFAULT COLLATE utf8mb4_general_ci;
65
66 --
67 -- TABLE challenge
68 --
69 CREATE TABLE IF NOT EXISTS `challenge` (
70         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
71         `challenge` varchar(255) NOT NULL DEFAULT '' COMMENT '',
72         `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
73         `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
74         `type` varchar(255) NOT NULL DEFAULT '' COMMENT '',
75         `last_update` varchar(255) NOT NULL DEFAULT '' COMMENT '',
76          PRIMARY KEY(`id`)
77 ) DEFAULT COLLATE utf8mb4_general_ci;
78
79 --
80 -- TABLE clients
81 --
82 CREATE TABLE IF NOT EXISTS `clients` (
83         `client_id` varchar(20) NOT NULL COMMENT '',
84         `pw` varchar(20) NOT NULL DEFAULT '' COMMENT '',
85         `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
86         `name` text COMMENT '',
87         `icon` text COMMENT '',
88         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
89          PRIMARY KEY(`client_id`)
90 ) DEFAULT COLLATE utf8mb4_general_ci;
91
92 --
93 -- TABLE config
94 --
95 CREATE TABLE IF NOT EXISTS `config` (
96         `id` int unsigned NOT NULL auto_increment COMMENT '',
97         `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
98         `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
99         `v` mediumtext COMMENT '',
100          PRIMARY KEY(`id`),
101          UNIQUE INDEX `cat_k` (`cat`,`k`)
102 ) DEFAULT COLLATE utf8mb4_general_ci;
103
104 --
105 -- TABLE contact
106 --
107 CREATE TABLE IF NOT EXISTS `contact` (
108         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
109         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
110         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
111         `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
112         `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
113         `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
114         `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
115         `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network protocol of the contact',
116         `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
117         `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
118         `location` varchar(255) NOT NULL DEFAULT '' COMMENT '',
119         `about` text COMMENT '',
120         `keywords` text COMMENT 'public keywords (interests) of the contact',
121         `gender` varchar(32) NOT NULL DEFAULT '' COMMENT '',
122         `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
123         `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
124         `avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '',
125         `photo` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
126         `thumb` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
127         `micro` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
128         `site-pubkey` text COMMENT '',
129         `issued-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
130         `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
131         `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
132         `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
133         `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
134         `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
135         `pubkey` text COMMENT 'RSA public key 4096 bit',
136         `prvkey` text COMMENT 'RSA private key 4096 bit',
137         `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
138         `request` varchar(255) COMMENT '',
139         `notify` varchar(255) COMMENT '',
140         `poll` varchar(255) COMMENT '',
141         `confirm` varchar(255) COMMENT '',
142         `poco` varchar(255) COMMENT '',
143         `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT '',
144         `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT '',
145         `usehub` boolean NOT NULL DEFAULT '0' COMMENT '',
146         `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
147         `hub-verify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
148         `last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
149         `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
150         `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
151         `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
152         `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
153         `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
154         `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
155         `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
156         `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
157         `blocked` boolean NOT NULL DEFAULT '1' COMMENT '',
158         `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
159         `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
160         `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum',
161         `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group',
162         `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT '',
163         `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
164         `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
165         `pending` boolean NOT NULL DEFAULT '1' COMMENT '',
166         `rating` tinyint NOT NULL DEFAULT 0 COMMENT '',
167         `reason` text COMMENT '',
168         `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT '',
169         `info` mediumtext COMMENT '',
170         `profile-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
171         `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
172         `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
173         `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
174         `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
175         `ffi_keyword_blacklist` text COMMENT '',
176          PRIMARY KEY(`id`),
177          INDEX `uid_name` (`uid`,`name`(190)),
178          INDEX `self_uid` (`self`,`uid`),
179          INDEX `alias_uid` (`alias`(32),`uid`),
180          INDEX `pending_uid` (`pending`,`uid`),
181          INDEX `blocked_uid` (`blocked`,`uid`),
182          INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
183          INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
184          INDEX `addr_uid` (`addr`(32),`uid`),
185          INDEX `nurl_uid` (`nurl`(32),`uid`),
186          INDEX `nick_uid` (`nick`(32),`uid`),
187          INDEX `dfrn-id` (`dfrn-id`(64)),
188          INDEX `issued-id` (`issued-id`(64))
189 ) DEFAULT COLLATE utf8mb4_general_ci;
190
191 --
192 -- TABLE conv
193 --
194 CREATE TABLE IF NOT EXISTS `conv` (
195         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
196         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
197         `recips` text COMMENT 'sender_handle;recipient_handle',
198         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
199         `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
200         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
201         `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
202         `subject` text COMMENT 'subject of initial message',
203          PRIMARY KEY(`id`),
204          INDEX `uid` (`uid`)
205 ) DEFAULT COLLATE utf8mb4_general_ci;
206
207 --
208 -- TABLE conversation
209 --
210 CREATE TABLE IF NOT EXISTS `conversation` (
211         `item-uri` varbinary(255) NOT NULL COMMENT 'URI of the item',
212         `reply-to-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'URI to which this item is a reply',
213         `conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI',
214         `conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link',
215         `protocol` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The protocol of the item',
216         `source` mediumtext COMMENT 'Original source',
217         `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Receiving date',
218          PRIMARY KEY(`item-uri`),
219          INDEX `conversation-uri` (`conversation-uri`),
220          INDEX `received` (`received`)
221 ) DEFAULT COLLATE utf8mb4_general_ci;
222
223 --
224 -- TABLE event
225 --
226 CREATE TABLE IF NOT EXISTS `event` (
227         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
228         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
229         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
230         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
231         `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
232         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
233         `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
234         `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
235         `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
236         `summary` text COMMENT 'short description or title of the event',
237         `desc` text COMMENT 'event description',
238         `location` text COMMENT 'event location',
239         `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
240         `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
241         `adjust` boolean NOT NULL DEFAULT '1' COMMENT 'adjust to timezone of the recipient (0 or 1)',
242         `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
243         `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
244         `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
245         `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
246         `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
247          PRIMARY KEY(`id`),
248          INDEX `uid_start` (`uid`,`start`)
249 ) DEFAULT COLLATE utf8mb4_general_ci;
250
251 --
252 -- TABLE fcontact
253 --
254 CREATE TABLE IF NOT EXISTS `fcontact` (
255         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
256         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
257         `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
258         `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
259         `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
260         `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
261         `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
262         `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
263         `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
264         `notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
265         `poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
266         `confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
267         `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
268         `network` char(4) NOT NULL DEFAULT '' COMMENT '',
269         `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
270         `pubkey` text COMMENT '',
271         `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
272          PRIMARY KEY(`id`),
273          INDEX `addr` (`addr`(32)),
274          UNIQUE INDEX `url` (`url`(190))
275 ) DEFAULT COLLATE utf8mb4_general_ci;
276
277 --
278 -- TABLE fsuggest
279 --
280 CREATE TABLE IF NOT EXISTS `fsuggest` (
281         `id` int unsigned NOT NULL auto_increment COMMENT '',
282         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
283         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
284         `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
285         `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
286         `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
287         `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
288         `note` text COMMENT '',
289         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
290          PRIMARY KEY(`id`)
291 ) DEFAULT COLLATE utf8mb4_general_ci;
292
293 --
294 -- TABLE gcign
295 --
296 CREATE TABLE IF NOT EXISTS `gcign` (
297         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
298         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Local User id',
299         `gcid` int unsigned NOT NULL DEFAULT 0 COMMENT 'gcontact.id of ignored contact',
300          PRIMARY KEY(`id`),
301          INDEX `uid` (`uid`),
302          INDEX `gcid` (`gcid`)
303 ) DEFAULT COLLATE utf8mb4_general_ci;
304
305 --
306 -- TABLE gcontact
307 --
308 CREATE TABLE IF NOT EXISTS `gcontact` (
309         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
310         `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
311         `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
312         `url` varchar(255) NOT NULL DEFAULT '' COMMENT 'Link to the contacts profile page',
313         `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
314         `photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'Link to the profile photo',
315         `connect` varchar(255) NOT NULL DEFAULT '' COMMENT '',
316         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
317         `updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
318         `last_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
319         `last_failure` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
320         `location` varchar(255) NOT NULL DEFAULT '' COMMENT '',
321         `about` text COMMENT '',
322         `keywords` text COMMENT 'puplic keywords (interests)',
323         `gender` varchar(32) NOT NULL DEFAULT '' COMMENT '',
324         `birthday` varchar(32) NOT NULL DEFAULT '0001-01-01' COMMENT '',
325         `community` boolean NOT NULL DEFAULT '0' COMMENT '1 if contact is forum account',
326         `contact-type` tinyint NOT NULL DEFAULT -1 COMMENT '',
327         `hide` boolean NOT NULL DEFAULT '0' COMMENT '1 = should be hidden from search',
328         `nsfw` boolean NOT NULL DEFAULT '0' COMMENT '1 = contact posts nsfw content',
329         `network` char(4) NOT NULL DEFAULT '' COMMENT 'social network protocol',
330         `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
331         `notify` varchar(255) COMMENT '',
332         `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
333         `generation` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
334         `server_url` varchar(255) NOT NULL DEFAULT '' COMMENT 'baseurl of the contacts server',
335          PRIMARY KEY(`id`),
336          UNIQUE INDEX `nurl` (`nurl`(190)),
337          INDEX `name` (`name`(64)),
338          INDEX `nick` (`nick`(32)),
339          INDEX `addr` (`addr`(64)),
340          INDEX `hide_network_updated` (`hide`,`network`,`updated`),
341          INDEX `updated` (`updated`)
342 ) DEFAULT COLLATE utf8mb4_general_ci;
343
344 --
345 -- TABLE glink
346 --
347 CREATE TABLE IF NOT EXISTS `glink` (
348         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
349         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
350         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
351         `gcid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
352         `zcid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
353         `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
354          PRIMARY KEY(`id`),
355          UNIQUE INDEX `cid_uid_gcid_zcid` (`cid`,`uid`,`gcid`,`zcid`),
356          INDEX `gcid` (`gcid`)
357 ) DEFAULT COLLATE utf8mb4_general_ci;
358
359 --
360 -- TABLE group
361 --
362 CREATE TABLE IF NOT EXISTS `group` (
363         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
364         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
365         `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
366         `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
367         `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
368          PRIMARY KEY(`id`),
369          INDEX `uid` (`uid`)
370 ) DEFAULT COLLATE utf8mb4_general_ci;
371
372 --
373 -- TABLE group_member
374 --
375 CREATE TABLE IF NOT EXISTS `group_member` (
376         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
377         `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
378         `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id  of the member assigned to the associated group',
379          PRIMARY KEY(`id`),
380          INDEX `contactid` (`contact-id`),
381          UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`)
382 ) DEFAULT COLLATE utf8mb4_general_ci;
383
384 --
385 -- TABLE gserver
386 --
387 CREATE TABLE IF NOT EXISTS `gserver` (
388         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
389         `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
390         `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
391         `version` varchar(255) NOT NULL DEFAULT '' COMMENT '',
392         `site_name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
393         `info` text COMMENT '',
394         `register_policy` tinyint NOT NULL DEFAULT 0 COMMENT '',
395         `registered-users` int unsigned NOT NULL DEFAULT 0 COMMENT 'Number of registered users',
396         `poco` varchar(255) NOT NULL DEFAULT '' COMMENT '',
397         `noscrape` varchar(255) NOT NULL DEFAULT '' COMMENT '',
398         `network` char(4) NOT NULL DEFAULT '' COMMENT '',
399         `platform` varchar(255) NOT NULL DEFAULT '' COMMENT '',
400         `relay-subscribe` boolean NOT NULL DEFAULT '0' COMMENT 'Has the server subscribed to the relay system',
401         `relay-scope` varchar(10) NOT NULL DEFAULT '' COMMENT 'The scope of messages that the server wants to get',
402         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
403         `last_poco_query` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
404         `last_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
405         `last_failure` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
406          PRIMARY KEY(`id`),
407          UNIQUE INDEX `nurl` (`nurl`(190))
408 ) DEFAULT COLLATE utf8mb4_general_ci;
409
410 --
411 -- TABLE gserver-tag
412 --
413 CREATE TABLE IF NOT EXISTS `gserver-tag` (
414         `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
415         `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
416          PRIMARY KEY(`gserver-id`,`tag`),
417          INDEX `tag` (`tag`)
418 ) DEFAULT COLLATE utf8mb4_general_ci;
419
420 --
421 -- TABLE hook
422 --
423 CREATE TABLE IF NOT EXISTS `hook` (
424         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
425         `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
426         `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
427         `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
428         `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',
429          PRIMARY KEY(`id`),
430          UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
431 ) DEFAULT COLLATE utf8mb4_general_ci;
432
433 --
434 -- TABLE intro
435 --
436 CREATE TABLE IF NOT EXISTS `intro` (
437         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
438         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
439         `fid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
440         `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
441         `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
442         `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
443         `note` text COMMENT '',
444         `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
445         `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
446         `blocked` boolean NOT NULL DEFAULT '1' COMMENT '',
447         `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
448          PRIMARY KEY(`id`)
449 ) DEFAULT COLLATE utf8mb4_general_ci;
450
451 --
452 -- TABLE item
453 --
454 CREATE TABLE IF NOT EXISTS `item` (
455         `id` int unsigned NOT NULL auto_increment,
456         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this item',
457         `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
458         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
459         `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
460         `type` varchar(20) NOT NULL DEFAULT '' COMMENT '',
461         `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
462         `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
463         `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',
464         `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT 'uri of the parent to this item',
465         `extid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
466         `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',
467         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
468         `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
469         `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last comment/reply to this item',
470         `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
471         `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',
472         `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
473         `owner-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name of the owner of this item',
474         `owner-link` varchar(255) NOT NULL DEFAULT '' COMMENT 'Link to the profile page of the owner of this item',
475         `owner-avatar` varchar(255) NOT NULL DEFAULT '' COMMENT 'Link to the avatar picture of the owner of this item',
476         `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
477         `author-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name of the author of this item',
478         `author-link` varchar(255) NOT NULL DEFAULT '' COMMENT 'Link to the profile page of the author of this item',
479         `author-avatar` varchar(255) NOT NULL DEFAULT '' COMMENT 'Link to the avatar picture of the author of this item',
480         `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
481         `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
482         `body` mediumtext COMMENT 'item body content',
483         `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
484         `verb` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams verb',
485         `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
486         `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
487         `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
488         `target` text COMMENT 'JSON encoded target structure if used',
489         `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',
490         `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
491         `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',
492         `event-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Used to link to the event.id',
493         `tag` mediumtext COMMENT '',
494         `attach` mediumtext COMMENT 'JSON structure representing attachments to this item',
495         `inform` mediumtext COMMENT '',
496         `file` mediumtext COMMENT '',
497         `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
498         `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
499         `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
500         `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
501         `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
502         `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
503         `private` boolean NOT NULL DEFAULT '0' COMMENT 'distribution is restricted',
504         `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
505         `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
506         `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
507         `starred` boolean NOT NULL DEFAULT '0' COMMENT 'item has been favourited',
508         `bookmark` boolean NOT NULL DEFAULT '0' COMMENT 'item has been bookmarked',
509         `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'item has not been seen',
510         `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been deleted',
511         `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
512         `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
513         `mention` boolean NOT NULL DEFAULT '0' COMMENT 'The owner of this item was mentioned in it',
514         `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
515         `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
516         `rendered-html` mediumtext COMMENT 'item.body converted to html',
517          PRIMARY KEY(`id`),
518          INDEX `guid` (`guid`(191)),
519          INDEX `uri` (`uri`(191)),
520          INDEX `parent` (`parent`),
521          INDEX `parent-uri` (`parent-uri`(191)),
522          INDEX `extid` (`extid`(191)),
523          INDEX `uid_id` (`uid`,`id`),
524          INDEX `uid_contactid_id` (`uid`,`contact-id`,`id`),
525          INDEX `uid_created` (`uid`,`created`),
526          INDEX `uid_commented` (`uid`,`commented`),
527          INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
528          INDEX `uid_network_received` (`uid`,`network`,`received`),
529          INDEX `uid_network_commented` (`uid`,`network`,`commented`),
530          INDEX `uid_thrparent` (`uid`,`thr-parent`(190)),
531          INDEX `uid_parenturi` (`uid`,`parent-uri`(190)),
532          INDEX `uid_contactid_created` (`uid`,`contact-id`,`created`),
533          INDEX `authorid_created` (`author-id`,`created`),
534          INDEX `ownerid` (`owner-id`),
535          INDEX `uid_uri` (`uid`,`uri`(190)),
536          INDEX `resource-id` (`resource-id`),
537          INDEX `contactid_allowcid_allowpid_denycid_denygid` (`contact-id`,`allow_cid`(10),`allow_gid`(10),`deny_cid`(10),`deny_gid`(10)),
538          INDEX `uid_type_changed` (`uid`,`type`,`changed`),
539          INDEX `contactid_verb` (`contact-id`,`verb`),
540          INDEX `deleted_changed` (`deleted`,`changed`),
541          INDEX `uid_wall_changed` (`uid`,`wall`,`changed`),
542          INDEX `uid_eventid` (`uid`,`event-id`),
543          INDEX `uid_authorlink` (`uid`,`author-link`(190)),
544          INDEX `uid_ownerlink` (`uid`,`owner-link`(190))
545 ) DEFAULT COLLATE utf8mb4_general_ci;
546
547 --
548 -- TABLE locks
549 --
550 CREATE TABLE IF NOT EXISTS `locks` (
551         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
552         `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
553         `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
554         `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
555          PRIMARY KEY(`id`)
556 ) DEFAULT COLLATE utf8mb4_general_ci;
557
558 --
559 -- TABLE mail
560 --
561 CREATE TABLE IF NOT EXISTS `mail` (
562         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
563         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
564         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
565         `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
566         `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
567         `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
568         `contact-id` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact.id',
569         `convid` int unsigned NOT NULL DEFAULT 0 COMMENT 'conv.id',
570         `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
571         `body` mediumtext COMMENT '',
572         `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
573         `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
574         `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
575         `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
576         `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
577         `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
578         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
579          PRIMARY KEY(`id`),
580          INDEX `uid_seen` (`uid`,`seen`),
581          INDEX `convid` (`convid`),
582          INDEX `uri` (`uri`(64)),
583          INDEX `parent-uri` (`parent-uri`(64)),
584          INDEX `contactid` (`contact-id`(32))
585 ) DEFAULT COLLATE utf8mb4_general_ci;
586
587 --
588 -- TABLE mailacct
589 --
590 CREATE TABLE IF NOT EXISTS `mailacct` (
591         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
592         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
593         `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
594         `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
595         `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
596         `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
597         `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
598         `pass` text COMMENT '',
599         `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
600         `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
601         `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
602         `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
603         `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
604          PRIMARY KEY(`id`)
605 ) DEFAULT COLLATE utf8mb4_general_ci;
606
607 --
608 -- TABLE manage
609 --
610 CREATE TABLE IF NOT EXISTS `manage` (
611         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
612         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
613         `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
614          PRIMARY KEY(`id`),
615          UNIQUE INDEX `uid_mid` (`uid`,`mid`)
616 ) DEFAULT COLLATE utf8mb4_general_ci;
617
618 --
619 -- TABLE notify
620 --
621 CREATE TABLE IF NOT EXISTS `notify` (
622         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
623         `hash` varchar(64) NOT NULL DEFAULT '' COMMENT '',
624         `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
625         `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
626         `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
627         `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
628         `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
629         `msg` mediumtext COMMENT '',
630         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
631         `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
632         `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'item.id',
633         `parent` int unsigned NOT NULL DEFAULT 0 COMMENT '',
634         `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
635         `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
636         `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
637         `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
638         `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
639          PRIMARY KEY(`id`),
640          INDEX `hash_uid` (`hash`,`uid`),
641          INDEX `seen_uid_date` (`seen`,`uid`,`date`),
642          INDEX `uid_date` (`uid`,`date`),
643          INDEX `uid_type_link` (`uid`,`type`,`link`(190))
644 ) DEFAULT COLLATE utf8mb4_general_ci;
645
646 --
647 -- TABLE notify-threads
648 --
649 CREATE TABLE IF NOT EXISTS `notify-threads` (
650         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
651         `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
652         `master-parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
653         `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
654         `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
655          PRIMARY KEY(`id`)
656 ) DEFAULT COLLATE utf8mb4_general_ci;
657
658 --
659 -- TABLE oembed
660 --
661 CREATE TABLE IF NOT EXISTS `oembed` (
662         `url` varbinary(255) NOT NULL COMMENT 'page url',
663         `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
664         `content` mediumtext COMMENT 'OEmbed data of the page',
665         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
666          PRIMARY KEY(`url`,`maxwidth`),
667          INDEX `created` (`created`)
668 ) DEFAULT COLLATE utf8mb4_general_ci;
669
670 --
671 -- TABLE parsed_url
672 --
673 CREATE TABLE IF NOT EXISTS `parsed_url` (
674         `url` varbinary(255) NOT NULL COMMENT 'page url',
675         `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
676         `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
677         `content` mediumtext COMMENT 'page data',
678         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
679          PRIMARY KEY(`url`,`guessing`,`oembed`),
680          INDEX `created` (`created`)
681 ) DEFAULT COLLATE utf8mb4_general_ci;
682
683 --
684 -- TABLE participation
685 --
686 CREATE TABLE IF NOT EXISTS `participation` (
687         `iid` int unsigned NOT NULL COMMENT '',
688         `server` varchar(60) NOT NULL COMMENT '',
689         `cid` int unsigned NOT NULL COMMENT '',
690         `fid` int unsigned NOT NULL COMMENT '',
691          PRIMARY KEY(`iid`,`server`)
692 ) DEFAULT COLLATE utf8mb4_general_ci;
693
694 --
695 -- TABLE pconfig
696 --
697 CREATE TABLE IF NOT EXISTS `pconfig` (
698         `id` int unsigned NOT NULL auto_increment COMMENT '',
699         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
700         `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
701         `k` varbinary(100) NOT NULL DEFAULT '' COMMENT '',
702         `v` mediumtext COMMENT '',
703          PRIMARY KEY(`id`),
704          UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`)
705 ) DEFAULT COLLATE utf8mb4_general_ci;
706
707 --
708 -- TABLE photo
709 --
710 CREATE TABLE IF NOT EXISTS `photo` (
711         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
712         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
713         `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
714         `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
715         `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
716         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
717         `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
718         `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
719         `desc` text COMMENT '',
720         `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
721         `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
722         `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
723         `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
724         `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
725         `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
726         `data` mediumblob NOT NULL COMMENT '',
727         `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
728         `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
729         `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
730         `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
731         `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
732         `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
733          PRIMARY KEY(`id`),
734          INDEX `contactid` (`contact-id`),
735          INDEX `uid_contactid` (`uid`,`contact-id`),
736          INDEX `uid_profile` (`uid`,`profile`),
737          INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
738          INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
739          INDEX `resource-id` (`resource-id`)
740 ) DEFAULT COLLATE utf8mb4_general_ci;
741
742 --
743 -- TABLE poll
744 --
745 CREATE TABLE IF NOT EXISTS `poll` (
746         `id` int unsigned NOT NULL auto_increment COMMENT '',
747         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
748         `q0` text COMMENT '',
749         `q1` text COMMENT '',
750         `q2` text COMMENT '',
751         `q3` text COMMENT '',
752         `q4` text COMMENT '',
753         `q5` text COMMENT '',
754         `q6` text COMMENT '',
755         `q7` text COMMENT '',
756         `q8` text COMMENT '',
757         `q9` text COMMENT '',
758          PRIMARY KEY(`id`),
759          INDEX `uid` (`uid`)
760 ) DEFAULT COLLATE utf8mb4_general_ci;
761
762 --
763 -- TABLE poll_result
764 --
765 CREATE TABLE IF NOT EXISTS `poll_result` (
766         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
767         `poll_id` int unsigned NOT NULL DEFAULT 0,
768         `choice` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
769          PRIMARY KEY(`id`),
770          INDEX `poll_id` (`poll_id`)
771 ) DEFAULT COLLATE utf8mb4_general_ci;
772
773 --
774 -- TABLE process
775 --
776 CREATE TABLE IF NOT EXISTS `process` (
777         `pid` int unsigned NOT NULL COMMENT '',
778         `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
779         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
780          PRIMARY KEY(`pid`),
781          INDEX `command` (`command`)
782 ) DEFAULT COLLATE utf8mb4_general_ci;
783
784 --
785 -- TABLE profile
786 --
787 CREATE TABLE IF NOT EXISTS `profile` (
788         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
789         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
790         `profile-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name of the profile',
791         `is-default` boolean NOT NULL DEFAULT '0' COMMENT 'Mark this profile as default profile',
792         `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
793         `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
794         `pdesc` varchar(255) NOT NULL DEFAULT '' COMMENT 'Title or description',
795         `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
796         `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
797         `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
798         `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
799         `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
800         `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
801         `hometown` varchar(255) NOT NULL DEFAULT '' COMMENT '',
802         `gender` varchar(32) NOT NULL DEFAULT '' COMMENT '',
803         `marital` varchar(255) NOT NULL DEFAULT '' COMMENT '',
804         `with` text COMMENT '',
805         `howlong` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
806         `sexual` varchar(255) NOT NULL DEFAULT '' COMMENT '',
807         `politic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
808         `religion` varchar(255) NOT NULL DEFAULT '' COMMENT '',
809         `pub_keywords` text COMMENT '',
810         `prv_keywords` text COMMENT '',
811         `likes` text COMMENT '',
812         `dislikes` text COMMENT '',
813         `about` text COMMENT '',
814         `summary` varchar(255) NOT NULL DEFAULT '' COMMENT '',
815         `music` text COMMENT '',
816         `book` text COMMENT '',
817         `tv` text COMMENT '',
818         `film` text COMMENT '',
819         `interest` text COMMENT '',
820         `romance` text COMMENT '',
821         `work` text COMMENT '',
822         `education` text COMMENT '',
823         `contact` text COMMENT '',
824         `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
825         `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
826         `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
827         `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
828         `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
829         `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
830          PRIMARY KEY(`id`),
831          INDEX `uid_is-default` (`uid`,`is-default`)
832 ) DEFAULT COLLATE utf8mb4_general_ci;
833
834 --
835 -- TABLE profile_check
836 --
837 CREATE TABLE IF NOT EXISTS `profile_check` (
838         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
839         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
840         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
841         `dfrn_id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
842         `sec` varchar(255) NOT NULL DEFAULT '' COMMENT '',
843         `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
844          PRIMARY KEY(`id`)
845 ) DEFAULT COLLATE utf8mb4_general_ci;
846
847 --
848 -- TABLE push_subscriber
849 --
850 CREATE TABLE IF NOT EXISTS `push_subscriber` (
851         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
852         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
853         `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
854         `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
855         `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
856         `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
857         `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
858         `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
859         `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
860         `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
861          PRIMARY KEY(`id`),
862          INDEX `next_try` (`next_try`)
863 ) DEFAULT COLLATE utf8mb4_general_ci;
864
865 --
866 -- TABLE queue
867 --
868 CREATE TABLE IF NOT EXISTS `queue` (
869         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
870         `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Message receiver',
871         `network` char(4) NOT NULL DEFAULT '' COMMENT 'Receiver\'s network',
872         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'Unique GUID of the message',
873         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date, when the message was created',
874         `last` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last trial',
875         `next` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
876         `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
877         `content` mediumtext COMMENT '',
878         `batch` boolean NOT NULL DEFAULT '0' COMMENT '',
879          PRIMARY KEY(`id`),
880          INDEX `last` (`last`),
881          INDEX `next` (`next`)
882 ) DEFAULT COLLATE utf8mb4_general_ci;
883
884 --
885 -- TABLE register
886 --
887 CREATE TABLE IF NOT EXISTS `register` (
888         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
889         `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
890         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
891         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
892         `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
893         `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
894         `note` text COMMENT '',
895          PRIMARY KEY(`id`)
896 ) DEFAULT COLLATE utf8mb4_general_ci;
897
898 --
899 -- TABLE search
900 --
901 CREATE TABLE IF NOT EXISTS `search` (
902         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
903         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
904         `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
905          PRIMARY KEY(`id`),
906          INDEX `uid` (`uid`)
907 ) DEFAULT COLLATE utf8mb4_general_ci;
908
909 --
910 -- TABLE session
911 --
912 CREATE TABLE IF NOT EXISTS `session` (
913         `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
914         `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
915         `data` text COMMENT '',
916         `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
917          PRIMARY KEY(`id`),
918          INDEX `sid` (`sid`(64)),
919          INDEX `expire` (`expire`)
920 ) DEFAULT COLLATE utf8mb4_general_ci;
921
922 --
923 -- TABLE sign
924 --
925 CREATE TABLE IF NOT EXISTS `sign` (
926         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
927         `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'item.id',
928         `signed_text` mediumtext COMMENT '',
929         `signature` text COMMENT '',
930         `signer` varchar(255) NOT NULL DEFAULT '' COMMENT '',
931          PRIMARY KEY(`id`),
932          UNIQUE INDEX `iid` (`iid`)
933 ) DEFAULT COLLATE utf8mb4_general_ci;
934
935 --
936 -- TABLE term
937 --
938 CREATE TABLE IF NOT EXISTS `term` (
939         `tid` int unsigned NOT NULL auto_increment COMMENT '',
940         `oid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
941         `otype` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
942         `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
943         `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
944         `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
945         `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
946         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
947         `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
948         `global` boolean NOT NULL DEFAULT '0' COMMENT '',
949         `aid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
950         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
951          PRIMARY KEY(`tid`),
952          INDEX `oid_otype_type_term` (`oid`,`otype`,`type`,`term`(32)),
953          INDEX `uid_otype_type_term_global_created` (`uid`,`otype`,`type`,`term`(32),`global`,`created`),
954          INDEX `uid_otype_type_url` (`uid`,`otype`,`type`,`url`(64)),
955          INDEX `guid` (`guid`(64))
956 ) DEFAULT COLLATE utf8mb4_general_ci;
957
958 --
959 -- TABLE thread
960 --
961 CREATE TABLE IF NOT EXISTS `thread` (
962         `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'sequential ID',
963         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
964         `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
965         `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
966         `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
967         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
968         `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
969         `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
970         `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
971         `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
972         `wall` boolean NOT NULL DEFAULT '0' COMMENT '',
973         `private` boolean NOT NULL DEFAULT '0' COMMENT '',
974         `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
975         `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
976         `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
977         `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
978         `ignored` boolean NOT NULL DEFAULT '0' COMMENT '',
979         `bookmark` boolean NOT NULL DEFAULT '0' COMMENT '',
980         `unseen` boolean NOT NULL DEFAULT '1' COMMENT '',
981         `deleted` boolean NOT NULL DEFAULT '0' COMMENT '',
982         `origin` boolean NOT NULL DEFAULT '0' COMMENT '',
983         `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
984         `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
985         `network` char(4) NOT NULL DEFAULT '' COMMENT '',
986          PRIMARY KEY(`iid`),
987          INDEX `uid_network_commented` (`uid`,`network`,`commented`),
988          INDEX `uid_network_created` (`uid`,`network`,`created`),
989          INDEX `uid_contactid_commented` (`uid`,`contact-id`,`commented`),
990          INDEX `uid_contactid_created` (`uid`,`contact-id`,`created`),
991          INDEX `contactid` (`contact-id`),
992          INDEX `ownerid` (`owner-id`),
993          INDEX `authorid` (`author-id`),
994          INDEX `uid_created` (`uid`,`created`),
995          INDEX `uid_commented` (`uid`,`commented`),
996          INDEX `uid_wall_created` (`uid`,`wall`,`created`),
997          INDEX `private_wall_origin_commented` (`private`,`wall`,`origin`,`commented`)
998 ) DEFAULT COLLATE utf8mb4_general_ci;
999
1000 --
1001 -- TABLE tokens
1002 --
1003 CREATE TABLE IF NOT EXISTS `tokens` (
1004         `id` varchar(40) NOT NULL COMMENT '',
1005         `secret` text COMMENT '',
1006         `client_id` varchar(20) NOT NULL DEFAULT '',
1007         `expires` int NOT NULL DEFAULT 0 COMMENT '',
1008         `scope` varchar(200) NOT NULL DEFAULT '' COMMENT '',
1009         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1010          PRIMARY KEY(`id`)
1011 ) DEFAULT COLLATE utf8mb4_general_ci;
1012
1013 --
1014 -- TABLE user
1015 --
1016 CREATE TABLE IF NOT EXISTS `user` (
1017         `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1018         `parent-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'The parent user that has full control about this user',
1019         `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
1020         `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
1021         `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
1022         `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
1023         `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
1024         `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
1025         `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
1026         `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
1027         `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
1028         `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
1029         `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
1030         `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
1031         `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
1032         `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
1033         `pubkey` text COMMENT 'RSA public key 4096 bit',
1034         `prvkey` text COMMENT 'RSA private key 4096 bit',
1035         `spubkey` text COMMENT '',
1036         `sprvkey` text COMMENT '',
1037         `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
1038         `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
1039         `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
1040         `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unkown viewers',
1041         `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
1042         `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
1043         `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
1044         `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
1045         `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
1046         `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
1047         `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
1048         `pwdreset` varchar(255) COMMENT 'Password reset request token',
1049         `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
1050         `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
1051         `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1052         `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
1053         `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
1054         `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
1055         `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
1056         `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
1057         `allow_cid` mediumtext COMMENT 'default permission for this user',
1058         `allow_gid` mediumtext COMMENT 'default permission for this user',
1059         `deny_cid` mediumtext COMMENT 'default permission for this user',
1060         `deny_gid` mediumtext COMMENT 'default permission for this user',
1061         `openidserver` text COMMENT '',
1062          PRIMARY KEY(`uid`),
1063          INDEX `nickname` (`nickname`(32))
1064 ) DEFAULT COLLATE utf8mb4_general_ci;
1065
1066 --
1067 -- TABLE userd
1068 --
1069 CREATE TABLE IF NOT EXISTS `userd` (
1070         `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
1071         `username` varchar(255) NOT NULL COMMENT '',
1072          PRIMARY KEY(`id`),
1073          INDEX `username` (`username`(32))
1074 ) DEFAULT COLLATE utf8mb4_general_ci;
1075
1076 --
1077 -- TABLE user-item
1078 --
1079 CREATE TABLE IF NOT EXISTS `user-item` (
1080         `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item id',
1081         `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
1082         `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide an item from the user',
1083          PRIMARY KEY(`uid`,`iid`)
1084 ) DEFAULT COLLATE utf8mb4_general_ci;
1085
1086 --
1087 -- TABLE workerqueue
1088 --
1089 CREATE TABLE IF NOT EXISTS `workerqueue` (
1090         `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
1091         `parameter` mediumblob COMMENT 'Task command',
1092         `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
1093         `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
1094         `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
1095         `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
1096         `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
1097          PRIMARY KEY(`id`),
1098          INDEX `pid` (`pid`),
1099          INDEX `parameter` (`parameter`(64)),
1100          INDEX `priority_created` (`priority`,`created`),
1101          INDEX `done_executed` (`done`,`executed`)
1102 ) DEFAULT COLLATE utf8mb4_general_ci;
1103
1104