20251208000000_test_schema.sql

  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    linked_worktrees text
312);
313
314CREATE TABLE public.project_repository_statuses (
315    project_id integer NOT NULL,
316    repository_id bigint NOT NULL,
317    repo_path character varying NOT NULL,
318    status bigint NOT NULL,
319    status_kind integer NOT NULL,
320    first_status integer,
321    second_status integer,
322    scan_id bigint NOT NULL,
323    is_deleted boolean NOT NULL,
324    lines_added integer,
325    lines_deleted integer
326);
327
328CREATE TABLE public.projects (
329    id integer NOT NULL,
330    host_user_id integer,
331    unregistered boolean DEFAULT false NOT NULL,
332    room_id integer,
333    host_connection_id integer,
334    host_connection_server_id integer,
335    windows_paths boolean DEFAULT false,
336    features text NOT NULL DEFAULT ''
337);
338
339CREATE SEQUENCE public.projects_id_seq
340    AS integer
341    START WITH 1
342    INCREMENT BY 1
343    NO MINVALUE
344    NO MAXVALUE
345    CACHE 1;
346
347ALTER SEQUENCE public.projects_id_seq OWNED BY public.projects.id;
348
349CREATE TABLE public.room_participants (
350    id integer NOT NULL,
351    room_id integer NOT NULL,
352    user_id integer NOT NULL,
353    answering_connection_id integer,
354    location_kind integer,
355    location_project_id integer,
356    initial_project_id integer,
357    calling_user_id integer NOT NULL,
358    calling_connection_id integer NOT NULL,
359    answering_connection_lost boolean DEFAULT false NOT NULL,
360    answering_connection_server_id integer,
361    calling_connection_server_id integer,
362    participant_index integer,
363    role text
364);
365
366CREATE SEQUENCE public.room_participants_id_seq
367    AS integer
368    START WITH 1
369    INCREMENT BY 1
370    NO MINVALUE
371    NO MAXVALUE
372    CACHE 1;
373
374ALTER SEQUENCE public.room_participants_id_seq OWNED BY public.room_participants.id;
375
376CREATE TABLE public.rooms (
377    id integer NOT NULL,
378    live_kit_room character varying NOT NULL,
379    channel_id integer
380);
381
382CREATE SEQUENCE public.rooms_id_seq
383    AS integer
384    START WITH 1
385    INCREMENT BY 1
386    NO MINVALUE
387    NO MAXVALUE
388    CACHE 1;
389
390ALTER SEQUENCE public.rooms_id_seq OWNED BY public.rooms.id;
391
392CREATE TABLE public.servers (
393    id integer NOT NULL,
394    environment character varying NOT NULL
395);
396
397CREATE SEQUENCE public.servers_id_seq
398    AS integer
399    START WITH 1
400    INCREMENT BY 1
401    NO MINVALUE
402    NO MAXVALUE
403    CACHE 1;
404
405ALTER SEQUENCE public.servers_id_seq OWNED BY public.servers.id;
406
407CREATE TABLE public.shared_threads (
408    id uuid NOT NULL,
409    user_id integer NOT NULL,
410    title text NOT NULL,
411    data bytea NOT NULL,
412    created_at timestamp without time zone DEFAULT now() NOT NULL,
413    updated_at timestamp without time zone DEFAULT now() NOT NULL
414);
415
416CREATE TABLE public.users (
417    id integer NOT NULL,
418    github_login character varying,
419    admin boolean NOT NULL,
420    email_address character varying(255) DEFAULT NULL::character varying,
421    connected_once boolean DEFAULT false NOT NULL,
422    created_at timestamp without time zone DEFAULT now() NOT NULL,
423    github_user_id integer NOT NULL,
424    metrics_id uuid DEFAULT gen_random_uuid() NOT NULL,
425    accepted_tos_at timestamp without time zone,
426    github_user_created_at timestamp without time zone,
427    custom_llm_monthly_allowance_in_cents integer,
428    name text
429);
430
431CREATE SEQUENCE public.users_id_seq
432    AS integer
433    START WITH 1
434    INCREMENT BY 1
435    NO MINVALUE
436    NO MAXVALUE
437    CACHE 1;
438
439ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;
440
441CREATE TABLE public.worktree_diagnostic_summaries (
442    project_id integer NOT NULL,
443    worktree_id bigint NOT NULL,
444    path character varying NOT NULL,
445    language_server_id bigint NOT NULL,
446    error_count integer NOT NULL,
447    warning_count integer NOT NULL
448);
449
450CREATE TABLE public.worktree_entries (
451    project_id integer NOT NULL,
452    worktree_id bigint NOT NULL,
453    id bigint NOT NULL,
454    is_dir boolean NOT NULL,
455    path character varying NOT NULL,
456    inode bigint NOT NULL,
457    mtime_seconds bigint NOT NULL,
458    mtime_nanos integer NOT NULL,
459    is_symlink boolean DEFAULT false NOT NULL,
460    is_ignored boolean NOT NULL,
461    scan_id bigint,
462    is_deleted boolean,
463    git_status bigint,
464    is_external boolean DEFAULT false NOT NULL,
465    is_fifo boolean DEFAULT false NOT NULL,
466    canonical_path text,
467    is_hidden boolean DEFAULT false NOT NULL
468);
469
470CREATE TABLE public.worktree_settings_files (
471    project_id integer NOT NULL,
472    worktree_id bigint NOT NULL,
473    path character varying NOT NULL,
474    content text NOT NULL,
475    kind character varying,
476    outside_worktree boolean DEFAULT false NOT NULL
477);
478
479CREATE TABLE public.worktrees (
480    project_id integer NOT NULL,
481    id bigint NOT NULL,
482    root_name character varying NOT NULL,
483    abs_path character varying NOT NULL,
484    visible boolean NOT NULL,
485    scan_id bigint NOT NULL,
486    is_complete boolean DEFAULT false NOT NULL,
487    completed_scan_id bigint
488);
489
490ALTER TABLE ONLY public.breakpoints ALTER COLUMN id SET DEFAULT nextval('public.breakpoints_id_seq'::regclass);
491
492ALTER TABLE ONLY public.buffers ALTER COLUMN id SET DEFAULT nextval('public.buffers_id_seq'::regclass);
493
494ALTER TABLE ONLY public.channel_buffer_collaborators ALTER COLUMN id SET DEFAULT nextval('public.channel_buffer_collaborators_id_seq'::regclass);
495
496ALTER TABLE ONLY public.channel_chat_participants ALTER COLUMN id SET DEFAULT nextval('public.channel_chat_participants_id_seq'::regclass);
497
498ALTER TABLE ONLY public.channel_members ALTER COLUMN id SET DEFAULT nextval('public.channel_members_id_seq'::regclass);
499
500ALTER TABLE ONLY public.channels ALTER COLUMN id SET DEFAULT nextval('public.channels_id_seq'::regclass);
501
502ALTER TABLE ONLY public.contacts ALTER COLUMN id SET DEFAULT nextval('public.contacts_id_seq'::regclass);
503
504ALTER TABLE ONLY public.extensions ALTER COLUMN id SET DEFAULT nextval('public.extensions_id_seq'::regclass);
505
506ALTER TABLE ONLY public.followers ALTER COLUMN id SET DEFAULT nextval('public.followers_id_seq'::regclass);
507
508ALTER TABLE ONLY public.notification_kinds ALTER COLUMN id SET DEFAULT nextval('public.notification_kinds_id_seq'::regclass);
509
510ALTER TABLE ONLY public.notifications ALTER COLUMN id SET DEFAULT nextval('public.notifications_id_seq'::regclass);
511
512ALTER TABLE ONLY public.project_collaborators ALTER COLUMN id SET DEFAULT nextval('public.project_collaborators_id_seq'::regclass);
513
514ALTER TABLE ONLY public.projects ALTER COLUMN id SET DEFAULT nextval('public.projects_id_seq'::regclass);
515
516ALTER TABLE ONLY public.room_participants ALTER COLUMN id SET DEFAULT nextval('public.room_participants_id_seq'::regclass);
517
518ALTER TABLE ONLY public.rooms ALTER COLUMN id SET DEFAULT nextval('public.rooms_id_seq'::regclass);
519
520ALTER TABLE ONLY public.servers ALTER COLUMN id SET DEFAULT nextval('public.servers_id_seq'::regclass);
521
522ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);
523
524ALTER TABLE ONLY public.breakpoints
525    ADD CONSTRAINT breakpoints_pkey PRIMARY KEY (id);
526
527ALTER TABLE ONLY public.buffer_operations
528    ADD CONSTRAINT buffer_operations_pkey PRIMARY KEY (buffer_id, epoch, lamport_timestamp, replica_id);
529
530ALTER TABLE ONLY public.buffer_snapshots
531    ADD CONSTRAINT buffer_snapshots_pkey PRIMARY KEY (buffer_id, epoch);
532
533ALTER TABLE ONLY public.buffers
534    ADD CONSTRAINT buffers_pkey PRIMARY KEY (id);
535
536ALTER TABLE ONLY public.channel_buffer_collaborators
537    ADD CONSTRAINT channel_buffer_collaborators_pkey PRIMARY KEY (id);
538
539ALTER TABLE ONLY public.channel_chat_participants
540    ADD CONSTRAINT channel_chat_participants_pkey PRIMARY KEY (id);
541
542ALTER TABLE ONLY public.channel_members
543    ADD CONSTRAINT channel_members_pkey PRIMARY KEY (id);
544
545ALTER TABLE ONLY public.channels
546    ADD CONSTRAINT channels_pkey PRIMARY KEY (id);
547
548ALTER TABLE ONLY public.contacts
549    ADD CONSTRAINT contacts_pkey PRIMARY KEY (id);
550
551ALTER TABLE ONLY public.contributors
552    ADD CONSTRAINT contributors_pkey PRIMARY KEY (user_id);
553
554ALTER TABLE ONLY public.extension_versions
555    ADD CONSTRAINT extension_versions_pkey PRIMARY KEY (extension_id, version);
556
557ALTER TABLE ONLY public.extensions
558    ADD CONSTRAINT extensions_pkey PRIMARY KEY (id);
559
560ALTER TABLE ONLY public.followers
561    ADD CONSTRAINT followers_pkey PRIMARY KEY (id);
562
563ALTER TABLE ONLY public.language_servers
564    ADD CONSTRAINT language_servers_pkey PRIMARY KEY (project_id, id);
565
566ALTER TABLE ONLY public.notification_kinds
567    ADD CONSTRAINT notification_kinds_pkey PRIMARY KEY (id);
568
569ALTER TABLE ONLY public.notifications
570    ADD CONSTRAINT notifications_pkey PRIMARY KEY (id);
571
572ALTER TABLE ONLY public.observed_buffer_edits
573    ADD CONSTRAINT observed_buffer_edits_pkey PRIMARY KEY (user_id, buffer_id);
574
575ALTER TABLE ONLY public.project_collaborators
576    ADD CONSTRAINT project_collaborators_pkey PRIMARY KEY (id);
577
578ALTER TABLE ONLY public.project_repositories
579    ADD CONSTRAINT project_repositories_pkey PRIMARY KEY (project_id, id);
580
581ALTER TABLE ONLY public.project_repository_statuses
582    ADD CONSTRAINT project_repository_statuses_pkey PRIMARY KEY (project_id, repository_id, repo_path);
583
584ALTER TABLE ONLY public.projects
585    ADD CONSTRAINT projects_pkey PRIMARY KEY (id);
586
587ALTER TABLE ONLY public.room_participants
588    ADD CONSTRAINT room_participants_pkey PRIMARY KEY (id);
589
590ALTER TABLE ONLY public.rooms
591    ADD CONSTRAINT rooms_pkey PRIMARY KEY (id);
592
593ALTER TABLE ONLY public.servers
594    ADD CONSTRAINT servers_pkey PRIMARY KEY (id);
595
596ALTER TABLE ONLY public.shared_threads
597    ADD CONSTRAINT shared_threads_pkey PRIMARY KEY (id);
598
599ALTER TABLE ONLY public.users
600    ADD CONSTRAINT users_pkey PRIMARY KEY (id);
601
602ALTER TABLE ONLY public.worktree_diagnostic_summaries
603    ADD CONSTRAINT worktree_diagnostic_summaries_pkey PRIMARY KEY (project_id, worktree_id, path);
604
605ALTER TABLE ONLY public.worktree_entries
606    ADD CONSTRAINT worktree_entries_pkey PRIMARY KEY (project_id, worktree_id, id);
607
608ALTER TABLE ONLY public.worktree_settings_files
609    ADD CONSTRAINT worktree_settings_files_pkey PRIMARY KEY (project_id, worktree_id, path);
610
611ALTER TABLE ONLY public.worktrees
612    ADD CONSTRAINT worktrees_pkey PRIMARY KEY (project_id, id);
613
614CREATE INDEX idx_shared_threads_user_id ON public.shared_threads USING btree (user_id);
615
616CREATE INDEX index_breakpoints_on_project_id ON public.breakpoints USING btree (project_id);
617
618CREATE INDEX index_buffers_on_channel_id ON public.buffers USING btree (channel_id);
619
620CREATE INDEX index_channel_buffer_collaborators_on_channel_id ON public.channel_buffer_collaborators USING btree (channel_id);
621
622CREATE UNIQUE INDEX index_channel_buffer_collaborators_on_channel_id_and_replica_id ON public.channel_buffer_collaborators USING btree (channel_id, replica_id);
623
624CREATE 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);
625
626CREATE INDEX index_channel_buffer_collaborators_on_connection_id ON public.channel_buffer_collaborators USING btree (connection_id);
627
628CREATE INDEX index_channel_buffer_collaborators_on_connection_server_id ON public.channel_buffer_collaborators USING btree (connection_server_id);
629
630CREATE INDEX index_channel_chat_participants_on_channel_id ON public.channel_chat_participants USING btree (channel_id);
631
632CREATE UNIQUE INDEX index_channel_members_on_channel_id_and_user_id ON public.channel_members USING btree (channel_id, user_id);
633
634CREATE INDEX index_channels_on_parent_path ON public.channels USING btree (parent_path text_pattern_ops);
635
636CREATE INDEX index_channels_on_parent_path_and_order ON public.channels USING btree (parent_path, channel_order);
637
638CREATE INDEX index_contacts_user_id_b ON public.contacts USING btree (user_id_b);
639
640CREATE UNIQUE INDEX index_contacts_user_ids ON public.contacts USING btree (user_id_a, user_id_b);
641
642CREATE UNIQUE INDEX index_extensions_external_id ON public.extensions USING btree (external_id);
643
644CREATE INDEX index_extensions_total_download_count ON public.extensions USING btree (total_download_count);
645
646CREATE 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);
647
648CREATE INDEX index_followers_on_room_id ON public.followers USING btree (room_id);
649
650CREATE INDEX index_language_servers_on_project_id ON public.language_servers USING btree (project_id);
651
652CREATE UNIQUE INDEX index_notification_kinds_on_name ON public.notification_kinds USING btree (name);
653
654CREATE INDEX index_notifications_on_recipient_id_is_read_kind_entity_id ON public.notifications USING btree (recipient_id, is_read, kind, entity_id);
655
656CREATE UNIQUE INDEX index_observed_buffer_user_and_buffer_id ON public.observed_buffer_edits USING btree (user_id, buffer_id);
657
658CREATE INDEX index_project_collaborators_on_connection_id ON public.project_collaborators USING btree (connection_id);
659
660CREATE INDEX index_project_collaborators_on_connection_server_id ON public.project_collaborators USING btree (connection_server_id);
661
662CREATE INDEX index_project_collaborators_on_project_id ON public.project_collaborators USING btree (project_id);
663
664CREATE UNIQUE INDEX index_project_collaborators_on_project_id_and_replica_id ON public.project_collaborators USING btree (project_id, replica_id);
665
666CREATE 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);
667
668CREATE INDEX index_project_repos_statuses_on_project_id ON public.project_repository_statuses USING btree (project_id);
669
670CREATE INDEX index_project_repos_statuses_on_project_id_and_repo_id ON public.project_repository_statuses USING btree (project_id, repository_id);
671
672CREATE INDEX index_project_repositories_on_project_id ON public.project_repositories USING btree (project_id);
673
674CREATE INDEX index_projects_on_host_connection_id_and_host_connection_server ON public.projects USING btree (host_connection_id, host_connection_server_id);
675
676CREATE INDEX index_projects_on_host_connection_server_id ON public.projects USING btree (host_connection_server_id);
677
678CREATE INDEX index_room_participants_on_answering_connection_id ON public.room_participants USING btree (answering_connection_id);
679
680CREATE UNIQUE INDEX index_room_participants_on_answering_connection_id_and_answerin ON public.room_participants USING btree (answering_connection_id, answering_connection_server_id);
681
682CREATE INDEX index_room_participants_on_answering_connection_server_id ON public.room_participants USING btree (answering_connection_server_id);
683
684CREATE INDEX index_room_participants_on_calling_connection_server_id ON public.room_participants USING btree (calling_connection_server_id);
685
686CREATE INDEX index_room_participants_on_room_id ON public.room_participants USING btree (room_id);
687
688CREATE UNIQUE INDEX index_room_participants_on_user_id ON public.room_participants USING btree (user_id);
689
690CREATE UNIQUE INDEX index_rooms_on_channel_id ON public.rooms USING btree (channel_id);
691
692CREATE INDEX index_settings_files_on_project_id ON public.worktree_settings_files USING btree (project_id);
693
694CREATE INDEX index_settings_files_on_project_id_and_wt_id ON public.worktree_settings_files USING btree (project_id, worktree_id);
695
696CREATE UNIQUE INDEX index_users_github_login ON public.users USING btree (github_login);
697
698CREATE INDEX index_users_on_email_address ON public.users USING btree (email_address);
699
700CREATE INDEX index_worktree_diagnostic_summaries_on_project_id ON public.worktree_diagnostic_summaries USING btree (project_id);
701
702CREATE INDEX index_worktree_diagnostic_summaries_on_project_id_and_worktree_ ON public.worktree_diagnostic_summaries USING btree (project_id, worktree_id);
703
704CREATE INDEX index_worktree_entries_on_project_id ON public.worktree_entries USING btree (project_id);
705
706CREATE INDEX index_worktree_entries_on_project_id_and_worktree_id ON public.worktree_entries USING btree (project_id, worktree_id);
707
708CREATE INDEX index_worktrees_on_project_id ON public.worktrees USING btree (project_id);
709
710CREATE INDEX trigram_index_extensions_name ON public.extensions USING gin (name public.gin_trgm_ops);
711
712CREATE INDEX trigram_index_users_on_github_login ON public.users USING gin (github_login public.gin_trgm_ops);
713
714CREATE INDEX trigram_index_users_on_name ON public.users USING gin (name public.gin_trgm_ops);
715
716CREATE 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));
717
718CREATE UNIQUE INDEX uix_users_on_github_user_id ON public.users USING btree (github_user_id);
719
720ALTER TABLE ONLY public.breakpoints
721    ADD CONSTRAINT breakpoints_project_id_fkey FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
722
723ALTER TABLE ONLY public.buffer_operations
724    ADD CONSTRAINT buffer_operations_buffer_id_fkey FOREIGN KEY (buffer_id) REFERENCES public.buffers(id) ON DELETE CASCADE;
725
726ALTER TABLE ONLY public.buffer_snapshots
727    ADD CONSTRAINT buffer_snapshots_buffer_id_fkey FOREIGN KEY (buffer_id) REFERENCES public.buffers(id) ON DELETE CASCADE;
728
729ALTER TABLE ONLY public.buffers
730    ADD CONSTRAINT buffers_channel_id_fkey FOREIGN KEY (channel_id) REFERENCES public.channels(id) ON DELETE CASCADE;
731
732ALTER TABLE ONLY public.channel_buffer_collaborators
733    ADD CONSTRAINT channel_buffer_collaborators_channel_id_fkey FOREIGN KEY (channel_id) REFERENCES public.channels(id) ON DELETE CASCADE;
734
735ALTER TABLE ONLY public.channel_buffer_collaborators
736    ADD CONSTRAINT channel_buffer_collaborators_connection_server_id_fkey FOREIGN KEY (connection_server_id) REFERENCES public.servers(id) ON DELETE CASCADE;
737
738ALTER TABLE ONLY public.channel_buffer_collaborators
739    ADD CONSTRAINT channel_buffer_collaborators_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
740
741ALTER TABLE ONLY public.channel_chat_participants
742    ADD CONSTRAINT channel_chat_participants_channel_id_fkey FOREIGN KEY (channel_id) REFERENCES public.channels(id) ON DELETE CASCADE;
743
744ALTER TABLE ONLY public.channel_chat_participants
745    ADD CONSTRAINT channel_chat_participants_connection_server_id_fkey FOREIGN KEY (connection_server_id) REFERENCES public.servers(id) ON DELETE CASCADE;
746
747ALTER TABLE ONLY public.channel_chat_participants
748    ADD CONSTRAINT channel_chat_participants_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
749
750ALTER TABLE ONLY public.channel_members
751    ADD CONSTRAINT channel_members_channel_id_fkey FOREIGN KEY (channel_id) REFERENCES public.channels(id) ON DELETE CASCADE;
752
753ALTER TABLE ONLY public.channel_members
754    ADD CONSTRAINT channel_members_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
755
756ALTER TABLE ONLY public.contacts
757    ADD CONSTRAINT contacts_user_id_a_fkey FOREIGN KEY (user_id_a) REFERENCES public.users(id) ON DELETE CASCADE;
758
759ALTER TABLE ONLY public.contacts
760    ADD CONSTRAINT contacts_user_id_b_fkey FOREIGN KEY (user_id_b) REFERENCES public.users(id) ON DELETE CASCADE;
761
762ALTER TABLE ONLY public.contributors
763    ADD CONSTRAINT contributors_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
764
765ALTER TABLE ONLY public.extension_versions
766    ADD CONSTRAINT extension_versions_extension_id_fkey FOREIGN KEY (extension_id) REFERENCES public.extensions(id);
767
768ALTER TABLE ONLY public.project_repositories
769    ADD CONSTRAINT fk_project_repositories_project_id FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
770
771ALTER TABLE ONLY public.project_repository_statuses
772    ADD CONSTRAINT fk_project_repository_statuses_project_id FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
773
774ALTER TABLE ONLY public.followers
775    ADD CONSTRAINT followers_follower_connection_server_id_fkey FOREIGN KEY (follower_connection_server_id) REFERENCES public.servers(id) ON DELETE CASCADE;
776
777ALTER TABLE ONLY public.followers
778    ADD CONSTRAINT followers_leader_connection_server_id_fkey FOREIGN KEY (leader_connection_server_id) REFERENCES public.servers(id) ON DELETE CASCADE;
779
780ALTER TABLE ONLY public.followers
781    ADD CONSTRAINT followers_project_id_fkey FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
782
783ALTER TABLE ONLY public.followers
784    ADD CONSTRAINT followers_room_id_fkey FOREIGN KEY (room_id) REFERENCES public.rooms(id) ON DELETE CASCADE;
785
786ALTER TABLE ONLY public.language_servers
787    ADD CONSTRAINT language_servers_project_id_fkey FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
788
789ALTER TABLE ONLY public.notifications
790    ADD CONSTRAINT notifications_kind_fkey FOREIGN KEY (kind) REFERENCES public.notification_kinds(id);
791
792ALTER TABLE ONLY public.notifications
793    ADD CONSTRAINT notifications_recipient_id_fkey FOREIGN KEY (recipient_id) REFERENCES public.users(id) ON DELETE CASCADE;
794
795ALTER TABLE ONLY public.observed_buffer_edits
796    ADD CONSTRAINT observed_buffer_edits_buffer_id_fkey FOREIGN KEY (buffer_id) REFERENCES public.buffers(id) ON DELETE CASCADE;
797
798ALTER TABLE ONLY public.observed_buffer_edits
799    ADD CONSTRAINT observed_buffer_edits_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
800
801ALTER TABLE ONLY public.project_collaborators
802    ADD CONSTRAINT project_collaborators_connection_server_id_fkey FOREIGN KEY (connection_server_id) REFERENCES public.servers(id) ON DELETE CASCADE;
803
804ALTER TABLE ONLY public.project_collaborators
805    ADD CONSTRAINT project_collaborators_project_id_fkey FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
806
807ALTER TABLE ONLY public.projects
808    ADD CONSTRAINT projects_host_connection_server_id_fkey FOREIGN KEY (host_connection_server_id) REFERENCES public.servers(id) ON DELETE CASCADE;
809
810ALTER TABLE ONLY public.projects
811    ADD CONSTRAINT projects_host_user_id_fkey FOREIGN KEY (host_user_id) REFERENCES public.users(id);
812
813ALTER TABLE ONLY public.projects
814    ADD CONSTRAINT projects_room_id_fkey FOREIGN KEY (room_id) REFERENCES public.rooms(id) ON DELETE CASCADE;
815
816ALTER TABLE ONLY public.room_participants
817    ADD CONSTRAINT room_participants_answering_connection_server_id_fkey FOREIGN KEY (answering_connection_server_id) REFERENCES public.servers(id) ON DELETE CASCADE;
818
819ALTER TABLE ONLY public.room_participants
820    ADD CONSTRAINT room_participants_calling_connection_server_id_fkey FOREIGN KEY (calling_connection_server_id) REFERENCES public.servers(id) ON DELETE SET NULL;
821
822ALTER TABLE ONLY public.room_participants
823    ADD CONSTRAINT room_participants_calling_user_id_fkey FOREIGN KEY (calling_user_id) REFERENCES public.users(id);
824
825ALTER TABLE ONLY public.room_participants
826    ADD CONSTRAINT room_participants_room_id_fkey FOREIGN KEY (room_id) REFERENCES public.rooms(id);
827
828ALTER TABLE ONLY public.room_participants
829    ADD CONSTRAINT room_participants_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
830
831ALTER TABLE ONLY public.rooms
832    ADD CONSTRAINT rooms_channel_id_fkey FOREIGN KEY (channel_id) REFERENCES public.channels(id) ON DELETE CASCADE;
833
834ALTER TABLE ONLY public.shared_threads
835    ADD CONSTRAINT shared_threads_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
836
837ALTER TABLE ONLY public.worktree_diagnostic_summaries
838    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;
839
840ALTER TABLE ONLY public.worktree_entries
841    ADD CONSTRAINT worktree_entries_project_id_worktree_id_fkey FOREIGN KEY (project_id, worktree_id) REFERENCES public.worktrees(project_id, id) ON DELETE CASCADE;
842
843ALTER TABLE ONLY public.worktree_settings_files
844    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;
845
846ALTER TABLE ONLY public.worktrees
847    ADD CONSTRAINT worktrees_project_id_fkey FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;