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