-
Notifications
You must be signed in to change notification settings - Fork 332
Expand file tree
/
Copy pathpostgres-schema.sql
More file actions
618 lines (419 loc) · 15.9 KB
/
postgres-schema.sql
File metadata and controls
618 lines (419 loc) · 15.9 KB
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
-- automatically generated with `make postgres-schema`
------------------------------------------------------------------------------------------
-- Database: backendA
--
-- PostgreSQL database dump
--
\restrict 79bbfb4630959c48307653a5cd3d83f2582b3c2210f75f10d79e3ebf0015620
-- Dumped from database version 17.6
-- Dumped by pg_dump version 17.6
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: public; Type: SCHEMA; Schema: -; Owner: wire-server
--
-- *not* creating schema, since initdb creates it
ALTER SCHEMA public OWNER TO "wire-server";
--
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: wire-server
--
COMMENT ON SCHEMA public IS '';
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: apps; Type: TABLE; Schema: public; Owner: wire-server
--
CREATE TABLE public.apps (
user_id uuid NOT NULL,
team_id uuid NOT NULL,
metadata json,
category text DEFAULT 'other'::text NOT NULL,
description text DEFAULT ''::text NOT NULL,
creator uuid NOT NULL
);
ALTER TABLE public.apps OWNER TO "wire-server";
--
-- Name: collaborators; Type: TABLE; Schema: public; Owner: wire-server
--
CREATE TABLE public.collaborators (
user_id uuid NOT NULL,
team_id uuid NOT NULL,
permissions smallint[]
);
ALTER TABLE public.collaborators OWNER TO "wire-server";
--
-- Name: conversation; Type: TABLE; Schema: public; Owner: wire-server
--
CREATE TABLE public.conversation (
id uuid NOT NULL,
access integer[],
access_roles_v2 integer[],
cells_state integer,
channel_add_permission integer,
cipher_suite integer,
creator uuid,
epoch bigint,
epoch_timestamp timestamp with time zone,
group_conv_type integer,
group_id bytea,
message_timer bigint,
name text,
protocol integer,
public_group_state bytea,
receipt_mode integer,
team uuid,
type integer NOT NULL,
parent_conv uuid
);
ALTER TABLE public.conversation OWNER TO "wire-server";
--
-- Name: conversation_codes; Type: TABLE; Schema: public; Owner: wire-server
--
CREATE TABLE public.conversation_codes (
key text NOT NULL,
conversation uuid NOT NULL,
password bytea,
value text NOT NULL,
expires_at timestamp with time zone NOT NULL
);
ALTER TABLE public.conversation_codes OWNER TO "wire-server";
--
-- Name: conversation_member; Type: TABLE; Schema: public; Owner: wire-server
--
CREATE TABLE public.conversation_member (
conv uuid NOT NULL,
"user" uuid NOT NULL,
conversation_role text,
hidden boolean,
hidden_ref text,
otr_archived boolean,
otr_archived_ref text,
otr_muted boolean,
otr_muted_ref text,
otr_muted_status integer,
provider uuid,
service uuid
);
ALTER TABLE public.conversation_member OWNER TO "wire-server";
--
-- Name: conversation_migration_pending_deletes; Type: TABLE; Schema: public; Owner: wire-server
--
CREATE TABLE public.conversation_migration_pending_deletes (
typ text NOT NULL,
id uuid NOT NULL
);
ALTER TABLE public.conversation_migration_pending_deletes OWNER TO "wire-server";
--
-- Name: conversation_out_of_sync; Type: TABLE; Schema: public; Owner: wire-server
--
CREATE TABLE public.conversation_out_of_sync (
conv_id uuid NOT NULL,
out_of_sync boolean NOT NULL
);
ALTER TABLE public.conversation_out_of_sync OWNER TO "wire-server";
--
-- Name: local_conversation_remote_member; Type: TABLE; Schema: public; Owner: wire-server
--
CREATE TABLE public.local_conversation_remote_member (
conv uuid NOT NULL,
user_remote_domain text NOT NULL,
user_remote_id uuid NOT NULL,
conversation_role text
);
ALTER TABLE public.local_conversation_remote_member OWNER TO "wire-server";
--
-- Name: meetings; Type: ENUM; Schema: public; Owner: wire-server
--
CREATE TYPE recurrence_frequency AS ENUM ('daily', 'weekly', 'monthly', 'yearly');
ALTER TABLE public.recurrence_frequency OWNER TO "wire-server";
--
-- Name: meetings; Type: TABLE; Schema: public; Owner: wire-server
--
CREATE TABLE public.meetings (
id uuid NOT NULL DEFAULT gen_random_uuid(),
title text NOT NULL,
creator uuid NOT NULL,
start_time timestamptz NOT NULL,
end_time timestamptz NOT NULL,
recurrence_frequency recurrence_frequency,
recurrence_interval integer,
recurrence_until timestamptz,
conversation_id uuid NOT NULL,
invited_emails text[] DEFAULT '{}'::text[],
trial boolean DEFAULT false,
created_at timestamp with time zone DEFAULT now(),
updated_at timestamp with time zone DEFAULT now()
);
ALTER TABLE public.meetings OWNER TO "wire-server";
--
-- Name: mls_group_member_client; Type: TABLE; Schema: public; Owner: wire-server
--
CREATE TABLE public.mls_group_member_client (
group_id bytea NOT NULL,
user_domain text NOT NULL,
"user" uuid NOT NULL,
client text NOT NULL,
leaf_node_index integer NOT NULL,
removal_pending boolean NOT NULL
);
ALTER TABLE public.mls_group_member_client OWNER TO "wire-server";
--
-- Name: remote_conversation_local_member; Type: TABLE; Schema: public; Owner: wire-server
--
CREATE TABLE public.remote_conversation_local_member (
"user" uuid NOT NULL,
conv_remote_domain text NOT NULL,
conv_remote_id uuid NOT NULL,
hidden boolean,
hidden_ref text,
otr_archived boolean,
otr_archived_ref text,
otr_muted_ref text,
otr_muted_status integer
);
ALTER TABLE public.remote_conversation_local_member OWNER TO "wire-server";
--
-- Name: schema_migrations; Type: TABLE; Schema: public; Owner: wire-server
--
CREATE TABLE public.schema_migrations (
filename character varying(512) NOT NULL,
checksum character varying(32) NOT NULL,
executed_at timestamp without time zone DEFAULT now() NOT NULL
);
ALTER TABLE public.schema_migrations OWNER TO "wire-server";
--
-- Name: subconversation; Type: TABLE; Schema: public; Owner: wire-server
--
CREATE TABLE public.subconversation (
conv_id uuid NOT NULL,
subconv_id text NOT NULL,
cipher_suite integer,
epoch bigint NOT NULL,
epoch_timestamp timestamp with time zone NOT NULL,
group_id bytea NOT NULL,
public_group_state bytea
);
ALTER TABLE public.subconversation OWNER TO "wire-server";
--
-- Name: team_features; Type: TABLE; Schema: public; Owner: wire-server
--
CREATE TABLE public.team_features (
team uuid NOT NULL,
feature text NOT NULL,
config jsonb,
lock_status integer,
status integer
);
ALTER TABLE public.team_features OWNER TO "wire-server";
--
-- Name: user_group; Type: TABLE; Schema: public; Owner: wire-server
--
CREATE TABLE public.user_group (
team_id uuid NOT NULL,
id uuid DEFAULT gen_random_uuid() NOT NULL,
name text NOT NULL,
managed_by integer NOT NULL,
created_at timestamp with time zone DEFAULT now()
);
ALTER TABLE public.user_group OWNER TO "wire-server";
--
-- Name: user_group_channel; Type: TABLE; Schema: public; Owner: wire-server
--
CREATE TABLE public.user_group_channel (
user_group_id uuid NOT NULL,
conv_id uuid NOT NULL
);
ALTER TABLE public.user_group_channel OWNER TO "wire-server";
--
-- Name: user_group_member; Type: TABLE; Schema: public; Owner: wire-server
--
CREATE TABLE public.user_group_member (
user_group_id uuid NOT NULL,
user_id uuid NOT NULL
);
ALTER TABLE public.user_group_member OWNER TO "wire-server";
--
-- Name: apps apps_pkey; Type: CONSTRAINT; Schema: public; Owner: wire-server
--
ALTER TABLE ONLY public.apps
ADD CONSTRAINT apps_pkey PRIMARY KEY (user_id);
--
-- Name: collaborators collaborators_pkey; Type: CONSTRAINT; Schema: public; Owner: wire-server
--
ALTER TABLE ONLY public.collaborators
ADD CONSTRAINT collaborators_pkey PRIMARY KEY (user_id, team_id);
--
-- Name: conversation_codes conversation_codes_pkey; Type: CONSTRAINT; Schema: public; Owner: wire-server
--
ALTER TABLE ONLY public.conversation_codes
ADD CONSTRAINT conversation_codes_pkey PRIMARY KEY (key);
--
-- Name: conversation_member conversation_member_pkey; Type: CONSTRAINT; Schema: public; Owner: wire-server
--
ALTER TABLE ONLY public.conversation_member
ADD CONSTRAINT conversation_member_pkey PRIMARY KEY (conv, "user");
--
-- Name: conversation_migration_pending_deletes conversation_migration_pending_deletes_pkey; Type: CONSTRAINT; Schema: public; Owner: wire-server
--
ALTER TABLE ONLY public.conversation_migration_pending_deletes
ADD CONSTRAINT conversation_migration_pending_deletes_pkey PRIMARY KEY (typ, id);
--
-- Name: conversation_out_of_sync conversation_out_of_sync_pkey; Type: CONSTRAINT; Schema: public; Owner: wire-server
--
ALTER TABLE ONLY public.conversation_out_of_sync
ADD CONSTRAINT conversation_out_of_sync_pkey PRIMARY KEY (conv_id);
--
-- Name: conversation conversation_pkey; Type: CONSTRAINT; Schema: public; Owner: wire-server
--
ALTER TABLE ONLY public.conversation
ADD CONSTRAINT conversation_pkey PRIMARY KEY (id);
--
-- Name: meetings meetings_pkey; Type: CONSTRAINT; Schema: public; Owner: wire-server
--
ALTER TABLE ONLY public.meetings
ADD CONSTRAINT meetings_pkey PRIMARY KEY (id);
--
-- Name: local_conversation_remote_member local_conversation_remote_member_pkey; Type: CONSTRAINT; Schema: public; Owner: wire-server
--
ALTER TABLE ONLY public.local_conversation_remote_member
ADD CONSTRAINT local_conversation_remote_member_pkey PRIMARY KEY (conv, user_remote_domain, user_remote_id);
--
-- Name: mls_group_member_client mls_group_member_client_pkey; Type: CONSTRAINT; Schema: public; Owner: wire-server
--
ALTER TABLE ONLY public.mls_group_member_client
ADD CONSTRAINT mls_group_member_client_pkey PRIMARY KEY (group_id, user_domain, "user", client);
--
-- Name: remote_conversation_local_member remote_conversation_local_member_pkey; Type: CONSTRAINT; Schema: public; Owner: wire-server
--
ALTER TABLE ONLY public.remote_conversation_local_member
ADD CONSTRAINT remote_conversation_local_member_pkey PRIMARY KEY ("user", conv_remote_domain, conv_remote_id);
--
-- Name: subconversation subconversation_pkey; Type: CONSTRAINT; Schema: public; Owner: wire-server
--
ALTER TABLE ONLY public.subconversation
ADD CONSTRAINT subconversation_pkey PRIMARY KEY (conv_id, subconv_id);
--
-- Name: team_features team_features_pkey; Type: CONSTRAINT; Schema: public; Owner: wire-server
--
ALTER TABLE ONLY public.team_features
ADD CONSTRAINT team_features_pkey PRIMARY KEY (team, feature);
--
-- Name: user_group_channel user_group_channel_pkey; Type: CONSTRAINT; Schema: public; Owner: wire-server
--
ALTER TABLE ONLY public.user_group_channel
ADD CONSTRAINT user_group_channel_pkey PRIMARY KEY (user_group_id, conv_id);
--
-- Name: user_group user_group_id_key; Type: CONSTRAINT; Schema: public; Owner: wire-server
--
ALTER TABLE ONLY public.user_group
ADD CONSTRAINT user_group_id_key UNIQUE (id);
--
-- Name: user_group_member user_group_member_pkey; Type: CONSTRAINT; Schema: public; Owner: wire-server
--
ALTER TABLE ONLY public.user_group_member
ADD CONSTRAINT user_group_member_pkey PRIMARY KEY (user_group_id, user_id);
--
-- Name: user_group user_group_pkey; Type: CONSTRAINT; Schema: public; Owner: wire-server
--
ALTER TABLE ONLY public.user_group
ADD CONSTRAINT user_group_pkey PRIMARY KEY (team_id, id);
--
-- Name: collaborators_team_id_idx; Type: INDEX; Schema: public; Owner: wire-server
--
CREATE INDEX collaborators_team_id_idx ON public.collaborators USING btree (team_id);
--
-- Name: collaborators_user_id_idx; Type: INDEX; Schema: public; Owner: wire-server
--
CREATE INDEX collaborators_user_id_idx ON public.collaborators USING btree (user_id);
--
-- Name: conversation_codes_expires_at_idx; Type: INDEX; Schema: public; Owner: wire-server
--
CREATE INDEX conversation_codes_expires_at_idx ON public.conversation_codes USING btree (expires_at);
--
-- Name: conversation_codes_key_expires_at_idx; Type: INDEX; Schema: public; Owner: wire-server
--
CREATE INDEX conversation_codes_key_expires_at_idx ON public.conversation_codes USING btree (key, expires_at);
--
-- Name: conversation_member_user_idx; Type: INDEX; Schema: public; Owner: wire-server
--
CREATE INDEX conversation_member_user_idx ON public.conversation_member USING btree ("user");
--
-- Name: conversation_team_group_type_lower_name_id_idx; Type: INDEX; Schema: public; Owner: wire-server
--
CREATE INDEX conversation_team_group_type_lower_name_id_idx ON public.conversation USING btree (team, group_conv_type, lower(name), id);
--
-- Name: conversation_team_idx; Type: INDEX; Schema: public; Owner: wire-server
--
CREATE INDEX conversation_team_idx ON public.conversation USING btree (team);
--
-- Name: idx_meetings_conversation; Type: INDEX; Schema: public; Owner: wire-server
--
CREATE INDEX idx_meetings_conversation ON public.meetings USING btree (conversation_id);
--
-- Name: idx_meetings_creator; Type: INDEX; Schema: public; Owner: wire-server
--
CREATE INDEX idx_meetings_creator ON public.meetings USING btree (creator);
--
-- Name: idx_meetings_end_time; Type: INDEX; Schema: public; Owner: wire-server
--
CREATE INDEX idx_meetings_end_time ON public.meetings USING btree (end_time);
--
-- Name: idx_meetings_start_time; Type: INDEX; Schema: public; Owner: wire-server
--
CREATE INDEX idx_meetings_start_time ON public.meetings USING btree (start_time);
--
-- Name: user_group_member_user_id_idx; Type: INDEX; Schema: public; Owner: wire-server
--
CREATE INDEX user_group_member_user_id_idx ON public.user_group_member USING btree (user_id);
--
-- Name: conversation_member conversation_member_conv_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wire-server
--
ALTER TABLE ONLY public.conversation_member
ADD CONSTRAINT conversation_member_conv_fkey FOREIGN KEY (conv) REFERENCES public.conversation(id) ON DELETE CASCADE;
--
-- Name: conversation_out_of_sync conversation_out_of_sync_conv_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wire-server
--
ALTER TABLE ONLY public.conversation_out_of_sync
ADD CONSTRAINT conversation_out_of_sync_conv_id_fkey FOREIGN KEY (conv_id) REFERENCES public.conversation(id) ON DELETE CASCADE;
--
-- Name: conversation conversation_parent_conv_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wire-server
--
ALTER TABLE ONLY public.conversation
ADD CONSTRAINT conversation_parent_conv_fkey FOREIGN KEY (parent_conv) REFERENCES public.conversation(id) ON DELETE CASCADE;
--
-- Name: user_group_member fk_user_group; Type: FK CONSTRAINT; Schema: public; Owner: wire-server
--
ALTER TABLE ONLY public.user_group_member
ADD CONSTRAINT fk_user_group FOREIGN KEY (user_group_id) REFERENCES public.user_group(id) ON DELETE CASCADE;
--
-- Name: user_group_channel fk_user_group_channel; Type: FK CONSTRAINT; Schema: public; Owner: wire-server
--
ALTER TABLE ONLY public.user_group_channel
ADD CONSTRAINT fk_user_group_channel FOREIGN KEY (user_group_id) REFERENCES public.user_group(id) ON DELETE CASCADE;
--
-- Name: local_conversation_remote_member local_conversation_remote_member_conv_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wire-server
--
ALTER TABLE ONLY public.local_conversation_remote_member
ADD CONSTRAINT local_conversation_remote_member_conv_fkey FOREIGN KEY (conv) REFERENCES public.conversation(id) ON DELETE CASCADE;
--
-- Name: subconversation subconversation_conv_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wire-server
--
ALTER TABLE ONLY public.subconversation
ADD CONSTRAINT subconversation_conv_id_fkey FOREIGN KEY (conv_id) REFERENCES public.conversation(id) ON DELETE CASCADE;
--
-- Name: SCHEMA public; Type: ACL; Schema: -; Owner: wire-server
--
REVOKE USAGE ON SCHEMA public FROM PUBLIC;
--
-- PostgreSQL database dump complete
--
\unrestrict 79bbfb4630959c48307653a5cd3d83f2582b3c2210f75f10d79e3ebf0015620