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