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