forked from friendica/friendica
-
Notifications
You must be signed in to change notification settings - Fork 1
/
database.sql
3366 lines (3251 loc) · 161 KB
/
database.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- ------------------------------------------
-- Friendica 2024.03 (Yellow Archangel)
-- DB_UPDATE_VERSION 1557
-- ------------------------------------------
--
-- TABLE gserver
--
CREATE TABLE IF NOT EXISTS `gserver` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`nurl` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`version` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`site_name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`info` text COMMENT '',
`register_policy` tinyint NOT NULL DEFAULT 0 COMMENT '',
`registered-users` int unsigned NOT NULL DEFAULT 0 COMMENT 'Number of registered users',
`active-week-users` int unsigned COMMENT 'Number of active users in the last week',
`active-month-users` int unsigned COMMENT 'Number of active users in the last month',
`active-halfyear-users` int unsigned COMMENT 'Number of active users in the last six month',
`local-posts` int unsigned COMMENT 'Number of local posts',
`local-comments` int unsigned COMMENT 'Number of local comments',
`directory-type` tinyint DEFAULT 0 COMMENT 'Type of directory service (Poco, Mastodon)',
`poco` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`noscrape` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`network` char(4) NOT NULL DEFAULT '' COMMENT '',
`protocol` tinyint unsigned COMMENT 'The protocol of the server',
`platform` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`relay-subscribe` boolean NOT NULL DEFAULT '0' COMMENT 'Has the server subscribed to the relay system',
`relay-scope` varchar(10) NOT NULL DEFAULT '' COMMENT 'The scope of messages that the server wants to get',
`detection-method` tinyint unsigned COMMENT 'Method that had been used to detect that server',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`last_poco_query` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
`last_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Last successful connection request',
`last_failure` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Last failed connection request',
`blocked` boolean COMMENT 'Server is blocked',
`failed` boolean COMMENT 'Connection failed',
`next_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Next connection request',
PRIMARY KEY(`id`),
UNIQUE INDEX `nurl` (`nurl`(190)),
INDEX `next_contact` (`next_contact`),
INDEX `network` (`network`)
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Global servers';
--
-- TABLE user
--
CREATE TABLE IF NOT EXISTS `user` (
`uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`parent-uid` mediumint unsigned COMMENT 'The parent user that has full control about this user',
`guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
`username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
`password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
`legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
`nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
`email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
`openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
`language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
`register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
`login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
`last-activity` date COMMENT 'Day of the last activity',
`default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
`allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
`theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
`pubkey` text COMMENT 'RSA public key 4096 bit',
`prvkey` text COMMENT 'RSA private key 4096 bit',
`spubkey` text COMMENT '',
`sprvkey` text COMMENT '',
`verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
`blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
`blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
`hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unknown viewers',
`blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
`notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
`page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
`account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
`prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
`pwdreset` varchar(255) COMMENT 'Password reset request token',
`pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
`maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
`expire` int unsigned NOT NULL DEFAULT 0 COMMENT 'Delay in days before deleting user-related posts. Scope is controlled by pConfig.',
`account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
`account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
`account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
`expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
`def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
`allow_cid` mediumtext COMMENT 'default permission for this user',
`allow_gid` mediumtext COMMENT 'default permission for this user',
`deny_cid` mediumtext COMMENT 'default permission for this user',
`deny_gid` mediumtext COMMENT 'default permission for this user',
`openidserver` text COMMENT '',
PRIMARY KEY(`uid`),
INDEX `nickname` (`nickname`(32)),
INDEX `parent-uid` (`parent-uid`),
INDEX `guid` (`guid`),
INDEX `email` (`email`(64)),
FOREIGN KEY (`parent-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
--
-- TABLE user-gserver
--
CREATE TABLE IF NOT EXISTS `user-gserver` (
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
`gsid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Gserver id',
`ignored` boolean NOT NULL DEFAULT '0' COMMENT 'server accounts are ignored for the user',
PRIMARY KEY(`uid`,`gsid`),
INDEX `gsid` (`gsid`),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User settings about remote servers';
--
-- TABLE item-uri
--
CREATE TABLE IF NOT EXISTS `item-uri` (
`id` int unsigned NOT NULL auto_increment,
`uri` varbinary(383) NOT NULL COMMENT 'URI of an item',
`guid` varbinary(255) COMMENT 'A unique identifier for an item',
PRIMARY KEY(`id`),
UNIQUE INDEX `uri` (`uri`),
INDEX `guid` (`guid`)
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
--
-- TABLE contact
--
CREATE TABLE IF NOT EXISTS `contact` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last contact update',
`network` char(4) NOT NULL DEFAULT '' COMMENT 'Network of the contact',
`name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
`nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
`location` varchar(255) DEFAULT '' COMMENT '',
`about` text COMMENT '',
`keywords` text COMMENT 'public keywords (interests) of the contact',
`xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
`matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
`avatar` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`blurhash` varbinary(255) COMMENT 'BlurHash representation of the avatar',
`header` varbinary(383) COMMENT 'Header picture',
`url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`nurl` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
`addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`alias` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`pubkey` text COMMENT 'RSA public key 4096 bit',
`prvkey` text COMMENT 'RSA private key 4096 bit',
`batch` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`notify` varbinary(383) COMMENT '',
`poll` varbinary(383) COMMENT '',
`subscribe` varbinary(383) COMMENT '',
`last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
`next-update` datetime COMMENT 'Next connection request',
`success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
`failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
`failed` boolean COMMENT 'Connection failed',
`term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
`last-discovery` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last follower discovery',
`local-data` boolean COMMENT 'Is true when there are posts with this contact on the system',
`blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
`block_reason` text COMMENT 'Node-wide block reason',
`readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
`contact-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Person, organisation, news, community, relay',
`manually-approve` boolean COMMENT 'Contact requests have to be approved manually',
`archive` boolean NOT NULL DEFAULT '0' COMMENT '',
`unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
`sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
`baseurl` varbinary(383) DEFAULT '' COMMENT 'baseurl of the contact from the gserver record, can be missing',
`gsid` int unsigned COMMENT 'Global Server ID, can be missing',
`bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
`reason` text COMMENT '',
`self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
`remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
`rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
`protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
`subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
`hub-verify` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`rating` tinyint NOT NULL DEFAULT 0 COMMENT 'Automatically detected feed poll frequency',
`priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Feed poll priority',
`attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
`pending` boolean NOT NULL DEFAULT '1' COMMENT 'Contact request is pending',
`deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
`info` mediumtext COMMENT '',
`notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
`fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
`ffi_keyword_denylist` text COMMENT '',
`photo` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
`thumb` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
`micro` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
`name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`request` varbinary(383) COMMENT '',
`confirm` varbinary(383) COMMENT '',
`poco` varbinary(383) COMMENT '',
`writable` boolean NOT NULL DEFAULT '0' COMMENT '',
`forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a group. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = false instead',
`prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = true instead',
`bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
`site-pubkey` text COMMENT 'Deprecated',
`gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
`duplex` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
`issued-id` varbinary(383) NOT NULL DEFAULT '' COMMENT 'Deprecated',
`dfrn-id` varbinary(383) NOT NULL DEFAULT '' COMMENT 'Deprecated',
`aes_allow` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
`ret-aes` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
`usehub` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
`closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT 'Deprecated',
`profile-id` int unsigned COMMENT 'Deprecated',
PRIMARY KEY(`id`),
INDEX `uid_name` (`uid`,`name`(190)),
INDEX `self_uid` (`self`,`uid`),
INDEX `alias_uid` (`alias`(128),`uid`),
INDEX `pending_uid` (`pending`,`uid`),
INDEX `blocked_uid` (`blocked`,`uid`),
INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
INDEX `batch_contact-type` (`batch`(64),`contact-type`),
INDEX `addr_uid` (`addr`(128),`uid`),
INDEX `nurl_uid` (`nurl`(128),`uid`),
INDEX `nick_uid` (`nick`(128),`uid`),
INDEX `attag_uid` (`attag`(96),`uid`),
INDEX `network_uid_lastupdate` (`network`,`uid`,`last-update`),
INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`),
INDEX `next-update` (`next-update`),
INDEX `local-data-next-update` (`local-data`,`next-update`),
INDEX `uid_lastitem` (`uid`,`last-item`),
INDEX `baseurl` (`baseurl`(64)),
INDEX `uid_contact-type` (`uid`,`contact-type`),
INDEX `uid_self_contact-type` (`uid`,`self`,`contact-type`),
INDEX `self_network_uid` (`self`,`network`,`uid`),
INDEX `gsid_uid_failed` (`gsid`,`uid`,`failed`),
INDEX `uri-id` (`uri-id`),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
--
-- TABLE tag
--
CREATE TABLE IF NOT EXISTS `tag` (
`id` int unsigned NOT NULL auto_increment COMMENT '',
`name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
`url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`type` tinyint unsigned COMMENT 'Type of the tag (Unknown, General Collection, Follower Collection or Account)',
PRIMARY KEY(`id`),
UNIQUE INDEX `type_name_url` (`name`,`url`),
INDEX `url` (`url`)
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
--
-- TABLE permissionset
--
CREATE TABLE IF NOT EXISTS `permissionset` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
`allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
`allow_gid` mediumtext COMMENT 'Access Control - list of allowed circles',
`deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
`deny_gid` mediumtext COMMENT 'Access Control - list of denied circles',
PRIMARY KEY(`id`),
INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`uid`,`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30)),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
--
-- TABLE verb
--
CREATE TABLE IF NOT EXISTS `verb` (
`id` smallint unsigned NOT NULL auto_increment,
`name` varchar(100) NOT NULL DEFAULT '' COMMENT '',
PRIMARY KEY(`id`),
INDEX `name` (`name`)
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activity Verbs';
--
-- TABLE 2fa_app_specific_password
--
CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
`id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
`uid` mediumint unsigned NOT NULL COMMENT 'User ID',
`description` varchar(255) COMMENT 'Description of the usage of the password',
`hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
`generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
`last_used` datetime COMMENT 'Datetime the password was last used',
PRIMARY KEY(`id`),
INDEX `uid_description` (`uid`,`description`(190)),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
--
-- TABLE 2fa_recovery_codes
--
CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
`uid` mediumint unsigned NOT NULL COMMENT 'User ID',
`code` varchar(50) NOT NULL COMMENT 'Recovery code string',
`generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
`used` datetime COMMENT 'Datetime the code was used',
PRIMARY KEY(`uid`,`code`),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
--
-- TABLE 2fa_trusted_browser
--
CREATE TABLE IF NOT EXISTS `2fa_trusted_browser` (
`cookie_hash` varchar(80) NOT NULL COMMENT 'Trusted cookie hash',
`uid` mediumint unsigned NOT NULL COMMENT 'User ID',
`user_agent` text COMMENT 'User agent string',
`trusted` boolean NOT NULL DEFAULT '1' COMMENT 'Whenever this browser should be trusted or not',
`created` datetime NOT NULL COMMENT 'Datetime the trusted browser was recorded',
`last_used` datetime COMMENT 'Datetime the trusted browser was last used',
PRIMARY KEY(`cookie_hash`),
INDEX `uid` (`uid`),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication trusted browsers';
--
-- TABLE account-suggestion
--
CREATE TABLE IF NOT EXISTS `account-suggestion` (
`uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the account url',
`uid` mediumint unsigned NOT NULL COMMENT 'User ID',
`level` smallint unsigned COMMENT 'level of closeness',
`ignore` boolean NOT NULL DEFAULT '0' COMMENT 'If set, this account will not be suggested again',
PRIMARY KEY(`uid`,`uri-id`),
INDEX `uri-id_uid` (`uri-id`,`uid`),
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Account suggestion';
--
-- TABLE account-user
--
CREATE TABLE IF NOT EXISTS `account-user` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the account url',
`uid` mediumint unsigned NOT NULL COMMENT 'User ID',
PRIMARY KEY(`id`),
UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
INDEX `uid_uri-id` (`uid`,`uri-id`),
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Remote and local accounts';
--
-- TABLE apcontact
--
CREATE TABLE IF NOT EXISTS `apcontact` (
`url` varbinary(383) NOT NULL COMMENT 'URL of the contact',
`uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
`uuid` varbinary(255) COMMENT '',
`type` varchar(20) NOT NULL COMMENT '',
`following` varbinary(383) COMMENT '',
`followers` varbinary(383) COMMENT '',
`inbox` varbinary(383) NOT NULL COMMENT '',
`outbox` varbinary(383) COMMENT '',
`sharedinbox` varbinary(383) COMMENT '',
`featured` varbinary(383) COMMENT 'Address for the collection of featured posts',
`featured-tags` varbinary(383) COMMENT 'Address for the collection of featured tags',
`manually-approve` boolean COMMENT '',
`discoverable` boolean COMMENT 'Mastodon extension: true if profile is published in their directory',
`suspended` boolean COMMENT 'Mastodon extension: true if profile is suspended',
`nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`name` varchar(255) COMMENT '',
`about` text COMMENT '',
`xmpp` varchar(255) COMMENT 'XMPP address',
`matrix` varchar(255) COMMENT 'Matrix address',
`photo` varbinary(383) COMMENT '',
`header` varbinary(383) COMMENT 'Header picture',
`addr` varchar(255) COMMENT '',
`alias` varbinary(383) COMMENT '',
`pubkey` text COMMENT '',
`subscribe` varbinary(383) COMMENT '',
`baseurl` varbinary(383) COMMENT 'baseurl of the ap contact',
`gsid` int unsigned COMMENT 'Global Server ID',
`generator` varchar(255) COMMENT 'Name of the contact\'s system',
`following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
`followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
`statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
`updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
PRIMARY KEY(`url`),
INDEX `addr` (`addr`(32)),
INDEX `alias` (`alias`(190)),
INDEX `followers` (`followers`(190)),
INDEX `baseurl` (`baseurl`(190)),
INDEX `sharedinbox` (`sharedinbox`(190)),
INDEX `gsid` (`gsid`),
UNIQUE INDEX `uri-id` (`uri-id`),
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
--
-- TABLE application
--
CREATE TABLE IF NOT EXISTS `application` (
`id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
`client_id` varchar(64) NOT NULL COMMENT '',
`client_secret` varchar(64) NOT NULL COMMENT '',
`name` varchar(255) NOT NULL COMMENT '',
`redirect_uri` varbinary(383) NOT NULL COMMENT '',
`website` varbinary(383) COMMENT '',
`scopes` varchar(255) COMMENT '',
`read` boolean COMMENT 'Read scope',
`write` boolean COMMENT 'Write scope',
`follow` boolean COMMENT 'Follow scope',
`push` boolean COMMENT 'Push scope',
PRIMARY KEY(`id`),
UNIQUE INDEX `client_id` (`client_id`)
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth application';
--
-- TABLE application-marker
--
CREATE TABLE IF NOT EXISTS `application-marker` (
`application-id` int unsigned NOT NULL COMMENT '',
`uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
`timeline` varchar(64) NOT NULL COMMENT 'Marker (home, notifications)',
`last_read_id` varbinary(383) COMMENT 'Marker id for the timeline',
`version` smallint unsigned COMMENT 'Version number',
`updated_at` datetime COMMENT 'creation time',
PRIMARY KEY(`application-id`,`uid`,`timeline`),
INDEX `uid_id` (`uid`),
FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Timeline marker';
--
-- TABLE application-token
--
CREATE TABLE IF NOT EXISTS `application-token` (
`application-id` int unsigned NOT NULL COMMENT '',
`uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
`code` varchar(64) NOT NULL COMMENT '',
`access_token` varchar(64) NOT NULL COMMENT '',
`created_at` datetime NOT NULL COMMENT 'creation time',
`scopes` varchar(255) COMMENT '',
`read` boolean COMMENT 'Read scope',
`write` boolean COMMENT 'Write scope',
`follow` boolean COMMENT 'Follow scope',
`push` boolean COMMENT 'Push scope',
PRIMARY KEY(`application-id`,`uid`),
INDEX `uid_id` (`uid`,`application-id`),
FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth user token';
--
-- TABLE attach
--
CREATE TABLE IF NOT EXISTS `attach` (
`id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
`hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
`filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
`filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
`filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
`data` longblob NOT NULL COMMENT 'file data',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
`edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
`allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
`allow_gid` mediumtext COMMENT 'Access Control - list of allowed circles',
`deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
`deny_gid` mediumtext COMMENT 'Access Control - list of denied circles',
`backend-class` tinytext COMMENT 'Storage backend class',
`backend-ref` text COMMENT 'Storage backend data reference',
PRIMARY KEY(`id`),
INDEX `uid` (`uid`),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
--
-- TABLE cache
--
CREATE TABLE IF NOT EXISTS `cache` (
`k` varbinary(255) NOT NULL COMMENT 'cache key',
`v` mediumtext COMMENT 'cached serialized value',
`expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
`updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
PRIMARY KEY(`k`),
INDEX `k_expires` (`k`,`expires`)
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
--
-- TABLE channel
--
CREATE TABLE IF NOT EXISTS `channel` (
`id` int unsigned NOT NULL auto_increment COMMENT '',
`uid` mediumint unsigned NOT NULL COMMENT 'User id',
`label` varchar(64) NOT NULL COMMENT 'Channel label',
`description` varchar(64) COMMENT 'Channel description',
`circle` int COMMENT 'Circle or channel that this channel is based on',
`access-key` varchar(1) COMMENT 'Access key',
`include-tags` varchar(1023) COMMENT 'Comma separated list of tags that will be included in the channel',
`exclude-tags` varchar(1023) COMMENT 'Comma separated list of tags that aren\'t allowed in the channel',
`min-size` int unsigned COMMENT 'Minimum post size',
`max-size` int unsigned COMMENT 'Maximum post size',
`full-text-search` varchar(1023) COMMENT 'Full text search pattern, see https://mariadb.com/kb/en/full-text-index-overview/#in-boolean-mode',
`media-type` smallint unsigned COMMENT 'Filtered media types',
`languages` mediumtext COMMENT 'Desired languages',
`publish` boolean COMMENT 'publish channel content',
`valid` boolean COMMENT 'Set, when the full-text-search is valid',
PRIMARY KEY(`id`),
INDEX `uid` (`uid`),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User defined Channels';
--
-- TABLE config
--
CREATE TABLE IF NOT EXISTS `config` (
`id` int unsigned NOT NULL auto_increment COMMENT '',
`cat` varbinary(50) NOT NULL DEFAULT '' COMMENT 'The category of the entry',
`k` varbinary(50) NOT NULL DEFAULT '' COMMENT 'The key of the entry',
`v` mediumtext COMMENT '',
PRIMARY KEY(`id`),
UNIQUE INDEX `cat_k` (`cat`,`k`)
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
--
-- TABLE contact-relation
--
CREATE TABLE IF NOT EXISTS `contact-relation` (
`cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
`relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
`last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction by relation-cid on cid',
`follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
`follows` boolean NOT NULL DEFAULT '0' COMMENT 'if true, relation-cid follows cid',
`score` smallint unsigned COMMENT 'score for interactions of cid on relation-cid',
`relation-score` smallint unsigned COMMENT 'score for interactions of relation-cid on cid',
`thread-score` smallint unsigned COMMENT 'score for interactions of cid on threads of relation-cid',
`relation-thread-score` smallint unsigned COMMENT 'score for interactions of relation-cid on threads of cid',
`post-score` smallint unsigned COMMENT 'score for the amount of posts from cid that can be seen by relation-cid',
PRIMARY KEY(`cid`,`relation-cid`),
INDEX `relation-cid` (`relation-cid`),
FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
--
-- TABLE conv
--
CREATE TABLE IF NOT EXISTS `conv` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`guid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
`recips` text COMMENT 'sender_handle;recipient_handle',
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
`creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
`updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
`subject` text COMMENT 'subject of initial message',
PRIMARY KEY(`id`),
INDEX `uid` (`uid`),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
--
-- TABLE workerqueue
--
CREATE TABLE IF NOT EXISTS `workerqueue` (
`id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
`command` varchar(100) COMMENT 'Task command',
`parameter` mediumtext COMMENT 'Task parameter',
`priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
`pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
`executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
`next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
`retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
`done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
PRIMARY KEY(`id`),
INDEX `command` (`command`),
INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
INDEX `done_executed` (`done`,`executed`),
INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
--
-- TABLE delayed-post
--
CREATE TABLE IF NOT EXISTS `delayed-post` (
`id` int unsigned NOT NULL auto_increment,
`uri` varbinary(383) COMMENT 'URI of the post that will be distributed later',
`uid` mediumint unsigned COMMENT 'Owner User id',
`delayed` datetime COMMENT 'delay time',
`wid` int unsigned COMMENT 'Workerqueue id',
PRIMARY KEY(`id`),
UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
INDEX `wid` (`wid`),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
--
-- TABLE delivery-queue
--
CREATE TABLE IF NOT EXISTS `delivery-queue` (
`gsid` int unsigned NOT NULL COMMENT 'Target server',
`uri-id` int unsigned NOT NULL COMMENT 'Delivered post',
`created` datetime COMMENT '',
`command` varbinary(32) COMMENT '',
`cid` int unsigned COMMENT 'Target contact',
`uid` mediumint unsigned COMMENT 'Delivering user',
`failed` tinyint DEFAULT 0 COMMENT 'Number of times the delivery has failed',
PRIMARY KEY(`uri-id`,`gsid`),
INDEX `gsid_created` (`gsid`,`created`),
INDEX `uid` (`uid`),
INDEX `cid` (`cid`),
FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for posts for the batch processing';
--
-- TABLE diaspora-contact
--
CREATE TABLE IF NOT EXISTS `diaspora-contact` (
`uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the contact URL',
`addr` varchar(255) COMMENT '',
`alias` varchar(255) COMMENT '',
`nick` varchar(255) COMMENT '',
`name` varchar(255) COMMENT '',
`given-name` varchar(255) COMMENT '',
`family-name` varchar(255) COMMENT '',
`photo` varchar(255) COMMENT '',
`photo-medium` varchar(255) COMMENT '',
`photo-small` varchar(255) COMMENT '',
`batch` varchar(255) COMMENT '',
`notify` varchar(255) COMMENT '',
`poll` varchar(255) COMMENT '',
`subscribe` varchar(255) COMMENT '',
`searchable` boolean COMMENT '',
`pubkey` text COMMENT '',
`gsid` int unsigned COMMENT 'Global Server ID',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`interacting_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts this contact interacts with',
`interacted_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts that interacted with this contact',
`post_count` int unsigned DEFAULT 0 COMMENT 'Number of posts and comments',
PRIMARY KEY(`uri-id`),
UNIQUE INDEX `addr` (`addr`),
INDEX `alias` (`alias`),
INDEX `gsid` (`gsid`),
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
--
-- TABLE diaspora-interaction
--
CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
`uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
`interaction` mediumtext COMMENT 'The Diaspora interaction',
PRIMARY KEY(`uri-id`),
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
--
-- TABLE endpoint
--
CREATE TABLE IF NOT EXISTS `endpoint` (
`url` varbinary(383) NOT NULL COMMENT 'URL of the contact',
`type` varchar(20) NOT NULL COMMENT '',
`owner-uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
PRIMARY KEY(`url`),
UNIQUE INDEX `owner-uri-id_type` (`owner-uri-id`,`type`),
FOREIGN KEY (`owner-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub endpoints - used in the ActivityPub implementation';
--
-- TABLE event
--
CREATE TABLE IF NOT EXISTS `event` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`guid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
`cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
`uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the event uri',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
`edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
`start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
`finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
`summary` text COMMENT 'short description or title of the event',
`desc` text COMMENT 'event description',
`location` text COMMENT 'event location',
`type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
`nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
`ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
`allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
`allow_gid` mediumtext COMMENT 'Access Control - list of allowed circles',
`deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
`deny_gid` mediumtext COMMENT 'Access Control - list of denied circles',
PRIMARY KEY(`id`),
INDEX `uid_start` (`uid`,`start`),
INDEX `cid` (`cid`),
INDEX `uri-id` (`uri-id`),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
--
-- TABLE fetch-entry
--
CREATE TABLE IF NOT EXISTS `fetch-entry` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`url` varbinary(383) COMMENT 'url that awaiting to be fetched',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of the fetch request',
`wid` int unsigned COMMENT 'Workerqueue id',
PRIMARY KEY(`id`),
UNIQUE INDEX `url` (`url`),
INDEX `created` (`created`),
INDEX `wid` (`wid`),
FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
--
-- TABLE fsuggest
--
CREATE TABLE IF NOT EXISTS `fsuggest` (
`id` int unsigned NOT NULL auto_increment COMMENT '',
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
`cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
`name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`request` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`note` text COMMENT '',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
PRIMARY KEY(`id`),
INDEX `cid` (`cid`),
INDEX `uid` (`uid`),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
--
-- TABLE group
--
CREATE TABLE IF NOT EXISTS `group` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
`visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
`deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the circle has been deleted',
`cid` int unsigned COMMENT 'Contact id of group. When this field is filled then the members are synced automatically.',
`name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of circle',
PRIMARY KEY(`id`),
INDEX `uid` (`uid`),
INDEX `cid` (`cid`),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy circles, circle info';
--
-- TABLE group_member
--
CREATE TABLE IF NOT EXISTS `group_member` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'group.id of the associated circle',
`contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated circle',
PRIMARY KEY(`id`),
INDEX `contactid` (`contact-id`),
UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`),
FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy circles, member info';
--
-- TABLE gserver-tag
--
CREATE TABLE IF NOT EXISTS `gserver-tag` (
`gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
`tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
PRIMARY KEY(`gserver-id`,`tag`),
INDEX `tag` (`tag`),
FOREIGN KEY (`gserver-id`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
--
-- TABLE hook
--
CREATE TABLE IF NOT EXISTS `hook` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
`file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
`function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
`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',
PRIMARY KEY(`id`),
INDEX `priority` (`priority`),
UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
--
-- TABLE inbox-entry
--
CREATE TABLE IF NOT EXISTS `inbox-entry` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`activity-id` varbinary(383) COMMENT 'id of the incoming activity',
`object-id` varbinary(383) COMMENT '',
`in-reply-to-id` varbinary(383) COMMENT '',
`conversation` varbinary(383) COMMENT '',
`type` varchar(64) COMMENT 'Type of the activity',
`object-type` varchar(64) COMMENT 'Type of the object activity',
`object-object-type` varchar(64) COMMENT 'Type of the object\'s object activity',
`received` datetime COMMENT 'Receiving date',
`activity` mediumtext COMMENT 'The JSON activity',
`signer` varchar(255) COMMENT '',
`push` boolean COMMENT 'Is the entry pushed or have pulled it?',
`trust` boolean COMMENT 'Do we trust this entry?',
`wid` int unsigned COMMENT 'Workerqueue id',
PRIMARY KEY(`id`),
UNIQUE INDEX `activity-id` (`activity-id`),
INDEX `object-id` (`object-id`),
INDEX `received` (`received`),
INDEX `wid` (`wid`),
FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Incoming activity';
--
-- TABLE inbox-entry-receiver
--
CREATE TABLE IF NOT EXISTS `inbox-entry-receiver` (
`queue-id` int unsigned NOT NULL COMMENT '',
`uid` mediumint unsigned NOT NULL COMMENT 'User id',
PRIMARY KEY(`queue-id`,`uid`),
INDEX `uid` (`uid`),
FOREIGN KEY (`queue-id`) REFERENCES `inbox-entry` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Receiver for the incoming activity';
--
-- TABLE inbox-status
--
CREATE TABLE IF NOT EXISTS `inbox-status` (
`url` varbinary(383) NOT NULL COMMENT 'URL of the inbox',
`uri-id` int unsigned COMMENT 'Item-uri id of inbox url',
`gsid` int unsigned COMMENT 'ID of the related server',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
`success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
`failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
`previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
`archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
`shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
PRIMARY KEY(`url`),
INDEX `uri-id` (`uri-id`),
INDEX `gsid` (`gsid`),
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
--
-- TABLE intro
--
CREATE TABLE IF NOT EXISTS `intro` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
`fid` int unsigned COMMENT 'deprecated',
`contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
`suggest-cid` int unsigned COMMENT 'Suggested contact',
`knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
`duplex` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
`note` text COMMENT '',
`hash` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
`datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`blocked` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
`ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
PRIMARY KEY(`id`),
INDEX `contact-id` (`contact-id`),
INDEX `suggest-cid` (`suggest-cid`),
INDEX `uid` (`uid`),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`suggest-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
--
-- TABLE key-value
--
CREATE TABLE IF NOT EXISTS `key-value` (
`k` varbinary(50) NOT NULL COMMENT '',
`v` mediumtext COMMENT '',
`updated_at` int unsigned NOT NULL COMMENT 'timestamp of the last update',
PRIMARY KEY(`k`)
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='A key value storage';
--
-- TABLE locks
--
CREATE TABLE IF NOT EXISTS `locks` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
`locked` boolean NOT NULL DEFAULT '0' COMMENT '',
`pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
`expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
PRIMARY KEY(`id`),
INDEX `name_expires` (`name`,`expires`)
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
--
-- TABLE mail
--
CREATE TABLE IF NOT EXISTS `mail` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
`guid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
`from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
`from-photo` varbinary(383) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
`from-url` varbinary(383) NOT NULL DEFAULT '' COMMENT 'profile link of the sender',
`contact-id` varbinary(255) COMMENT 'contact.id',
`author-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the author of the mail',
`convid` int unsigned COMMENT 'conv.id',
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`body` mediumtext COMMENT '',
`seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
`reply` boolean NOT NULL DEFAULT '0' COMMENT '',
`replied` boolean NOT NULL DEFAULT '0' COMMENT '',
`unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
`uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`uri-id` int unsigned COMMENT 'Item-uri id of the related mail',
`parent-uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related mail',
`thr-parent` varbinary(383) COMMENT '',
`thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
PRIMARY KEY(`id`),
INDEX `uid_seen` (`uid`,`seen`),
INDEX `convid` (`convid`),
INDEX `uri` (`uri`(64)),
INDEX `parent-uri` (`parent-uri`(64)),
INDEX `contactid` (`contact-id`(32)),
INDEX `author-id` (`author-id`),
INDEX `uri-id` (`uri-id`),
INDEX `parent-uri-id` (`parent-uri-id`),
INDEX `thr-parent-id` (`thr-parent-id`),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
--
-- TABLE mailacct
--
CREATE TABLE IF NOT EXISTS `mailacct` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
`server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
`ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
`mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`pass` text COMMENT '',
`reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
`movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
`last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
PRIMARY KEY(`id`),
INDEX `uid` (`uid`),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
--
-- TABLE manage
--
CREATE TABLE IF NOT EXISTS `manage` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
`mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
PRIMARY KEY(`id`),
UNIQUE INDEX `uid_mid` (`uid`,`mid`),
INDEX `mid` (`mid`),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`mid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
--
-- TABLE notification
--
CREATE TABLE IF NOT EXISTS `notification` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`uid` mediumint unsigned COMMENT 'Owner User id',
`vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
`type` smallint unsigned COMMENT '',