Cargo.lock π
@@ -5799,6 +5799,7 @@ dependencies = [
"gpui",
"heck 0.5.0",
"http_client",
+ "indoc",
"language",
"log",
"lsp",
Richard Feldman created
Cargo.lock | 1
Dockerfile-collab | 4
crates/collab/README.md | 12
crates/collab/k8s/migrate.template.yml | 21
crates/collab/migrations/20210527024318_initial_schema.sql | 20
crates/collab/migrations/20210607190313_create_access_tokens.sql | 7
crates/collab/migrations/20210805175147_create_chat_tables.sql | 46
crates/collab/migrations/20210916123647_add_nonce_to_channel_messages.sql | 4
crates/collab/migrations/20210920192001_add_interests_to_signups.sql | 4
crates/collab/migrations/20220421165757_drop_signups.sql | 1
crates/collab/migrations/20220505144506_add_trigram_index_to_users.sql | 2
crates/collab/migrations/20220506130724_create_contacts.sql | 11
crates/collab/migrations/20220518151305_add_invites_to_users.sql | 9
crates/collab/migrations/20220523232954_allow_user_deletes.sql | 6
crates/collab/migrations/20220620211403_create_projects.sql | 24
crates/collab/migrations/20220913211150_create_signups.sql | 27
crates/collab/migrations/20220929182110_add_metrics_id.sql | 2
crates/collab/migrations/20221111092550_reconnection_support.sql | 90
crates/collab/migrations/20221125192125_add_added_to_mailing_list_to_signups.sql | 2
crates/collab/migrations/20221207165001_add_connection_lost_to_room_participants.sql | 7
crates/collab/migrations/20221213125710_index_room_participants_on_room_id.sql | 1
crates/collab/migrations/20221214144346_change_epoch_from_uuid_to_integer.sql | 30
crates/collab/migrations/20221219181850_project_reconnection_support.sql | 3
crates/collab/migrations/20230103200902_replace_is_completed_with_completed_scan_id.sql | 3
crates/collab/migrations/20230202155735_followers.sql | 15
crates/collab/migrations/20230508211523_add-repository-entries.sql | 13
crates/collab/migrations/20230511004019_add_repository_statuses.sql | 15
crates/collab/migrations/20230529164700_add_worktree_settings_files.sql | 10
crates/collab/migrations/20230605191135_remove_repository_statuses.sql | 2
crates/collab/migrations/20230616134535_add_is_external_to_worktree_entries.sql | 2
crates/collab/migrations/20230727150500_add_channels.sql | 30
crates/collab/migrations/20230819154600_add_channel_buffers.sql | 40
crates/collab/migrations/20230825190322_add_server_feature_flags.sql | 16
crates/collab/migrations/20230907114200_add_channel_messages.sql | 19
crates/collab/migrations/20230925210437_add_channel_changes.sql | 19
crates/collab/migrations/20230926102500_add_participant_index_to_room_participants.sql | 1
crates/collab/migrations/20231004130100_create_notifications.sql | 22
crates/collab/migrations/20231009181554_add_release_channel_to_rooms.sql | 1
crates/collab/migrations/20231010114600_add_unique_index_on_rooms_channel_id.sql | 1
crates/collab/migrations/20231011214412_add_guest_role.sql | 4
crates/collab/migrations/20231017185833_projects_room_id_fkey_on_delete_cascade.sql | 8
crates/collab/migrations/20231018102700_create_mentions.sql | 11
crates/collab/migrations/20231024085546_move_channel_paths_to_channels_table.sql | 12
crates/collab/migrations/20240103025509_add_role_to_room_participants.sql | 1
crates/collab/migrations/20240111085546_fix_column_name.sql | 1
crates/collab/migrations/20240117150300_add_impersonator_to_access_tokens.sql | 1
crates/collab/migrations/20240122174606_add_contributors.sql | 5
crates/collab/migrations/20240122224506_add_requires_zed_cla_column_to_channels.sql | 1
crates/collab/migrations/20240129193601_fix_parent_path_index.sql | 4
crates/collab/migrations/20240203113741_add_reply_to_message.sql | 1
crates/collab/migrations/20240207041417_add_in_call_column_to_room_participants.sql | 3
crates/collab/migrations/20240213200201_remove_unused_room_columns.sql | 4
crates/collab/migrations/20240214102900_add_extensions.sql | 22
crates/collab/migrations/20240220234826_add_rate_buckets.sql | 11
crates/collab/migrations/20240221151017_add_edited_at_field_to_channel_message.sql | 1
crates/collab/migrations/20240226163408_hosted_projects.sql | 11
crates/collab/migrations/20240226164505_unique_channel_names.sql | 3
crates/collab/migrations/20240227215556_hosted_projects_in_projects.sql | 3
crates/collab/migrations/20240307163119_denormalize_buffer_ops.sql | 17
crates/collab/migrations/20240315182903_non_null_channel_role.sql | 4
crates/collab/migrations/20240315183903_channel_parent_path_not_null.sql | 2
crates/collab/migrations/20240320124800_add_extension_schema_version.sql | 2
crates/collab/migrations/20240321162658_add_devservers.sql | 7
crates/collab/migrations/20240335123500_add_extension_wasm_api_version.sql | 1
crates/collab/migrations/20240402155003_add_dev_server_projects.sql | 9
crates/collab/migrations/20240409082755_create_embeddings.sql | 9
crates/collab/migrations/20240412165156_dev_servers_per_user.sql | 7
crates/collab/migrations/20240417192746_unique_remote_projects_by_paths.sql | 3
crates/collab/migrations/20240502150229_rename_to_dev_server_projects.sql | 11
crates/collab/migrations/20240502180204_remove_old_remote_projects.sql | 2
crates/collab/migrations/20240514164510_store_ssh_connect_string.sql | 1
crates/collab/migrations/20240715230940_add_worktrees_to_dev_server_projects.sql | 4
crates/collab/migrations/20240729170526_add_billing_subscription.sql | 12
crates/collab/migrations/20240730014107_add_billing_customer.sql | 18
crates/collab/migrations/20240730122654_add_last_stripe_event_id.sql | 2
crates/collab/migrations/20240730182554_add_processed_stripe_events.sql | 11
crates/collab/migrations/20240731120800_add_stripe_cancel_at_to_billing_subscriptions.sql | 1
crates/collab/migrations/20240812073542_add_accepted_tos_at.sql | 1
crates/collab/migrations/20240812204045_add_github_user_created_at_to_users.sql | 1
crates/collab/migrations/20240816181658_add_enabled_for_all_to_feature_flags.sql | 1
crates/collab/migrations/20240822215737_add_unique_constraint_on_github_user_id_on_users.sql | 4
crates/collab/migrations/20240823155956_add_is_fifo_to_worktree_entries.sql | 2
crates/collab/migrations/20241002120231_add_local_settings_kind.sql | 1
crates/collab/migrations/20241009190639_add_billing_preferences.sql | 8
crates/collab/migrations/20241019184824_adjust_symlink_data.sql | 2
crates/collab/migrations/20241021202606_add_custom_llm_monthly_allowance_in_cents_to_users.sql | 1
crates/collab/migrations/20241023201725_remove_dev_servers.sql | 6
crates/collab/migrations/20241121185750_add_breakpoints.sql | 11
crates/collab/migrations/20250108184547_add_stripe_cancellation_reason_to_billing_subscriptions.sql | 2
crates/collab/migrations/20250113230049_expand_git_status_information.sql | 13
crates/collab/migrations/20250117100620_add_user_name.sql | 1
crates/collab/migrations/20250204224004_add_has_overdue_invoices_to_billing_customers.sql | 2
crates/collab/migrations/20250205192813_add_provides_fields_to_extension_versions.sql | 10
crates/collab/migrations/20250205232017_add_conflicts_to_repositories.sql | 2
crates/collab/migrations/20250210223746_add_branch_summary.sql | 2
crates/collab/migrations/20250212060936_add_worktree_branch_summary.sql | 1
crates/collab/migrations/20250319182812_create_project_repositories.sql | 32
crates/collab/migrations/20250415164141_add_kind_and_period_to_billing_subscriptions.sql | 4
crates/collab/migrations/20250422194500_add_trial_started_at_to_billing_customers.sql | 2
crates/collab/migrations/20250423150129_add_head_commit_details_to_project_repositories.sql | 2
crates/collab/migrations/20250425201930_add_model_request_overages_to_billing_preferences.sql | 3
crates/collab/migrations/20250530175450_add_channel_order.sql | 16
crates/collab/migrations/20250612153105_add_collaborator_commit_email.sql | 4
crates/collab/migrations/20250617082236_add_debug_adapter_provides_field_to_extensions.sql | 2
crates/collab/migrations/20250618090000_add_agent_servers_provides_field_to_extensions.sql | 2
crates/collab/migrations/20250702185129_add_cascading_delete_to_repository_entries.sql | 25
crates/collab/migrations/20250707182700_add_access_tokens_cascade_delete_on_user.sql | 3
crates/collab/migrations/20250804080620_language_server_capabilities.sql | 5
crates/collab/migrations/20250816124707_make_admin_required_on_users.sql | 2
crates/collab/migrations/20250816133027_add_orb_customer_id_to_billing_customers.sql | 2
crates/collab/migrations/20250816135346_drop_rate_buckets_table.sql | 1
crates/collab/migrations/20250818192156_add_git_merge_message.sql | 1
crates/collab/migrations/20250819022421_add_orb_subscription_id_to_billing_subscriptions.sql | 2
crates/collab/migrations/20250819225916_make_stripe_fields_optional_on_billing_subscription.sql | 3
crates/collab/migrations/20250821133754_add_orb_subscription_status_and_period_to_billing_subscriptions.sql | 4
crates/collab/migrations/20250827084812_worktree_in_servers.sql | 2
crates/collab/migrations/20250913035238_add_orb_cancellation_date_to_billing_subscriptions.sql | 2
crates/collab/migrations/20250914022147_add_orb_portal_url_to_billing_customers.sql | 2
crates/collab/migrations/20250916173002_add_path_style_to_project.sql | 1
crates/collab/migrations/20251002214229_add_token_spend_in_cents_to_billing_subscriptions.sql | 3
crates/collab/migrations/20251008120000_add_is_hidden_to_worktree_entries.sql | 2
crates/collab/migrations/20251110214057_drop_channel_messages.sql | 3
crates/collab/migrations/20251111161644_drop_embeddings.sql | 1
crates/collab/migrations/20251117215316_add_external_id_to_billing_customers.sql | 4
crates/collab/migrations/20251203234258_add_remote_urls_to_project_repositories.sql | 2
crates/collab/migrations/20251208000000_test_schema.sql | 899
crates/collab/migrations_llm/20240806182921_create_providers_and_models.sql | 19
crates/collab/migrations_llm/20240806213401_create_usages.sql | 19
crates/collab/migrations_llm/20240809130000_change_rate_limit_columns_to_bigint.sql | 4
crates/collab/migrations_llm/20240809160000_add_pricing_columns_to_models.sql | 3
crates/collab/migrations_llm/20240812184444_add_is_staff_to_usages.sql | 1
crates/collab/migrations_llm/20240812225346_create_lifetime_usages.sql | 9
crates/collab/migrations_llm/20240813002237_add_revoked_access_tokens_table.sql | 7
crates/collab/migrations_llm/20241007173634_add_cache_token_counts.sql | 11
crates/collab/migrations_llm/20241007220716_drop_incorrect_usages_columns.sql | 3
crates/collab/migrations_llm/20241008155620_create_monthly_usages.sql | 13
crates/collab/migrations_llm/20241010151249_create_billing_events.sql | 12
crates/collab/migrations_llm/20250404141155_add_granular_token_limits_to_models.sql | 3
crates/collab/migrations_llm/20250415213005_add_subscription_usages.sql | 10
crates/collab/migrations_llm/20250416181354_add_plan_to_subscription_usages.sql | 4
crates/collab/migrations_llm/20250425171838_add_subscription_usage_meters.sql | 8
crates/collab/migrations_llm/20250429143553_add_mode_to_subscription_usage_meters.sql | 6
crates/collab/migrations_llm/20250503162708_add_v2_subscription_usage_and_meter_tables.sql | 23
crates/collab/migrations_llm/20250504132836_drop_legacy_subscription_usage_and_meter_tables.sql | 2
crates/collab/migrations_llm/20250521211721_drop_monthly_and_lifetime_usages_tables.sql | 2
crates/collab/migrations_llm/20250521222416_drop_billing_events_table.sql | 1
crates/collab/src/db/tables.rs | 1
crates/collab/src/db/tables/signup.rs | 28
crates/collab/src/db/tests.rs | 17
crates/collab/src/db/tests/migrations.rs | 0
crates/collab/src/lib.rs | 2
crates/collab/src/llm.rs | 1
crates/collab/src/llm/db.rs | 98
crates/collab/src/main.rs | 62
crates/collab_ui/src/collab_panel.rs | 18
crates/editor/src/actions.rs | 17
crates/editor/src/editor.rs | 48
crates/editor/src/editor_tests.rs | 76
crates/editor/src/element.rs | 1
crates/extension/Cargo.toml | 3
crates/extension/src/extension_builder.rs | 169
crates/extension_cli/src/main.rs | 1
crates/extension_host/benches/extension_compilation_benchmark.rs | 11
crates/extension_host/src/extension_host.rs | 5
crates/languages/src/typescript.rs | 54
crates/snippet_provider/src/lib.rs | 2
crates/title_bar/src/collab.rs | 26
crates/title_bar/src/title_bar.rs | 2
crates/util/src/rel_path.rs | 7
script/create-migration | 3
typos.toml | 12
171 files changed, 1,259 insertions(+), 1,445 deletions(-)
@@ -5799,6 +5799,7 @@ dependencies = [
"gpui",
"heck 0.5.0",
"http_client",
+ "indoc",
"language",
"log",
"lsp",
@@ -34,8 +34,4 @@ RUN apt-get update; \
linux-perf binutils
WORKDIR app
COPY --from=builder /app/collab /app/collab
-COPY --from=builder /app/crates/collab/migrations /app/migrations
-COPY --from=builder /app/crates/collab/migrations_llm /app/migrations_llm
-ENV MIGRATIONS_PATH=/app/migrations
-ENV LLM_DATABASE_MIGRATIONS_PATH=/app/migrations_llm
ENTRYPOINT ["/app/collab"]
@@ -63,15 +63,3 @@ Deployment is triggered by pushing to the `collab-staging` (or `collab-productio
- `./script/deploy-collab production`
You can tell what is currently deployed with `./script/what-is-deployed`.
-
-# Database Migrations
-
-To create a new migration:
-
-```sh
-./script/create-migration <name>
-```
-
-Migrations are run automatically on service start, so run `foreman start` again. The service will crash if the migrations fail.
-
-When you create a new migration, you also need to update the [SQLite schema](./migrations.sqlite/20221109000000_test_schema.sql) that is used for testing.
@@ -1,21 +0,0 @@
-apiVersion: batch/v1
-kind: Job
-metadata:
- namespace: ${ZED_KUBE_NAMESPACE}
- name: ${ZED_MIGRATE_JOB_NAME}
-spec:
- template:
- spec:
- restartPolicy: Never
- containers:
- - name: migrator
- imagePullPolicy: Always
- image: ${ZED_IMAGE_ID}
- args:
- - migrate
- env:
- - name: DATABASE_URL
- valueFrom:
- secretKeyRef:
- name: database
- key: url
@@ -1,20 +0,0 @@
-CREATE TABLE IF NOT EXISTS "sessions" (
- "id" VARCHAR NOT NULL PRIMARY KEY,
- "expires" TIMESTAMP WITH TIME ZONE NULL,
- "session" TEXT NOT NULL
-);
-
-CREATE TABLE IF NOT EXISTS "users" (
- "id" SERIAL PRIMARY KEY,
- "github_login" VARCHAR,
- "admin" BOOLEAN
-);
-
-CREATE UNIQUE INDEX "index_users_github_login" ON "users" ("github_login");
-
-CREATE TABLE IF NOT EXISTS "signups" (
- "id" SERIAL PRIMARY KEY,
- "github_login" VARCHAR,
- "email_address" VARCHAR,
- "about" TEXT
-);
@@ -1,7 +0,0 @@
-CREATE TABLE IF NOT EXISTS "access_tokens" (
- "id" SERIAL PRIMARY KEY,
- "user_id" INTEGER REFERENCES users (id),
- "hash" VARCHAR(128)
-);
-
-CREATE INDEX "index_access_tokens_user_id" ON "access_tokens" ("user_id");
@@ -1,46 +0,0 @@
-CREATE TABLE IF NOT EXISTS "orgs" (
- "id" SERIAL PRIMARY KEY,
- "name" VARCHAR NOT NULL,
- "slug" VARCHAR NOT NULL
-);
-
-CREATE UNIQUE INDEX "index_orgs_slug" ON "orgs" ("slug");
-
-CREATE TABLE IF NOT EXISTS "org_memberships" (
- "id" SERIAL PRIMARY KEY,
- "org_id" INTEGER REFERENCES orgs (id) NOT NULL,
- "user_id" INTEGER REFERENCES users (id) NOT NULL,
- "admin" BOOLEAN NOT NULL
-);
-
-CREATE INDEX "index_org_memberships_user_id" ON "org_memberships" ("user_id");
-CREATE UNIQUE INDEX "index_org_memberships_org_id_and_user_id" ON "org_memberships" ("org_id", "user_id");
-
-CREATE TABLE IF NOT EXISTS "channels" (
- "id" SERIAL PRIMARY KEY,
- "owner_id" INTEGER NOT NULL,
- "owner_is_user" BOOLEAN NOT NULL,
- "name" VARCHAR NOT NULL
-);
-
-CREATE UNIQUE INDEX "index_channels_owner_and_name" ON "channels" ("owner_is_user", "owner_id", "name");
-
-CREATE TABLE IF NOT EXISTS "channel_memberships" (
- "id" SERIAL PRIMARY KEY,
- "channel_id" INTEGER REFERENCES channels (id) NOT NULL,
- "user_id" INTEGER REFERENCES users (id) NOT NULL,
- "admin" BOOLEAN NOT NULL
-);
-
-CREATE INDEX "index_channel_memberships_user_id" ON "channel_memberships" ("user_id");
-CREATE UNIQUE INDEX "index_channel_memberships_channel_id_and_user_id" ON "channel_memberships" ("channel_id", "user_id");
-
-CREATE TABLE IF NOT EXISTS "channel_messages" (
- "id" SERIAL PRIMARY KEY,
- "channel_id" INTEGER REFERENCES channels (id) NOT NULL,
- "sender_id" INTEGER REFERENCES users (id) NOT NULL,
- "body" TEXT NOT NULL,
- "sent_at" TIMESTAMP
-);
-
-CREATE INDEX "index_channel_messages_channel_id" ON "channel_messages" ("channel_id");
@@ -1,4 +0,0 @@
-ALTER TABLE "channel_messages"
-ADD "nonce" UUID NOT NULL DEFAULT gen_random_uuid();
-
-CREATE UNIQUE INDEX "index_channel_messages_nonce" ON "channel_messages" ("nonce");
@@ -1,4 +0,0 @@
-ALTER TABLE "signups"
- ADD "wants_releases" BOOLEAN,
- ADD "wants_updates" BOOLEAN,
- ADD "wants_community" BOOLEAN;
@@ -1 +0,0 @@
-DROP TABLE IF EXISTS "signups";
@@ -1,2 +0,0 @@
-CREATE EXTENSION IF NOT EXISTS pg_trgm;
-CREATE INDEX trigram_index_users_on_github_login ON users USING GIN(github_login gin_trgm_ops);
@@ -1,11 +0,0 @@
-CREATE TABLE IF NOT EXISTS "contacts" (
- "id" SERIAL PRIMARY KEY,
- "user_id_a" INTEGER REFERENCES users (id) NOT NULL,
- "user_id_b" INTEGER REFERENCES users (id) NOT NULL,
- "a_to_b" BOOLEAN NOT NULL,
- "should_notify" BOOLEAN NOT NULL,
- "accepted" BOOLEAN NOT NULL
-);
-
-CREATE UNIQUE INDEX "index_contacts_user_ids" ON "contacts" ("user_id_a", "user_id_b");
-CREATE INDEX "index_contacts_user_id_b" ON "contacts" ("user_id_b");
@@ -1,9 +0,0 @@
-ALTER TABLE users
-ADD email_address VARCHAR(255) DEFAULT NULL,
-ADD invite_code VARCHAR(64),
-ADD invite_count INTEGER NOT NULL DEFAULT 0,
-ADD inviter_id INTEGER REFERENCES users (id),
-ADD connected_once BOOLEAN NOT NULL DEFAULT false,
-ADD created_at TIMESTAMP NOT NULL DEFAULT NOW();
-
-CREATE UNIQUE INDEX "index_invite_code_users" ON "users" ("invite_code");
@@ -1,6 +0,0 @@
-ALTER TABLE contacts DROP CONSTRAINT contacts_user_id_a_fkey;
-ALTER TABLE contacts DROP CONSTRAINT contacts_user_id_b_fkey;
-ALTER TABLE contacts ADD CONSTRAINT contacts_user_id_a_fkey FOREIGN KEY (user_id_a) REFERENCES users(id) ON DELETE CASCADE;
-ALTER TABLE contacts ADD CONSTRAINT contacts_user_id_b_fkey FOREIGN KEY (user_id_b) REFERENCES users(id) ON DELETE CASCADE;
-ALTER TABLE users DROP CONSTRAINT users_inviter_id_fkey;
-ALTER TABLE users ADD CONSTRAINT users_inviter_id_fkey FOREIGN KEY (inviter_id) REFERENCES users(id) ON DELETE SET NULL;
@@ -1,24 +0,0 @@
-CREATE TABLE IF NOT EXISTS "projects" (
- "id" SERIAL PRIMARY KEY,
- "host_user_id" INTEGER REFERENCES users (id) NOT NULL,
- "unregistered" BOOLEAN NOT NULL DEFAULT false
-);
-
-CREATE TABLE IF NOT EXISTS "worktree_extensions" (
- "id" SERIAL PRIMARY KEY,
- "project_id" INTEGER REFERENCES projects (id) NOT NULL,
- "worktree_id" INTEGER NOT NULL,
- "extension" VARCHAR(255),
- "count" INTEGER NOT NULL
-);
-
-CREATE TABLE IF NOT EXISTS "project_activity_periods" (
- "id" SERIAL PRIMARY KEY,
- "duration_millis" INTEGER NOT NULL,
- "ended_at" TIMESTAMP NOT NULL,
- "user_id" INTEGER REFERENCES users (id) NOT NULL,
- "project_id" INTEGER REFERENCES projects (id) NOT NULL
-);
-
-CREATE INDEX "index_project_activity_periods_on_ended_at" ON "project_activity_periods" ("ended_at");
-CREATE UNIQUE INDEX "index_worktree_extensions_on_project_id_and_worktree_id_and_extension" ON "worktree_extensions" ("project_id", "worktree_id", "extension");
@@ -1,27 +0,0 @@
-CREATE TABLE IF NOT EXISTS "signups" (
- "id" SERIAL PRIMARY KEY,
- "email_address" VARCHAR NOT NULL,
- "email_confirmation_code" VARCHAR(64) NOT NULL,
- "email_confirmation_sent" BOOLEAN NOT NULL,
- "created_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "device_id" VARCHAR,
- "user_id" INTEGER REFERENCES users (id) ON DELETE CASCADE,
- "inviting_user_id" INTEGER REFERENCES users (id) ON DELETE SET NULL,
-
- "platform_mac" BOOLEAN NOT NULL,
- "platform_linux" BOOLEAN NOT NULL,
- "platform_windows" BOOLEAN NOT NULL,
- "platform_unknown" BOOLEAN NOT NULL,
-
- "editor_features" VARCHAR[],
- "programming_languages" VARCHAR[]
-);
-
-CREATE UNIQUE INDEX "index_signups_on_email_address" ON "signups" ("email_address");
-CREATE INDEX "index_signups_on_email_confirmation_sent" ON "signups" ("email_confirmation_sent");
-
-ALTER TABLE "users"
- ADD "github_user_id" INTEGER;
-
-CREATE INDEX "index_users_on_email_address" ON "users" ("email_address");
-CREATE INDEX "index_users_on_github_user_id" ON "users" ("github_user_id");
@@ -1,2 +0,0 @@
-ALTER TABLE "users"
- ADD "metrics_id" uuid NOT NULL DEFAULT gen_random_uuid();
@@ -1,90 +0,0 @@
-CREATE TABLE IF NOT EXISTS "rooms" (
- "id" SERIAL PRIMARY KEY,
- "live_kit_room" VARCHAR NOT NULL
-);
-
-ALTER TABLE "projects"
- ADD "room_id" INTEGER REFERENCES rooms (id),
- ADD "host_connection_id" INTEGER,
- ADD "host_connection_epoch" UUID;
-CREATE INDEX "index_projects_on_host_connection_epoch" ON "projects" ("host_connection_epoch");
-
-CREATE TABLE "worktrees" (
- "project_id" INTEGER NOT NULL REFERENCES projects (id) ON DELETE CASCADE,
- "id" INT8 NOT NULL,
- "root_name" VARCHAR NOT NULL,
- "abs_path" VARCHAR NOT NULL,
- "visible" BOOL NOT NULL,
- "scan_id" INT8 NOT NULL,
- "is_complete" BOOL NOT NULL,
- PRIMARY KEY(project_id, id)
-);
-CREATE INDEX "index_worktrees_on_project_id" ON "worktrees" ("project_id");
-
-CREATE TABLE "worktree_entries" (
- "project_id" INTEGER NOT NULL,
- "worktree_id" INT8 NOT NULL,
- "id" INT8 NOT NULL,
- "is_dir" BOOL NOT NULL,
- "path" VARCHAR NOT NULL,
- "inode" INT8 NOT NULL,
- "mtime_seconds" INT8 NOT NULL,
- "mtime_nanos" INTEGER NOT NULL,
- "is_symlink" BOOL NOT NULL,
- "is_ignored" BOOL NOT NULL,
- PRIMARY KEY(project_id, worktree_id, id),
- FOREIGN KEY(project_id, worktree_id) REFERENCES worktrees (project_id, id) ON DELETE CASCADE
-);
-CREATE INDEX "index_worktree_entries_on_project_id" ON "worktree_entries" ("project_id");
-CREATE INDEX "index_worktree_entries_on_project_id_and_worktree_id" ON "worktree_entries" ("project_id", "worktree_id");
-
-CREATE TABLE "worktree_diagnostic_summaries" (
- "project_id" INTEGER NOT NULL,
- "worktree_id" INT8 NOT NULL,
- "path" VARCHAR NOT NULL,
- "language_server_id" INT8 NOT NULL,
- "error_count" INTEGER NOT NULL,
- "warning_count" INTEGER NOT NULL,
- PRIMARY KEY(project_id, worktree_id, path),
- FOREIGN KEY(project_id, worktree_id) REFERENCES worktrees (project_id, id) ON DELETE CASCADE
-);
-CREATE INDEX "index_worktree_diagnostic_summaries_on_project_id" ON "worktree_diagnostic_summaries" ("project_id");
-CREATE INDEX "index_worktree_diagnostic_summaries_on_project_id_and_worktree_id" ON "worktree_diagnostic_summaries" ("project_id", "worktree_id");
-
-CREATE TABLE "language_servers" (
- "project_id" INTEGER NOT NULL REFERENCES projects (id) ON DELETE CASCADE,
- "id" INT8 NOT NULL,
- "name" VARCHAR NOT NULL,
- PRIMARY KEY(project_id, id)
-);
-CREATE INDEX "index_language_servers_on_project_id" ON "language_servers" ("project_id");
-
-CREATE TABLE "project_collaborators" (
- "id" SERIAL PRIMARY KEY,
- "project_id" INTEGER NOT NULL REFERENCES projects (id) ON DELETE CASCADE,
- "connection_id" INTEGER NOT NULL,
- "connection_epoch" UUID NOT NULL,
- "user_id" INTEGER NOT NULL,
- "replica_id" INTEGER NOT NULL,
- "is_host" BOOLEAN NOT NULL
-);
-CREATE INDEX "index_project_collaborators_on_project_id" ON "project_collaborators" ("project_id");
-CREATE UNIQUE INDEX "index_project_collaborators_on_project_id_and_replica_id" ON "project_collaborators" ("project_id", "replica_id");
-CREATE INDEX "index_project_collaborators_on_connection_epoch" ON "project_collaborators" ("connection_epoch");
-
-CREATE TABLE "room_participants" (
- "id" SERIAL PRIMARY KEY,
- "room_id" INTEGER NOT NULL REFERENCES rooms (id),
- "user_id" INTEGER NOT NULL REFERENCES users (id),
- "answering_connection_id" INTEGER,
- "answering_connection_epoch" UUID,
- "location_kind" INTEGER,
- "location_project_id" INTEGER,
- "initial_project_id" INTEGER,
- "calling_user_id" INTEGER NOT NULL REFERENCES users (id),
- "calling_connection_id" INTEGER NOT NULL,
- "calling_connection_epoch" UUID NOT NULL
-);
-CREATE UNIQUE INDEX "index_room_participants_on_user_id" ON "room_participants" ("user_id");
-CREATE INDEX "index_room_participants_on_answering_connection_epoch" ON "room_participants" ("answering_connection_epoch");
-CREATE INDEX "index_room_participants_on_calling_connection_epoch" ON "room_participants" ("calling_connection_epoch");
@@ -1,2 +0,0 @@
-ALTER TABLE "signups"
- ADD "added_to_mailing_list" BOOLEAN NOT NULL DEFAULT FALSE;
@@ -1,7 +0,0 @@
-ALTER TABLE "room_participants"
- ADD "answering_connection_lost" BOOLEAN NOT NULL DEFAULT FALSE;
-
-CREATE INDEX "index_project_collaborators_on_connection_id" ON "project_collaborators" ("connection_id");
-CREATE UNIQUE INDEX "index_project_collaborators_on_project_id_connection_id_and_epoch" ON "project_collaborators" ("project_id", "connection_id", "connection_epoch");
-CREATE INDEX "index_room_participants_on_answering_connection_id" ON "room_participants" ("answering_connection_id");
-CREATE UNIQUE INDEX "index_room_participants_on_answering_connection_id_and_answering_connection_epoch" ON "room_participants" ("answering_connection_id", "answering_connection_epoch");
@@ -1 +0,0 @@
-CREATE INDEX "index_room_participants_on_room_id" ON "room_participants" ("room_id");
@@ -1,30 +0,0 @@
-CREATE TABLE servers (
- id SERIAL PRIMARY KEY,
- environment VARCHAR NOT NULL
-);
-
-DROP TABLE worktree_extensions;
-DROP TABLE project_activity_periods;
-DELETE from projects;
-ALTER TABLE projects
- DROP COLUMN host_connection_epoch,
- ADD COLUMN host_connection_server_id INTEGER REFERENCES servers (id) ON DELETE CASCADE;
-CREATE INDEX "index_projects_on_host_connection_server_id" ON "projects" ("host_connection_server_id");
-CREATE INDEX "index_projects_on_host_connection_id_and_host_connection_server_id" ON "projects" ("host_connection_id", "host_connection_server_id");
-
-DELETE FROM project_collaborators;
-ALTER TABLE project_collaborators
- DROP COLUMN connection_epoch,
- ADD COLUMN connection_server_id INTEGER NOT NULL REFERENCES servers (id) ON DELETE CASCADE;
-CREATE INDEX "index_project_collaborators_on_connection_server_id" ON "project_collaborators" ("connection_server_id");
-CREATE UNIQUE INDEX "index_project_collaborators_on_project_id_connection_id_and_server_id" ON "project_collaborators" ("project_id", "connection_id", "connection_server_id");
-
-DELETE FROM room_participants;
-ALTER TABLE room_participants
- DROP COLUMN answering_connection_epoch,
- DROP COLUMN calling_connection_epoch,
- ADD COLUMN answering_connection_server_id INTEGER REFERENCES servers (id) ON DELETE CASCADE,
- ADD COLUMN calling_connection_server_id INTEGER REFERENCES servers (id) ON DELETE SET NULL;
-CREATE INDEX "index_room_participants_on_answering_connection_server_id" ON "room_participants" ("answering_connection_server_id");
-CREATE INDEX "index_room_participants_on_calling_connection_server_id" ON "room_participants" ("calling_connection_server_id");
-CREATE UNIQUE INDEX "index_room_participants_on_answering_connection_id_and_answering_connection_server_id" ON "room_participants" ("answering_connection_id", "answering_connection_server_id");
@@ -1,3 +0,0 @@
-ALTER TABLE "worktree_entries"
- ADD COLUMN "scan_id" INT8,
- ADD COLUMN "is_deleted" BOOL;
@@ -1,3 +0,0 @@
-ALTER TABLE worktrees
- ALTER COLUMN is_complete SET DEFAULT FALSE,
- ADD COLUMN completed_scan_id INT8;
@@ -1,15 +0,0 @@
-CREATE TABLE IF NOT EXISTS "followers" (
- "id" SERIAL PRIMARY KEY,
- "room_id" INTEGER NOT NULL REFERENCES rooms (id) ON DELETE CASCADE,
- "project_id" INTEGER NOT NULL REFERENCES projects (id) ON DELETE CASCADE,
- "leader_connection_server_id" INTEGER NOT NULL REFERENCES servers (id) ON DELETE CASCADE,
- "leader_connection_id" INTEGER NOT NULL,
- "follower_connection_server_id" INTEGER NOT NULL REFERENCES servers (id) ON DELETE CASCADE,
- "follower_connection_id" INTEGER NOT NULL
-);
-
-CREATE UNIQUE INDEX
- "index_followers_on_project_id_and_leader_connection_server_id_and_leader_connection_id_and_follower_connection_server_id_and_follower_connection_id"
-ON "followers" ("project_id", "leader_connection_server_id", "leader_connection_id", "follower_connection_server_id", "follower_connection_id");
-
-CREATE INDEX "index_followers_on_room_id" ON "followers" ("room_id");
@@ -1,13 +0,0 @@
-CREATE TABLE "worktree_repositories" (
- "project_id" INTEGER NOT NULL,
- "worktree_id" INT8 NOT NULL,
- "work_directory_id" INT8 NOT NULL,
- "scan_id" INT8 NOT NULL,
- "branch" VARCHAR,
- "is_deleted" BOOL NOT NULL,
- PRIMARY KEY(project_id, worktree_id, work_directory_id),
- FOREIGN KEY(project_id, worktree_id) REFERENCES worktrees (project_id, id) ON DELETE CASCADE,
- FOREIGN KEY(project_id, worktree_id, work_directory_id) REFERENCES worktree_entries (project_id, worktree_id, id) ON DELETE CASCADE
-);
-CREATE INDEX "index_worktree_repositories_on_project_id" ON "worktree_repositories" ("project_id");
-CREATE INDEX "index_worktree_repositories_on_project_id_and_worktree_id" ON "worktree_repositories" ("project_id", "worktree_id");
@@ -1,15 +0,0 @@
-CREATE TABLE "worktree_repository_statuses" (
- "project_id" INTEGER NOT NULL,
- "worktree_id" INT8 NOT NULL,
- "work_directory_id" INT8 NOT NULL,
- "repo_path" VARCHAR NOT NULL,
- "status" INT8 NOT NULL,
- "scan_id" INT8 NOT NULL,
- "is_deleted" BOOL NOT NULL,
- PRIMARY KEY(project_id, worktree_id, work_directory_id, repo_path),
- FOREIGN KEY(project_id, worktree_id) REFERENCES worktrees (project_id, id) ON DELETE CASCADE,
- FOREIGN KEY(project_id, worktree_id, work_directory_id) REFERENCES worktree_entries (project_id, worktree_id, id) ON DELETE CASCADE
-);
-CREATE INDEX "index_wt_repos_statuses_on_project_id" ON "worktree_repository_statuses" ("project_id");
-CREATE INDEX "index_wt_repos_statuses_on_project_id_and_wt_id" ON "worktree_repository_statuses" ("project_id", "worktree_id");
-CREATE INDEX "index_wt_repos_statuses_on_project_id_and_wt_id_and_wd_id" ON "worktree_repository_statuses" ("project_id", "worktree_id", "work_directory_id");
@@ -1,10 +0,0 @@
-CREATE TABLE "worktree_settings_files" (
- "project_id" INTEGER NOT NULL,
- "worktree_id" INT8 NOT NULL,
- "path" VARCHAR NOT NULL,
- "content" TEXT NOT NULL,
- PRIMARY KEY(project_id, worktree_id, path),
- FOREIGN KEY(project_id, worktree_id) REFERENCES worktrees (project_id, id) ON DELETE CASCADE
-);
-CREATE INDEX "index_settings_files_on_project_id" ON "worktree_settings_files" ("project_id");
-CREATE INDEX "index_settings_files_on_project_id_and_wt_id" ON "worktree_settings_files" ("project_id", "worktree_id");
@@ -1,2 +0,0 @@
-ALTER TABLE "worktree_entries"
-ADD "git_status" INT8;
@@ -1,2 +0,0 @@
-ALTER TABLE "worktree_entries"
-ADD "is_external" BOOL NOT NULL DEFAULT FALSE;
@@ -1,30 +0,0 @@
-DROP TABLE "channel_messages";
-DROP TABLE "channel_memberships";
-DROP TABLE "org_memberships";
-DROP TABLE "orgs";
-DROP TABLE "channels";
-
-CREATE TABLE "channels" (
- "id" SERIAL PRIMARY KEY,
- "name" VARCHAR NOT NULL,
- "created_at" TIMESTAMP NOT NULL DEFAULT now()
-);
-
-CREATE TABLE "channel_paths" (
- "id_path" VARCHAR NOT NULL PRIMARY KEY,
- "channel_id" INTEGER NOT NULL REFERENCES channels (id) ON DELETE CASCADE
-);
-CREATE INDEX "index_channel_paths_on_channel_id" ON "channel_paths" ("channel_id");
-
-CREATE TABLE "channel_members" (
- "id" SERIAL PRIMARY KEY,
- "channel_id" INTEGER NOT NULL REFERENCES channels (id) ON DELETE CASCADE,
- "user_id" INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE,
- "admin" BOOLEAN NOT NULL DEFAULT false,
- "accepted" BOOLEAN NOT NULL DEFAULT false,
- "updated_at" TIMESTAMP NOT NULL DEFAULT now()
-);
-
-CREATE UNIQUE INDEX "index_channel_members_on_channel_id_and_user_id" ON "channel_members" ("channel_id", "user_id");
-
-ALTER TABLE rooms ADD COLUMN "channel_id" INTEGER REFERENCES channels (id) ON DELETE CASCADE;
@@ -1,40 +0,0 @@
-CREATE TABLE "buffers" (
- "id" SERIAL PRIMARY KEY,
- "channel_id" INTEGER NOT NULL REFERENCES channels (id) ON DELETE CASCADE,
- "epoch" INTEGER NOT NULL DEFAULT 0
-);
-
-CREATE INDEX "index_buffers_on_channel_id" ON "buffers" ("channel_id");
-
-CREATE TABLE "buffer_operations" (
- "buffer_id" INTEGER NOT NULL REFERENCES buffers (id) ON DELETE CASCADE,
- "epoch" INTEGER NOT NULL,
- "replica_id" INTEGER NOT NULL,
- "lamport_timestamp" INTEGER NOT NULL,
- "value" BYTEA NOT NULL,
- PRIMARY KEY(buffer_id, epoch, lamport_timestamp, replica_id)
-);
-
-CREATE TABLE "buffer_snapshots" (
- "buffer_id" INTEGER NOT NULL REFERENCES buffers (id) ON DELETE CASCADE,
- "epoch" INTEGER NOT NULL,
- "text" TEXT NOT NULL,
- "operation_serialization_version" INTEGER NOT NULL,
- PRIMARY KEY(buffer_id, epoch)
-);
-
-CREATE TABLE "channel_buffer_collaborators" (
- "id" SERIAL PRIMARY KEY,
- "channel_id" INTEGER NOT NULL REFERENCES channels (id) ON DELETE CASCADE,
- "connection_id" INTEGER NOT NULL,
- "connection_server_id" INTEGER NOT NULL REFERENCES servers (id) ON DELETE CASCADE,
- "connection_lost" BOOLEAN NOT NULL DEFAULT FALSE,
- "user_id" INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE,
- "replica_id" INTEGER NOT NULL
-);
-
-CREATE INDEX "index_channel_buffer_collaborators_on_channel_id" ON "channel_buffer_collaborators" ("channel_id");
-CREATE UNIQUE INDEX "index_channel_buffer_collaborators_on_channel_id_and_replica_id" ON "channel_buffer_collaborators" ("channel_id", "replica_id");
-CREATE INDEX "index_channel_buffer_collaborators_on_connection_server_id" ON "channel_buffer_collaborators" ("connection_server_id");
-CREATE INDEX "index_channel_buffer_collaborators_on_connection_id" ON "channel_buffer_collaborators" ("connection_id");
-CREATE UNIQUE INDEX "index_channel_buffer_collaborators_on_channel_id_connection_id_and_server_id" ON "channel_buffer_collaborators" ("channel_id", "connection_id", "connection_server_id");
@@ -1,16 +0,0 @@
-CREATE TABLE "feature_flags" (
- "id" SERIAL PRIMARY KEY,
- "flag" VARCHAR(255) NOT NULL UNIQUE
-);
-
-CREATE UNIQUE INDEX "index_feature_flags" ON "feature_flags" ("id");
-
-CREATE TABLE "user_features" (
- "user_id" INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
- "feature_id" INTEGER NOT NULL REFERENCES feature_flags(id) ON DELETE CASCADE,
- PRIMARY KEY (user_id, feature_id)
-);
-
-CREATE UNIQUE INDEX "index_user_features_user_id_and_feature_id" ON "user_features" ("user_id", "feature_id");
-CREATE INDEX "index_user_features_on_user_id" ON "user_features" ("user_id");
-CREATE INDEX "index_user_features_on_feature_id" ON "user_features" ("feature_id");
@@ -1,19 +0,0 @@
-CREATE TABLE IF NOT EXISTS "channel_messages" (
- "id" SERIAL PRIMARY KEY,
- "channel_id" INTEGER NOT NULL REFERENCES channels (id) ON DELETE CASCADE,
- "sender_id" INTEGER NOT NULL REFERENCES users (id),
- "body" TEXT NOT NULL,
- "sent_at" TIMESTAMP,
- "nonce" UUID NOT NULL
-);
-CREATE INDEX "index_channel_messages_on_channel_id" ON "channel_messages" ("channel_id");
-CREATE UNIQUE INDEX "index_channel_messages_on_nonce" ON "channel_messages" ("nonce");
-
-CREATE TABLE IF NOT EXISTS "channel_chat_participants" (
- "id" SERIAL PRIMARY KEY,
- "user_id" INTEGER NOT NULL REFERENCES users (id),
- "channel_id" INTEGER NOT NULL REFERENCES channels (id) ON DELETE CASCADE,
- "connection_id" INTEGER NOT NULL,
- "connection_server_id" INTEGER NOT NULL REFERENCES servers (id) ON DELETE CASCADE
-);
-CREATE INDEX "index_channel_chat_participants_on_channel_id" ON "channel_chat_participants" ("channel_id");
@@ -1,19 +0,0 @@
-CREATE TABLE IF NOT EXISTS "observed_buffer_edits" (
- "user_id" INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE,
- "buffer_id" INTEGER NOT NULL REFERENCES buffers (id) ON DELETE CASCADE,
- "epoch" INTEGER NOT NULL,
- "lamport_timestamp" INTEGER NOT NULL,
- "replica_id" INTEGER NOT NULL,
- PRIMARY KEY (user_id, buffer_id)
-);
-
-CREATE UNIQUE INDEX "index_observed_buffer_user_and_buffer_id" ON "observed_buffer_edits" ("user_id", "buffer_id");
-
-CREATE TABLE IF NOT EXISTS "observed_channel_messages" (
- "user_id" INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE,
- "channel_id" INTEGER NOT NULL REFERENCES channels (id) ON DELETE CASCADE,
- "channel_message_id" INTEGER NOT NULL,
- PRIMARY KEY (user_id, channel_id)
-);
-
-CREATE UNIQUE INDEX "index_observed_channel_messages_user_and_channel_id" ON "observed_channel_messages" ("user_id", "channel_id");
@@ -1 +0,0 @@
-ALTER TABLE room_participants ADD COLUMN participant_index INTEGER;
@@ -1,22 +0,0 @@
-CREATE TABLE "notification_kinds" (
- "id" SERIAL PRIMARY KEY,
- "name" VARCHAR NOT NULL
-);
-
-CREATE UNIQUE INDEX "index_notification_kinds_on_name" ON "notification_kinds" ("name");
-
-CREATE TABLE notifications (
- "id" SERIAL PRIMARY KEY,
- "created_at" TIMESTAMP NOT NULL DEFAULT now(),
- "recipient_id" INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE,
- "kind" INTEGER NOT NULL REFERENCES notification_kinds (id),
- "entity_id" INTEGER,
- "content" TEXT,
- "is_read" BOOLEAN NOT NULL DEFAULT FALSE,
- "response" BOOLEAN
-);
-
-CREATE INDEX
- "index_notifications_on_recipient_id_is_read_kind_entity_id"
- ON "notifications"
- ("recipient_id", "is_read", "kind", "entity_id");
@@ -1 +0,0 @@
-ALTER TABLE rooms ADD COLUMN enviroment TEXT;
@@ -1 +0,0 @@
-CREATE UNIQUE INDEX "index_rooms_on_channel_id" ON "rooms" ("channel_id");
@@ -1,4 +0,0 @@
-ALTER TABLE channel_members ADD COLUMN role TEXT;
-UPDATE channel_members SET role = CASE WHEN admin THEN 'admin' ELSE 'member' END;
-
-ALTER TABLE channels ADD COLUMN visibility TEXT NOT NULL DEFAULT 'members';
@@ -1,8 +0,0 @@
--- Add migration script here
-
-ALTER TABLE projects
- DROP CONSTRAINT projects_room_id_fkey,
- ADD CONSTRAINT projects_room_id_fkey
- FOREIGN KEY (room_id)
- REFERENCES rooms (id)
- ON DELETE CASCADE;
@@ -1,11 +0,0 @@
-CREATE TABLE "channel_message_mentions" (
- "message_id" INTEGER NOT NULL REFERENCES channel_messages (id) ON DELETE CASCADE,
- "start_offset" INTEGER NOT NULL,
- "end_offset" INTEGER NOT NULL,
- "user_id" INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE,
- PRIMARY KEY(message_id, start_offset)
-);
-
--- We use 'on conflict update' with this index, so it should be per-user.
-CREATE UNIQUE INDEX "index_channel_messages_on_sender_id_nonce" ON "channel_messages" ("sender_id", "nonce");
-DROP INDEX "index_channel_messages_on_nonce";
@@ -1,12 +0,0 @@
-ALTER TABLE channels ADD COLUMN parent_path TEXT;
-
-UPDATE channels
-SET parent_path = substr(
- channel_paths.id_path,
- 2,
- length(channel_paths.id_path) - length('/' || channel_paths.channel_id::text || '/')
-)
-FROM channel_paths
-WHERE channel_paths.channel_id = channels.id;
-
-CREATE INDEX "index_channels_on_parent_path" ON "channels" ("parent_path");
@@ -1 +0,0 @@
-ALTER TABLE room_participants ADD COLUMN role TEXT;
@@ -1 +0,0 @@
-ALTER TABLE rooms ADD COLUMN environment TEXT;
@@ -1 +0,0 @@
-ALTER TABLE access_tokens ADD COLUMN impersonated_user_id integer;
@@ -1,5 +0,0 @@
-CREATE TABLE contributors (
- user_id INTEGER REFERENCES users(id),
- signed_at TIMESTAMP NOT NULL DEFAULT NOW(),
- PRIMARY KEY (user_id)
-);
@@ -1 +0,0 @@
-ALTER TABLE "channels" ADD COLUMN "requires_zed_cla" BOOLEAN NOT NULL DEFAULT FALSE;
@@ -1,4 +0,0 @@
--- Add migration script here
-
-DROP INDEX index_channels_on_parent_path;
-CREATE INDEX index_channels_on_parent_path ON channels (parent_path text_pattern_ops);
@@ -1 +0,0 @@
-ALTER TABLE channel_messages ADD reply_to_message_id INTEGER DEFAULT NULL
@@ -1,3 +0,0 @@
--- Add migration script here
-
-ALTER TABLE room_participants ADD COLUMN in_call BOOL NOT NULL DEFAULT FALSE;
@@ -1,4 +0,0 @@
--- Add migration script here
-ALTER TABLE rooms DROP COLUMN enviroment;
-ALTER TABLE rooms DROP COLUMN environment;
-ALTER TABLE room_participants DROP COLUMN in_call;
@@ -1,22 +0,0 @@
-CREATE TABLE IF NOT EXISTS extensions (
- id SERIAL PRIMARY KEY,
- name TEXT NOT NULL,
- external_id TEXT NOT NULL,
- latest_version TEXT NOT NULL,
- total_download_count BIGINT NOT NULL DEFAULT 0
-);
-
-CREATE TABLE IF NOT EXISTS extension_versions (
- extension_id INTEGER REFERENCES extensions(id),
- version TEXT NOT NULL,
- published_at TIMESTAMP NOT NULL DEFAULT now(),
- authors TEXT NOT NULL,
- repository TEXT NOT NULL,
- description TEXT NOT NULL,
- download_count BIGINT NOT NULL DEFAULT 0,
- PRIMARY KEY(extension_id, version)
-);
-
-CREATE UNIQUE INDEX "index_extensions_external_id" ON "extensions" ("external_id");
-CREATE INDEX "trigram_index_extensions_name" ON "extensions" USING GIN(name gin_trgm_ops);
-CREATE INDEX "index_extensions_total_download_count" ON "extensions" ("total_download_count");
@@ -1,11 +0,0 @@
-CREATE TABLE IF NOT EXISTS rate_buckets (
- user_id INT NOT NULL,
- rate_limit_name VARCHAR(255) NOT NULL,
- token_count INT NOT NULL,
- last_refill TIMESTAMP WITHOUT TIME ZONE NOT NULL,
- PRIMARY KEY (user_id, rate_limit_name),
- CONSTRAINT fk_user
- FOREIGN KEY (user_id) REFERENCES users(id)
-);
-
-CREATE INDEX idx_user_id_rate_limit ON rate_buckets (user_id, rate_limit_name);
@@ -1 +0,0 @@
-ALTER TABLE channel_messages ADD edited_at TIMESTAMP DEFAULT NULL;
@@ -1,11 +0,0 @@
--- Add migration script here
-
-CREATE TABLE hosted_projects (
- id INT PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
- channel_id INT NOT NULL REFERENCES channels(id),
- name TEXT NOT NULL,
- visibility TEXT NOT NULL,
- deleted_at TIMESTAMP NULL
-);
-CREATE INDEX idx_hosted_projects_on_channel_id ON hosted_projects (channel_id);
-CREATE UNIQUE INDEX uix_hosted_projects_on_channel_id_and_name ON hosted_projects (channel_id, name) WHERE (deleted_at IS NULL);
@@ -1,3 +0,0 @@
--- Add migration script here
-
-CREATE UNIQUE INDEX uix_channels_parent_path_name ON channels(parent_path, name) WHERE (parent_path IS NOT NULL AND parent_path != '');
@@ -1,3 +0,0 @@
--- Add migration script here
-ALTER TABLE projects ALTER COLUMN host_user_id DROP NOT NULL;
-ALTER TABLE projects ADD COLUMN hosted_project_id INTEGER REFERENCES hosted_projects(id) UNIQUE NULL;
@@ -1,17 +0,0 @@
--- Add migration script here
-
-ALTER TABLE buffers ADD COLUMN latest_operation_epoch INTEGER;
-ALTER TABLE buffers ADD COLUMN latest_operation_lamport_timestamp INTEGER;
-ALTER TABLE buffers ADD COLUMN latest_operation_replica_id INTEGER;
-
-WITH ops AS (
- SELECT DISTINCT ON (buffer_id) buffer_id, epoch, lamport_timestamp, replica_id
- FROM buffer_operations
- ORDER BY buffer_id, epoch DESC, lamport_timestamp DESC, replica_id DESC
-)
-UPDATE buffers
-SET latest_operation_epoch = ops.epoch,
- latest_operation_lamport_timestamp = ops.lamport_timestamp,
- latest_operation_replica_id = ops.replica_id
-FROM ops
-WHERE buffers.id = ops.buffer_id;
@@ -1,4 +0,0 @@
--- Add migration script here
-
-ALTER TABLE channel_members ALTER role SET NOT NULL;
-ALTER TABLE channel_members DROP COLUMN admin;
@@ -1,2 +0,0 @@
--- Add migration script here
-ALTER TABLE channels ALTER parent_path SET NOT NULL;
@@ -1,2 +0,0 @@
--- Add migration script here
-ALTER TABLE extension_versions ADD COLUMN schema_version INTEGER NOT NULL DEFAULT 0;
@@ -1,7 +0,0 @@
-CREATE TABLE dev_servers (
- id INT PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
- channel_id INT NOT NULL REFERENCES channels(id),
- name TEXT NOT NULL,
- hashed_token TEXT NOT NULL
-);
-CREATE INDEX idx_dev_servers_on_channel_id ON dev_servers (channel_id);
@@ -1 +0,0 @@
-ALTER TABLE extension_versions ADD COLUMN wasm_api_version TEXT;
@@ -1,9 +0,0 @@
-CREATE TABLE remote_projects (
- id INT PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
- channel_id INT NOT NULL REFERENCES channels(id),
- dev_server_id INT NOT NULL REFERENCES dev_servers(id),
- name TEXT NOT NULL,
- path TEXT NOT NULL
-);
-
-ALTER TABLE projects ADD COLUMN remote_project_id INTEGER REFERENCES remote_projects(id);
@@ -1,9 +0,0 @@
-CREATE TABLE IF NOT EXISTS "embeddings" (
- "model" TEXT,
- "digest" BYTEA,
- "dimensions" FLOAT4[1536],
- "retrieved_at" TIMESTAMP NOT NULL DEFAULT now(),
- PRIMARY KEY ("model", "digest")
-);
-
-CREATE INDEX IF NOT EXISTS "idx_retrieved_at_on_embeddings" ON "embeddings" ("retrieved_at");
@@ -1,7 +0,0 @@
-DELETE FROM remote_projects;
-DELETE FROM dev_servers;
-
-ALTER TABLE dev_servers DROP COLUMN channel_id;
-ALTER TABLE dev_servers ADD COLUMN user_id INT NOT NULL REFERENCES users(id);
-
-ALTER TABLE remote_projects DROP COLUMN channel_id;
@@ -1,3 +0,0 @@
-ALTER TABLE remote_projects DROP COLUMN name;
-ALTER TABLE remote_projects
-ADD CONSTRAINT unique_path_constraint UNIQUE(dev_server_id, path);
@@ -1,11 +0,0 @@
-CREATE TABLE dev_server_projects (
- id INT PRIMARY KEY GENERATED ALWAYS AS IDENTITY (START WITH 100),
- dev_server_id INT NOT NULL REFERENCES dev_servers(id) ON DELETE CASCADE,
- path TEXT NOT NULL
-);
-INSERT INTO dev_server_projects OVERRIDING SYSTEM VALUE SELECT * FROM remote_projects;
-
-ALTER TABLE dev_server_projects ADD CONSTRAINT uix_dev_server_projects_dev_server_id_path UNIQUE(dev_server_id, path);
-
-ALTER TABLE projects ADD COLUMN dev_server_project_id INTEGER REFERENCES dev_server_projects(id);
-UPDATE projects SET dev_server_project_id = remote_project_id;
@@ -1,2 +0,0 @@
-ALTER TABLE projects DROP COLUMN remote_project_id;
-DROP TABLE remote_projects;
@@ -1 +0,0 @@
-ALTER TABLE dev_servers ADD COLUMN ssh_connection_string TEXT;
@@ -1,4 +0,0 @@
-ALTER TABLE dev_server_projects ADD COLUMN paths JSONB NULL;
-UPDATE dev_server_projects SET paths = to_json(ARRAY[path]);
-ALTER TABLE dev_server_projects ALTER COLUMN paths SET NOT NULL;
-ALTER TABLE dev_server_projects ALTER COLUMN path DROP NOT NULL;
@@ -1,12 +0,0 @@
-CREATE TABLE IF NOT EXISTS billing_subscriptions (
- id SERIAL PRIMARY KEY,
- created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT now(),
- user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
- stripe_customer_id TEXT NOT NULL,
- stripe_subscription_id TEXT NOT NULL,
- stripe_subscription_status TEXT NOT NULL
-);
-
-CREATE INDEX "ix_billing_subscriptions_on_user_id" ON billing_subscriptions (user_id);
-CREATE INDEX "ix_billing_subscriptions_on_stripe_customer_id" ON billing_subscriptions (stripe_customer_id);
-CREATE UNIQUE INDEX "uix_billing_subscriptions_on_stripe_subscription_id" ON billing_subscriptions (stripe_subscription_id);
@@ -1,18 +0,0 @@
-CREATE TABLE IF NOT EXISTS billing_customers (
- id SERIAL PRIMARY KEY,
- created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT now(),
- user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
- stripe_customer_id TEXT NOT NULL
-);
-
-CREATE UNIQUE INDEX "uix_billing_customers_on_user_id" ON billing_customers (user_id);
-CREATE UNIQUE INDEX "uix_billing_customers_on_stripe_customer_id" ON billing_customers (stripe_customer_id);
-
--- Make `billing_subscriptions` reference `billing_customers` instead of having its
--- own `user_id` and `stripe_customer_id`.
-DROP INDEX IF EXISTS "ix_billing_subscriptions_on_user_id";
-DROP INDEX IF EXISTS "ix_billing_subscriptions_on_stripe_customer_id";
-ALTER TABLE billing_subscriptions DROP COLUMN user_id;
-ALTER TABLE billing_subscriptions DROP COLUMN stripe_customer_id;
-ALTER TABLE billing_subscriptions ADD COLUMN billing_customer_id INTEGER NOT NULL REFERENCES billing_customers (id) ON DELETE CASCADE;
-CREATE INDEX "ix_billing_subscriptions_on_billing_customer_id" ON billing_subscriptions (billing_customer_id);
@@ -1,2 +0,0 @@
-ALTER TABLE billing_customers ADD COLUMN last_stripe_event_id TEXT;
-ALTER TABLE billing_subscriptions ADD COLUMN last_stripe_event_id TEXT;
@@ -1,11 +0,0 @@
-ALTER TABLE billing_customers DROP COLUMN last_stripe_event_id;
-ALTER TABLE billing_subscriptions DROP COLUMN last_stripe_event_id;
-
-CREATE TABLE IF NOT EXISTS processed_stripe_events (
- stripe_event_id TEXT PRIMARY KEY,
- stripe_event_type TEXT NOT NULL,
- stripe_event_created_timestamp BIGINT NOT NULL,
- processed_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT now()
-);
-
-CREATE INDEX "ix_processed_stripe_events_on_stripe_event_created_timestamp" ON processed_stripe_events (stripe_event_created_timestamp);
@@ -1 +0,0 @@
-ALTER TABLE billing_subscriptions ADD COLUMN stripe_cancel_at TIMESTAMP WITHOUT TIME ZONE;
@@ -1 +0,0 @@
-ALTER TABLE users ADD accepted_tos_at TIMESTAMP WITHOUT TIME ZONE;
@@ -1 +0,0 @@
-ALTER TABLE "users" ADD COLUMN "github_user_created_at" TIMESTAMP WITHOUT TIME ZONE;
@@ -1 +0,0 @@
-alter table feature_flags add column enabled_for_all boolean not null default false;
@@ -1,4 +0,0 @@
-alter table users alter column github_user_id set not null;
-
-drop index index_users_on_github_user_id;
-create unique index uix_users_on_github_user_id on users (github_user_id);
@@ -1,2 +0,0 @@
-ALTER TABLE "worktree_entries"
-ADD "is_fifo" BOOL NOT NULL DEFAULT FALSE;
@@ -1 +0,0 @@
-ALTER TABLE "worktree_settings_files" ADD COLUMN "kind" VARCHAR;
@@ -1,8 +0,0 @@
-create table if not exists billing_preferences (
- id serial primary key,
- created_at timestamp without time zone not null default now(),
- user_id integer not null references users(id) on delete cascade,
- max_monthly_llm_usage_spending_in_cents integer not null
-);
-
-create unique index "uix_billing_preferences_on_user_id" on billing_preferences (user_id);
@@ -1,2 +0,0 @@
-ALTER TABLE worktree_entries ADD COLUMN canonical_path text;
-ALTER TABLE worktree_entries ALTER COLUMN is_symlink SET DEFAULT false;
@@ -1 +0,0 @@
-alter table users add column custom_llm_monthly_allowance_in_cents integer;
@@ -1,6 +0,0 @@
-ALTER TABLE projects DROP COLUMN dev_server_project_id;
-ALTER TABLE projects DROP COLUMN hosted_project_id;
-
-DROP TABLE hosted_projects;
-DROP TABLE dev_server_projects;
-DROP TABLE dev_servers;
@@ -1,11 +0,0 @@
-CREATE TABLE IF NOT EXISTS "breakpoints" (
- "id" SERIAL PRIMARY KEY,
- "project_id" INTEGER NOT NULL REFERENCES projects (id) ON DELETE CASCADE,
- "position" INTEGER NOT NULL,
- "log_message" TEXT NULL,
- "worktree_id" BIGINT NOT NULL,
- "path" TEXT NOT NULL,
- "kind" VARCHAR NOT NULL
-);
-
-CREATE INDEX "index_breakpoints_on_project_id" ON "breakpoints" ("project_id");
@@ -1,2 +0,0 @@
-alter table billing_subscriptions
-add column stripe_cancellation_reason text;
@@ -1,13 +0,0 @@
-ALTER TABLE worktree_repository_statuses
-ADD COLUMN status_kind INTEGER,
-ADD COLUMN first_status INTEGER,
-ADD COLUMN second_status INTEGER;
-
-UPDATE worktree_repository_statuses
-SET
- status_kind = 0;
-
-ALTER TABLE worktree_repository_statuses
-ALTER COLUMN status_kind
-SET
- NOT NULL;
@@ -1 +0,0 @@
-ALTER TABLE users ADD COLUMN name TEXT;
@@ -1,2 +0,0 @@
-alter table billing_customers
-add column has_overdue_invoices bool not null default false;
@@ -1,10 +0,0 @@
-alter table extension_versions
-add column provides_themes bool not null default false,
-add column provides_icon_themes bool not null default false,
-add column provides_languages bool not null default false,
-add column provides_grammars bool not null default false,
-add column provides_language_servers bool not null default false,
-add column provides_context_servers bool not null default false,
-add column provides_slash_commands bool not null default false,
-add column provides_indexed_docs_providers bool not null default false,
-add column provides_snippets bool not null default false;
@@ -1,2 +0,0 @@
-ALTER TABLE worktree_repositories
-ADD COLUMN current_merge_conflicts VARCHAR NULL;
@@ -1,2 +0,0 @@
-ALTER TABLE worktree_repositories
-ADD COLUMN worktree_repositories VARCHAR NULL;
@@ -1 +0,0 @@
-ALTER TABLE worktree_repositories ADD COLUMN branch_summary TEXT NULL;
@@ -1,32 +0,0 @@
-CREATE TABLE "project_repositories" (
- "project_id" INTEGER NOT NULL,
- "abs_path" VARCHAR,
- "id" INT8 NOT NULL,
- "legacy_worktree_id" INT8,
- "entry_ids" VARCHAR,
- "branch" VARCHAR,
- "scan_id" INT8 NOT NULL,
- "is_deleted" BOOL NOT NULL,
- "current_merge_conflicts" VARCHAR,
- "branch_summary" VARCHAR,
- PRIMARY KEY (project_id, id)
-);
-
-CREATE INDEX "index_project_repositories_on_project_id" ON "project_repositories" ("project_id");
-
-CREATE TABLE "project_repository_statuses" (
- "project_id" INTEGER NOT NULL,
- "repository_id" INT8 NOT NULL,
- "repo_path" VARCHAR NOT NULL,
- "status" INT8 NOT NULL,
- "status_kind" INT4 NOT NULL,
- "first_status" INT4 NULL,
- "second_status" INT4 NULL,
- "scan_id" INT8 NOT NULL,
- "is_deleted" BOOL NOT NULL,
- PRIMARY KEY (project_id, repository_id, repo_path)
-);
-
-CREATE INDEX "index_project_repos_statuses_on_project_id" ON "project_repository_statuses" ("project_id");
-
-CREATE INDEX "index_project_repos_statuses_on_project_id_and_repo_id" ON "project_repository_statuses" ("project_id", "repository_id");
@@ -1,4 +0,0 @@
-alter table billing_subscriptions
- add column kind text,
- add column stripe_current_period_start bigint,
- add column stripe_current_period_end bigint;
@@ -1,2 +0,0 @@
-alter table billing_customers
- add column trial_started_at timestamp without time zone;
@@ -1,2 +0,0 @@
-alter table project_repositories
- add column head_commit_details varchar;
@@ -1,3 +0,0 @@
-alter table billing_preferences
- add column model_request_overages_enabled bool not null default false,
- add column model_request_overages_spend_limit_in_cents integer not null default 0;
@@ -1,16 +0,0 @@
--- Add channel_order column to channels table with default value
-ALTER TABLE channels ADD COLUMN channel_order INTEGER NOT NULL DEFAULT 1;
-
--- Update channel_order for existing channels using ROW_NUMBER for deterministic ordering
-UPDATE channels
-SET channel_order = (
- SELECT ROW_NUMBER() OVER (
- PARTITION BY parent_path
- ORDER BY name, id
- )
- FROM channels c2
- WHERE c2.id = channels.id
-);
-
--- Create index for efficient ordering queries
-CREATE INDEX "index_channels_on_parent_path_and_order" ON "channels" ("parent_path", "channel_order");
@@ -1,4 +0,0 @@
-alter table project_collaborators
- add column committer_name varchar;
-alter table project_collaborators
- add column committer_email varchar;
@@ -1,2 +0,0 @@
-alter table extension_versions
-add column provides_debug_adapters bool not null default false
@@ -1,2 +0,0 @@
-alter table extension_versions
-add column provides_agent_servers bool not null default false
@@ -1,25 +0,0 @@
-DELETE FROM project_repositories
-WHERE project_id NOT IN (SELECT id FROM projects);
-
-ALTER TABLE project_repositories
- ADD CONSTRAINT fk_project_repositories_project_id
- FOREIGN KEY (project_id)
- REFERENCES projects (id)
- ON DELETE CASCADE
- NOT VALID;
-
-ALTER TABLE project_repositories
- VALIDATE CONSTRAINT fk_project_repositories_project_id;
-
-DELETE FROM project_repository_statuses
-WHERE project_id NOT IN (SELECT id FROM projects);
-
-ALTER TABLE project_repository_statuses
- ADD CONSTRAINT fk_project_repository_statuses_project_id
- FOREIGN KEY (project_id)
- REFERENCES projects (id)
- ON DELETE CASCADE
- NOT VALID;
-
-ALTER TABLE project_repository_statuses
- VALIDATE CONSTRAINT fk_project_repository_statuses_project_id;
@@ -1,3 +0,0 @@
-ALTER TABLE access_tokens DROP CONSTRAINT access_tokens_user_id_fkey;
-ALTER TABLE access_tokens ADD CONSTRAINT access_tokens_user_id_fkey
- FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
@@ -1,5 +0,0 @@
-ALTER TABLE language_servers
- ADD COLUMN capabilities TEXT NOT NULL DEFAULT '{}';
-
-ALTER TABLE language_servers
- ALTER COLUMN capabilities DROP DEFAULT;
@@ -1,2 +0,0 @@
-alter table users
-alter column admin set not null;
@@ -1,2 +0,0 @@
-alter table billing_customers
- add column orb_customer_id text;
@@ -1 +0,0 @@
-drop table rate_buckets;
@@ -1 +0,0 @@
-ALTER TABLE "project_repositories" ADD COLUMN "merge_message" VARCHAR;
@@ -1,2 +0,0 @@
-alter table billing_subscriptions
- add column orb_subscription_id text;
@@ -1,3 +0,0 @@
-alter table billing_subscriptions
- alter column stripe_subscription_id drop not null,
- alter column stripe_subscription_status drop not null;
@@ -1,4 +0,0 @@
-alter table billing_subscriptions
- add column orb_subscription_status text,
- add column orb_current_billing_period_start_date timestamp without time zone,
- add column orb_current_billing_period_end_date timestamp without time zone;
@@ -1,2 +0,0 @@
-ALTER TABLE language_servers
- ADD COLUMN worktree_id BIGINT;
@@ -1,2 +0,0 @@
-alter table billing_subscriptions
- add column orb_cancellation_date timestamp without time zone;
@@ -1,2 +0,0 @@
-alter table billing_customers
- add column orb_portal_url text;
@@ -1 +0,0 @@
-ALTER TABLE projects ADD COLUMN windows_paths BOOLEAN DEFAULT FALSE;
@@ -1,3 +0,0 @@
-alter table billing_subscriptions
- add column token_spend_in_cents integer,
- add column token_spend_in_cents_updated_at timestamp without time zone;
@@ -1,2 +0,0 @@
-ALTER TABLE "worktree_entries"
-ADD "is_hidden" BOOL NOT NULL DEFAULT FALSE;
@@ -1,3 +0,0 @@
-drop table observed_channel_messages;
-drop table channel_message_mentions;
-drop table channel_messages;
@@ -1 +0,0 @@
-drop table embeddings;
@@ -1,4 +0,0 @@
-alter table billing_customers
- add column external_id text;
-
-create unique index uix_billing_customers_on_external_id on billing_customers (external_id);
@@ -1,2 +0,0 @@
-ALTER TABLE "project_repositories" ADD COLUMN "remote_upstream_url" VARCHAR;
-ALTER TABLE "project_repositories" ADD COLUMN "remote_origin_url" VARCHAR;
@@ -0,0 +1,899 @@
+CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public;
+
+CREATE TABLE public.access_tokens (
+ id integer NOT NULL,
+ user_id integer,
+ hash character varying(128),
+ impersonated_user_id integer
+);
+
+CREATE SEQUENCE public.access_tokens_id_seq
+ AS integer
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE public.access_tokens_id_seq OWNED BY public.access_tokens.id;
+
+CREATE TABLE public.breakpoints (
+ id integer NOT NULL,
+ project_id integer NOT NULL,
+ "position" integer NOT NULL,
+ log_message text,
+ worktree_id bigint NOT NULL,
+ path text NOT NULL,
+ kind character varying NOT NULL
+);
+
+CREATE SEQUENCE public.breakpoints_id_seq
+ AS integer
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE public.breakpoints_id_seq OWNED BY public.breakpoints.id;
+
+CREATE TABLE public.buffer_operations (
+ buffer_id integer NOT NULL,
+ epoch integer NOT NULL,
+ replica_id integer NOT NULL,
+ lamport_timestamp integer NOT NULL,
+ value bytea NOT NULL
+);
+
+CREATE TABLE public.buffer_snapshots (
+ buffer_id integer NOT NULL,
+ epoch integer NOT NULL,
+ text text NOT NULL,
+ operation_serialization_version integer NOT NULL
+);
+
+CREATE TABLE public.buffers (
+ id integer NOT NULL,
+ channel_id integer NOT NULL,
+ epoch integer DEFAULT 0 NOT NULL,
+ latest_operation_epoch integer,
+ latest_operation_lamport_timestamp integer,
+ latest_operation_replica_id integer
+);
+
+CREATE SEQUENCE public.buffers_id_seq
+ AS integer
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE public.buffers_id_seq OWNED BY public.buffers.id;
+
+CREATE TABLE public.channel_buffer_collaborators (
+ id integer NOT NULL,
+ channel_id integer NOT NULL,
+ connection_id integer NOT NULL,
+ connection_server_id integer NOT NULL,
+ connection_lost boolean DEFAULT false NOT NULL,
+ user_id integer NOT NULL,
+ replica_id integer NOT NULL
+);
+
+CREATE SEQUENCE public.channel_buffer_collaborators_id_seq
+ AS integer
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE public.channel_buffer_collaborators_id_seq OWNED BY public.channel_buffer_collaborators.id;
+
+CREATE TABLE public.channel_chat_participants (
+ id integer NOT NULL,
+ user_id integer NOT NULL,
+ channel_id integer NOT NULL,
+ connection_id integer NOT NULL,
+ connection_server_id integer NOT NULL
+);
+
+CREATE SEQUENCE public.channel_chat_participants_id_seq
+ AS integer
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE public.channel_chat_participants_id_seq OWNED BY public.channel_chat_participants.id;
+
+CREATE TABLE public.channel_members (
+ id integer NOT NULL,
+ channel_id integer NOT NULL,
+ user_id integer NOT NULL,
+ accepted boolean DEFAULT false NOT NULL,
+ updated_at timestamp without time zone DEFAULT now() NOT NULL,
+ role text NOT NULL
+);
+
+CREATE SEQUENCE public.channel_members_id_seq
+ AS integer
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE public.channel_members_id_seq OWNED BY public.channel_members.id;
+
+CREATE TABLE public.channels (
+ id integer NOT NULL,
+ name character varying NOT NULL,
+ created_at timestamp without time zone DEFAULT now() NOT NULL,
+ visibility text DEFAULT 'members'::text NOT NULL,
+ parent_path text NOT NULL,
+ requires_zed_cla boolean DEFAULT false NOT NULL,
+ channel_order integer DEFAULT 1 NOT NULL
+);
+
+CREATE SEQUENCE public.channels_id_seq
+ AS integer
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE public.channels_id_seq OWNED BY public.channels.id;
+
+CREATE TABLE public.contacts (
+ id integer NOT NULL,
+ user_id_a integer NOT NULL,
+ user_id_b integer NOT NULL,
+ a_to_b boolean NOT NULL,
+ should_notify boolean NOT NULL,
+ accepted boolean NOT NULL
+);
+
+CREATE SEQUENCE public.contacts_id_seq
+ AS integer
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE public.contacts_id_seq OWNED BY public.contacts.id;
+
+CREATE TABLE public.contributors (
+ user_id integer NOT NULL,
+ signed_at timestamp without time zone DEFAULT now() NOT NULL
+);
+
+CREATE TABLE public.extension_versions (
+ extension_id integer NOT NULL,
+ version text NOT NULL,
+ published_at timestamp without time zone DEFAULT now() NOT NULL,
+ authors text NOT NULL,
+ repository text NOT NULL,
+ description text NOT NULL,
+ download_count bigint DEFAULT 0 NOT NULL,
+ schema_version integer DEFAULT 0 NOT NULL,
+ wasm_api_version text,
+ provides_themes boolean DEFAULT false NOT NULL,
+ provides_icon_themes boolean DEFAULT false NOT NULL,
+ provides_languages boolean DEFAULT false NOT NULL,
+ provides_grammars boolean DEFAULT false NOT NULL,
+ provides_language_servers boolean DEFAULT false NOT NULL,
+ provides_context_servers boolean DEFAULT false NOT NULL,
+ provides_slash_commands boolean DEFAULT false NOT NULL,
+ provides_indexed_docs_providers boolean DEFAULT false NOT NULL,
+ provides_snippets boolean DEFAULT false NOT NULL,
+ provides_debug_adapters boolean DEFAULT false NOT NULL,
+ provides_agent_servers boolean DEFAULT false NOT NULL
+);
+
+CREATE TABLE public.extensions (
+ id integer NOT NULL,
+ name text NOT NULL,
+ external_id text NOT NULL,
+ latest_version text NOT NULL,
+ total_download_count bigint DEFAULT 0 NOT NULL
+);
+
+CREATE SEQUENCE public.extensions_id_seq
+ AS integer
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE public.extensions_id_seq OWNED BY public.extensions.id;
+
+CREATE TABLE public.feature_flags (
+ id integer NOT NULL,
+ flag character varying(255) NOT NULL,
+ enabled_for_all boolean DEFAULT false NOT NULL
+);
+
+CREATE SEQUENCE public.feature_flags_id_seq
+ AS integer
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE public.feature_flags_id_seq OWNED BY public.feature_flags.id;
+
+CREATE TABLE public.followers (
+ id integer NOT NULL,
+ room_id integer NOT NULL,
+ project_id integer NOT NULL,
+ leader_connection_server_id integer NOT NULL,
+ leader_connection_id integer NOT NULL,
+ follower_connection_server_id integer NOT NULL,
+ follower_connection_id integer NOT NULL
+);
+
+CREATE SEQUENCE public.followers_id_seq
+ AS integer
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE public.followers_id_seq OWNED BY public.followers.id;
+
+CREATE TABLE public.language_servers (
+ project_id integer NOT NULL,
+ id bigint NOT NULL,
+ name character varying NOT NULL,
+ capabilities text NOT NULL,
+ worktree_id bigint
+);
+
+CREATE TABLE public.notification_kinds (
+ id integer NOT NULL,
+ name character varying NOT NULL
+);
+
+CREATE SEQUENCE public.notification_kinds_id_seq
+ AS integer
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE public.notification_kinds_id_seq OWNED BY public.notification_kinds.id;
+
+CREATE TABLE public.notifications (
+ id integer NOT NULL,
+ created_at timestamp without time zone DEFAULT now() NOT NULL,
+ recipient_id integer NOT NULL,
+ kind integer NOT NULL,
+ entity_id integer,
+ content text,
+ is_read boolean DEFAULT false NOT NULL,
+ response boolean
+);
+
+CREATE SEQUENCE public.notifications_id_seq
+ AS integer
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE public.notifications_id_seq OWNED BY public.notifications.id;
+
+CREATE TABLE public.observed_buffer_edits (
+ user_id integer NOT NULL,
+ buffer_id integer NOT NULL,
+ epoch integer NOT NULL,
+ lamport_timestamp integer NOT NULL,
+ replica_id integer NOT NULL
+);
+
+CREATE TABLE public.project_collaborators (
+ id integer NOT NULL,
+ project_id integer NOT NULL,
+ connection_id integer NOT NULL,
+ user_id integer NOT NULL,
+ replica_id integer NOT NULL,
+ is_host boolean NOT NULL,
+ connection_server_id integer NOT NULL,
+ committer_name character varying,
+ committer_email character varying
+);
+
+CREATE SEQUENCE public.project_collaborators_id_seq
+ AS integer
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE public.project_collaborators_id_seq OWNED BY public.project_collaborators.id;
+
+CREATE TABLE public.project_repositories (
+ project_id integer NOT NULL,
+ abs_path character varying,
+ id bigint NOT NULL,
+ legacy_worktree_id bigint,
+ entry_ids character varying,
+ branch character varying,
+ scan_id bigint NOT NULL,
+ is_deleted boolean NOT NULL,
+ current_merge_conflicts character varying,
+ branch_summary character varying,
+ head_commit_details character varying,
+ merge_message character varying
+);
+
+CREATE TABLE public.project_repository_statuses (
+ project_id integer NOT NULL,
+ repository_id bigint NOT NULL,
+ repo_path character varying NOT NULL,
+ status bigint NOT NULL,
+ status_kind integer NOT NULL,
+ first_status integer,
+ second_status integer,
+ scan_id bigint NOT NULL,
+ is_deleted boolean NOT NULL
+);
+
+CREATE TABLE public.projects (
+ id integer NOT NULL,
+ host_user_id integer,
+ unregistered boolean DEFAULT false NOT NULL,
+ room_id integer,
+ host_connection_id integer,
+ host_connection_server_id integer,
+ windows_paths boolean DEFAULT false
+);
+
+CREATE SEQUENCE public.projects_id_seq
+ AS integer
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE public.projects_id_seq OWNED BY public.projects.id;
+
+CREATE TABLE public.room_participants (
+ id integer NOT NULL,
+ room_id integer NOT NULL,
+ user_id integer NOT NULL,
+ answering_connection_id integer,
+ location_kind integer,
+ location_project_id integer,
+ initial_project_id integer,
+ calling_user_id integer NOT NULL,
+ calling_connection_id integer NOT NULL,
+ answering_connection_lost boolean DEFAULT false NOT NULL,
+ answering_connection_server_id integer,
+ calling_connection_server_id integer,
+ participant_index integer,
+ role text
+);
+
+CREATE SEQUENCE public.room_participants_id_seq
+ AS integer
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE public.room_participants_id_seq OWNED BY public.room_participants.id;
+
+CREATE TABLE public.rooms (
+ id integer NOT NULL,
+ live_kit_room character varying NOT NULL,
+ channel_id integer
+);
+
+CREATE SEQUENCE public.rooms_id_seq
+ AS integer
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE public.rooms_id_seq OWNED BY public.rooms.id;
+
+CREATE TABLE public.servers (
+ id integer NOT NULL,
+ environment character varying NOT NULL
+);
+
+CREATE SEQUENCE public.servers_id_seq
+ AS integer
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE public.servers_id_seq OWNED BY public.servers.id;
+
+CREATE TABLE public.user_features (
+ user_id integer NOT NULL,
+ feature_id integer NOT NULL
+);
+
+CREATE TABLE public.users (
+ id integer NOT NULL,
+ github_login character varying,
+ admin boolean NOT NULL,
+ email_address character varying(255) DEFAULT NULL::character varying,
+ invite_code character varying(64),
+ invite_count integer DEFAULT 0 NOT NULL,
+ inviter_id integer,
+ connected_once boolean DEFAULT false NOT NULL,
+ created_at timestamp without time zone DEFAULT now() NOT NULL,
+ github_user_id integer NOT NULL,
+ metrics_id uuid DEFAULT gen_random_uuid() NOT NULL,
+ accepted_tos_at timestamp without time zone,
+ github_user_created_at timestamp without time zone,
+ custom_llm_monthly_allowance_in_cents integer,
+ name text
+);
+
+CREATE SEQUENCE public.users_id_seq
+ AS integer
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;
+
+CREATE TABLE public.worktree_diagnostic_summaries (
+ project_id integer NOT NULL,
+ worktree_id bigint NOT NULL,
+ path character varying NOT NULL,
+ language_server_id bigint NOT NULL,
+ error_count integer NOT NULL,
+ warning_count integer NOT NULL
+);
+
+CREATE TABLE public.worktree_entries (
+ project_id integer NOT NULL,
+ worktree_id bigint NOT NULL,
+ id bigint NOT NULL,
+ is_dir boolean NOT NULL,
+ path character varying NOT NULL,
+ inode bigint NOT NULL,
+ mtime_seconds bigint NOT NULL,
+ mtime_nanos integer NOT NULL,
+ is_symlink boolean DEFAULT false NOT NULL,
+ is_ignored boolean NOT NULL,
+ scan_id bigint,
+ is_deleted boolean,
+ git_status bigint,
+ is_external boolean DEFAULT false NOT NULL,
+ is_fifo boolean DEFAULT false NOT NULL,
+ canonical_path text,
+ is_hidden boolean DEFAULT false NOT NULL
+);
+
+CREATE TABLE public.worktree_settings_files (
+ project_id integer NOT NULL,
+ worktree_id bigint NOT NULL,
+ path character varying NOT NULL,
+ content text NOT NULL,
+ kind character varying
+);
+
+CREATE TABLE public.worktrees (
+ project_id integer NOT NULL,
+ id bigint NOT NULL,
+ root_name character varying NOT NULL,
+ abs_path character varying NOT NULL,
+ visible boolean NOT NULL,
+ scan_id bigint NOT NULL,
+ is_complete boolean DEFAULT false NOT NULL,
+ completed_scan_id bigint
+);
+
+ALTER TABLE ONLY public.access_tokens ALTER COLUMN id SET DEFAULT nextval('public.access_tokens_id_seq'::regclass);
+
+ALTER TABLE ONLY public.breakpoints ALTER COLUMN id SET DEFAULT nextval('public.breakpoints_id_seq'::regclass);
+
+ALTER TABLE ONLY public.buffers ALTER COLUMN id SET DEFAULT nextval('public.buffers_id_seq'::regclass);
+
+ALTER TABLE ONLY public.channel_buffer_collaborators ALTER COLUMN id SET DEFAULT nextval('public.channel_buffer_collaborators_id_seq'::regclass);
+
+ALTER TABLE ONLY public.channel_chat_participants ALTER COLUMN id SET DEFAULT nextval('public.channel_chat_participants_id_seq'::regclass);
+
+ALTER TABLE ONLY public.channel_members ALTER COLUMN id SET DEFAULT nextval('public.channel_members_id_seq'::regclass);
+
+ALTER TABLE ONLY public.channels ALTER COLUMN id SET DEFAULT nextval('public.channels_id_seq'::regclass);
+
+ALTER TABLE ONLY public.contacts ALTER COLUMN id SET DEFAULT nextval('public.contacts_id_seq'::regclass);
+
+ALTER TABLE ONLY public.extensions ALTER COLUMN id SET DEFAULT nextval('public.extensions_id_seq'::regclass);
+
+ALTER TABLE ONLY public.feature_flags ALTER COLUMN id SET DEFAULT nextval('public.feature_flags_id_seq'::regclass);
+
+ALTER TABLE ONLY public.followers ALTER COLUMN id SET DEFAULT nextval('public.followers_id_seq'::regclass);
+
+ALTER TABLE ONLY public.notification_kinds ALTER COLUMN id SET DEFAULT nextval('public.notification_kinds_id_seq'::regclass);
+
+ALTER TABLE ONLY public.notifications ALTER COLUMN id SET DEFAULT nextval('public.notifications_id_seq'::regclass);
+
+ALTER TABLE ONLY public.project_collaborators ALTER COLUMN id SET DEFAULT nextval('public.project_collaborators_id_seq'::regclass);
+
+ALTER TABLE ONLY public.projects ALTER COLUMN id SET DEFAULT nextval('public.projects_id_seq'::regclass);
+
+ALTER TABLE ONLY public.room_participants ALTER COLUMN id SET DEFAULT nextval('public.room_participants_id_seq'::regclass);
+
+ALTER TABLE ONLY public.rooms ALTER COLUMN id SET DEFAULT nextval('public.rooms_id_seq'::regclass);
+
+ALTER TABLE ONLY public.servers ALTER COLUMN id SET DEFAULT nextval('public.servers_id_seq'::regclass);
+
+ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);
+
+ALTER TABLE ONLY public.access_tokens
+ ADD CONSTRAINT access_tokens_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY public.breakpoints
+ ADD CONSTRAINT breakpoints_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY public.buffer_operations
+ ADD CONSTRAINT buffer_operations_pkey PRIMARY KEY (buffer_id, epoch, lamport_timestamp, replica_id);
+
+ALTER TABLE ONLY public.buffer_snapshots
+ ADD CONSTRAINT buffer_snapshots_pkey PRIMARY KEY (buffer_id, epoch);
+
+ALTER TABLE ONLY public.buffers
+ ADD CONSTRAINT buffers_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY public.channel_buffer_collaborators
+ ADD CONSTRAINT channel_buffer_collaborators_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY public.channel_chat_participants
+ ADD CONSTRAINT channel_chat_participants_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY public.channel_members
+ ADD CONSTRAINT channel_members_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY public.channels
+ ADD CONSTRAINT channels_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY public.contacts
+ ADD CONSTRAINT contacts_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY public.contributors
+ ADD CONSTRAINT contributors_pkey PRIMARY KEY (user_id);
+
+ALTER TABLE ONLY public.extension_versions
+ ADD CONSTRAINT extension_versions_pkey PRIMARY KEY (extension_id, version);
+
+ALTER TABLE ONLY public.extensions
+ ADD CONSTRAINT extensions_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY public.feature_flags
+ ADD CONSTRAINT feature_flags_flag_key UNIQUE (flag);
+
+ALTER TABLE ONLY public.feature_flags
+ ADD CONSTRAINT feature_flags_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY public.followers
+ ADD CONSTRAINT followers_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY public.language_servers
+ ADD CONSTRAINT language_servers_pkey PRIMARY KEY (project_id, id);
+
+ALTER TABLE ONLY public.notification_kinds
+ ADD CONSTRAINT notification_kinds_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY public.notifications
+ ADD CONSTRAINT notifications_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY public.observed_buffer_edits
+ ADD CONSTRAINT observed_buffer_edits_pkey PRIMARY KEY (user_id, buffer_id);
+
+ALTER TABLE ONLY public.project_collaborators
+ ADD CONSTRAINT project_collaborators_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY public.project_repositories
+ ADD CONSTRAINT project_repositories_pkey PRIMARY KEY (project_id, id);
+
+ALTER TABLE ONLY public.project_repository_statuses
+ ADD CONSTRAINT project_repository_statuses_pkey PRIMARY KEY (project_id, repository_id, repo_path);
+
+ALTER TABLE ONLY public.projects
+ ADD CONSTRAINT projects_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY public.room_participants
+ ADD CONSTRAINT room_participants_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY public.rooms
+ ADD CONSTRAINT rooms_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY public.servers
+ ADD CONSTRAINT servers_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY public.user_features
+ ADD CONSTRAINT user_features_pkey PRIMARY KEY (user_id, feature_id);
+
+ALTER TABLE ONLY public.users
+ ADD CONSTRAINT users_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY public.worktree_diagnostic_summaries
+ ADD CONSTRAINT worktree_diagnostic_summaries_pkey PRIMARY KEY (project_id, worktree_id, path);
+
+ALTER TABLE ONLY public.worktree_entries
+ ADD CONSTRAINT worktree_entries_pkey PRIMARY KEY (project_id, worktree_id, id);
+
+ALTER TABLE ONLY public.worktree_settings_files
+ ADD CONSTRAINT worktree_settings_files_pkey PRIMARY KEY (project_id, worktree_id, path);
+
+ALTER TABLE ONLY public.worktrees
+ ADD CONSTRAINT worktrees_pkey PRIMARY KEY (project_id, id);
+
+CREATE INDEX index_access_tokens_user_id ON public.access_tokens USING btree (user_id);
+
+CREATE INDEX index_breakpoints_on_project_id ON public.breakpoints USING btree (project_id);
+
+CREATE INDEX index_buffers_on_channel_id ON public.buffers USING btree (channel_id);
+
+CREATE INDEX index_channel_buffer_collaborators_on_channel_id ON public.channel_buffer_collaborators USING btree (channel_id);
+
+CREATE UNIQUE INDEX index_channel_buffer_collaborators_on_channel_id_and_replica_id ON public.channel_buffer_collaborators USING btree (channel_id, replica_id);
+
+CREATE 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);
+
+CREATE INDEX index_channel_buffer_collaborators_on_connection_id ON public.channel_buffer_collaborators USING btree (connection_id);
+
+CREATE INDEX index_channel_buffer_collaborators_on_connection_server_id ON public.channel_buffer_collaborators USING btree (connection_server_id);
+
+CREATE INDEX index_channel_chat_participants_on_channel_id ON public.channel_chat_participants USING btree (channel_id);
+
+CREATE UNIQUE INDEX index_channel_members_on_channel_id_and_user_id ON public.channel_members USING btree (channel_id, user_id);
+
+CREATE INDEX index_channels_on_parent_path ON public.channels USING btree (parent_path text_pattern_ops);
+
+CREATE INDEX index_channels_on_parent_path_and_order ON public.channels USING btree (parent_path, channel_order);
+
+CREATE INDEX index_contacts_user_id_b ON public.contacts USING btree (user_id_b);
+
+CREATE UNIQUE INDEX index_contacts_user_ids ON public.contacts USING btree (user_id_a, user_id_b);
+
+CREATE UNIQUE INDEX index_extensions_external_id ON public.extensions USING btree (external_id);
+
+CREATE INDEX index_extensions_total_download_count ON public.extensions USING btree (total_download_count);
+
+CREATE UNIQUE INDEX index_feature_flags ON public.feature_flags USING btree (id);
+
+CREATE 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);
+
+CREATE INDEX index_followers_on_room_id ON public.followers USING btree (room_id);
+
+CREATE UNIQUE INDEX index_invite_code_users ON public.users USING btree (invite_code);
+
+CREATE INDEX index_language_servers_on_project_id ON public.language_servers USING btree (project_id);
+
+CREATE UNIQUE INDEX index_notification_kinds_on_name ON public.notification_kinds USING btree (name);
+
+CREATE INDEX index_notifications_on_recipient_id_is_read_kind_entity_id ON public.notifications USING btree (recipient_id, is_read, kind, entity_id);
+
+CREATE UNIQUE INDEX index_observed_buffer_user_and_buffer_id ON public.observed_buffer_edits USING btree (user_id, buffer_id);
+
+CREATE INDEX index_project_collaborators_on_connection_id ON public.project_collaborators USING btree (connection_id);
+
+CREATE INDEX index_project_collaborators_on_connection_server_id ON public.project_collaborators USING btree (connection_server_id);
+
+CREATE INDEX index_project_collaborators_on_project_id ON public.project_collaborators USING btree (project_id);
+
+CREATE UNIQUE INDEX index_project_collaborators_on_project_id_and_replica_id ON public.project_collaborators USING btree (project_id, replica_id);
+
+CREATE 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);
+
+CREATE INDEX index_project_repos_statuses_on_project_id ON public.project_repository_statuses USING btree (project_id);
+
+CREATE INDEX index_project_repos_statuses_on_project_id_and_repo_id ON public.project_repository_statuses USING btree (project_id, repository_id);
+
+CREATE INDEX index_project_repositories_on_project_id ON public.project_repositories USING btree (project_id);
+
+CREATE INDEX index_projects_on_host_connection_id_and_host_connection_server ON public.projects USING btree (host_connection_id, host_connection_server_id);
+
+CREATE INDEX index_projects_on_host_connection_server_id ON public.projects USING btree (host_connection_server_id);
+
+CREATE INDEX index_room_participants_on_answering_connection_id ON public.room_participants USING btree (answering_connection_id);
+
+CREATE UNIQUE INDEX index_room_participants_on_answering_connection_id_and_answerin ON public.room_participants USING btree (answering_connection_id, answering_connection_server_id);
+
+CREATE INDEX index_room_participants_on_answering_connection_server_id ON public.room_participants USING btree (answering_connection_server_id);
+
+CREATE INDEX index_room_participants_on_calling_connection_server_id ON public.room_participants USING btree (calling_connection_server_id);
+
+CREATE INDEX index_room_participants_on_room_id ON public.room_participants USING btree (room_id);
+
+CREATE UNIQUE INDEX index_room_participants_on_user_id ON public.room_participants USING btree (user_id);
+
+CREATE UNIQUE INDEX index_rooms_on_channel_id ON public.rooms USING btree (channel_id);
+
+CREATE INDEX index_settings_files_on_project_id ON public.worktree_settings_files USING btree (project_id);
+
+CREATE INDEX index_settings_files_on_project_id_and_wt_id ON public.worktree_settings_files USING btree (project_id, worktree_id);
+
+CREATE INDEX index_user_features_on_feature_id ON public.user_features USING btree (feature_id);
+
+CREATE INDEX index_user_features_on_user_id ON public.user_features USING btree (user_id);
+
+CREATE UNIQUE INDEX index_user_features_user_id_and_feature_id ON public.user_features USING btree (user_id, feature_id);
+
+CREATE UNIQUE INDEX index_users_github_login ON public.users USING btree (github_login);
+
+CREATE INDEX index_users_on_email_address ON public.users USING btree (email_address);
+
+CREATE INDEX index_worktree_diagnostic_summaries_on_project_id ON public.worktree_diagnostic_summaries USING btree (project_id);
+
+CREATE INDEX index_worktree_diagnostic_summaries_on_project_id_and_worktree_ ON public.worktree_diagnostic_summaries USING btree (project_id, worktree_id);
+
+CREATE INDEX index_worktree_entries_on_project_id ON public.worktree_entries USING btree (project_id);
+
+CREATE INDEX index_worktree_entries_on_project_id_and_worktree_id ON public.worktree_entries USING btree (project_id, worktree_id);
+
+CREATE INDEX index_worktrees_on_project_id ON public.worktrees USING btree (project_id);
+
+CREATE INDEX trigram_index_extensions_name ON public.extensions USING gin (name public.gin_trgm_ops);
+
+CREATE INDEX trigram_index_users_on_github_login ON public.users USING gin (github_login public.gin_trgm_ops);
+
+CREATE 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));
+
+CREATE UNIQUE INDEX uix_users_on_github_user_id ON public.users USING btree (github_user_id);
+
+ALTER TABLE ONLY public.access_tokens
+ ADD CONSTRAINT access_tokens_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.breakpoints
+ ADD CONSTRAINT breakpoints_project_id_fkey FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.buffer_operations
+ ADD CONSTRAINT buffer_operations_buffer_id_fkey FOREIGN KEY (buffer_id) REFERENCES public.buffers(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.buffer_snapshots
+ ADD CONSTRAINT buffer_snapshots_buffer_id_fkey FOREIGN KEY (buffer_id) REFERENCES public.buffers(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.buffers
+ ADD CONSTRAINT buffers_channel_id_fkey FOREIGN KEY (channel_id) REFERENCES public.channels(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.channel_buffer_collaborators
+ ADD CONSTRAINT channel_buffer_collaborators_channel_id_fkey FOREIGN KEY (channel_id) REFERENCES public.channels(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.channel_buffer_collaborators
+ ADD CONSTRAINT channel_buffer_collaborators_connection_server_id_fkey FOREIGN KEY (connection_server_id) REFERENCES public.servers(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.channel_buffer_collaborators
+ ADD CONSTRAINT channel_buffer_collaborators_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.channel_chat_participants
+ ADD CONSTRAINT channel_chat_participants_channel_id_fkey FOREIGN KEY (channel_id) REFERENCES public.channels(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.channel_chat_participants
+ ADD CONSTRAINT channel_chat_participants_connection_server_id_fkey FOREIGN KEY (connection_server_id) REFERENCES public.servers(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.channel_chat_participants
+ ADD CONSTRAINT channel_chat_participants_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
+
+ALTER TABLE ONLY public.channel_members
+ ADD CONSTRAINT channel_members_channel_id_fkey FOREIGN KEY (channel_id) REFERENCES public.channels(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.channel_members
+ ADD CONSTRAINT channel_members_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.contacts
+ ADD CONSTRAINT contacts_user_id_a_fkey FOREIGN KEY (user_id_a) REFERENCES public.users(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.contacts
+ ADD CONSTRAINT contacts_user_id_b_fkey FOREIGN KEY (user_id_b) REFERENCES public.users(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.contributors
+ ADD CONSTRAINT contributors_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
+
+ALTER TABLE ONLY public.extension_versions
+ ADD CONSTRAINT extension_versions_extension_id_fkey FOREIGN KEY (extension_id) REFERENCES public.extensions(id);
+
+ALTER TABLE ONLY public.project_repositories
+ ADD CONSTRAINT fk_project_repositories_project_id FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.project_repository_statuses
+ ADD CONSTRAINT fk_project_repository_statuses_project_id FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.followers
+ ADD CONSTRAINT followers_follower_connection_server_id_fkey FOREIGN KEY (follower_connection_server_id) REFERENCES public.servers(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.followers
+ ADD CONSTRAINT followers_leader_connection_server_id_fkey FOREIGN KEY (leader_connection_server_id) REFERENCES public.servers(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.followers
+ ADD CONSTRAINT followers_project_id_fkey FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.followers
+ ADD CONSTRAINT followers_room_id_fkey FOREIGN KEY (room_id) REFERENCES public.rooms(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.language_servers
+ ADD CONSTRAINT language_servers_project_id_fkey FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.notifications
+ ADD CONSTRAINT notifications_kind_fkey FOREIGN KEY (kind) REFERENCES public.notification_kinds(id);
+
+ALTER TABLE ONLY public.notifications
+ ADD CONSTRAINT notifications_recipient_id_fkey FOREIGN KEY (recipient_id) REFERENCES public.users(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.observed_buffer_edits
+ ADD CONSTRAINT observed_buffer_edits_buffer_id_fkey FOREIGN KEY (buffer_id) REFERENCES public.buffers(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.observed_buffer_edits
+ ADD CONSTRAINT observed_buffer_edits_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.project_collaborators
+ ADD CONSTRAINT project_collaborators_connection_server_id_fkey FOREIGN KEY (connection_server_id) REFERENCES public.servers(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.project_collaborators
+ ADD CONSTRAINT project_collaborators_project_id_fkey FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.projects
+ ADD CONSTRAINT projects_host_connection_server_id_fkey FOREIGN KEY (host_connection_server_id) REFERENCES public.servers(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.projects
+ ADD CONSTRAINT projects_host_user_id_fkey FOREIGN KEY (host_user_id) REFERENCES public.users(id);
+
+ALTER TABLE ONLY public.projects
+ ADD CONSTRAINT projects_room_id_fkey FOREIGN KEY (room_id) REFERENCES public.rooms(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.room_participants
+ ADD CONSTRAINT room_participants_answering_connection_server_id_fkey FOREIGN KEY (answering_connection_server_id) REFERENCES public.servers(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.room_participants
+ ADD CONSTRAINT room_participants_calling_connection_server_id_fkey FOREIGN KEY (calling_connection_server_id) REFERENCES public.servers(id) ON DELETE SET NULL;
+
+ALTER TABLE ONLY public.room_participants
+ ADD CONSTRAINT room_participants_calling_user_id_fkey FOREIGN KEY (calling_user_id) REFERENCES public.users(id);
+
+ALTER TABLE ONLY public.room_participants
+ ADD CONSTRAINT room_participants_room_id_fkey FOREIGN KEY (room_id) REFERENCES public.rooms(id);
+
+ALTER TABLE ONLY public.room_participants
+ ADD CONSTRAINT room_participants_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
+
+ALTER TABLE ONLY public.rooms
+ ADD CONSTRAINT rooms_channel_id_fkey FOREIGN KEY (channel_id) REFERENCES public.channels(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.user_features
+ ADD CONSTRAINT user_features_feature_id_fkey FOREIGN KEY (feature_id) REFERENCES public.feature_flags(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.user_features
+ ADD CONSTRAINT user_features_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.users
+ ADD CONSTRAINT users_inviter_id_fkey FOREIGN KEY (inviter_id) REFERENCES public.users(id) ON DELETE SET NULL;
+
+ALTER TABLE ONLY public.worktree_diagnostic_summaries
+ 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;
+
+ALTER TABLE ONLY public.worktree_entries
+ ADD CONSTRAINT worktree_entries_project_id_worktree_id_fkey FOREIGN KEY (project_id, worktree_id) REFERENCES public.worktrees(project_id, id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY public.worktree_settings_files
+ 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;
+
+ALTER TABLE ONLY public.worktrees
+ ADD CONSTRAINT worktrees_project_id_fkey FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
@@ -1,19 +0,0 @@
-create table if not exists providers (
- id serial primary key,
- name text not null
-);
-
-create unique index uix_providers_on_name on providers (name);
-
-create table if not exists models (
- id serial primary key,
- provider_id integer not null references providers (id) on delete cascade,
- name text not null,
- max_requests_per_minute integer not null,
- max_tokens_per_minute integer not null,
- max_tokens_per_day integer not null
-);
-
-create unique index uix_models_on_provider_id_name on models (provider_id, name);
-create index ix_models_on_provider_id on models (provider_id);
-create index ix_models_on_name on models (name);
@@ -1,19 +0,0 @@
-create table usage_measures (
- id serial primary key,
- name text not null
-);
-
-create unique index uix_usage_measures_on_name on usage_measures (name);
-
-create table if not exists usages (
- id serial primary key,
- user_id integer not null,
- model_id integer not null references models (id) on delete cascade,
- measure_id integer not null references usage_measures (id) on delete cascade,
- timestamp timestamp without time zone not null,
- buckets bigint[] not null
-);
-
-create index ix_usages_on_user_id on usages (user_id);
-create index ix_usages_on_model_id on usages (model_id);
-create unique index uix_usages_on_user_id_model_id_measure_id on usages (user_id, model_id, measure_id);
@@ -1,4 +0,0 @@
-ALTER TABLE models
- ALTER COLUMN max_requests_per_minute TYPE bigint,
- ALTER COLUMN max_tokens_per_minute TYPE bigint,
- ALTER COLUMN max_tokens_per_day TYPE bigint;
@@ -1,3 +0,0 @@
-ALTER TABLE models
- ADD COLUMN price_per_million_input_tokens integer NOT NULL DEFAULT 0,
- ADD COLUMN price_per_million_output_tokens integer NOT NULL DEFAULT 0;
@@ -1 +0,0 @@
-alter table usages add column is_staff boolean not null default false;
@@ -1,9 +0,0 @@
-create table lifetime_usages (
- id serial primary key,
- user_id integer not null,
- model_id integer not null references models (id) on delete cascade,
- input_tokens bigint not null default 0,
- output_tokens bigint not null default 0
-);
-
-create unique index uix_lifetime_usages_on_user_id_model_id on lifetime_usages (user_id, model_id);
@@ -1,7 +0,0 @@
-create table revoked_access_tokens (
- id serial primary key,
- jti text not null,
- revoked_at timestamp without time zone not null default now()
-);
-
-create unique index uix_revoked_access_tokens_on_jti on revoked_access_tokens (jti);
@@ -1,11 +0,0 @@
-alter table models
- add column price_per_million_cache_creation_input_tokens integer not null default 0,
- add column price_per_million_cache_read_input_tokens integer not null default 0;
-
-alter table usages
- add column cache_creation_input_tokens_this_month bigint not null default 0,
- add column cache_read_input_tokens_this_month bigint not null default 0;
-
-alter table lifetime_usages
- add column cache_creation_input_tokens bigint not null default 0,
- add column cache_read_input_tokens bigint not null default 0;
@@ -1,3 +0,0 @@
-alter table usages
- drop column cache_creation_input_tokens_this_month,
- drop column cache_read_input_tokens_this_month;
@@ -1,13 +0,0 @@
-create table monthly_usages (
- id serial primary key,
- user_id integer not null,
- model_id integer not null references models (id) on delete cascade,
- month integer not null,
- year integer not null,
- input_tokens bigint not null default 0,
- cache_creation_input_tokens bigint not null default 0,
- cache_read_input_tokens bigint not null default 0,
- output_tokens bigint not null default 0
-);
-
-create unique index uix_monthly_usages_on_user_id_model_id_month_year on monthly_usages (user_id, model_id, month, year);
@@ -1,12 +0,0 @@
-create table billing_events (
- id serial primary key,
- idempotency_key uuid not null default gen_random_uuid(),
- user_id integer not null,
- model_id integer not null references models (id) on delete cascade,
- input_tokens bigint not null default 0,
- input_cache_creation_tokens bigint not null default 0,
- input_cache_read_tokens bigint not null default 0,
- output_tokens bigint not null default 0
-);
-
-create index uix_billing_events_on_user_id_model_id on billing_events (user_id, model_id);
@@ -1,3 +0,0 @@
-alter table models
- add column max_input_tokens_per_minute bigint not null default 0,
- add column max_output_tokens_per_minute bigint not null default 0;
@@ -1,10 +0,0 @@
-create table subscription_usages (
- id serial primary key,
- user_id integer not null,
- period_start_at timestamp without time zone not null,
- period_end_at timestamp without time zone not null,
- model_requests int not null default 0,
- edit_predictions int not null default 0
-);
-
-create unique index uix_subscription_usages_on_user_id_start_at_end_at on subscription_usages (user_id, period_start_at, period_end_at);
@@ -1,4 +0,0 @@
-alter table subscription_usages
- add column plan text not null;
-
-create index ix_subscription_usages_on_plan on subscription_usages (plan);
@@ -1,8 +0,0 @@
-create table subscription_usage_meters (
- id serial primary key,
- subscription_usage_id integer not null references subscription_usages (id) on delete cascade,
- model_id integer not null references models (id) on delete cascade,
- requests integer not null default 0
-);
-
-create unique index uix_subscription_usage_meters_on_subscription_usage_model on subscription_usage_meters (subscription_usage_id, model_id);
@@ -1,6 +0,0 @@
-alter table subscription_usage_meters
- add column mode text not null default 'normal';
-
-drop index uix_subscription_usage_meters_on_subscription_usage_model;
-
-create unique index uix_subscription_usage_meters_on_subscription_usage_model_mode on subscription_usage_meters (subscription_usage_id, model_id, mode);
@@ -1,23 +0,0 @@
-create table subscription_usages_v2 (
- id uuid primary key,
- user_id integer not null,
- period_start_at timestamp without time zone not null,
- period_end_at timestamp without time zone not null,
- plan text not null,
- model_requests int not null default 0,
- edit_predictions int not null default 0
-);
-
-create unique index uix_subscription_usages_v2_on_user_id_start_at_end_at on subscription_usages_v2 (user_id, period_start_at, period_end_at);
-
-create index ix_subscription_usages_v2_on_plan on subscription_usages_v2 (plan);
-
-create table subscription_usage_meters_v2 (
- id uuid primary key,
- subscription_usage_id uuid not null references subscription_usages_v2 (id) on delete cascade,
- model_id integer not null references models (id) on delete cascade,
- mode text not null,
- requests integer not null default 0
-);
-
-create unique index uix_subscription_usage_meters_v2_on_usage_model_mode on subscription_usage_meters_v2 (subscription_usage_id, model_id, mode);
@@ -1,2 +0,0 @@
-drop table subscription_usage_meters;
-drop table subscription_usages;
@@ -1,2 +0,0 @@
-drop table monthly_usages;
-drop table lifetime_usages;
@@ -1 +0,0 @@
-drop table billing_events;
@@ -22,7 +22,6 @@ pub mod project_repository_statuses;
pub mod room;
pub mod room_participant;
pub mod server;
-pub mod signup;
pub mod user;
pub mod worktree;
pub mod worktree_diagnostic_summary;
@@ -1,28 +0,0 @@
-use crate::db::{SignupId, UserId};
-use sea_orm::entity::prelude::*;
-
-#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
-#[sea_orm(table_name = "signups")]
-pub struct Model {
- #[sea_orm(primary_key)]
- pub id: SignupId,
- pub email_address: String,
- pub email_confirmation_code: String,
- pub email_confirmation_sent: bool,
- pub created_at: DateTime,
- pub device_id: Option<String>,
- pub user_id: Option<UserId>,
- pub inviting_user_id: Option<UserId>,
- pub platform_mac: bool,
- pub platform_linux: bool,
- pub platform_windows: bool,
- pub platform_unknown: bool,
- pub editor_features: Option<Vec<String>>,
- pub programming_languages: Option<Vec<String>>,
- pub added_to_mailing_list: bool,
-}
-
-#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
-pub enum Relation {}
-
-impl ActiveModelBehavior for ActiveModel {}
@@ -3,22 +3,21 @@ mod channel_tests;
mod contributor_tests;
mod db_tests;
mod extension_tests;
+mod migrations;
-use crate::migrations::run_database_migrations;
+use std::sync::Arc;
+use std::sync::atomic::{AtomicI32, Ordering::SeqCst};
+use std::time::Duration;
-use super::*;
use gpui::BackgroundExecutor;
use parking_lot::Mutex;
use rand::prelude::*;
use sea_orm::ConnectionTrait;
use sqlx::migrate::MigrateDatabase;
-use std::{
- sync::{
- Arc,
- atomic::{AtomicI32, Ordering::SeqCst},
- },
- time::Duration,
-};
+
+use self::migrations::run_database_migrations;
+
+use super::*;
pub struct TestDb {
pub db: Option<Arc<Database>>,
@@ -3,8 +3,6 @@ pub mod auth;
pub mod db;
pub mod env;
pub mod executor;
-pub mod llm;
-pub mod migrations;
pub mod rpc;
pub mod seed;
@@ -1 +0,0 @@
-pub mod db;
@@ -1,98 +0,0 @@
-use std::future::Future;
-use std::sync::Arc;
-
-use anyhow::Context;
-pub use sea_orm::ConnectOptions;
-use sea_orm::{DatabaseConnection, DatabaseTransaction, IsolationLevel, TransactionTrait};
-
-use crate::Result;
-use crate::db::TransactionHandle;
-use crate::executor::Executor;
-
-/// The database for the LLM service.
-pub struct LlmDatabase {
- options: ConnectOptions,
- pool: DatabaseConnection,
- #[allow(unused)]
- executor: Executor,
- #[cfg(test)]
- runtime: Option<tokio::runtime::Runtime>,
-}
-
-impl LlmDatabase {
- /// Connects to the database with the given options
- pub async fn new(options: ConnectOptions, executor: Executor) -> Result<Self> {
- sqlx::any::install_default_drivers();
- Ok(Self {
- options: options.clone(),
- pool: sea_orm::Database::connect(options).await?,
- executor,
- #[cfg(test)]
- runtime: None,
- })
- }
-
- pub fn options(&self) -> &ConnectOptions {
- &self.options
- }
-
- pub async fn transaction<F, Fut, T>(&self, f: F) -> Result<T>
- where
- F: Send + Fn(TransactionHandle) -> Fut,
- Fut: Send + Future<Output = Result<T>>,
- {
- let body = async {
- let (tx, result) = self.with_transaction(&f).await?;
- match result {
- Ok(result) => match tx.commit().await.map_err(Into::into) {
- Ok(()) => Ok(result),
- Err(error) => Err(error),
- },
- Err(error) => {
- tx.rollback().await?;
- Err(error)
- }
- }
- };
-
- self.run(body).await
- }
-
- async fn with_transaction<F, Fut, T>(&self, f: &F) -> Result<(DatabaseTransaction, Result<T>)>
- where
- F: Send + Fn(TransactionHandle) -> Fut,
- Fut: Send + Future<Output = Result<T>>,
- {
- let tx = self
- .pool
- .begin_with_config(Some(IsolationLevel::ReadCommitted), None)
- .await?;
-
- let mut tx = Arc::new(Some(tx));
- let result = f(TransactionHandle(tx.clone())).await;
- let tx = Arc::get_mut(&mut tx)
- .and_then(|tx| tx.take())
- .context("couldn't complete transaction because it's still in use")?;
-
- Ok((tx, result))
- }
-
- async fn run<F, T>(&self, future: F) -> Result<T>
- where
- F: Future<Output = Result<T>>,
- {
- #[cfg(test)]
- {
- if let Executor::Deterministic(executor) = &self.executor {
- executor.simulate_random_delay().await;
- }
-
- self.runtime.as_ref().unwrap().block_on(future)
- }
-
- #[cfg(not(test))]
- {
- future.await
- }
- }
-}
@@ -1,4 +1,4 @@
-use anyhow::{Context as _, anyhow};
+use anyhow::anyhow;
use axum::headers::HeaderMapExt;
use axum::{
Extension, Router,
@@ -9,8 +9,6 @@ use axum::{
use collab::ServiceMode;
use collab::api::CloudflareIpCountryHeader;
-use collab::llm::db::LlmDatabase;
-use collab::migrations::run_database_migrations;
use collab::{
AppState, Config, Result, api::fetch_extensions_from_blob_store_periodically, db, env,
executor::Executor,
@@ -19,7 +17,6 @@ use db::Database;
use std::{
env::args,
net::{SocketAddr, TcpListener},
- path::Path,
sync::Arc,
time::Duration,
};
@@ -49,10 +46,6 @@ async fn main() -> Result<()> {
Some("version") => {
println!("collab v{} ({})", VERSION, REVISION.unwrap_or("unknown"));
}
- Some("migrate") => {
- let config = envy::from_env::<Config>().expect("error loading config");
- setup_app_database(&config).await?;
- }
Some("seed") => {
let config = envy::from_env::<Config>().expect("error loading config");
let db_options = db::ConnectOptions::new(config.database_url.clone());
@@ -69,7 +62,7 @@ async fn main() -> Result<()> {
Some("all") => ServiceMode::All,
_ => {
return Err(anyhow!(
- "usage: collab <version | migrate | seed | serve <api|collab|all>>"
+ "usage: collab <version | seed | serve <api|collab|all>>"
))?;
}
};
@@ -90,7 +83,6 @@ async fn main() -> Result<()> {
if mode.is_collab() || mode.is_api() {
setup_app_database(&config).await?;
- setup_llm_database(&config).await?;
let state = AppState::new(config, Executor::Production).await?;
@@ -211,25 +203,6 @@ async fn setup_app_database(config: &Config) -> Result<()> {
let db_options = db::ConnectOptions::new(config.database_url.clone());
let mut db = Database::new(db_options).await?;
- let migrations_path = config.migrations_path.as_deref().unwrap_or_else(|| {
- #[cfg(feature = "sqlite")]
- let default_migrations = concat!(env!("CARGO_MANIFEST_DIR"), "/migrations.sqlite");
- #[cfg(not(feature = "sqlite"))]
- let default_migrations = concat!(env!("CARGO_MANIFEST_DIR"), "/migrations");
-
- Path::new(default_migrations)
- });
-
- let migrations = run_database_migrations(db.options(), migrations_path).await?;
- for (migration, duration) in migrations {
- log::info!(
- "Migrated {} {} {:?}",
- migration.version,
- migration.description,
- duration
- );
- }
-
db.initialize_notification_kinds().await?;
if config.seed_path.is_some() {
@@ -239,37 +212,6 @@ async fn setup_app_database(config: &Config) -> Result<()> {
Ok(())
}
-async fn setup_llm_database(config: &Config) -> Result<()> {
- let database_url = config
- .llm_database_url
- .as_ref()
- .context("missing LLM_DATABASE_URL")?;
-
- let db_options = db::ConnectOptions::new(database_url.clone());
- let db = LlmDatabase::new(db_options, Executor::Production).await?;
-
- let migrations_path = config
- .llm_database_migrations_path
- .as_deref()
- .unwrap_or_else(|| {
- let default_migrations = concat!(env!("CARGO_MANIFEST_DIR"), "/migrations_llm");
-
- Path::new(default_migrations)
- });
-
- let migrations = run_database_migrations(db.options(), migrations_path).await?;
- for (migration, duration) in migrations {
- log::info!(
- "Migrated {} {} {:?}",
- migration.version,
- migration.description,
- duration
- );
- }
-
- Ok(())
-}
-
async fn handle_root(Extension(mode): Extension<ServiceMode>) -> String {
format!("zed:{mode} v{VERSION} ({})", REVISION.unwrap_or("unknown"))
}
@@ -109,22 +109,8 @@ pub fn init(cx: &mut App) {
});
// TODO: make it possible to bind this one to a held key for push to talk?
// how to make "toggle_on_modifiers_press" contextual?
- workspace.register_action(|_, _: &Mute, window, cx| {
- let room = ActiveCall::global(cx).read(cx).room().cloned();
- if let Some(room) = room {
- window.defer(cx, move |_window, cx| {
- room.update(cx, |room, cx| room.toggle_mute(cx))
- });
- }
- });
- workspace.register_action(|_, _: &Deafen, window, cx| {
- let room = ActiveCall::global(cx).read(cx).room().cloned();
- if let Some(room) = room {
- window.defer(cx, move |_window, cx| {
- room.update(cx, |room, cx| room.toggle_deafen(cx))
- });
- }
- });
+ workspace.register_action(|_, _: &Mute, _, cx| title_bar::collab::toggle_mute(cx));
+ workspace.register_action(|_, _: &Deafen, _, cx| title_bar::collab::toggle_deafen(cx));
workspace.register_action(|_, _: &LeaveCall, window, cx| {
CollabPanel::leave_call(window, cx);
});
@@ -327,6 +327,23 @@ pub struct AddSelectionBelow {
pub skip_soft_wrap: bool,
}
+/// Inserts a snippet at the cursor.
+#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
+#[action(namespace = editor)]
+#[serde(deny_unknown_fields)]
+pub struct InsertSnippet {
+ /// Language name if using a named snippet, or `None` for a global snippet
+ ///
+ /// This is typically lowercase and matches the filename containing the snippet, without the `.json` extension.
+ pub language: Option<String>,
+ /// Name if using a named snippet
+ pub name: Option<String>,
+
+ /// Snippet body, if not using a named snippet
+ // todo(andrew): use `ListOrDirect` or similar for multiline snippet body
+ pub snippet: Option<String>,
+}
+
actions!(
debugger,
[
@@ -79,7 +79,7 @@ use ::git::{
status::FileStatus,
};
use aho_corasick::{AhoCorasick, AhoCorasickBuilder, BuildError};
-use anyhow::{Context as _, Result, anyhow};
+use anyhow::{Context as _, Result, anyhow, bail};
use blink_manager::BlinkManager;
use buffer_diff::DiffHunkStatus;
use client::{Collaborator, ParticipantIndex, parse_zed_link};
@@ -14811,6 +14811,52 @@ impl Editor {
}
}
+ pub fn insert_snippet_at_selections(
+ &mut self,
+ action: &InsertSnippet,
+ window: &mut Window,
+ cx: &mut Context<Self>,
+ ) {
+ self.try_insert_snippet_at_selections(action, window, cx)
+ .log_err();
+ }
+
+ fn try_insert_snippet_at_selections(
+ &mut self,
+ action: &InsertSnippet,
+ window: &mut Window,
+ cx: &mut Context<Self>,
+ ) -> Result<()> {
+ let insertion_ranges = self
+ .selections
+ .all::<MultiBufferOffset>(&self.display_snapshot(cx))
+ .into_iter()
+ .map(|selection| selection.range())
+ .collect_vec();
+
+ let snippet = if let Some(snippet_body) = &action.snippet {
+ if action.language.is_none() && action.name.is_none() {
+ Snippet::parse(snippet_body)?
+ } else {
+ bail!("`snippet` is mutually exclusive with `language` and `name`")
+ }
+ } else if let Some(name) = &action.name {
+ let project = self.project().context("no project")?;
+ let snippet_store = project.read(cx).snippets().read(cx);
+ let snippet = snippet_store
+ .snippets_for(action.language.clone(), cx)
+ .into_iter()
+ .find(|snippet| snippet.name == *name)
+ .context("snippet not found")?;
+ Snippet::parse(&snippet.body)?
+ } else {
+ // todo(andrew): open modal to select snippet
+ bail!("`name` or `snippet` is required")
+ };
+
+ self.insert_snippet(&insertion_ranges, snippet, window, cx)
+ }
+
fn select_match_ranges(
&mut self,
range: Range<MultiBufferOffset>,
@@ -26895,6 +26895,82 @@ async fn test_add_selection_skip_soft_wrap_option(cx: &mut TestAppContext) {
});
}
+#[gpui::test]
+async fn test_insert_snippet(cx: &mut TestAppContext) {
+ init_test(cx, |_| {});
+ let mut cx = EditorTestContext::new(cx).await;
+
+ cx.update_editor(|editor, _, cx| {
+ editor.project().unwrap().update(cx, |project, cx| {
+ project.snippets().update(cx, |snippets, _cx| {
+ let snippet = project::snippet_provider::Snippet {
+ prefix: vec![], // no prefix needed!
+ body: "an Unspecified".to_string(),
+ description: Some("shhhh it's a secret".to_string()),
+ name: "super secret snippet".to_string(),
+ };
+ snippets.add_snippet_for_test(
+ None,
+ PathBuf::from("test_snippets.json"),
+ vec![Arc::new(snippet)],
+ );
+
+ let snippet = project::snippet_provider::Snippet {
+ prefix: vec![], // no prefix needed!
+ body: " Location".to_string(),
+ description: Some("the word 'location'".to_string()),
+ name: "location word".to_string(),
+ };
+ snippets.add_snippet_for_test(
+ Some("Markdown".to_string()),
+ PathBuf::from("test_snippets.json"),
+ vec![Arc::new(snippet)],
+ );
+ });
+ })
+ });
+
+ cx.set_state(indoc!(r#"First cursor at Λ and second cursor at Λ"#));
+
+ cx.update_editor(|editor, window, cx| {
+ editor.insert_snippet_at_selections(
+ &InsertSnippet {
+ language: None,
+ name: Some("super secret snippet".to_string()),
+ snippet: None,
+ },
+ window,
+ cx,
+ );
+
+ // Language is specified in the action,
+ // so the buffer language does not need to match
+ editor.insert_snippet_at_selections(
+ &InsertSnippet {
+ language: Some("Markdown".to_string()),
+ name: Some("location word".to_string()),
+ snippet: None,
+ },
+ window,
+ cx,
+ );
+
+ editor.insert_snippet_at_selections(
+ &InsertSnippet {
+ language: None,
+ name: None,
+ snippet: Some("$0 after".to_string()),
+ },
+ window,
+ cx,
+ );
+ });
+
+ cx.assert_editor_state(
+ r#"First cursor at an Unspecified LocationΛ after and second cursor at an Unspecified LocationΛ after"#,
+ );
+}
+
#[gpui::test(iterations = 10)]
async fn test_document_colors(cx: &mut TestAppContext) {
let expected_color = Rgba {
@@ -365,6 +365,7 @@ impl EditorElement {
register_action(editor, window, Editor::split_selection_into_lines);
register_action(editor, window, Editor::add_selection_above);
register_action(editor, window, Editor::add_selection_below);
+ register_action(editor, window, Editor::insert_snippet_at_selections);
register_action(editor, window, |editor, action, window, cx| {
editor.select_next(action, window, cx).log_err();
});
@@ -37,5 +37,8 @@ wasm-encoder.workspace = true
wasmparser.workspace = true
[dev-dependencies]
+fs = { workspace = true, "features" = ["test-support"] }
+gpui = { workspace = true, "features" = ["test-support"] }
+indoc.workspace = true
pretty_assertions.workspace = true
tempfile.workspace = true
@@ -2,8 +2,9 @@ use crate::{
ExtensionLibraryKind, ExtensionManifest, GrammarManifestEntry, build_debug_adapter_schema_path,
parse_wasm_extension_version,
};
+use ::fs::Fs;
use anyhow::{Context as _, Result, bail};
-use futures::AsyncReadExt;
+use futures::{AsyncReadExt, StreamExt};
use heck::ToSnakeCase;
use http_client::{self, AsyncBody, HttpClient};
use serde::Deserialize;
@@ -77,8 +78,9 @@ impl ExtensionBuilder {
extension_dir: &Path,
extension_manifest: &mut ExtensionManifest,
options: CompileExtensionOptions,
+ fs: Arc<dyn Fs>,
) -> Result<()> {
- populate_defaults(extension_manifest, extension_dir)?;
+ populate_defaults(extension_manifest, extension_dir, fs).await?;
if extension_dir.is_relative() {
bail!(
@@ -546,7 +548,11 @@ impl ExtensionBuilder {
}
}
-fn populate_defaults(manifest: &mut ExtensionManifest, extension_path: &Path) -> Result<()> {
+async fn populate_defaults(
+ manifest: &mut ExtensionManifest,
+ extension_path: &Path,
+ fs: Arc<dyn Fs>,
+) -> Result<()> {
// For legacy extensions on the v0 schema (aka, using `extension.json`), clear out any existing
// contents of the computed fields, since we don't care what the existing values are.
if manifest.schema_version.is_v0() {
@@ -561,12 +567,16 @@ fn populate_defaults(manifest: &mut ExtensionManifest, extension_path: &Path) ->
}
let languages_dir = extension_path.join("languages");
- if languages_dir.exists() {
- for entry in fs::read_dir(&languages_dir).context("failed to list languages dir")? {
- let entry = entry?;
- let language_dir = entry.path();
+ if fs.is_dir(&languages_dir).await {
+ let mut language_dir_entries = fs
+ .read_dir(&languages_dir)
+ .await
+ .context("failed to list languages dir")?;
+
+ while let Some(language_dir) = language_dir_entries.next().await {
+ let language_dir = language_dir?;
let config_path = language_dir.join("config.toml");
- if config_path.exists() {
+ if fs.is_file(config_path.as_path()).await {
let relative_language_dir =
language_dir.strip_prefix(extension_path)?.to_path_buf();
if !manifest.languages.contains(&relative_language_dir) {
@@ -577,10 +587,14 @@ fn populate_defaults(manifest: &mut ExtensionManifest, extension_path: &Path) ->
}
let themes_dir = extension_path.join("themes");
- if themes_dir.exists() {
- for entry in fs::read_dir(&themes_dir).context("failed to list themes dir")? {
- let entry = entry?;
- let theme_path = entry.path();
+ if fs.is_dir(&themes_dir).await {
+ let mut theme_dir_entries = fs
+ .read_dir(&themes_dir)
+ .await
+ .context("failed to list themes dir")?;
+
+ while let Some(theme_path) = theme_dir_entries.next().await {
+ let theme_path = theme_path?;
if theme_path.extension() == Some("json".as_ref()) {
let relative_theme_path = theme_path.strip_prefix(extension_path)?.to_path_buf();
if !manifest.themes.contains(&relative_theme_path) {
@@ -591,10 +605,14 @@ fn populate_defaults(manifest: &mut ExtensionManifest, extension_path: &Path) ->
}
let icon_themes_dir = extension_path.join("icon_themes");
- if icon_themes_dir.exists() {
- for entry in fs::read_dir(&icon_themes_dir).context("failed to list icon themes dir")? {
- let entry = entry?;
- let icon_theme_path = entry.path();
+ if fs.is_dir(&icon_themes_dir).await {
+ let mut icon_theme_dir_entries = fs
+ .read_dir(&icon_themes_dir)
+ .await
+ .context("failed to list icon themes dir")?;
+
+ while let Some(icon_theme_path) = icon_theme_dir_entries.next().await {
+ let icon_theme_path = icon_theme_path?;
if icon_theme_path.extension() == Some("json".as_ref()) {
let relative_icon_theme_path =
icon_theme_path.strip_prefix(extension_path)?.to_path_buf();
@@ -603,21 +621,26 @@ fn populate_defaults(manifest: &mut ExtensionManifest, extension_path: &Path) ->
}
}
}
- }
-
- let snippets_json_path = extension_path.join("snippets.json");
- if snippets_json_path.exists() {
- manifest.snippets = Some(snippets_json_path);
+ };
+ if manifest.snippets.is_none()
+ && let snippets_json_path = extension_path.join("snippets.json")
+ && fs.is_file(&snippets_json_path).await
+ {
+ manifest.snippets = Some("snippets.json".into());
}
// For legacy extensions on the v0 schema (aka, using `extension.json`), we want to populate the grammars in
// the manifest using the contents of the `grammars` directory.
if manifest.schema_version.is_v0() {
let grammars_dir = extension_path.join("grammars");
- if grammars_dir.exists() {
- for entry in fs::read_dir(&grammars_dir).context("failed to list grammars dir")? {
- let entry = entry?;
- let grammar_path = entry.path();
+ if fs.is_dir(&grammars_dir).await {
+ let mut grammar_dir_entries = fs
+ .read_dir(&grammars_dir)
+ .await
+ .context("failed to list grammars dir")?;
+
+ while let Some(grammar_path) = grammar_dir_entries.next().await {
+ let grammar_path = grammar_path?;
if grammar_path.extension() == Some("toml".as_ref()) {
#[derive(Deserialize)]
struct GrammarConfigToml {
@@ -627,7 +650,7 @@ fn populate_defaults(manifest: &mut ExtensionManifest, extension_path: &Path) ->
pub path: Option<String>,
}
- let grammar_config = fs::read_to_string(&grammar_path)?;
+ let grammar_config = fs.load(&grammar_path).await?;
let grammar_config: GrammarConfigToml = toml::from_str(&grammar_config)?;
let grammar_name = grammar_path
@@ -677,9 +700,20 @@ fn file_newer_than_deps(target: &Path, dependencies: &[&Path]) -> Result<bool, s
#[cfg(test)]
mod tests {
- use super::*;
+ use std::{
+ path::{Path, PathBuf},
+ str::FromStr,
+ thread::sleep,
+ time::Duration,
+ };
- use std::{fs, thread::sleep, time::Duration};
+ use gpui::TestAppContext;
+ use indoc::indoc;
+
+ use crate::{
+ ExtensionManifest,
+ extension_builder::{file_newer_than_deps, populate_defaults},
+ };
#[test]
fn test_file_newer_than_deps() {
@@ -693,13 +727,13 @@ mod tests {
!file_newer_than_deps(&target, &[&dep1, &dep2]).unwrap(),
"target doesn't exist"
);
- fs::write(&target, "foo").unwrap(); // Create target
+ std::fs::write(&target, "foo").unwrap(); // Create target
assert!(
file_newer_than_deps(&target, &[&dep1, &dep2]).unwrap(),
"dependencies don't exist; target is newer"
);
sleep(Duration::from_secs(1));
- fs::write(&dep1, "foo").unwrap(); // Create dep1 (newer than target)
+ std::fs::write(&dep1, "foo").unwrap(); // Create dep1 (newer than target)
// Dependency is newer
assert!(
!file_newer_than_deps(&target, &[&dep1, &dep2]).unwrap(),
@@ -708,9 +742,9 @@ mod tests {
dep1.metadata().unwrap().modified().unwrap(),
);
sleep(Duration::from_secs(1));
- fs::write(&dep2, "foo").unwrap(); // Create dep2
+ std::fs::write(&dep2, "foo").unwrap(); // Create dep2
sleep(Duration::from_secs(1));
- fs::write(&target, "foobar").unwrap(); // Update target
+ std::fs::write(&target, "foobar").unwrap(); // Update target
assert!(
file_newer_than_deps(&target, &[&dep1, &dep2]).unwrap(),
"target is newer than dependencies (target {:?}, dep2 {:?})",
@@ -718,4 +752,75 @@ mod tests {
dep2.metadata().unwrap().modified().unwrap(),
);
}
+
+ #[gpui::test]
+ async fn test_snippet_location_is_kept(cx: &mut TestAppContext) {
+ let fs = fs::FakeFs::new(cx.executor());
+ let extension_path = Path::new("/extension");
+
+ fs.insert_tree(
+ extension_path,
+ serde_json::json!({
+ "extension.toml": indoc! {r#"
+ id = "test-manifest"
+ name = "Test Manifest"
+ version = "0.0.1"
+ schema_version = 1
+
+ snippets = "./snippets/snippets.json"
+ "#
+ },
+ "snippets.json": "",
+ }),
+ )
+ .await;
+
+ let mut manifest = ExtensionManifest::load(fs.clone(), extension_path)
+ .await
+ .unwrap();
+
+ populate_defaults(&mut manifest, extension_path, fs.clone())
+ .await
+ .unwrap();
+
+ assert_eq!(
+ manifest.snippets,
+ Some(PathBuf::from_str("./snippets/snippets.json").unwrap())
+ )
+ }
+
+ #[gpui::test]
+ async fn test_automatic_snippet_location_is_relative(cx: &mut TestAppContext) {
+ let fs = fs::FakeFs::new(cx.executor());
+ let extension_path = Path::new("/extension");
+
+ fs.insert_tree(
+ extension_path,
+ serde_json::json!({
+ "extension.toml": indoc! {r#"
+ id = "test-manifest"
+ name = "Test Manifest"
+ version = "0.0.1"
+ schema_version = 1
+
+ "#
+ },
+ "snippets.json": "",
+ }),
+ )
+ .await;
+
+ let mut manifest = ExtensionManifest::load(fs.clone(), extension_path)
+ .await
+ .unwrap();
+
+ populate_defaults(&mut manifest, extension_path, fs.clone())
+ .await
+ .unwrap();
+
+ assert_eq!(
+ manifest.snippets,
+ Some(PathBuf::from_str("snippets.json").unwrap())
+ )
+ }
}
@@ -71,6 +71,7 @@ async fn main() -> Result<()> {
&extension_path,
&mut manifest,
CompileExtensionOptions { release: true },
+ fs.clone(),
)
.await
.context("failed to compile extension")?;
@@ -7,7 +7,7 @@ use extension::{
extension_builder::{CompileExtensionOptions, ExtensionBuilder},
};
use extension_host::wasm_host::WasmHost;
-use fs::RealFs;
+use fs::{Fs, RealFs};
use gpui::{TestAppContext, TestDispatcher};
use http_client::{FakeHttpClient, Response};
use node_runtime::NodeRuntime;
@@ -24,7 +24,11 @@ fn extension_benchmarks(c: &mut Criterion) {
let mut group = c.benchmark_group("load");
let mut manifest = manifest();
- let wasm_bytes = wasm_bytes(&cx, &mut manifest);
+ let wasm_bytes = wasm_bytes(
+ &cx,
+ &mut manifest,
+ Arc::new(RealFs::new(None, cx.executor())),
+ );
let manifest = Arc::new(manifest);
let extensions_dir = TempTree::new(json!({
"installed": {},
@@ -60,7 +64,7 @@ fn init() -> TestAppContext {
cx
}
-fn wasm_bytes(cx: &TestAppContext, manifest: &mut ExtensionManifest) -> Vec<u8> {
+fn wasm_bytes(cx: &TestAppContext, manifest: &mut ExtensionManifest, fs: Arc<dyn Fs>) -> Vec<u8> {
let extension_builder = extension_builder();
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.parent()
@@ -73,6 +77,7 @@ fn wasm_bytes(cx: &TestAppContext, manifest: &mut ExtensionManifest) -> Vec<u8>
&path,
manifest,
CompileExtensionOptions { release: true },
+ fs,
))
.unwrap();
std::fs::read(path.join("extension.wasm")).unwrap()
@@ -1101,12 +1101,14 @@ impl ExtensionStore {
cx.background_spawn({
let extension_source_path = extension_source_path.clone();
+ let fs = fs.clone();
async move {
builder
.compile_extension(
&extension_source_path,
&mut extension_manifest,
CompileExtensionOptions { release: false },
+ fs,
)
.await
}
@@ -1163,12 +1165,13 @@ impl ExtensionStore {
cx.notify();
let compile = cx.background_spawn(async move {
- let mut manifest = ExtensionManifest::load(fs, &path).await?;
+ let mut manifest = ExtensionManifest::load(fs.clone(), &path).await?;
builder
.compile_extension(
&path,
&mut manifest,
CompileExtensionOptions { release: true },
+ fs,
)
.await
});
@@ -599,14 +599,19 @@ pub struct TypeScriptLspAdapter {
}
impl TypeScriptLspAdapter {
- const OLD_SERVER_PATH: &'static str = "node_modules/typescript-language-server/lib/cli.js";
- const NEW_SERVER_PATH: &'static str = "node_modules/typescript-language-server/lib/cli.mjs";
- const SERVER_NAME: LanguageServerName =
- LanguageServerName::new_static("typescript-language-server");
+ const OLD_SERVER_PATH: &str = "node_modules/typescript-language-server/lib/cli.js";
+ const NEW_SERVER_PATH: &str = "node_modules/typescript-language-server/lib/cli.mjs";
+
const PACKAGE_NAME: &str = "typescript";
+ const SERVER_PACKAGE_NAME: &str = "typescript-language-server";
+
+ const SERVER_NAME: LanguageServerName =
+ LanguageServerName::new_static(Self::SERVER_PACKAGE_NAME);
+
pub fn new(node: NodeRuntime, fs: Arc<dyn Fs>) -> Self {
TypeScriptLspAdapter { fs, node }
}
+
async fn tsdk_path(&self, adapter: &Arc<dyn LspAdapterDelegate>) -> Option<&'static str> {
let is_yarn = adapter
.read_text_file(RelPath::unix(".yarn/sdks/typescript/lib/typescript.js").unwrap())
@@ -646,10 +651,13 @@ impl LspInstaller for TypeScriptLspAdapter {
_: &mut AsyncApp,
) -> Result<TypeScriptVersions> {
Ok(TypeScriptVersions {
- typescript_version: self.node.npm_package_latest_version("typescript").await?,
+ typescript_version: self
+ .node
+ .npm_package_latest_version(Self::PACKAGE_NAME)
+ .await?,
server_version: self
.node
- .npm_package_latest_version("typescript-language-server")
+ .npm_package_latest_version(Self::SERVER_PACKAGE_NAME)
.await?,
})
}
@@ -662,7 +670,7 @@ impl LspInstaller for TypeScriptLspAdapter {
) -> Option<LanguageServerBinary> {
let server_path = container_dir.join(Self::NEW_SERVER_PATH);
- let should_install_language_server = self
+ if self
.node
.should_install_npm_package(
Self::PACKAGE_NAME,
@@ -670,17 +678,29 @@ impl LspInstaller for TypeScriptLspAdapter {
container_dir,
VersionStrategy::Latest(version.typescript_version.as_str()),
)
- .await;
+ .await
+ {
+ return None;
+ }
- if should_install_language_server {
- None
- } else {
- Some(LanguageServerBinary {
- path: self.node.binary_path().await.ok()?,
- env: None,
- arguments: typescript_server_binary_arguments(&server_path),
- })
+ if self
+ .node
+ .should_install_npm_package(
+ Self::SERVER_PACKAGE_NAME,
+ &server_path,
+ container_dir,
+ VersionStrategy::Latest(version.server_version.as_str()),
+ )
+ .await
+ {
+ return None;
}
+
+ Some(LanguageServerBinary {
+ path: self.node.binary_path().await.ok()?,
+ env: None,
+ arguments: typescript_server_binary_arguments(&server_path),
+ })
}
async fn fetch_server_binary(
@@ -700,7 +720,7 @@ impl LspInstaller for TypeScriptLspAdapter {
latest_version.typescript_version.as_str(),
),
(
- "typescript-language-server",
+ Self::SERVER_PACKAGE_NAME,
latest_version.server_version.as_str(),
),
],
@@ -22,7 +22,7 @@ pub fn init(cx: &mut App) {
extension_snippet::init(cx);
}
-// Is `None` if the snippet file is global.
+/// Language name, or `None` if the snippet file is global.
type SnippetKind = Option<String>;
fn file_stem_to_key(stem: &str) -> SnippetKind {
if stem == "snippets" {
@@ -8,7 +8,7 @@ use gpui::{
AnyElement, Hsla, IntoElement, MouseButton, Path, ScreenCaptureSource, Styled, WeakEntity,
canvas, point,
};
-use gpui::{App, Task, Window, actions};
+use gpui::{App, Task, Window};
use project::WorktreeSettings;
use rpc::proto::{self};
use settings::{Settings as _, SettingsLocation};
@@ -22,19 +22,7 @@ use workspace::notifications::DetachAndPromptErr;
use crate::TitleBar;
-actions!(
- collab,
- [
- /// Toggles screen sharing on or off.
- ToggleScreenSharing,
- /// Toggles microphone mute.
- ToggleMute,
- /// Toggles deafen mode (mute both microphone and speakers).
- ToggleDeafen
- ]
-);
-
-fn toggle_screen_sharing(
+pub fn toggle_screen_sharing(
screen: anyhow::Result<Option<Rc<dyn ScreenCaptureSource>>>,
window: &mut Window,
cx: &mut App,
@@ -90,7 +78,7 @@ fn toggle_screen_sharing(
toggle_screen_sharing.detach_and_prompt_err("Sharing Screen Failed", window, cx, |e, _, _| Some(format!("{:?}\n\nPlease check that you have given Zed permissions to record your screen in Settings.", e)));
}
-fn toggle_mute(_: &ToggleMute, cx: &mut App) {
+pub fn toggle_mute(cx: &mut App) {
let call = ActiveCall::global(cx).read(cx);
if let Some(room) = call.room().cloned() {
room.update(cx, |room, cx| {
@@ -110,7 +98,7 @@ fn toggle_mute(_: &ToggleMute, cx: &mut App) {
}
}
-fn toggle_deafen(_: &ToggleDeafen, cx: &mut App) {
+pub fn toggle_deafen(cx: &mut App) {
if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() {
room.update(cx, |room, cx| room.toggle_deafen(cx));
}
@@ -458,9 +446,7 @@ impl TitleBar {
.icon_size(IconSize::Small)
.toggle_state(is_muted)
.selected_style(ButtonStyle::Tinted(TintColor::Error))
- .on_click(move |_, _window, cx| {
- toggle_mute(&Default::default(), cx);
- })
+ .on_click(move |_, _window, cx| toggle_mute(cx))
.into_any_element(),
);
}
@@ -497,7 +483,7 @@ impl TitleBar {
}
}
})
- .on_click(move |_, _, cx| toggle_deafen(&Default::default(), cx))
+ .on_click(move |_, _, cx| toggle_deafen(cx))
.into_any_element(),
);
@@ -1,5 +1,5 @@
mod application_menu;
-mod collab;
+pub mod collab;
mod onboarding_banner;
pub mod platform_title_bar;
mod platforms;
@@ -161,7 +161,7 @@ impl RelPath {
false
}
- pub fn strip_prefix<'a>(&'a self, other: &Self) -> Result<&'a Self> {
+ pub fn strip_prefix<'a>(&'a self, other: &Self) -> Result<&'a Self, StripPrefixError> {
if other.is_empty() {
return Ok(self);
}
@@ -172,7 +172,7 @@ impl RelPath {
return Ok(Self::empty());
}
}
- Err(anyhow!("failed to strip prefix: {other:?} from {self:?}"))
+ Err(StripPrefixError)
}
pub fn len(&self) -> usize {
@@ -251,6 +251,9 @@ impl RelPath {
}
}
+#[derive(Debug)]
+pub struct StripPrefixError;
+
impl ToOwned for RelPath {
type Owned = RelPathBuf;
@@ -1,3 +0,0 @@
-zed . \
- "crates/collab/migrations.sqlite/20221109000000_test_schema.sql" \
- "crates/collab/migrations/$(date -u +%Y%m%d%H%M%S)_$(echo $1 | sed 's/[^a-z0-9]/_/g').sql"
@@ -11,16 +11,12 @@ extend-exclude = [
"crates/theme/src/icon_theme.rs",
"crates/extensions_ui/src/extension_suggest.rs",
- # Some countries codes are flagged as typos.
- "crates/anthropic/src/supported_countries.rs",
- "crates/google_ai/src/supported_countries.rs",
- "crates/open_ai/src/supported_countries.rs",
-
# Some mock data is flagged as typos.
"crates/assistant_tools/src/web_search_tool.rs",
- # Stripe IDs are flagged as typos.
- "crates/collab/src/db/tests/processed_stripe_event_tests.rs",
+ # Suppress false positives in database schema.
+ "crates/collab/migrations/20251208000000_test_schema.sql",
+
# Not our typos.
"crates/livekit_api/",
# Vim makes heavy use of partial typing tables.
@@ -63,8 +59,6 @@ extend-ignore-re = [
'cl\[ist]',
'\[lan\]guage',
'"ba"',
- # :/ crates/collab/migrations/20231009181554_add_release_channel_to_rooms.sql
- "COLUMN enviroment",
"doas",
# ProtoLS crate with tree-sitter Protobuf grammar.
"protols",