This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
full.sql.postgres
1983 lines (1032 loc) · 39.3 KB
/
full.sql.postgres
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
CREATE TABLE access_tokens (
id bigint NOT NULL,
user_id text NOT NULL,
device_id text,
token text NOT NULL,
last_used bigint
);
CREATE TABLE account_data (
user_id text NOT NULL,
account_data_type text NOT NULL,
stream_id bigint NOT NULL,
content text NOT NULL
);
CREATE TABLE account_data_max_stream_id (
lock character(1) DEFAULT 'X'::bpchar NOT NULL,
stream_id bigint NOT NULL,
CONSTRAINT private_user_data_max_stream_id_lock_check CHECK ((lock = 'X'::bpchar))
);
CREATE TABLE account_validity (
user_id text NOT NULL,
expiration_ts_ms bigint NOT NULL,
email_sent boolean NOT NULL,
renewal_token text
);
CREATE TABLE application_services_state (
as_id text NOT NULL,
state character varying(5),
last_txn integer
);
CREATE TABLE application_services_txns (
as_id text NOT NULL,
txn_id integer NOT NULL,
event_ids text NOT NULL
);
CREATE TABLE appservice_room_list (
appservice_id text NOT NULL,
network_id text NOT NULL,
room_id text NOT NULL
);
CREATE TABLE appservice_stream_position (
lock character(1) DEFAULT 'X'::bpchar NOT NULL,
stream_ordering bigint,
CONSTRAINT appservice_stream_position_lock_check CHECK ((lock = 'X'::bpchar))
);
CREATE TABLE blocked_rooms (
room_id text NOT NULL,
user_id text NOT NULL
);
CREATE TABLE cache_invalidation_stream (
stream_id bigint,
cache_func text,
keys text[],
invalidation_ts bigint
);
CREATE TABLE current_state_delta_stream (
stream_id bigint NOT NULL,
room_id text NOT NULL,
type text NOT NULL,
state_key text NOT NULL,
event_id text,
prev_event_id text
);
CREATE TABLE current_state_events (
event_id text NOT NULL,
room_id text NOT NULL,
type text NOT NULL,
state_key text NOT NULL
);
CREATE TABLE deleted_pushers (
stream_id bigint NOT NULL,
app_id text NOT NULL,
pushkey text NOT NULL,
user_id text NOT NULL
);
CREATE TABLE destinations (
destination text NOT NULL,
retry_last_ts bigint,
retry_interval integer
);
CREATE TABLE device_federation_inbox (
origin text NOT NULL,
message_id text NOT NULL,
received_ts bigint NOT NULL
);
CREATE TABLE device_federation_outbox (
destination text NOT NULL,
stream_id bigint NOT NULL,
queued_ts bigint NOT NULL,
messages_json text NOT NULL
);
CREATE TABLE device_inbox (
user_id text NOT NULL,
device_id text NOT NULL,
stream_id bigint NOT NULL,
message_json text NOT NULL
);
CREATE TABLE device_lists_outbound_last_success (
destination text NOT NULL,
user_id text NOT NULL,
stream_id bigint NOT NULL
);
CREATE TABLE device_lists_outbound_pokes (
destination text NOT NULL,
stream_id bigint NOT NULL,
user_id text NOT NULL,
device_id text NOT NULL,
sent boolean NOT NULL,
ts bigint NOT NULL
);
CREATE TABLE device_lists_remote_cache (
user_id text NOT NULL,
device_id text NOT NULL,
content text NOT NULL
);
CREATE TABLE device_lists_remote_extremeties (
user_id text NOT NULL,
stream_id text NOT NULL
);
CREATE TABLE device_lists_stream (
stream_id bigint NOT NULL,
user_id text NOT NULL,
device_id text NOT NULL
);
CREATE TABLE device_max_stream_id (
stream_id bigint NOT NULL
);
CREATE TABLE devices (
user_id text NOT NULL,
device_id text NOT NULL,
display_name text
);
CREATE TABLE e2e_device_keys_json (
user_id text NOT NULL,
device_id text NOT NULL,
ts_added_ms bigint NOT NULL,
key_json text NOT NULL
);
CREATE TABLE e2e_one_time_keys_json (
user_id text NOT NULL,
device_id text NOT NULL,
algorithm text NOT NULL,
key_id text NOT NULL,
ts_added_ms bigint NOT NULL,
key_json text NOT NULL
);
CREATE TABLE e2e_room_keys (
user_id text NOT NULL,
room_id text NOT NULL,
session_id text NOT NULL,
version bigint NOT NULL,
first_message_index integer,
forwarded_count integer,
is_verified boolean,
session_data text NOT NULL
);
CREATE TABLE e2e_room_keys_versions (
user_id text NOT NULL,
version bigint NOT NULL,
algorithm text NOT NULL,
auth_data text NOT NULL,
deleted smallint DEFAULT 0 NOT NULL
);
CREATE TABLE erased_users (
user_id text NOT NULL
);
CREATE TABLE event_auth (
event_id text NOT NULL,
auth_id text NOT NULL,
room_id text NOT NULL
);
CREATE TABLE event_backward_extremities (
event_id text NOT NULL,
room_id text NOT NULL
);
CREATE TABLE event_edges (
event_id text NOT NULL,
prev_event_id text NOT NULL,
room_id text NOT NULL,
is_state boolean NOT NULL
);
CREATE TABLE event_forward_extremities (
event_id text NOT NULL,
room_id text NOT NULL
);
CREATE TABLE event_json (
event_id text NOT NULL,
room_id text NOT NULL,
internal_metadata text NOT NULL,
json text NOT NULL,
format_version integer
);
CREATE TABLE event_push_actions (
room_id text NOT NULL,
event_id text NOT NULL,
user_id text NOT NULL,
profile_tag character varying(32),
actions text NOT NULL,
topological_ordering bigint,
stream_ordering bigint,
notif smallint,
highlight smallint
);
CREATE TABLE event_push_actions_staging (
event_id text NOT NULL,
user_id text NOT NULL,
actions text NOT NULL,
notif smallint NOT NULL,
highlight smallint NOT NULL
);
CREATE TABLE event_push_summary (
user_id text NOT NULL,
room_id text NOT NULL,
notif_count bigint NOT NULL,
stream_ordering bigint NOT NULL
);
CREATE TABLE event_push_summary_stream_ordering (
lock character(1) DEFAULT 'X'::bpchar NOT NULL,
stream_ordering bigint NOT NULL,
CONSTRAINT event_push_summary_stream_ordering_lock_check CHECK ((lock = 'X'::bpchar))
);
CREATE TABLE event_reference_hashes (
event_id text,
algorithm text,
hash bytea
);
CREATE TABLE event_relations (
event_id text NOT NULL,
relates_to_id text NOT NULL,
relation_type text NOT NULL,
aggregation_key text
);
CREATE TABLE event_reports (
id bigint NOT NULL,
received_ts bigint NOT NULL,
room_id text NOT NULL,
event_id text NOT NULL,
user_id text NOT NULL,
reason text,
content text
);
CREATE TABLE event_search (
event_id text,
room_id text,
sender text,
key text,
vector tsvector,
origin_server_ts bigint,
stream_ordering bigint
);
CREATE TABLE event_to_state_groups (
event_id text NOT NULL,
state_group bigint NOT NULL
);
CREATE TABLE events (
stream_ordering integer NOT NULL,
topological_ordering bigint NOT NULL,
event_id text NOT NULL,
type text NOT NULL,
room_id text NOT NULL,
content text,
unrecognized_keys text,
processed boolean NOT NULL,
outlier boolean NOT NULL,
depth bigint DEFAULT 0 NOT NULL,
origin_server_ts bigint,
received_ts bigint,
sender text,
contains_url boolean
);
CREATE TABLE ex_outlier_stream (
event_stream_ordering bigint NOT NULL,
event_id text NOT NULL,
state_group bigint NOT NULL
);
CREATE TABLE federation_stream_position (
type text NOT NULL,
stream_id integer NOT NULL
);
CREATE TABLE group_attestations_remote (
group_id text NOT NULL,
user_id text NOT NULL,
valid_until_ms bigint NOT NULL,
attestation_json text NOT NULL
);
CREATE TABLE group_attestations_renewals (
group_id text NOT NULL,
user_id text NOT NULL,
valid_until_ms bigint NOT NULL
);
CREATE TABLE group_invites (
group_id text NOT NULL,
user_id text NOT NULL
);
CREATE TABLE group_roles (
group_id text NOT NULL,
role_id text NOT NULL,
profile text NOT NULL,
is_public boolean NOT NULL
);
CREATE TABLE group_room_categories (
group_id text NOT NULL,
category_id text NOT NULL,
profile text NOT NULL,
is_public boolean NOT NULL
);
CREATE TABLE group_rooms (
group_id text NOT NULL,
room_id text NOT NULL,
is_public boolean NOT NULL
);
CREATE TABLE group_summary_roles (
group_id text NOT NULL,
role_id text NOT NULL,
role_order bigint NOT NULL,
CONSTRAINT group_summary_roles_role_order_check CHECK ((role_order > 0))
);
CREATE TABLE group_summary_room_categories (
group_id text NOT NULL,
category_id text NOT NULL,
cat_order bigint NOT NULL,
CONSTRAINT group_summary_room_categories_cat_order_check CHECK ((cat_order > 0))
);
CREATE TABLE group_summary_rooms (
group_id text NOT NULL,
room_id text NOT NULL,
category_id text NOT NULL,
room_order bigint NOT NULL,
is_public boolean NOT NULL,
CONSTRAINT group_summary_rooms_room_order_check CHECK ((room_order > 0))
);
CREATE TABLE group_summary_users (
group_id text NOT NULL,
user_id text NOT NULL,
role_id text NOT NULL,
user_order bigint NOT NULL,
is_public boolean NOT NULL
);
CREATE TABLE group_users (
group_id text NOT NULL,
user_id text NOT NULL,
is_admin boolean NOT NULL,
is_public boolean NOT NULL
);
CREATE TABLE groups (
group_id text NOT NULL,
name text,
avatar_url text,
short_description text,
long_description text,
is_public boolean NOT NULL,
join_policy text DEFAULT 'invite'::text NOT NULL
);
CREATE TABLE guest_access (
event_id text NOT NULL,
room_id text NOT NULL,
guest_access text NOT NULL
);
CREATE TABLE history_visibility (
event_id text NOT NULL,
room_id text NOT NULL,
history_visibility text NOT NULL
);
CREATE TABLE local_group_membership (
group_id text NOT NULL,
user_id text NOT NULL,
is_admin boolean NOT NULL,
membership text NOT NULL,
is_publicised boolean NOT NULL,
content text NOT NULL
);
CREATE TABLE local_group_updates (
stream_id bigint NOT NULL,
group_id text NOT NULL,
user_id text NOT NULL,
type text NOT NULL,
content text NOT NULL
);
CREATE TABLE local_invites (
stream_id bigint NOT NULL,
inviter text NOT NULL,
invitee text NOT NULL,
event_id text NOT NULL,
room_id text NOT NULL,
locally_rejected text,
replaced_by text
);
CREATE TABLE local_media_repository (
media_id text,
media_type text,
media_length integer,
created_ts bigint,
upload_name text,
user_id text,
quarantined_by text,
url_cache text,
last_access_ts bigint
);
CREATE TABLE local_media_repository_thumbnails (
media_id text,
thumbnail_width integer,
thumbnail_height integer,
thumbnail_type text,
thumbnail_method text,
thumbnail_length integer
);
CREATE TABLE local_media_repository_url_cache (
url text,
response_code integer,
etag text,
expires_ts bigint,
og text,
media_id text,
download_ts bigint
);
CREATE TABLE monthly_active_users (
user_id text NOT NULL,
"timestamp" bigint NOT NULL
);
CREATE TABLE open_id_tokens (
token text NOT NULL,
ts_valid_until_ms bigint NOT NULL,
user_id text NOT NULL
);
CREATE TABLE presence (
user_id text NOT NULL,
state character varying(20),
status_msg text,
mtime bigint
);
CREATE TABLE presence_allow_inbound (
observed_user_id text NOT NULL,
observer_user_id text NOT NULL
);
CREATE TABLE presence_stream (
stream_id bigint,
user_id text,
state text,
last_active_ts bigint,
last_federation_update_ts bigint,
last_user_sync_ts bigint,
status_msg text,
currently_active boolean
);
CREATE TABLE profiles (
user_id text NOT NULL,
displayname text,
avatar_url text
);
CREATE TABLE public_room_list_stream (
stream_id bigint NOT NULL,
room_id text NOT NULL,
visibility boolean NOT NULL,
appservice_id text,
network_id text
);
CREATE TABLE push_rules (
id bigint NOT NULL,
user_name text NOT NULL,
rule_id text NOT NULL,
priority_class smallint NOT NULL,
priority integer DEFAULT 0 NOT NULL,
conditions text NOT NULL,
actions text NOT NULL
);
CREATE TABLE push_rules_enable (
id bigint NOT NULL,
user_name text NOT NULL,
rule_id text NOT NULL,
enabled smallint
);
CREATE TABLE push_rules_stream (
stream_id bigint NOT NULL,
event_stream_ordering bigint NOT NULL,
user_id text NOT NULL,
rule_id text NOT NULL,
op text NOT NULL,
priority_class smallint,
priority integer,
conditions text,
actions text
);
CREATE TABLE pusher_throttle (
pusher bigint NOT NULL,
room_id text NOT NULL,
last_sent_ts bigint,
throttle_ms bigint
);
CREATE TABLE pushers (
id bigint NOT NULL,
user_name text NOT NULL,
access_token bigint,
profile_tag text NOT NULL,
kind text NOT NULL,
app_id text NOT NULL,
app_display_name text NOT NULL,
device_display_name text NOT NULL,
pushkey text NOT NULL,
ts bigint NOT NULL,
lang text,
data text,
last_stream_ordering integer,
last_success bigint,
failing_since bigint
);
CREATE TABLE ratelimit_override (
user_id text NOT NULL,
messages_per_second bigint,
burst_count bigint
);
CREATE TABLE receipts_graph (
room_id text NOT NULL,
receipt_type text NOT NULL,
user_id text NOT NULL,
event_ids text NOT NULL,
data text NOT NULL
);
CREATE TABLE receipts_linearized (
stream_id bigint NOT NULL,
room_id text NOT NULL,
receipt_type text NOT NULL,
user_id text NOT NULL,
event_id text NOT NULL,
data text NOT NULL
);
CREATE TABLE received_transactions (
transaction_id text,
origin text,
ts bigint,
response_code integer,
response_json bytea,
has_been_referenced smallint DEFAULT 0
);
CREATE TABLE redactions (
event_id text NOT NULL,
redacts text NOT NULL
);
CREATE TABLE rejections (
event_id text NOT NULL,
reason text NOT NULL,
last_check text NOT NULL
);
CREATE TABLE remote_media_cache (
media_origin text,
media_id text,
media_type text,
created_ts bigint,
upload_name text,
media_length integer,
filesystem_id text,
last_access_ts bigint,
quarantined_by text
);
CREATE TABLE remote_media_cache_thumbnails (
media_origin text,
media_id text,
thumbnail_width integer,
thumbnail_height integer,
thumbnail_method text,
thumbnail_type text,
thumbnail_length integer,
filesystem_id text
);
CREATE TABLE remote_profile_cache (
user_id text NOT NULL,
displayname text,
avatar_url text,
last_check bigint NOT NULL
);
CREATE TABLE room_account_data (
user_id text NOT NULL,
room_id text NOT NULL,
account_data_type text NOT NULL,
stream_id bigint NOT NULL,
content text NOT NULL
);
CREATE TABLE room_alias_servers (
room_alias text NOT NULL,
server text NOT NULL
);
CREATE TABLE room_aliases (
room_alias text NOT NULL,
room_id text NOT NULL,
creator text
);
CREATE TABLE room_depth (
room_id text NOT NULL,
min_depth integer NOT NULL
);
CREATE TABLE room_memberships (
event_id text NOT NULL,
user_id text NOT NULL,
sender text NOT NULL,
room_id text NOT NULL,
membership text NOT NULL,
forgotten integer DEFAULT 0,
display_name text,
avatar_url text
);
CREATE TABLE room_names (
event_id text NOT NULL,
room_id text NOT NULL,
name text NOT NULL
);
CREATE TABLE room_state (
room_id text NOT NULL,
join_rules text,
history_visibility text,
encryption text,
name text,
topic text,
avatar text,
canonical_alias text
);
CREATE TABLE room_stats (
room_id text NOT NULL,
ts bigint NOT NULL,
bucket_size integer NOT NULL,
current_state_events integer NOT NULL,
joined_members integer NOT NULL,
invited_members integer NOT NULL,
left_members integer NOT NULL,
banned_members integer NOT NULL,
state_events integer NOT NULL
);
CREATE TABLE room_stats_earliest_token (
room_id text NOT NULL,
token bigint NOT NULL
);
CREATE TABLE room_tags (
user_id text NOT NULL,
room_id text NOT NULL,
tag text NOT NULL,
content text NOT NULL
);
CREATE TABLE room_tags_revisions (
user_id text NOT NULL,
room_id text NOT NULL,
stream_id bigint NOT NULL
);
CREATE TABLE rooms (
room_id text NOT NULL,
is_public boolean,
creator text
);
CREATE TABLE server_keys_json (
server_name text NOT NULL,
key_id text NOT NULL,
from_server text NOT NULL,
ts_added_ms bigint NOT NULL,
ts_valid_until_ms bigint NOT NULL,
key_json bytea NOT NULL
);
CREATE TABLE server_signature_keys (
server_name text,
key_id text,
from_server text,
ts_added_ms bigint,
verify_key bytea,
ts_valid_until_ms bigint
);
CREATE TABLE state_events (
event_id text NOT NULL,
room_id text NOT NULL,
type text NOT NULL,
state_key text NOT NULL,
prev_state text
);
CREATE TABLE stats_stream_pos (
lock character(1) DEFAULT 'X'::bpchar NOT NULL,
stream_id bigint,
CONSTRAINT stats_stream_pos_lock_check CHECK ((lock = 'X'::bpchar))
);
CREATE TABLE stream_ordering_to_exterm (
stream_ordering bigint NOT NULL,
room_id text NOT NULL,
event_id text NOT NULL
);
CREATE TABLE threepid_guest_access_tokens (
medium text,
address text,
guest_access_token text,
first_inviter text
);