1-- This file is auto-generated. Do not modify it by hand.
2-- To regenerate, run `cargo xtask db dump-schema app --collab` from the Cloud repository.
3
4CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public;
5
6CREATE TABLE public.breakpoints (
7 id integer NOT NULL,
8 project_id integer NOT NULL,
9 "position" integer NOT NULL,
10 log_message text,
11 worktree_id bigint NOT NULL,
12 path text NOT NULL,
13 kind character varying NOT NULL
14);
15
16CREATE SEQUENCE public.breakpoints_id_seq
17 AS integer
18 START WITH 1
19 INCREMENT BY 1
20 NO MINVALUE
21 NO MAXVALUE
22 CACHE 1;
23
24ALTER SEQUENCE public.breakpoints_id_seq OWNED BY public.breakpoints.id;
25
26CREATE TABLE public.buffer_operations (
27 buffer_id integer NOT NULL,
28 epoch integer NOT NULL,
29 replica_id integer NOT NULL,
30 lamport_timestamp integer NOT NULL,
31 value bytea NOT NULL
32);
33
34CREATE TABLE public.buffer_snapshots (
35 buffer_id integer NOT NULL,
36 epoch integer NOT NULL,
37 text text NOT NULL,
38 operation_serialization_version integer NOT NULL
39);
40
41CREATE TABLE public.buffers (
42 id integer NOT NULL,
43 channel_id integer NOT NULL,
44 epoch integer DEFAULT 0 NOT NULL,
45 latest_operation_epoch integer,
46 latest_operation_lamport_timestamp integer,
47 latest_operation_replica_id integer
48);
49
50CREATE SEQUENCE public.buffers_id_seq
51 AS integer
52 START WITH 1
53 INCREMENT BY 1
54 NO MINVALUE
55 NO MAXVALUE
56 CACHE 1;
57
58ALTER SEQUENCE public.buffers_id_seq OWNED BY public.buffers.id;
59
60CREATE TABLE public.channel_buffer_collaborators (
61 id integer NOT NULL,
62 channel_id integer NOT NULL,
63 connection_id integer NOT NULL,
64 connection_server_id integer NOT NULL,
65 connection_lost boolean DEFAULT false NOT NULL,
66 user_id integer NOT NULL,
67 replica_id integer NOT NULL
68);
69
70CREATE SEQUENCE public.channel_buffer_collaborators_id_seq
71 AS integer
72 START WITH 1
73 INCREMENT BY 1
74 NO MINVALUE
75 NO MAXVALUE
76 CACHE 1;
77
78ALTER SEQUENCE public.channel_buffer_collaborators_id_seq OWNED BY public.channel_buffer_collaborators.id;
79
80CREATE TABLE public.channel_chat_participants (
81 id integer NOT NULL,
82 user_id integer NOT NULL,
83 channel_id integer NOT NULL,
84 connection_id integer NOT NULL,
85 connection_server_id integer NOT NULL
86);
87
88CREATE SEQUENCE public.channel_chat_participants_id_seq
89 AS integer
90 START WITH 1
91 INCREMENT BY 1
92 NO MINVALUE
93 NO MAXVALUE
94 CACHE 1;
95
96ALTER SEQUENCE public.channel_chat_participants_id_seq OWNED BY public.channel_chat_participants.id;
97
98CREATE TABLE public.channel_members (
99 id integer NOT NULL,
100 channel_id integer NOT NULL,
101 user_id integer NOT NULL,
102 accepted boolean DEFAULT false NOT NULL,
103 updated_at timestamp without time zone DEFAULT now() NOT NULL,
104 role text NOT NULL
105);
106
107CREATE SEQUENCE public.channel_members_id_seq
108 AS integer
109 START WITH 1
110 INCREMENT BY 1
111 NO MINVALUE
112 NO MAXVALUE
113 CACHE 1;
114
115ALTER SEQUENCE public.channel_members_id_seq OWNED BY public.channel_members.id;
116
117CREATE TABLE public.channels (
118 id integer NOT NULL,
119 name character varying NOT NULL,
120 created_at timestamp without time zone DEFAULT now() NOT NULL,
121 visibility text DEFAULT 'members'::text NOT NULL,
122 parent_path text NOT NULL,
123 requires_zed_cla boolean DEFAULT false NOT NULL,
124 channel_order integer DEFAULT 1 NOT NULL
125);
126
127CREATE SEQUENCE public.channels_id_seq
128 AS integer
129 START WITH 1
130 INCREMENT BY 1
131 NO MINVALUE
132 NO MAXVALUE
133 CACHE 1;
134
135ALTER SEQUENCE public.channels_id_seq OWNED BY public.channels.id;
136
137CREATE TABLE public.contacts (
138 id integer NOT NULL,
139 user_id_a integer NOT NULL,
140 user_id_b integer NOT NULL,
141 a_to_b boolean NOT NULL,
142 should_notify boolean NOT NULL,
143 accepted boolean NOT NULL
144);
145
146CREATE SEQUENCE public.contacts_id_seq
147 AS integer
148 START WITH 1
149 INCREMENT BY 1
150 NO MINVALUE
151 NO MAXVALUE
152 CACHE 1;
153
154ALTER SEQUENCE public.contacts_id_seq OWNED BY public.contacts.id;
155
156CREATE TABLE public.contributors (
157 user_id integer NOT NULL,
158 signed_at timestamp without time zone DEFAULT now() NOT NULL
159);
160
161CREATE TABLE public.extension_versions (
162 extension_id integer NOT NULL,
163 version text NOT NULL,
164 published_at timestamp without time zone DEFAULT now() NOT NULL,
165 authors text NOT NULL,
166 repository text NOT NULL,
167 description text NOT NULL,
168 download_count bigint DEFAULT 0 NOT NULL,
169 schema_version integer DEFAULT 0 NOT NULL,
170 wasm_api_version text,
171 provides_themes boolean DEFAULT false NOT NULL,
172 provides_icon_themes boolean DEFAULT false NOT NULL,
173 provides_languages boolean DEFAULT false NOT NULL,
174 provides_grammars boolean DEFAULT false NOT NULL,
175 provides_language_servers boolean DEFAULT false NOT NULL,
176 provides_context_servers boolean DEFAULT false NOT NULL,
177 provides_slash_commands boolean DEFAULT false NOT NULL,
178 provides_indexed_docs_providers boolean DEFAULT false NOT NULL,
179 provides_snippets boolean DEFAULT false NOT NULL,
180 provides_debug_adapters boolean DEFAULT false NOT NULL,
181 provides_agent_servers boolean DEFAULT false NOT NULL
182);
183
184CREATE TABLE public.extensions (
185 id integer NOT NULL,
186 name text NOT NULL,
187 external_id text NOT NULL,
188 latest_version text NOT NULL,
189 total_download_count bigint DEFAULT 0 NOT NULL
190);
191
192CREATE SEQUENCE public.extensions_id_seq
193 AS integer
194 START WITH 1
195 INCREMENT BY 1
196 NO MINVALUE
197 NO MAXVALUE
198 CACHE 1;
199
200ALTER SEQUENCE public.extensions_id_seq OWNED BY public.extensions.id;
201
202CREATE TABLE public.followers (
203 id integer NOT NULL,
204 room_id integer NOT NULL,
205 project_id integer NOT NULL,
206 leader_connection_server_id integer NOT NULL,
207 leader_connection_id integer NOT NULL,
208 follower_connection_server_id integer NOT NULL,
209 follower_connection_id integer NOT NULL
210);
211
212CREATE SEQUENCE public.followers_id_seq
213 AS integer
214 START WITH 1
215 INCREMENT BY 1
216 NO MINVALUE
217 NO MAXVALUE
218 CACHE 1;
219
220ALTER SEQUENCE public.followers_id_seq OWNED BY public.followers.id;
221
222CREATE TABLE public.language_servers (
223 project_id integer NOT NULL,
224 id bigint NOT NULL,
225 name character varying NOT NULL,
226 capabilities text NOT NULL,
227 worktree_id bigint
228);
229
230CREATE TABLE public.notification_kinds (
231 id integer NOT NULL,
232 name character varying NOT NULL
233);
234
235CREATE SEQUENCE public.notification_kinds_id_seq
236 AS integer
237 START WITH 1
238 INCREMENT BY 1
239 NO MINVALUE
240 NO MAXVALUE
241 CACHE 1;
242
243ALTER SEQUENCE public.notification_kinds_id_seq OWNED BY public.notification_kinds.id;
244
245CREATE TABLE public.notifications (
246 id integer NOT NULL,
247 created_at timestamp without time zone DEFAULT now() NOT NULL,
248 recipient_id integer NOT NULL,
249 kind integer NOT NULL,
250 entity_id integer,
251 content text,
252 is_read boolean DEFAULT false NOT NULL,
253 response boolean
254);
255
256CREATE SEQUENCE public.notifications_id_seq
257 AS integer
258 START WITH 1
259 INCREMENT BY 1
260 NO MINVALUE
261 NO MAXVALUE
262 CACHE 1;
263
264ALTER SEQUENCE public.notifications_id_seq OWNED BY public.notifications.id;
265
266CREATE TABLE public.observed_buffer_edits (
267 user_id integer NOT NULL,
268 buffer_id integer NOT NULL,
269 epoch integer NOT NULL,
270 lamport_timestamp integer NOT NULL,
271 replica_id integer NOT NULL
272);
273
274CREATE TABLE public.project_collaborators (
275 id integer NOT NULL,
276 project_id integer NOT NULL,
277 connection_id integer NOT NULL,
278 user_id integer NOT NULL,
279 replica_id integer NOT NULL,
280 is_host boolean NOT NULL,
281 connection_server_id integer NOT NULL,
282 committer_name character varying,
283 committer_email character varying
284);
285
286CREATE SEQUENCE public.project_collaborators_id_seq
287 AS integer
288 START WITH 1
289 INCREMENT BY 1
290 NO MINVALUE
291 NO MAXVALUE
292 CACHE 1;
293
294ALTER SEQUENCE public.project_collaborators_id_seq OWNED BY public.project_collaborators.id;
295
296CREATE TABLE public.project_repositories (
297 project_id integer NOT NULL,
298 abs_path character varying,
299 id bigint NOT NULL,
300 legacy_worktree_id bigint,
301 entry_ids character varying,
302 branch character varying,
303 scan_id bigint NOT NULL,
304 is_deleted boolean NOT NULL,
305 current_merge_conflicts character varying,
306 branch_summary character varying,
307 head_commit_details character varying,
308 merge_message character varying,
309 remote_upstream_url character varying,
310 remote_origin_url character varying
311);
312
313CREATE TABLE public.project_repository_statuses (
314 project_id integer NOT NULL,
315 repository_id bigint NOT NULL,
316 repo_path character varying NOT NULL,
317 status bigint NOT NULL,
318 status_kind integer NOT NULL,
319 first_status integer,
320 second_status integer,
321 scan_id bigint NOT NULL,
322 is_deleted boolean NOT NULL,
323 lines_added integer,
324 lines_deleted integer
325);
326
327CREATE TABLE public.projects (
328 id integer NOT NULL,
329 host_user_id integer,
330 unregistered boolean DEFAULT false NOT NULL,
331 room_id integer,
332 host_connection_id integer,
333 host_connection_server_id integer,
334 windows_paths boolean DEFAULT false
335);
336
337CREATE SEQUENCE public.projects_id_seq
338 AS integer
339 START WITH 1
340 INCREMENT BY 1
341 NO MINVALUE
342 NO MAXVALUE
343 CACHE 1;
344
345ALTER SEQUENCE public.projects_id_seq OWNED BY public.projects.id;
346
347CREATE TABLE public.room_participants (
348 id integer NOT NULL,
349 room_id integer NOT NULL,
350 user_id integer NOT NULL,
351 answering_connection_id integer,
352 location_kind integer,
353 location_project_id integer,
354 initial_project_id integer,
355 calling_user_id integer NOT NULL,
356 calling_connection_id integer NOT NULL,
357 answering_connection_lost boolean DEFAULT false NOT NULL,
358 answering_connection_server_id integer,
359 calling_connection_server_id integer,
360 participant_index integer,
361 role text
362);
363
364CREATE SEQUENCE public.room_participants_id_seq
365 AS integer
366 START WITH 1
367 INCREMENT BY 1
368 NO MINVALUE
369 NO MAXVALUE
370 CACHE 1;
371
372ALTER SEQUENCE public.room_participants_id_seq OWNED BY public.room_participants.id;
373
374CREATE TABLE public.rooms (
375 id integer NOT NULL,
376 live_kit_room character varying NOT NULL,
377 channel_id integer
378);
379
380CREATE SEQUENCE public.rooms_id_seq
381 AS integer
382 START WITH 1
383 INCREMENT BY 1
384 NO MINVALUE
385 NO MAXVALUE
386 CACHE 1;
387
388ALTER SEQUENCE public.rooms_id_seq OWNED BY public.rooms.id;
389
390CREATE TABLE public.servers (
391 id integer NOT NULL,
392 environment character varying NOT NULL
393);
394
395CREATE SEQUENCE public.servers_id_seq
396 AS integer
397 START WITH 1
398 INCREMENT BY 1
399 NO MINVALUE
400 NO MAXVALUE
401 CACHE 1;
402
403ALTER SEQUENCE public.servers_id_seq OWNED BY public.servers.id;
404
405CREATE TABLE public.shared_threads (
406 id uuid NOT NULL,
407 user_id integer NOT NULL,
408 title text NOT NULL,
409 data bytea NOT NULL,
410 created_at timestamp without time zone DEFAULT now() NOT NULL,
411 updated_at timestamp without time zone DEFAULT now() NOT NULL
412);
413
414CREATE TABLE public.users (
415 id integer NOT NULL,
416 github_login character varying,
417 admin boolean NOT NULL,
418 email_address character varying(255) DEFAULT NULL::character varying,
419 connected_once boolean DEFAULT false NOT NULL,
420 created_at timestamp without time zone DEFAULT now() NOT NULL,
421 github_user_id integer NOT NULL,
422 metrics_id uuid DEFAULT gen_random_uuid() NOT NULL,
423 accepted_tos_at timestamp without time zone,
424 github_user_created_at timestamp without time zone,
425 custom_llm_monthly_allowance_in_cents integer,
426 name text
427);
428
429CREATE SEQUENCE public.users_id_seq
430 AS integer
431 START WITH 1
432 INCREMENT BY 1
433 NO MINVALUE
434 NO MAXVALUE
435 CACHE 1;
436
437ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;
438
439CREATE TABLE public.worktree_diagnostic_summaries (
440 project_id integer NOT NULL,
441 worktree_id bigint NOT NULL,
442 path character varying NOT NULL,
443 language_server_id bigint NOT NULL,
444 error_count integer NOT NULL,
445 warning_count integer NOT NULL
446);
447
448CREATE TABLE public.worktree_entries (
449 project_id integer NOT NULL,
450 worktree_id bigint NOT NULL,
451 id bigint NOT NULL,
452 is_dir boolean NOT NULL,
453 path character varying NOT NULL,
454 inode bigint NOT NULL,
455 mtime_seconds bigint NOT NULL,
456 mtime_nanos integer NOT NULL,
457 is_symlink boolean DEFAULT false NOT NULL,
458 is_ignored boolean NOT NULL,
459 scan_id bigint,
460 is_deleted boolean,
461 git_status bigint,
462 is_external boolean DEFAULT false NOT NULL,
463 is_fifo boolean DEFAULT false NOT NULL,
464 canonical_path text,
465 is_hidden boolean DEFAULT false NOT NULL
466);
467
468CREATE TABLE public.worktree_settings_files (
469 project_id integer NOT NULL,
470 worktree_id bigint NOT NULL,
471 path character varying NOT NULL,
472 content text NOT NULL,
473 kind character varying,
474 outside_worktree boolean DEFAULT false NOT NULL
475);
476
477CREATE TABLE public.worktrees (
478 project_id integer NOT NULL,
479 id bigint NOT NULL,
480 root_name character varying NOT NULL,
481 abs_path character varying NOT NULL,
482 visible boolean NOT NULL,
483 scan_id bigint NOT NULL,
484 is_complete boolean DEFAULT false NOT NULL,
485 completed_scan_id bigint
486);
487
488ALTER TABLE ONLY public.breakpoints ALTER COLUMN id SET DEFAULT nextval('public.breakpoints_id_seq'::regclass);
489
490ALTER TABLE ONLY public.buffers ALTER COLUMN id SET DEFAULT nextval('public.buffers_id_seq'::regclass);
491
492ALTER TABLE ONLY public.channel_buffer_collaborators ALTER COLUMN id SET DEFAULT nextval('public.channel_buffer_collaborators_id_seq'::regclass);
493
494ALTER TABLE ONLY public.channel_chat_participants ALTER COLUMN id SET DEFAULT nextval('public.channel_chat_participants_id_seq'::regclass);
495
496ALTER TABLE ONLY public.channel_members ALTER COLUMN id SET DEFAULT nextval('public.channel_members_id_seq'::regclass);
497
498ALTER TABLE ONLY public.channels ALTER COLUMN id SET DEFAULT nextval('public.channels_id_seq'::regclass);
499
500ALTER TABLE ONLY public.contacts ALTER COLUMN id SET DEFAULT nextval('public.contacts_id_seq'::regclass);
501
502ALTER TABLE ONLY public.extensions ALTER COLUMN id SET DEFAULT nextval('public.extensions_id_seq'::regclass);
503
504ALTER TABLE ONLY public.followers ALTER COLUMN id SET DEFAULT nextval('public.followers_id_seq'::regclass);
505
506ALTER TABLE ONLY public.notification_kinds ALTER COLUMN id SET DEFAULT nextval('public.notification_kinds_id_seq'::regclass);
507
508ALTER TABLE ONLY public.notifications ALTER COLUMN id SET DEFAULT nextval('public.notifications_id_seq'::regclass);
509
510ALTER TABLE ONLY public.project_collaborators ALTER COLUMN id SET DEFAULT nextval('public.project_collaborators_id_seq'::regclass);
511
512ALTER TABLE ONLY public.projects ALTER COLUMN id SET DEFAULT nextval('public.projects_id_seq'::regclass);
513
514ALTER TABLE ONLY public.room_participants ALTER COLUMN id SET DEFAULT nextval('public.room_participants_id_seq'::regclass);
515
516ALTER TABLE ONLY public.rooms ALTER COLUMN id SET DEFAULT nextval('public.rooms_id_seq'::regclass);
517
518ALTER TABLE ONLY public.servers ALTER COLUMN id SET DEFAULT nextval('public.servers_id_seq'::regclass);
519
520ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);
521
522ALTER TABLE ONLY public.breakpoints
523 ADD CONSTRAINT breakpoints_pkey PRIMARY KEY (id);
524
525ALTER TABLE ONLY public.buffer_operations
526 ADD CONSTRAINT buffer_operations_pkey PRIMARY KEY (buffer_id, epoch, lamport_timestamp, replica_id);
527
528ALTER TABLE ONLY public.buffer_snapshots
529 ADD CONSTRAINT buffer_snapshots_pkey PRIMARY KEY (buffer_id, epoch);
530
531ALTER TABLE ONLY public.buffers
532 ADD CONSTRAINT buffers_pkey PRIMARY KEY (id);
533
534ALTER TABLE ONLY public.channel_buffer_collaborators
535 ADD CONSTRAINT channel_buffer_collaborators_pkey PRIMARY KEY (id);
536
537ALTER TABLE ONLY public.channel_chat_participants
538 ADD CONSTRAINT channel_chat_participants_pkey PRIMARY KEY (id);
539
540ALTER TABLE ONLY public.channel_members
541 ADD CONSTRAINT channel_members_pkey PRIMARY KEY (id);
542
543ALTER TABLE ONLY public.channels
544 ADD CONSTRAINT channels_pkey PRIMARY KEY (id);
545
546ALTER TABLE ONLY public.contacts
547 ADD CONSTRAINT contacts_pkey PRIMARY KEY (id);
548
549ALTER TABLE ONLY public.contributors
550 ADD CONSTRAINT contributors_pkey PRIMARY KEY (user_id);
551
552ALTER TABLE ONLY public.extension_versions
553 ADD CONSTRAINT extension_versions_pkey PRIMARY KEY (extension_id, version);
554
555ALTER TABLE ONLY public.extensions
556 ADD CONSTRAINT extensions_pkey PRIMARY KEY (id);
557
558ALTER TABLE ONLY public.followers
559 ADD CONSTRAINT followers_pkey PRIMARY KEY (id);
560
561ALTER TABLE ONLY public.language_servers
562 ADD CONSTRAINT language_servers_pkey PRIMARY KEY (project_id, id);
563
564ALTER TABLE ONLY public.notification_kinds
565 ADD CONSTRAINT notification_kinds_pkey PRIMARY KEY (id);
566
567ALTER TABLE ONLY public.notifications
568 ADD CONSTRAINT notifications_pkey PRIMARY KEY (id);
569
570ALTER TABLE ONLY public.observed_buffer_edits
571 ADD CONSTRAINT observed_buffer_edits_pkey PRIMARY KEY (user_id, buffer_id);
572
573ALTER TABLE ONLY public.project_collaborators
574 ADD CONSTRAINT project_collaborators_pkey PRIMARY KEY (id);
575
576ALTER TABLE ONLY public.project_repositories
577 ADD CONSTRAINT project_repositories_pkey PRIMARY KEY (project_id, id);
578
579ALTER TABLE ONLY public.project_repository_statuses
580 ADD CONSTRAINT project_repository_statuses_pkey PRIMARY KEY (project_id, repository_id, repo_path);
581
582ALTER TABLE ONLY public.projects
583 ADD CONSTRAINT projects_pkey PRIMARY KEY (id);
584
585ALTER TABLE ONLY public.room_participants
586 ADD CONSTRAINT room_participants_pkey PRIMARY KEY (id);
587
588ALTER TABLE ONLY public.rooms
589 ADD CONSTRAINT rooms_pkey PRIMARY KEY (id);
590
591ALTER TABLE ONLY public.servers
592 ADD CONSTRAINT servers_pkey PRIMARY KEY (id);
593
594ALTER TABLE ONLY public.shared_threads
595 ADD CONSTRAINT shared_threads_pkey PRIMARY KEY (id);
596
597ALTER TABLE ONLY public.users
598 ADD CONSTRAINT users_pkey PRIMARY KEY (id);
599
600ALTER TABLE ONLY public.worktree_diagnostic_summaries
601 ADD CONSTRAINT worktree_diagnostic_summaries_pkey PRIMARY KEY (project_id, worktree_id, path);
602
603ALTER TABLE ONLY public.worktree_entries
604 ADD CONSTRAINT worktree_entries_pkey PRIMARY KEY (project_id, worktree_id, id);
605
606ALTER TABLE ONLY public.worktree_settings_files
607 ADD CONSTRAINT worktree_settings_files_pkey PRIMARY KEY (project_id, worktree_id, path);
608
609ALTER TABLE ONLY public.worktrees
610 ADD CONSTRAINT worktrees_pkey PRIMARY KEY (project_id, id);
611
612CREATE INDEX idx_shared_threads_user_id ON public.shared_threads USING btree (user_id);
613
614CREATE INDEX index_breakpoints_on_project_id ON public.breakpoints USING btree (project_id);
615
616CREATE INDEX index_buffers_on_channel_id ON public.buffers USING btree (channel_id);
617
618CREATE INDEX index_channel_buffer_collaborators_on_channel_id ON public.channel_buffer_collaborators USING btree (channel_id);
619
620CREATE UNIQUE INDEX index_channel_buffer_collaborators_on_channel_id_and_replica_id ON public.channel_buffer_collaborators USING btree (channel_id, replica_id);
621
622CREATE UNIQUE INDEX index_channel_buffer_collaborators_on_channel_id_connection_id_ ON public.channel_buffer_collaborators USING btree (channel_id, connection_id, connection_server_id);
623
624CREATE INDEX index_channel_buffer_collaborators_on_connection_id ON public.channel_buffer_collaborators USING btree (connection_id);
625
626CREATE INDEX index_channel_buffer_collaborators_on_connection_server_id ON public.channel_buffer_collaborators USING btree (connection_server_id);
627
628CREATE INDEX index_channel_chat_participants_on_channel_id ON public.channel_chat_participants USING btree (channel_id);
629
630CREATE UNIQUE INDEX index_channel_members_on_channel_id_and_user_id ON public.channel_members USING btree (channel_id, user_id);
631
632CREATE INDEX index_channels_on_parent_path ON public.channels USING btree (parent_path text_pattern_ops);
633
634CREATE INDEX index_channels_on_parent_path_and_order ON public.channels USING btree (parent_path, channel_order);
635
636CREATE INDEX index_contacts_user_id_b ON public.contacts USING btree (user_id_b);
637
638CREATE UNIQUE INDEX index_contacts_user_ids ON public.contacts USING btree (user_id_a, user_id_b);
639
640CREATE UNIQUE INDEX index_extensions_external_id ON public.extensions USING btree (external_id);
641
642CREATE INDEX index_extensions_total_download_count ON public.extensions USING btree (total_download_count);
643
644CREATE UNIQUE INDEX index_followers_on_project_id_and_leader_connection_server_id_a ON public.followers USING btree (project_id, leader_connection_server_id, leader_connection_id, follower_connection_server_id, follower_connection_id);
645
646CREATE INDEX index_followers_on_room_id ON public.followers USING btree (room_id);
647
648CREATE INDEX index_language_servers_on_project_id ON public.language_servers USING btree (project_id);
649
650CREATE UNIQUE INDEX index_notification_kinds_on_name ON public.notification_kinds USING btree (name);
651
652CREATE INDEX index_notifications_on_recipient_id_is_read_kind_entity_id ON public.notifications USING btree (recipient_id, is_read, kind, entity_id);
653
654CREATE UNIQUE INDEX index_observed_buffer_user_and_buffer_id ON public.observed_buffer_edits USING btree (user_id, buffer_id);
655
656CREATE INDEX index_project_collaborators_on_connection_id ON public.project_collaborators USING btree (connection_id);
657
658CREATE INDEX index_project_collaborators_on_connection_server_id ON public.project_collaborators USING btree (connection_server_id);
659
660CREATE INDEX index_project_collaborators_on_project_id ON public.project_collaborators USING btree (project_id);
661
662CREATE UNIQUE INDEX index_project_collaborators_on_project_id_and_replica_id ON public.project_collaborators USING btree (project_id, replica_id);
663
664CREATE UNIQUE INDEX index_project_collaborators_on_project_id_connection_id_and_ser ON public.project_collaborators USING btree (project_id, connection_id, connection_server_id);
665
666CREATE INDEX index_project_repos_statuses_on_project_id ON public.project_repository_statuses USING btree (project_id);
667
668CREATE INDEX index_project_repos_statuses_on_project_id_and_repo_id ON public.project_repository_statuses USING btree (project_id, repository_id);
669
670CREATE INDEX index_project_repositories_on_project_id ON public.project_repositories USING btree (project_id);
671
672CREATE INDEX index_projects_on_host_connection_id_and_host_connection_server ON public.projects USING btree (host_connection_id, host_connection_server_id);
673
674CREATE INDEX index_projects_on_host_connection_server_id ON public.projects USING btree (host_connection_server_id);
675
676CREATE INDEX index_room_participants_on_answering_connection_id ON public.room_participants USING btree (answering_connection_id);
677
678CREATE UNIQUE INDEX index_room_participants_on_answering_connection_id_and_answerin ON public.room_participants USING btree (answering_connection_id, answering_connection_server_id);
679
680CREATE INDEX index_room_participants_on_answering_connection_server_id ON public.room_participants USING btree (answering_connection_server_id);
681
682CREATE INDEX index_room_participants_on_calling_connection_server_id ON public.room_participants USING btree (calling_connection_server_id);
683
684CREATE INDEX index_room_participants_on_room_id ON public.room_participants USING btree (room_id);
685
686CREATE UNIQUE INDEX index_room_participants_on_user_id ON public.room_participants USING btree (user_id);
687
688CREATE UNIQUE INDEX index_rooms_on_channel_id ON public.rooms USING btree (channel_id);
689
690CREATE INDEX index_settings_files_on_project_id ON public.worktree_settings_files USING btree (project_id);
691
692CREATE INDEX index_settings_files_on_project_id_and_wt_id ON public.worktree_settings_files USING btree (project_id, worktree_id);
693
694CREATE UNIQUE INDEX index_users_github_login ON public.users USING btree (github_login);
695
696CREATE INDEX index_users_on_email_address ON public.users USING btree (email_address);
697
698CREATE INDEX index_worktree_diagnostic_summaries_on_project_id ON public.worktree_diagnostic_summaries USING btree (project_id);
699
700CREATE INDEX index_worktree_diagnostic_summaries_on_project_id_and_worktree_ ON public.worktree_diagnostic_summaries USING btree (project_id, worktree_id);
701
702CREATE INDEX index_worktree_entries_on_project_id ON public.worktree_entries USING btree (project_id);
703
704CREATE INDEX index_worktree_entries_on_project_id_and_worktree_id ON public.worktree_entries USING btree (project_id, worktree_id);
705
706CREATE INDEX index_worktrees_on_project_id ON public.worktrees USING btree (project_id);
707
708CREATE INDEX trigram_index_extensions_name ON public.extensions USING gin (name public.gin_trgm_ops);
709
710CREATE INDEX trigram_index_users_on_github_login ON public.users USING gin (github_login public.gin_trgm_ops);
711
712CREATE INDEX trigram_index_users_on_name ON public.users USING gin (name public.gin_trgm_ops);
713
714CREATE UNIQUE INDEX uix_channels_parent_path_name ON public.channels USING btree (parent_path, name) WHERE ((parent_path IS NOT NULL) AND (parent_path <> ''::text));
715
716CREATE UNIQUE INDEX uix_users_on_github_user_id ON public.users USING btree (github_user_id);
717
718ALTER TABLE ONLY public.breakpoints
719 ADD CONSTRAINT breakpoints_project_id_fkey FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
720
721ALTER TABLE ONLY public.buffer_operations
722 ADD CONSTRAINT buffer_operations_buffer_id_fkey FOREIGN KEY (buffer_id) REFERENCES public.buffers(id) ON DELETE CASCADE;
723
724ALTER TABLE ONLY public.buffer_snapshots
725 ADD CONSTRAINT buffer_snapshots_buffer_id_fkey FOREIGN KEY (buffer_id) REFERENCES public.buffers(id) ON DELETE CASCADE;
726
727ALTER TABLE ONLY public.buffers
728 ADD CONSTRAINT buffers_channel_id_fkey FOREIGN KEY (channel_id) REFERENCES public.channels(id) ON DELETE CASCADE;
729
730ALTER TABLE ONLY public.channel_buffer_collaborators
731 ADD CONSTRAINT channel_buffer_collaborators_channel_id_fkey FOREIGN KEY (channel_id) REFERENCES public.channels(id) ON DELETE CASCADE;
732
733ALTER TABLE ONLY public.channel_buffer_collaborators
734 ADD CONSTRAINT channel_buffer_collaborators_connection_server_id_fkey FOREIGN KEY (connection_server_id) REFERENCES public.servers(id) ON DELETE CASCADE;
735
736ALTER TABLE ONLY public.channel_buffer_collaborators
737 ADD CONSTRAINT channel_buffer_collaborators_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
738
739ALTER TABLE ONLY public.channel_chat_participants
740 ADD CONSTRAINT channel_chat_participants_channel_id_fkey FOREIGN KEY (channel_id) REFERENCES public.channels(id) ON DELETE CASCADE;
741
742ALTER TABLE ONLY public.channel_chat_participants
743 ADD CONSTRAINT channel_chat_participants_connection_server_id_fkey FOREIGN KEY (connection_server_id) REFERENCES public.servers(id) ON DELETE CASCADE;
744
745ALTER TABLE ONLY public.channel_chat_participants
746 ADD CONSTRAINT channel_chat_participants_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
747
748ALTER TABLE ONLY public.channel_members
749 ADD CONSTRAINT channel_members_channel_id_fkey FOREIGN KEY (channel_id) REFERENCES public.channels(id) ON DELETE CASCADE;
750
751ALTER TABLE ONLY public.channel_members
752 ADD CONSTRAINT channel_members_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
753
754ALTER TABLE ONLY public.contacts
755 ADD CONSTRAINT contacts_user_id_a_fkey FOREIGN KEY (user_id_a) REFERENCES public.users(id) ON DELETE CASCADE;
756
757ALTER TABLE ONLY public.contacts
758 ADD CONSTRAINT contacts_user_id_b_fkey FOREIGN KEY (user_id_b) REFERENCES public.users(id) ON DELETE CASCADE;
759
760ALTER TABLE ONLY public.contributors
761 ADD CONSTRAINT contributors_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
762
763ALTER TABLE ONLY public.extension_versions
764 ADD CONSTRAINT extension_versions_extension_id_fkey FOREIGN KEY (extension_id) REFERENCES public.extensions(id);
765
766ALTER TABLE ONLY public.project_repositories
767 ADD CONSTRAINT fk_project_repositories_project_id FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
768
769ALTER TABLE ONLY public.project_repository_statuses
770 ADD CONSTRAINT fk_project_repository_statuses_project_id FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
771
772ALTER TABLE ONLY public.followers
773 ADD CONSTRAINT followers_follower_connection_server_id_fkey FOREIGN KEY (follower_connection_server_id) REFERENCES public.servers(id) ON DELETE CASCADE;
774
775ALTER TABLE ONLY public.followers
776 ADD CONSTRAINT followers_leader_connection_server_id_fkey FOREIGN KEY (leader_connection_server_id) REFERENCES public.servers(id) ON DELETE CASCADE;
777
778ALTER TABLE ONLY public.followers
779 ADD CONSTRAINT followers_project_id_fkey FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
780
781ALTER TABLE ONLY public.followers
782 ADD CONSTRAINT followers_room_id_fkey FOREIGN KEY (room_id) REFERENCES public.rooms(id) ON DELETE CASCADE;
783
784ALTER TABLE ONLY public.language_servers
785 ADD CONSTRAINT language_servers_project_id_fkey FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
786
787ALTER TABLE ONLY public.notifications
788 ADD CONSTRAINT notifications_kind_fkey FOREIGN KEY (kind) REFERENCES public.notification_kinds(id);
789
790ALTER TABLE ONLY public.notifications
791 ADD CONSTRAINT notifications_recipient_id_fkey FOREIGN KEY (recipient_id) REFERENCES public.users(id) ON DELETE CASCADE;
792
793ALTER TABLE ONLY public.observed_buffer_edits
794 ADD CONSTRAINT observed_buffer_edits_buffer_id_fkey FOREIGN KEY (buffer_id) REFERENCES public.buffers(id) ON DELETE CASCADE;
795
796ALTER TABLE ONLY public.observed_buffer_edits
797 ADD CONSTRAINT observed_buffer_edits_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
798
799ALTER TABLE ONLY public.project_collaborators
800 ADD CONSTRAINT project_collaborators_connection_server_id_fkey FOREIGN KEY (connection_server_id) REFERENCES public.servers(id) ON DELETE CASCADE;
801
802ALTER TABLE ONLY public.project_collaborators
803 ADD CONSTRAINT project_collaborators_project_id_fkey FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
804
805ALTER TABLE ONLY public.projects
806 ADD CONSTRAINT projects_host_connection_server_id_fkey FOREIGN KEY (host_connection_server_id) REFERENCES public.servers(id) ON DELETE CASCADE;
807
808ALTER TABLE ONLY public.projects
809 ADD CONSTRAINT projects_host_user_id_fkey FOREIGN KEY (host_user_id) REFERENCES public.users(id);
810
811ALTER TABLE ONLY public.projects
812 ADD CONSTRAINT projects_room_id_fkey FOREIGN KEY (room_id) REFERENCES public.rooms(id) ON DELETE CASCADE;
813
814ALTER TABLE ONLY public.room_participants
815 ADD CONSTRAINT room_participants_answering_connection_server_id_fkey FOREIGN KEY (answering_connection_server_id) REFERENCES public.servers(id) ON DELETE CASCADE;
816
817ALTER TABLE ONLY public.room_participants
818 ADD CONSTRAINT room_participants_calling_connection_server_id_fkey FOREIGN KEY (calling_connection_server_id) REFERENCES public.servers(id) ON DELETE SET NULL;
819
820ALTER TABLE ONLY public.room_participants
821 ADD CONSTRAINT room_participants_calling_user_id_fkey FOREIGN KEY (calling_user_id) REFERENCES public.users(id);
822
823ALTER TABLE ONLY public.room_participants
824 ADD CONSTRAINT room_participants_room_id_fkey FOREIGN KEY (room_id) REFERENCES public.rooms(id);
825
826ALTER TABLE ONLY public.room_participants
827 ADD CONSTRAINT room_participants_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
828
829ALTER TABLE ONLY public.rooms
830 ADD CONSTRAINT rooms_channel_id_fkey FOREIGN KEY (channel_id) REFERENCES public.channels(id) ON DELETE CASCADE;
831
832ALTER TABLE ONLY public.shared_threads
833 ADD CONSTRAINT shared_threads_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
834
835ALTER TABLE ONLY public.worktree_diagnostic_summaries
836 ADD CONSTRAINT worktree_diagnostic_summaries_project_id_worktree_id_fkey FOREIGN KEY (project_id, worktree_id) REFERENCES public.worktrees(project_id, id) ON DELETE CASCADE;
837
838ALTER TABLE ONLY public.worktree_entries
839 ADD CONSTRAINT worktree_entries_project_id_worktree_id_fkey FOREIGN KEY (project_id, worktree_id) REFERENCES public.worktrees(project_id, id) ON DELETE CASCADE;
840
841ALTER TABLE ONLY public.worktree_settings_files
842 ADD CONSTRAINT worktree_settings_files_project_id_worktree_id_fkey FOREIGN KEY (project_id, worktree_id) REFERENCES public.worktrees(project_id, id) ON DELETE CASCADE;
843
844ALTER TABLE ONLY public.worktrees
845 ADD CONSTRAINT worktrees_project_id_fkey FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;