diff --git a/Cargo.lock b/Cargo.lock index bf910847a0c0fd8dc636ab86b6f426ada881753a..e72eaa951236711f57817931237319e9c0c5d6a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5799,6 +5799,7 @@ dependencies = [ "gpui", "heck 0.5.0", "http_client", + "indoc", "language", "log", "lsp", diff --git a/Dockerfile-collab b/Dockerfile-collab index 4bc369140e79219b9719b570659e9edd27453260..68f898618a5d0cd1ad9999e5482c53dc0cb26da6 100644 --- a/Dockerfile-collab +++ b/Dockerfile-collab @@ -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"] diff --git a/crates/collab/README.md b/crates/collab/README.md index 0ec6d8008ba313357c4ac8e44555ff978d9a1121..902c9841e2d7fb0b52b3143002fd0da29b980802 100644 --- a/crates/collab/README.md +++ b/crates/collab/README.md @@ -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 -``` - -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. diff --git a/crates/collab/k8s/migrate.template.yml b/crates/collab/k8s/migrate.template.yml deleted file mode 100644 index c890d7b330c0eca260ca327e5f7db10259f91eaa..0000000000000000000000000000000000000000 --- a/crates/collab/k8s/migrate.template.yml +++ /dev/null @@ -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 diff --git a/crates/collab/migrations/20210527024318_initial_schema.sql b/crates/collab/migrations/20210527024318_initial_schema.sql deleted file mode 100644 index 4b065318484a5c352dde00da9ba55744c4da9adb..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20210527024318_initial_schema.sql +++ /dev/null @@ -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 -); diff --git a/crates/collab/migrations/20210607190313_create_access_tokens.sql b/crates/collab/migrations/20210607190313_create_access_tokens.sql deleted file mode 100644 index 60745a98bae9ac8bc3e2016e598480e74e0b6473..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20210607190313_create_access_tokens.sql +++ /dev/null @@ -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"); diff --git a/crates/collab/migrations/20210805175147_create_chat_tables.sql b/crates/collab/migrations/20210805175147_create_chat_tables.sql deleted file mode 100644 index 5bba4689d9c21e65d989cf05e2e1eedb0151621d..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20210805175147_create_chat_tables.sql +++ /dev/null @@ -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"); diff --git a/crates/collab/migrations/20210916123647_add_nonce_to_channel_messages.sql b/crates/collab/migrations/20210916123647_add_nonce_to_channel_messages.sql deleted file mode 100644 index ee4d4aa319f6417e854137332011115570153eae..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20210916123647_add_nonce_to_channel_messages.sql +++ /dev/null @@ -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"); diff --git a/crates/collab/migrations/20210920192001_add_interests_to_signups.sql b/crates/collab/migrations/20210920192001_add_interests_to_signups.sql deleted file mode 100644 index 2457abfc757a3d3c6171d9639e2c280981689ead..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20210920192001_add_interests_to_signups.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE "signups" - ADD "wants_releases" BOOLEAN, - ADD "wants_updates" BOOLEAN, - ADD "wants_community" BOOLEAN; \ No newline at end of file diff --git a/crates/collab/migrations/20220421165757_drop_signups.sql b/crates/collab/migrations/20220421165757_drop_signups.sql deleted file mode 100644 index d7cd6e204c95e2ea10ee4b4b8183cbe701abb4c0..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20220421165757_drop_signups.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE IF EXISTS "signups"; diff --git a/crates/collab/migrations/20220505144506_add_trigram_index_to_users.sql b/crates/collab/migrations/20220505144506_add_trigram_index_to_users.sql deleted file mode 100644 index 3d6fd3179a236bf8407464f69f1e67469eb31d27..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20220505144506_add_trigram_index_to_users.sql +++ /dev/null @@ -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); diff --git a/crates/collab/migrations/20220506130724_create_contacts.sql b/crates/collab/migrations/20220506130724_create_contacts.sql deleted file mode 100644 index 56beb70fd06ce8a3b7bb00d2f0ada2e465906c69..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20220506130724_create_contacts.sql +++ /dev/null @@ -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"); diff --git a/crates/collab/migrations/20220518151305_add_invites_to_users.sql b/crates/collab/migrations/20220518151305_add_invites_to_users.sql deleted file mode 100644 index 2ac89b649e8adab60ac93aeba36476d92484dc93..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20220518151305_add_invites_to_users.sql +++ /dev/null @@ -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"); diff --git a/crates/collab/migrations/20220523232954_allow_user_deletes.sql b/crates/collab/migrations/20220523232954_allow_user_deletes.sql deleted file mode 100644 index ddf3f6f9bd094bfa96f75efe72b64da06e47d0c5..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20220523232954_allow_user_deletes.sql +++ /dev/null @@ -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; diff --git a/crates/collab/migrations/20220620211403_create_projects.sql b/crates/collab/migrations/20220620211403_create_projects.sql deleted file mode 100644 index d813c9f7a1811e50227c312c66df0fd679c35166..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20220620211403_create_projects.sql +++ /dev/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"); \ No newline at end of file diff --git a/crates/collab/migrations/20220913211150_create_signups.sql b/crates/collab/migrations/20220913211150_create_signups.sql deleted file mode 100644 index 19559b747c33b0fc146572201ba3dd1d1c37bf47..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20220913211150_create_signups.sql +++ /dev/null @@ -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"); diff --git a/crates/collab/migrations/20220929182110_add_metrics_id.sql b/crates/collab/migrations/20220929182110_add_metrics_id.sql deleted file mode 100644 index 665d6323bf13b5553859ae6763392770dc33bebb..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20220929182110_add_metrics_id.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE "users" - ADD "metrics_id" uuid NOT NULL DEFAULT gen_random_uuid(); diff --git a/crates/collab/migrations/20221111092550_reconnection_support.sql b/crates/collab/migrations/20221111092550_reconnection_support.sql deleted file mode 100644 index 3289f6bbddb63e08acdc5e89a900193359423b2c..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20221111092550_reconnection_support.sql +++ /dev/null @@ -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"); diff --git a/crates/collab/migrations/20221125192125_add_added_to_mailing_list_to_signups.sql b/crates/collab/migrations/20221125192125_add_added_to_mailing_list_to_signups.sql deleted file mode 100644 index b154396df1259aa73b5e1a17c9db27d04510e062..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20221125192125_add_added_to_mailing_list_to_signups.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE "signups" - ADD "added_to_mailing_list" BOOLEAN NOT NULL DEFAULT FALSE; \ No newline at end of file diff --git a/crates/collab/migrations/20221207165001_add_connection_lost_to_room_participants.sql b/crates/collab/migrations/20221207165001_add_connection_lost_to_room_participants.sql deleted file mode 100644 index ed0cf972bc97f517fb878806b0929e8122b2b8a2..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20221207165001_add_connection_lost_to_room_participants.sql +++ /dev/null @@ -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"); diff --git a/crates/collab/migrations/20221213125710_index_room_participants_on_room_id.sql b/crates/collab/migrations/20221213125710_index_room_participants_on_room_id.sql deleted file mode 100644 index f40ca81906f41e8c30530ce349f892bb69111657..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20221213125710_index_room_participants_on_room_id.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE INDEX "index_room_participants_on_room_id" ON "room_participants" ("room_id"); diff --git a/crates/collab/migrations/20221214144346_change_epoch_from_uuid_to_integer.sql b/crates/collab/migrations/20221214144346_change_epoch_from_uuid_to_integer.sql deleted file mode 100644 index 5e02f76ce25d59d799d5e5d9719e4e038d1bac02..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20221214144346_change_epoch_from_uuid_to_integer.sql +++ /dev/null @@ -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"); diff --git a/crates/collab/migrations/20221219181850_project_reconnection_support.sql b/crates/collab/migrations/20221219181850_project_reconnection_support.sql deleted file mode 100644 index 6efef5571c5855beb0c4b59d5f52ff92b323bb20..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20221219181850_project_reconnection_support.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE "worktree_entries" - ADD COLUMN "scan_id" INT8, - ADD COLUMN "is_deleted" BOOL; diff --git a/crates/collab/migrations/20230103200902_replace_is_completed_with_completed_scan_id.sql b/crates/collab/migrations/20230103200902_replace_is_completed_with_completed_scan_id.sql deleted file mode 100644 index 1894d888b92a89508981abe5de7f5fc3e710184f..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20230103200902_replace_is_completed_with_completed_scan_id.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE worktrees - ALTER COLUMN is_complete SET DEFAULT FALSE, - ADD COLUMN completed_scan_id INT8; diff --git a/crates/collab/migrations/20230202155735_followers.sql b/crates/collab/migrations/20230202155735_followers.sql deleted file mode 100644 index c82d6ba3bdaa4f2b2a60771bca7401c47678f247..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20230202155735_followers.sql +++ /dev/null @@ -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"); diff --git a/crates/collab/migrations/20230508211523_add-repository-entries.sql b/crates/collab/migrations/20230508211523_add-repository-entries.sql deleted file mode 100644 index 1e593479394c8434f56f3519b41ce2fa2a9fc2a3..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20230508211523_add-repository-entries.sql +++ /dev/null @@ -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"); diff --git a/crates/collab/migrations/20230511004019_add_repository_statuses.sql b/crates/collab/migrations/20230511004019_add_repository_statuses.sql deleted file mode 100644 index 862561c6866d361ca628924a15b925d97d0c39cb..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20230511004019_add_repository_statuses.sql +++ /dev/null @@ -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"); diff --git a/crates/collab/migrations/20230529164700_add_worktree_settings_files.sql b/crates/collab/migrations/20230529164700_add_worktree_settings_files.sql deleted file mode 100644 index 973a40af0f21908e5dbe0d5a30373629f24b7f1e..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20230529164700_add_worktree_settings_files.sql +++ /dev/null @@ -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"); diff --git a/crates/collab/migrations/20230605191135_remove_repository_statuses.sql b/crates/collab/migrations/20230605191135_remove_repository_statuses.sql deleted file mode 100644 index 3e5f907c442d3604ebff5f2fbf60e9c34caa25d9..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20230605191135_remove_repository_statuses.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE "worktree_entries" -ADD "git_status" INT8; diff --git a/crates/collab/migrations/20230616134535_add_is_external_to_worktree_entries.sql b/crates/collab/migrations/20230616134535_add_is_external_to_worktree_entries.sql deleted file mode 100644 index e4348af0cc5c12a43fac3adecc106eb16a6de005..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20230616134535_add_is_external_to_worktree_entries.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE "worktree_entries" -ADD "is_external" BOOL NOT NULL DEFAULT FALSE; diff --git a/crates/collab/migrations/20230727150500_add_channels.sql b/crates/collab/migrations/20230727150500_add_channels.sql deleted file mode 100644 index df981838bf72d7ef7392ed6f4e302ffdc57631db..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20230727150500_add_channels.sql +++ /dev/null @@ -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; diff --git a/crates/collab/migrations/20230819154600_add_channel_buffers.sql b/crates/collab/migrations/20230819154600_add_channel_buffers.sql deleted file mode 100644 index 5e6e7ce3393a628c86cbcdabf2349ebfa6667bd6..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20230819154600_add_channel_buffers.sql +++ /dev/null @@ -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"); diff --git a/crates/collab/migrations/20230825190322_add_server_feature_flags.sql b/crates/collab/migrations/20230825190322_add_server_feature_flags.sql deleted file mode 100644 index fffde54a20e4869ccbef2093de4e7fe5044132e2..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20230825190322_add_server_feature_flags.sql +++ /dev/null @@ -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"); diff --git a/crates/collab/migrations/20230907114200_add_channel_messages.sql b/crates/collab/migrations/20230907114200_add_channel_messages.sql deleted file mode 100644 index abe7753ca69fb45a1f0a56b732963d8dc5605e31..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20230907114200_add_channel_messages.sql +++ /dev/null @@ -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"); diff --git a/crates/collab/migrations/20230925210437_add_channel_changes.sql b/crates/collab/migrations/20230925210437_add_channel_changes.sql deleted file mode 100644 index 250a9ac731b59489e85cf34a6754307bfac543ee..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20230925210437_add_channel_changes.sql +++ /dev/null @@ -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"); diff --git a/crates/collab/migrations/20230926102500_add_participant_index_to_room_participants.sql b/crates/collab/migrations/20230926102500_add_participant_index_to_room_participants.sql deleted file mode 100644 index 1493119e2a97ac42f5d69ebc82ac3d3d0dc4dd63..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20230926102500_add_participant_index_to_room_participants.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE room_participants ADD COLUMN participant_index INTEGER; diff --git a/crates/collab/migrations/20231004130100_create_notifications.sql b/crates/collab/migrations/20231004130100_create_notifications.sql deleted file mode 100644 index 93c282c631f3d5545593b7c71f013d8457cd088a..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20231004130100_create_notifications.sql +++ /dev/null @@ -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"); diff --git a/crates/collab/migrations/20231009181554_add_release_channel_to_rooms.sql b/crates/collab/migrations/20231009181554_add_release_channel_to_rooms.sql deleted file mode 100644 index 8f3a704adde0c385b26bd553d273eff322a17702..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20231009181554_add_release_channel_to_rooms.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE rooms ADD COLUMN enviroment TEXT; diff --git a/crates/collab/migrations/20231010114600_add_unique_index_on_rooms_channel_id.sql b/crates/collab/migrations/20231010114600_add_unique_index_on_rooms_channel_id.sql deleted file mode 100644 index 21ec4cfbb75a574ad3704179a0ae14c8050149d1..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20231010114600_add_unique_index_on_rooms_channel_id.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE UNIQUE INDEX "index_rooms_on_channel_id" ON "rooms" ("channel_id"); diff --git a/crates/collab/migrations/20231011214412_add_guest_role.sql b/crates/collab/migrations/20231011214412_add_guest_role.sql deleted file mode 100644 index 17135471583a03bd6b39e82b3644b683cfc96d57..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20231011214412_add_guest_role.sql +++ /dev/null @@ -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'; diff --git a/crates/collab/migrations/20231017185833_projects_room_id_fkey_on_delete_cascade.sql b/crates/collab/migrations/20231017185833_projects_room_id_fkey_on_delete_cascade.sql deleted file mode 100644 index be535ff7fa6e707182b8698647ecc92d9f976183..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20231017185833_projects_room_id_fkey_on_delete_cascade.sql +++ /dev/null @@ -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; diff --git a/crates/collab/migrations/20231018102700_create_mentions.sql b/crates/collab/migrations/20231018102700_create_mentions.sql deleted file mode 100644 index 221a1748cfe16276deb4fc3dd2329983340307e7..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20231018102700_create_mentions.sql +++ /dev/null @@ -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"; diff --git a/crates/collab/migrations/20231024085546_move_channel_paths_to_channels_table.sql b/crates/collab/migrations/20231024085546_move_channel_paths_to_channels_table.sql deleted file mode 100644 index d9fc6c872267b89fe30c958b4b01bb7fdf1fc448..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20231024085546_move_channel_paths_to_channels_table.sql +++ /dev/null @@ -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"); diff --git a/crates/collab/migrations/20240103025509_add_role_to_room_participants.sql b/crates/collab/migrations/20240103025509_add_role_to_room_participants.sql deleted file mode 100644 index 2748e00ebaa18ec375111c648a7accafe90c5dbb..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240103025509_add_role_to_room_participants.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE room_participants ADD COLUMN role TEXT; diff --git a/crates/collab/migrations/20240111085546_fix_column_name.sql b/crates/collab/migrations/20240111085546_fix_column_name.sql deleted file mode 100644 index 3f32ee35c59107e12fda98159911dbba6e13434a..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240111085546_fix_column_name.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE rooms ADD COLUMN environment TEXT; diff --git a/crates/collab/migrations/20240117150300_add_impersonator_to_access_tokens.sql b/crates/collab/migrations/20240117150300_add_impersonator_to_access_tokens.sql deleted file mode 100644 index 8c79640cd88bfad58e5f9eafda90ae2d80e4e834..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240117150300_add_impersonator_to_access_tokens.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE access_tokens ADD COLUMN impersonated_user_id integer; diff --git a/crates/collab/migrations/20240122174606_add_contributors.sql b/crates/collab/migrations/20240122174606_add_contributors.sql deleted file mode 100644 index 16bec82d4f2bd0a1b3f4221366cd822ebcd70bb1..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240122174606_add_contributors.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE TABLE contributors ( - user_id INTEGER REFERENCES users(id), - signed_at TIMESTAMP NOT NULL DEFAULT NOW(), - PRIMARY KEY (user_id) -); diff --git a/crates/collab/migrations/20240122224506_add_requires_zed_cla_column_to_channels.sql b/crates/collab/migrations/20240122224506_add_requires_zed_cla_column_to_channels.sql deleted file mode 100644 index a9248d294a2178b73986ab20cd06383d0397626b..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240122224506_add_requires_zed_cla_column_to_channels.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE "channels" ADD COLUMN "requires_zed_cla" BOOLEAN NOT NULL DEFAULT FALSE; diff --git a/crates/collab/migrations/20240129193601_fix_parent_path_index.sql b/crates/collab/migrations/20240129193601_fix_parent_path_index.sql deleted file mode 100644 index 73dd6e37cdf82f2f5d77e8b3cd14a2fbe43f2320..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240129193601_fix_parent_path_index.sql +++ /dev/null @@ -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); diff --git a/crates/collab/migrations/20240203113741_add_reply_to_message.sql b/crates/collab/migrations/20240203113741_add_reply_to_message.sql deleted file mode 100644 index 6f40b62822bb4936f0f90e3be65f640e323d09d0..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240203113741_add_reply_to_message.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE channel_messages ADD reply_to_message_id INTEGER DEFAULT NULL diff --git a/crates/collab/migrations/20240207041417_add_in_call_column_to_room_participants.sql b/crates/collab/migrations/20240207041417_add_in_call_column_to_room_participants.sql deleted file mode 100644 index 09463c6e784d4e13df5376ad3cd53c8cb9ebcf45..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240207041417_add_in_call_column_to_room_participants.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Add migration script here - -ALTER TABLE room_participants ADD COLUMN in_call BOOL NOT NULL DEFAULT FALSE; diff --git a/crates/collab/migrations/20240213200201_remove_unused_room_columns.sql b/crates/collab/migrations/20240213200201_remove_unused_room_columns.sql deleted file mode 100644 index dc4897af48afd3fa9ebc403b6f8103b933993ac4..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240213200201_remove_unused_room_columns.sql +++ /dev/null @@ -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; diff --git a/crates/collab/migrations/20240214102900_add_extensions.sql b/crates/collab/migrations/20240214102900_add_extensions.sql deleted file mode 100644 index b32094036d6a8993a8dbc6dc2407dec0e53aea47..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240214102900_add_extensions.sql +++ /dev/null @@ -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"); diff --git a/crates/collab/migrations/20240220234826_add_rate_buckets.sql b/crates/collab/migrations/20240220234826_add_rate_buckets.sql deleted file mode 100644 index 864a4373034fc53ea357f0b4d46b1b127a9f8db5..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240220234826_add_rate_buckets.sql +++ /dev/null @@ -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); diff --git a/crates/collab/migrations/20240221151017_add_edited_at_field_to_channel_message.sql b/crates/collab/migrations/20240221151017_add_edited_at_field_to_channel_message.sql deleted file mode 100644 index 1d07b07de7bf382fe0610ce170a639ab769567d4..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240221151017_add_edited_at_field_to_channel_message.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE channel_messages ADD edited_at TIMESTAMP DEFAULT NULL; diff --git a/crates/collab/migrations/20240226163408_hosted_projects.sql b/crates/collab/migrations/20240226163408_hosted_projects.sql deleted file mode 100644 index c6ade7161cce7eafc00564f3e1b934be93b08186..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240226163408_hosted_projects.sql +++ /dev/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); diff --git a/crates/collab/migrations/20240226164505_unique_channel_names.sql b/crates/collab/migrations/20240226164505_unique_channel_names.sql deleted file mode 100644 index c9d9f0a1cbf55249ee1fc80c5338bdc45381b46f..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240226164505_unique_channel_names.sql +++ /dev/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 != ''); diff --git a/crates/collab/migrations/20240227215556_hosted_projects_in_projects.sql b/crates/collab/migrations/20240227215556_hosted_projects_in_projects.sql deleted file mode 100644 index 69905d12f6d0e9945f291dc7b86f446bdaab08ac..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240227215556_hosted_projects_in_projects.sql +++ /dev/null @@ -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; diff --git a/crates/collab/migrations/20240307163119_denormalize_buffer_ops.sql b/crates/collab/migrations/20240307163119_denormalize_buffer_ops.sql deleted file mode 100644 index a332a20d52c4564ac90989a60fc0dd850d86034c..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240307163119_denormalize_buffer_ops.sql +++ /dev/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; diff --git a/crates/collab/migrations/20240315182903_non_null_channel_role.sql b/crates/collab/migrations/20240315182903_non_null_channel_role.sql deleted file mode 100644 index 2d359f8058f0591e47bc733f1c8b4c60fe3a56cd..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240315182903_non_null_channel_role.sql +++ /dev/null @@ -1,4 +0,0 @@ --- Add migration script here - -ALTER TABLE channel_members ALTER role SET NOT NULL; -ALTER TABLE channel_members DROP COLUMN admin; diff --git a/crates/collab/migrations/20240315183903_channel_parent_path_not_null.sql b/crates/collab/migrations/20240315183903_channel_parent_path_not_null.sql deleted file mode 100644 index 5703578b008817bacaa6e1956b28cdac7919e5fa..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240315183903_channel_parent_path_not_null.sql +++ /dev/null @@ -1,2 +0,0 @@ --- Add migration script here -ALTER TABLE channels ALTER parent_path SET NOT NULL; diff --git a/crates/collab/migrations/20240320124800_add_extension_schema_version.sql b/crates/collab/migrations/20240320124800_add_extension_schema_version.sql deleted file mode 100644 index 75fd0f40e4f9013f41e57cd094b3e93bf5f46101..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240320124800_add_extension_schema_version.sql +++ /dev/null @@ -1,2 +0,0 @@ --- Add migration script here -ALTER TABLE extension_versions ADD COLUMN schema_version INTEGER NOT NULL DEFAULT 0; diff --git a/crates/collab/migrations/20240321162658_add_devservers.sql b/crates/collab/migrations/20240321162658_add_devservers.sql deleted file mode 100644 index cb1ff4df405f9f1deb9d2c9e86f4234b9ba6d2b2..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240321162658_add_devservers.sql +++ /dev/null @@ -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); diff --git a/crates/collab/migrations/20240335123500_add_extension_wasm_api_version.sql b/crates/collab/migrations/20240335123500_add_extension_wasm_api_version.sql deleted file mode 100644 index 3b95323d262f1666dfbe8696a780dd5e8b674c99..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240335123500_add_extension_wasm_api_version.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE extension_versions ADD COLUMN wasm_api_version TEXT; diff --git a/crates/collab/migrations/20240402155003_add_dev_server_projects.sql b/crates/collab/migrations/20240402155003_add_dev_server_projects.sql deleted file mode 100644 index 003c43f4e27f4f7fb4cbfbb84b4be11d3a42ecc0..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240402155003_add_dev_server_projects.sql +++ /dev/null @@ -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); diff --git a/crates/collab/migrations/20240409082755_create_embeddings.sql b/crates/collab/migrations/20240409082755_create_embeddings.sql deleted file mode 100644 index ae4b4bcb61c049ea75726fb92eaf2c795891370e..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240409082755_create_embeddings.sql +++ /dev/null @@ -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"); diff --git a/crates/collab/migrations/20240412165156_dev_servers_per_user.sql b/crates/collab/migrations/20240412165156_dev_servers_per_user.sql deleted file mode 100644 index 7ef9e2fde0530aeca9598a0a1030eabdba3036f0..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240412165156_dev_servers_per_user.sql +++ /dev/null @@ -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; diff --git a/crates/collab/migrations/20240417192746_unique_remote_projects_by_paths.sql b/crates/collab/migrations/20240417192746_unique_remote_projects_by_paths.sql deleted file mode 100644 index 923b948ceeb3ebe27502cb773a5232bc6cc39fc4..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240417192746_unique_remote_projects_by_paths.sql +++ /dev/null @@ -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); diff --git a/crates/collab/migrations/20240502150229_rename_to_dev_server_projects.sql b/crates/collab/migrations/20240502150229_rename_to_dev_server_projects.sql deleted file mode 100644 index 0d8e9de5e6ada47c617401b53dcca5d18b643aa6..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240502150229_rename_to_dev_server_projects.sql +++ /dev/null @@ -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; diff --git a/crates/collab/migrations/20240502180204_remove_old_remote_projects.sql b/crates/collab/migrations/20240502180204_remove_old_remote_projects.sql deleted file mode 100644 index 01ace43fab08bfeee9b7e665ccd28ebc50f27134..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240502180204_remove_old_remote_projects.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE projects DROP COLUMN remote_project_id; -DROP TABLE remote_projects; diff --git a/crates/collab/migrations/20240514164510_store_ssh_connect_string.sql b/crates/collab/migrations/20240514164510_store_ssh_connect_string.sql deleted file mode 100644 index 5085ca271bd130ab25d173391daae8542930ae27..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240514164510_store_ssh_connect_string.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE dev_servers ADD COLUMN ssh_connection_string TEXT; diff --git a/crates/collab/migrations/20240715230940_add_worktrees_to_dev_server_projects.sql b/crates/collab/migrations/20240715230940_add_worktrees_to_dev_server_projects.sql deleted file mode 100644 index 675df4885bb531722cf80a76bf93eac58add5b8c..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240715230940_add_worktrees_to_dev_server_projects.sql +++ /dev/null @@ -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; diff --git a/crates/collab/migrations/20240729170526_add_billing_subscription.sql b/crates/collab/migrations/20240729170526_add_billing_subscription.sql deleted file mode 100644 index acec4b3ddb43c3a59e221daabad4b3161c867d09..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240729170526_add_billing_subscription.sql +++ /dev/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); diff --git a/crates/collab/migrations/20240730014107_add_billing_customer.sql b/crates/collab/migrations/20240730014107_add_billing_customer.sql deleted file mode 100644 index 7f7d4a0f85608ba07595b81d90dd617a8acd4e0c..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240730014107_add_billing_customer.sql +++ /dev/null @@ -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); diff --git a/crates/collab/migrations/20240730122654_add_last_stripe_event_id.sql b/crates/collab/migrations/20240730122654_add_last_stripe_event_id.sql deleted file mode 100644 index 477eadd742e3a128356fdeb75d5f35c1e8f77795..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240730122654_add_last_stripe_event_id.sql +++ /dev/null @@ -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; diff --git a/crates/collab/migrations/20240730182554_add_processed_stripe_events.sql b/crates/collab/migrations/20240730182554_add_processed_stripe_events.sql deleted file mode 100644 index baf1aa3122e8009a705708e9b8880f5eba5f36f5..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240730182554_add_processed_stripe_events.sql +++ /dev/null @@ -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); diff --git a/crates/collab/migrations/20240731120800_add_stripe_cancel_at_to_billing_subscriptions.sql b/crates/collab/migrations/20240731120800_add_stripe_cancel_at_to_billing_subscriptions.sql deleted file mode 100644 index b09640bb1eabafda7b9eef9d0763db31d78d1e96..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240731120800_add_stripe_cancel_at_to_billing_subscriptions.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE billing_subscriptions ADD COLUMN stripe_cancel_at TIMESTAMP WITHOUT TIME ZONE; diff --git a/crates/collab/migrations/20240812073542_add_accepted_tos_at.sql b/crates/collab/migrations/20240812073542_add_accepted_tos_at.sql deleted file mode 100644 index 43fa0e7bbdcbfe1c0f05a5ae3a74966dcecd7f1b..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240812073542_add_accepted_tos_at.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE users ADD accepted_tos_at TIMESTAMP WITHOUT TIME ZONE; diff --git a/crates/collab/migrations/20240812204045_add_github_user_created_at_to_users.sql b/crates/collab/migrations/20240812204045_add_github_user_created_at_to_users.sql deleted file mode 100644 index a5f713ef7c489f9b87ea9c3b47345903f1e4b5b5..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240812204045_add_github_user_created_at_to_users.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE "users" ADD COLUMN "github_user_created_at" TIMESTAMP WITHOUT TIME ZONE; diff --git a/crates/collab/migrations/20240816181658_add_enabled_for_all_to_feature_flags.sql b/crates/collab/migrations/20240816181658_add_enabled_for_all_to_feature_flags.sql deleted file mode 100644 index a56c87b97a41de260ccb4aa7d44fd35d2c026293..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240816181658_add_enabled_for_all_to_feature_flags.sql +++ /dev/null @@ -1 +0,0 @@ -alter table feature_flags add column enabled_for_all boolean not null default false; diff --git a/crates/collab/migrations/20240822215737_add_unique_constraint_on_github_user_id_on_users.sql b/crates/collab/migrations/20240822215737_add_unique_constraint_on_github_user_id_on_users.sql deleted file mode 100644 index 3b418f7e2669adfed83919605387d2c613b7f01a..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240822215737_add_unique_constraint_on_github_user_id_on_users.sql +++ /dev/null @@ -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); diff --git a/crates/collab/migrations/20240823155956_add_is_fifo_to_worktree_entries.sql b/crates/collab/migrations/20240823155956_add_is_fifo_to_worktree_entries.sql deleted file mode 100644 index af6fdac19d2498e990605d9851cb690dff41e830..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20240823155956_add_is_fifo_to_worktree_entries.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE "worktree_entries" -ADD "is_fifo" BOOL NOT NULL DEFAULT FALSE; diff --git a/crates/collab/migrations/20241002120231_add_local_settings_kind.sql b/crates/collab/migrations/20241002120231_add_local_settings_kind.sql deleted file mode 100644 index aec4ffb8f8519b3fb30c90db4d9bd1221237d7c7..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20241002120231_add_local_settings_kind.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE "worktree_settings_files" ADD COLUMN "kind" VARCHAR; diff --git a/crates/collab/migrations/20241009190639_add_billing_preferences.sql b/crates/collab/migrations/20241009190639_add_billing_preferences.sql deleted file mode 100644 index 9aa5a1a303668eac7032555f0ea04c6c34b1718f..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20241009190639_add_billing_preferences.sql +++ /dev/null @@ -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); diff --git a/crates/collab/migrations/20241019184824_adjust_symlink_data.sql b/crates/collab/migrations/20241019184824_adjust_symlink_data.sql deleted file mode 100644 index a38dd21cde85e6ac48c2e45afd5397a81952e712..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20241019184824_adjust_symlink_data.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE worktree_entries ADD COLUMN canonical_path text; -ALTER TABLE worktree_entries ALTER COLUMN is_symlink SET DEFAULT false; diff --git a/crates/collab/migrations/20241021202606_add_custom_llm_monthly_allowance_in_cents_to_users.sql b/crates/collab/migrations/20241021202606_add_custom_llm_monthly_allowance_in_cents_to_users.sql deleted file mode 100644 index 60a9bfa91074b4bff08e2cd686e6203beb6b2cf4..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20241021202606_add_custom_llm_monthly_allowance_in_cents_to_users.sql +++ /dev/null @@ -1 +0,0 @@ -alter table users add column custom_llm_monthly_allowance_in_cents integer; diff --git a/crates/collab/migrations/20241023201725_remove_dev_servers.sql b/crates/collab/migrations/20241023201725_remove_dev_servers.sql deleted file mode 100644 index c5da673a29b1e08b371c712c2786676829f3c25f..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20241023201725_remove_dev_servers.sql +++ /dev/null @@ -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; diff --git a/crates/collab/migrations/20241121185750_add_breakpoints.sql b/crates/collab/migrations/20241121185750_add_breakpoints.sql deleted file mode 100644 index 4b3071457392f433959ce8270b4dd91f6b99bb78..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20241121185750_add_breakpoints.sql +++ /dev/null @@ -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"); diff --git a/crates/collab/migrations/20250108184547_add_stripe_cancellation_reason_to_billing_subscriptions.sql b/crates/collab/migrations/20250108184547_add_stripe_cancellation_reason_to_billing_subscriptions.sql deleted file mode 100644 index 31686f56bbc06e21797e5389664bf2b2850a6263..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250108184547_add_stripe_cancellation_reason_to_billing_subscriptions.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table billing_subscriptions -add column stripe_cancellation_reason text; diff --git a/crates/collab/migrations/20250113230049_expand_git_status_information.sql b/crates/collab/migrations/20250113230049_expand_git_status_information.sql deleted file mode 100644 index eada39fe304020556bd39dedf640a890144ae5dd..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250113230049_expand_git_status_information.sql +++ /dev/null @@ -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; diff --git a/crates/collab/migrations/20250117100620_add_user_name.sql b/crates/collab/migrations/20250117100620_add_user_name.sql deleted file mode 100644 index fff7f95b6052c54c47bcc0c40ef49c65e35b95b4..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250117100620_add_user_name.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE users ADD COLUMN name TEXT; diff --git a/crates/collab/migrations/20250204224004_add_has_overdue_invoices_to_billing_customers.sql b/crates/collab/migrations/20250204224004_add_has_overdue_invoices_to_billing_customers.sql deleted file mode 100644 index 07c40303994395e8f43c33df130955e0d82ab627..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250204224004_add_has_overdue_invoices_to_billing_customers.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table billing_customers -add column has_overdue_invoices bool not null default false; diff --git a/crates/collab/migrations/20250205192813_add_provides_fields_to_extension_versions.sql b/crates/collab/migrations/20250205192813_add_provides_fields_to_extension_versions.sql deleted file mode 100644 index 50dcb0508f35cc69a87bbcbf83fed9809f539b41..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250205192813_add_provides_fields_to_extension_versions.sql +++ /dev/null @@ -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; diff --git a/crates/collab/migrations/20250205232017_add_conflicts_to_repositories.sql b/crates/collab/migrations/20250205232017_add_conflicts_to_repositories.sql deleted file mode 100644 index e6e0770bba8cbbb7649689705c526ead9629518d..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250205232017_add_conflicts_to_repositories.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE worktree_repositories -ADD COLUMN current_merge_conflicts VARCHAR NULL; diff --git a/crates/collab/migrations/20250210223746_add_branch_summary.sql b/crates/collab/migrations/20250210223746_add_branch_summary.sql deleted file mode 100644 index 3294f38b94114a73713b6282d401b97fcdc383e5..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250210223746_add_branch_summary.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE worktree_repositories -ADD COLUMN worktree_repositories VARCHAR NULL; diff --git a/crates/collab/migrations/20250212060936_add_worktree_branch_summary.sql b/crates/collab/migrations/20250212060936_add_worktree_branch_summary.sql deleted file mode 100644 index d7e3c04e2ff7844ed8d47907b0d21b64ae7d9a1c..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250212060936_add_worktree_branch_summary.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE worktree_repositories ADD COLUMN branch_summary TEXT NULL; diff --git a/crates/collab/migrations/20250319182812_create_project_repositories.sql b/crates/collab/migrations/20250319182812_create_project_repositories.sql deleted file mode 100644 index 8ca8c3444e60ccc4105e01e7a0d035930d57da4d..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250319182812_create_project_repositories.sql +++ /dev/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"); diff --git a/crates/collab/migrations/20250415164141_add_kind_and_period_to_billing_subscriptions.sql b/crates/collab/migrations/20250415164141_add_kind_and_period_to_billing_subscriptions.sql deleted file mode 100644 index b91431b28ba2ed2ce9fcf13a72938aad46330f04..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250415164141_add_kind_and_period_to_billing_subscriptions.sql +++ /dev/null @@ -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; diff --git a/crates/collab/migrations/20250422194500_add_trial_started_at_to_billing_customers.sql b/crates/collab/migrations/20250422194500_add_trial_started_at_to_billing_customers.sql deleted file mode 100644 index 34a159cf65a2a92aa21b75daa62c9a0d91023bcc..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250422194500_add_trial_started_at_to_billing_customers.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table billing_customers - add column trial_started_at timestamp without time zone; diff --git a/crates/collab/migrations/20250423150129_add_head_commit_details_to_project_repositories.sql b/crates/collab/migrations/20250423150129_add_head_commit_details_to_project_repositories.sql deleted file mode 100644 index c37fed224229d99403868f462a23fe811b27fda6..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250423150129_add_head_commit_details_to_project_repositories.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table project_repositories - add column head_commit_details varchar; diff --git a/crates/collab/migrations/20250425201930_add_model_request_overages_to_billing_preferences.sql b/crates/collab/migrations/20250425201930_add_model_request_overages_to_billing_preferences.sql deleted file mode 100644 index 86e35c9202b9184796a8c3d2463f20f89766ec8c..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250425201930_add_model_request_overages_to_billing_preferences.sql +++ /dev/null @@ -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; diff --git a/crates/collab/migrations/20250530175450_add_channel_order.sql b/crates/collab/migrations/20250530175450_add_channel_order.sql deleted file mode 100644 index 977a4611cdb75d0e53c8d1c132290f9da7469dc5..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250530175450_add_channel_order.sql +++ /dev/null @@ -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"); diff --git a/crates/collab/migrations/20250612153105_add_collaborator_commit_email.sql b/crates/collab/migrations/20250612153105_add_collaborator_commit_email.sql deleted file mode 100644 index 73876e89652deea8bbebf354b99cb2d792894130..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250612153105_add_collaborator_commit_email.sql +++ /dev/null @@ -1,4 +0,0 @@ -alter table project_collaborators - add column committer_name varchar; -alter table project_collaborators - add column committer_email varchar; diff --git a/crates/collab/migrations/20250617082236_add_debug_adapter_provides_field_to_extensions.sql b/crates/collab/migrations/20250617082236_add_debug_adapter_provides_field_to_extensions.sql deleted file mode 100644 index 8455a82f9ee6b5fdf8cfba3da08c880018061a43..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250617082236_add_debug_adapter_provides_field_to_extensions.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table extension_versions -add column provides_debug_adapters bool not null default false diff --git a/crates/collab/migrations/20250618090000_add_agent_servers_provides_field_to_extensions.sql b/crates/collab/migrations/20250618090000_add_agent_servers_provides_field_to_extensions.sql deleted file mode 100644 index 3c399924b96891d490792fb36b61a034f8dce97f..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250618090000_add_agent_servers_provides_field_to_extensions.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table extension_versions -add column provides_agent_servers bool not null default false diff --git a/crates/collab/migrations/20250702185129_add_cascading_delete_to_repository_entries.sql b/crates/collab/migrations/20250702185129_add_cascading_delete_to_repository_entries.sql deleted file mode 100644 index 6d898c481199f4770ab7df5ce66c08e2fdf42423..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250702185129_add_cascading_delete_to_repository_entries.sql +++ /dev/null @@ -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; diff --git a/crates/collab/migrations/20250707182700_add_access_tokens_cascade_delete_on_user.sql b/crates/collab/migrations/20250707182700_add_access_tokens_cascade_delete_on_user.sql deleted file mode 100644 index ae0ffe24f6322196358225ff4159df9d1cfa6298..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250707182700_add_access_tokens_cascade_delete_on_user.sql +++ /dev/null @@ -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; diff --git a/crates/collab/migrations/20250804080620_language_server_capabilities.sql b/crates/collab/migrations/20250804080620_language_server_capabilities.sql deleted file mode 100644 index f74f094ed25d488720f2f85f30b6762f83647b02..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250804080620_language_server_capabilities.sql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER TABLE language_servers - ADD COLUMN capabilities TEXT NOT NULL DEFAULT '{}'; - -ALTER TABLE language_servers - ALTER COLUMN capabilities DROP DEFAULT; diff --git a/crates/collab/migrations/20250816124707_make_admin_required_on_users.sql b/crates/collab/migrations/20250816124707_make_admin_required_on_users.sql deleted file mode 100644 index e372723d6d5f5e822a2e437cfac4b95bc2023998..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250816124707_make_admin_required_on_users.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table users -alter column admin set not null; diff --git a/crates/collab/migrations/20250816133027_add_orb_customer_id_to_billing_customers.sql b/crates/collab/migrations/20250816133027_add_orb_customer_id_to_billing_customers.sql deleted file mode 100644 index ea5e4de52a829413030bb5e206f5c7401381adcf..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250816133027_add_orb_customer_id_to_billing_customers.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table billing_customers - add column orb_customer_id text; diff --git a/crates/collab/migrations/20250816135346_drop_rate_buckets_table.sql b/crates/collab/migrations/20250816135346_drop_rate_buckets_table.sql deleted file mode 100644 index f51a33ed30d7fb88bc9dc6c82e7217c7e4634b28..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250816135346_drop_rate_buckets_table.sql +++ /dev/null @@ -1 +0,0 @@ -drop table rate_buckets; diff --git a/crates/collab/migrations/20250818192156_add_git_merge_message.sql b/crates/collab/migrations/20250818192156_add_git_merge_message.sql deleted file mode 100644 index 335ea2f82493082e0e20d7762b5282696dc50224..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250818192156_add_git_merge_message.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE "project_repositories" ADD COLUMN "merge_message" VARCHAR; diff --git a/crates/collab/migrations/20250819022421_add_orb_subscription_id_to_billing_subscriptions.sql b/crates/collab/migrations/20250819022421_add_orb_subscription_id_to_billing_subscriptions.sql deleted file mode 100644 index 317f6a7653e3d1762f74e795a17d2f99b3831201..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250819022421_add_orb_subscription_id_to_billing_subscriptions.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table billing_subscriptions - add column orb_subscription_id text; diff --git a/crates/collab/migrations/20250819225916_make_stripe_fields_optional_on_billing_subscription.sql b/crates/collab/migrations/20250819225916_make_stripe_fields_optional_on_billing_subscription.sql deleted file mode 100644 index cf3b79da60be98da8dd78a2bcb01f7532be7fc59..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250819225916_make_stripe_fields_optional_on_billing_subscription.sql +++ /dev/null @@ -1,3 +0,0 @@ -alter table billing_subscriptions - alter column stripe_subscription_id drop not null, - alter column stripe_subscription_status drop not null; diff --git a/crates/collab/migrations/20250821133754_add_orb_subscription_status_and_period_to_billing_subscriptions.sql b/crates/collab/migrations/20250821133754_add_orb_subscription_status_and_period_to_billing_subscriptions.sql deleted file mode 100644 index 89a42ab82bd97f487a426ef1fa0a08aa5b0c8396..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250821133754_add_orb_subscription_status_and_period_to_billing_subscriptions.sql +++ /dev/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; diff --git a/crates/collab/migrations/20250827084812_worktree_in_servers.sql b/crates/collab/migrations/20250827084812_worktree_in_servers.sql deleted file mode 100644 index d4c6ffbbcccb2d2f23654cfc287b45bb8ea20508..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250827084812_worktree_in_servers.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE language_servers - ADD COLUMN worktree_id BIGINT; diff --git a/crates/collab/migrations/20250913035238_add_orb_cancellation_date_to_billing_subscriptions.sql b/crates/collab/migrations/20250913035238_add_orb_cancellation_date_to_billing_subscriptions.sql deleted file mode 100644 index 56144237421d49fa68545f9689bdb1688603739a..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250913035238_add_orb_cancellation_date_to_billing_subscriptions.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table billing_subscriptions - add column orb_cancellation_date timestamp without time zone; diff --git a/crates/collab/migrations/20250914022147_add_orb_portal_url_to_billing_customers.sql b/crates/collab/migrations/20250914022147_add_orb_portal_url_to_billing_customers.sql deleted file mode 100644 index 2de05740410f5d13f7cd510a85af24dd2ff171b6..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250914022147_add_orb_portal_url_to_billing_customers.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table billing_customers - add column orb_portal_url text; diff --git a/crates/collab/migrations/20250916173002_add_path_style_to_project.sql b/crates/collab/migrations/20250916173002_add_path_style_to_project.sql deleted file mode 100644 index b1244818f14403d38af577be4b14b1a8a765e07b..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20250916173002_add_path_style_to_project.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE projects ADD COLUMN windows_paths BOOLEAN DEFAULT FALSE; diff --git a/crates/collab/migrations/20251002214229_add_token_spend_in_cents_to_billing_subscriptions.sql b/crates/collab/migrations/20251002214229_add_token_spend_in_cents_to_billing_subscriptions.sql deleted file mode 100644 index ccae01e2833fedd530f290c55d2852c33de6957c..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20251002214229_add_token_spend_in_cents_to_billing_subscriptions.sql +++ /dev/null @@ -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; diff --git a/crates/collab/migrations/20251008120000_add_is_hidden_to_worktree_entries.sql b/crates/collab/migrations/20251008120000_add_is_hidden_to_worktree_entries.sql deleted file mode 100644 index 5b4207aeea500595c66508fa88a20662bc5693c1..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20251008120000_add_is_hidden_to_worktree_entries.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE "worktree_entries" -ADD "is_hidden" BOOL NOT NULL DEFAULT FALSE; diff --git a/crates/collab/migrations/20251110214057_drop_channel_messages.sql b/crates/collab/migrations/20251110214057_drop_channel_messages.sql deleted file mode 100644 index 468534542fbb7cee04aee985bfe2143f30d219ad..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20251110214057_drop_channel_messages.sql +++ /dev/null @@ -1,3 +0,0 @@ -drop table observed_channel_messages; -drop table channel_message_mentions; -drop table channel_messages; diff --git a/crates/collab/migrations/20251111161644_drop_embeddings.sql b/crates/collab/migrations/20251111161644_drop_embeddings.sql deleted file mode 100644 index 80f42c7d2c88b258ef8cc63757694a7e229643c7..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20251111161644_drop_embeddings.sql +++ /dev/null @@ -1 +0,0 @@ -drop table embeddings; diff --git a/crates/collab/migrations/20251117215316_add_external_id_to_billing_customers.sql b/crates/collab/migrations/20251117215316_add_external_id_to_billing_customers.sql deleted file mode 100644 index 6add45d4ad5d83cea6d86d2edc1e06613bd25560..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20251117215316_add_external_id_to_billing_customers.sql +++ /dev/null @@ -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); diff --git a/crates/collab/migrations/20251203234258_add_remote_urls_to_project_repositories.sql b/crates/collab/migrations/20251203234258_add_remote_urls_to_project_repositories.sql deleted file mode 100644 index e1396de27d90fb2c872197d25198743d19be86f8..0000000000000000000000000000000000000000 --- a/crates/collab/migrations/20251203234258_add_remote_urls_to_project_repositories.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE "project_repositories" ADD COLUMN "remote_upstream_url" VARCHAR; -ALTER TABLE "project_repositories" ADD COLUMN "remote_origin_url" VARCHAR; diff --git a/crates/collab/migrations/20251208000000_test_schema.sql b/crates/collab/migrations/20251208000000_test_schema.sql new file mode 100644 index 0000000000000000000000000000000000000000..ed9c9d16dbdf2fbe2e69134f407ee5365236161b --- /dev/null +++ b/crates/collab/migrations/20251208000000_test_schema.sql @@ -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; diff --git a/crates/collab/migrations_llm/20240806182921_create_providers_and_models.sql b/crates/collab/migrations_llm/20240806182921_create_providers_and_models.sql deleted file mode 100644 index b81ab7567f22ae750c9aad6357cbf995a75c47c4..0000000000000000000000000000000000000000 --- a/crates/collab/migrations_llm/20240806182921_create_providers_and_models.sql +++ /dev/null @@ -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); diff --git a/crates/collab/migrations_llm/20240806213401_create_usages.sql b/crates/collab/migrations_llm/20240806213401_create_usages.sql deleted file mode 100644 index da2245d4b9ac20fb6dddcb892221d1ff773cd156..0000000000000000000000000000000000000000 --- a/crates/collab/migrations_llm/20240806213401_create_usages.sql +++ /dev/null @@ -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); diff --git a/crates/collab/migrations_llm/20240809130000_change_rate_limit_columns_to_bigint.sql b/crates/collab/migrations_llm/20240809130000_change_rate_limit_columns_to_bigint.sql deleted file mode 100644 index f1def8209a742743a6c708365afc05f7ab911e18..0000000000000000000000000000000000000000 --- a/crates/collab/migrations_llm/20240809130000_change_rate_limit_columns_to_bigint.sql +++ /dev/null @@ -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; diff --git a/crates/collab/migrations_llm/20240809160000_add_pricing_columns_to_models.sql b/crates/collab/migrations_llm/20240809160000_add_pricing_columns_to_models.sql deleted file mode 100644 index d9ffe2f9f29c10acc9aaa6dc48389f92298c404f..0000000000000000000000000000000000000000 --- a/crates/collab/migrations_llm/20240809160000_add_pricing_columns_to_models.sql +++ /dev/null @@ -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; diff --git a/crates/collab/migrations_llm/20240812184444_add_is_staff_to_usages.sql b/crates/collab/migrations_llm/20240812184444_add_is_staff_to_usages.sql deleted file mode 100644 index a50feb2e3f41cd8e25265049a09140bdb04ea0d3..0000000000000000000000000000000000000000 --- a/crates/collab/migrations_llm/20240812184444_add_is_staff_to_usages.sql +++ /dev/null @@ -1 +0,0 @@ -alter table usages add column is_staff boolean not null default false; diff --git a/crates/collab/migrations_llm/20240812225346_create_lifetime_usages.sql b/crates/collab/migrations_llm/20240812225346_create_lifetime_usages.sql deleted file mode 100644 index 42047433e564d0f463a11f119ab4950d1d2d1254..0000000000000000000000000000000000000000 --- a/crates/collab/migrations_llm/20240812225346_create_lifetime_usages.sql +++ /dev/null @@ -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); diff --git a/crates/collab/migrations_llm/20240813002237_add_revoked_access_tokens_table.sql b/crates/collab/migrations_llm/20240813002237_add_revoked_access_tokens_table.sql deleted file mode 100644 index c30e58a6dd8bccd882a97b55b91e190950890aac..0000000000000000000000000000000000000000 --- a/crates/collab/migrations_llm/20240813002237_add_revoked_access_tokens_table.sql +++ /dev/null @@ -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); diff --git a/crates/collab/migrations_llm/20241007173634_add_cache_token_counts.sql b/crates/collab/migrations_llm/20241007173634_add_cache_token_counts.sql deleted file mode 100644 index 855e46ab0224dc4e20e0fb8634a3e678d584433e..0000000000000000000000000000000000000000 --- a/crates/collab/migrations_llm/20241007173634_add_cache_token_counts.sql +++ /dev/null @@ -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; diff --git a/crates/collab/migrations_llm/20241007220716_drop_incorrect_usages_columns.sql b/crates/collab/migrations_llm/20241007220716_drop_incorrect_usages_columns.sql deleted file mode 100644 index c204451b7538d8fefb41e3f2962433b552b91229..0000000000000000000000000000000000000000 --- a/crates/collab/migrations_llm/20241007220716_drop_incorrect_usages_columns.sql +++ /dev/null @@ -1,3 +0,0 @@ -alter table usages - drop column cache_creation_input_tokens_this_month, - drop column cache_read_input_tokens_this_month; diff --git a/crates/collab/migrations_llm/20241008155620_create_monthly_usages.sql b/crates/collab/migrations_llm/20241008155620_create_monthly_usages.sql deleted file mode 100644 index 2733552a3a16f2754ba1c191e42ab4548f67848c..0000000000000000000000000000000000000000 --- a/crates/collab/migrations_llm/20241008155620_create_monthly_usages.sql +++ /dev/null @@ -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); diff --git a/crates/collab/migrations_llm/20241010151249_create_billing_events.sql b/crates/collab/migrations_llm/20241010151249_create_billing_events.sql deleted file mode 100644 index 74a270872e5f664096d90179359e78a5a2298812..0000000000000000000000000000000000000000 --- a/crates/collab/migrations_llm/20241010151249_create_billing_events.sql +++ /dev/null @@ -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); diff --git a/crates/collab/migrations_llm/20250404141155_add_granular_token_limits_to_models.sql b/crates/collab/migrations_llm/20250404141155_add_granular_token_limits_to_models.sql deleted file mode 100644 index e5c50d8385745c602f01b2bb7daa9ba8d3580eaa..0000000000000000000000000000000000000000 --- a/crates/collab/migrations_llm/20250404141155_add_granular_token_limits_to_models.sql +++ /dev/null @@ -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; diff --git a/crates/collab/migrations_llm/20250415213005_add_subscription_usages.sql b/crates/collab/migrations_llm/20250415213005_add_subscription_usages.sql deleted file mode 100644 index b3873710580b39cdb9c8fe8a2bb176839b5163b4..0000000000000000000000000000000000000000 --- a/crates/collab/migrations_llm/20250415213005_add_subscription_usages.sql +++ /dev/null @@ -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); diff --git a/crates/collab/migrations_llm/20250416181354_add_plan_to_subscription_usages.sql b/crates/collab/migrations_llm/20250416181354_add_plan_to_subscription_usages.sql deleted file mode 100644 index 8d54c8b87ca820bd8aa46c7bf18ccd50ccf52807..0000000000000000000000000000000000000000 --- a/crates/collab/migrations_llm/20250416181354_add_plan_to_subscription_usages.sql +++ /dev/null @@ -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); diff --git a/crates/collab/migrations_llm/20250425171838_add_subscription_usage_meters.sql b/crates/collab/migrations_llm/20250425171838_add_subscription_usage_meters.sql deleted file mode 100644 index ded918e18385dbfe9f916bc0bdb49a3a6bde153f..0000000000000000000000000000000000000000 --- a/crates/collab/migrations_llm/20250425171838_add_subscription_usage_meters.sql +++ /dev/null @@ -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); diff --git a/crates/collab/migrations_llm/20250429143553_add_mode_to_subscription_usage_meters.sql b/crates/collab/migrations_llm/20250429143553_add_mode_to_subscription_usage_meters.sql deleted file mode 100644 index 9d63e299f56e0475a4016b2a69a0779f09cc8b4d..0000000000000000000000000000000000000000 --- a/crates/collab/migrations_llm/20250429143553_add_mode_to_subscription_usage_meters.sql +++ /dev/null @@ -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); diff --git a/crates/collab/migrations_llm/20250503162708_add_v2_subscription_usage_and_meter_tables.sql b/crates/collab/migrations_llm/20250503162708_add_v2_subscription_usage_and_meter_tables.sql deleted file mode 100644 index 59169d3c3ec722fd7dfcdde97f1ed3f34e5c51fd..0000000000000000000000000000000000000000 --- a/crates/collab/migrations_llm/20250503162708_add_v2_subscription_usage_and_meter_tables.sql +++ /dev/null @@ -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); diff --git a/crates/collab/migrations_llm/20250504132836_drop_legacy_subscription_usage_and_meter_tables.sql b/crates/collab/migrations_llm/20250504132836_drop_legacy_subscription_usage_and_meter_tables.sql deleted file mode 100644 index f06b152d7ba9a38419facb18fd620899a63b083d..0000000000000000000000000000000000000000 --- a/crates/collab/migrations_llm/20250504132836_drop_legacy_subscription_usage_and_meter_tables.sql +++ /dev/null @@ -1,2 +0,0 @@ -drop table subscription_usage_meters; -drop table subscription_usages; diff --git a/crates/collab/migrations_llm/20250521211721_drop_monthly_and_lifetime_usages_tables.sql b/crates/collab/migrations_llm/20250521211721_drop_monthly_and_lifetime_usages_tables.sql deleted file mode 100644 index 5f03f50d0b3e17acf3aabd433df9ef317172039a..0000000000000000000000000000000000000000 --- a/crates/collab/migrations_llm/20250521211721_drop_monthly_and_lifetime_usages_tables.sql +++ /dev/null @@ -1,2 +0,0 @@ -drop table monthly_usages; -drop table lifetime_usages; diff --git a/crates/collab/migrations_llm/20250521222416_drop_billing_events_table.sql b/crates/collab/migrations_llm/20250521222416_drop_billing_events_table.sql deleted file mode 100644 index 36b79266b6adc448e99d6bb3fa1c88b9ee9604f5..0000000000000000000000000000000000000000 --- a/crates/collab/migrations_llm/20250521222416_drop_billing_events_table.sql +++ /dev/null @@ -1 +0,0 @@ -drop table billing_events; diff --git a/crates/collab/src/db/tables.rs b/crates/collab/src/db/tables.rs index 0220955824af30f489afe32f9695af3dbb52cdc9..c179539e4bbc07fe070f3089f912b4c0b4fbf167 100644 --- a/crates/collab/src/db/tables.rs +++ b/crates/collab/src/db/tables.rs @@ -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; diff --git a/crates/collab/src/db/tables/signup.rs b/crates/collab/src/db/tables/signup.rs deleted file mode 100644 index 79d9f0580c13f981daf30283b1a9e8902ea0b995..0000000000000000000000000000000000000000 --- a/crates/collab/src/db/tables/signup.rs +++ /dev/null @@ -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, - pub user_id: Option, - pub inviting_user_id: Option, - pub platform_mac: bool, - pub platform_linux: bool, - pub platform_windows: bool, - pub platform_unknown: bool, - pub editor_features: Option>, - pub programming_languages: Option>, - pub added_to_mailing_list: bool, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation {} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/collab/src/db/tests.rs b/crates/collab/src/db/tests.rs index 7aed2ebc2dd16f31cde4116a70377b40b1cb8b2f..10a32691ed36b4db9502c63bd510df6ffe1fe5b6 100644 --- a/crates/collab/src/db/tests.rs +++ b/crates/collab/src/db/tests.rs @@ -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>, diff --git a/crates/collab/src/migrations.rs b/crates/collab/src/db/tests/migrations.rs similarity index 100% rename from crates/collab/src/migrations.rs rename to crates/collab/src/db/tests/migrations.rs diff --git a/crates/collab/src/lib.rs b/crates/collab/src/lib.rs index 14573e94b0b535b1644510e28dfc906b1a2c420e..08f7e61c020ca9ea23be62636e381f9abedf7cf0 100644 --- a/crates/collab/src/lib.rs +++ b/crates/collab/src/lib.rs @@ -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; diff --git a/crates/collab/src/llm.rs b/crates/collab/src/llm.rs deleted file mode 100644 index dec10232bdb000acef9def25cad519ceb213956b..0000000000000000000000000000000000000000 --- a/crates/collab/src/llm.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod db; diff --git a/crates/collab/src/llm/db.rs b/crates/collab/src/llm/db.rs deleted file mode 100644 index b15d5a42b5f183831b34552beba3f616d3a7c3f0..0000000000000000000000000000000000000000 --- a/crates/collab/src/llm/db.rs +++ /dev/null @@ -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, -} - -impl LlmDatabase { - /// Connects to the database with the given options - pub async fn new(options: ConnectOptions, executor: Executor) -> Result { - 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(&self, f: F) -> Result - where - F: Send + Fn(TransactionHandle) -> Fut, - Fut: Send + Future>, - { - 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(&self, f: &F) -> Result<(DatabaseTransaction, Result)> - where - F: Send + Fn(TransactionHandle) -> Fut, - Fut: Send + Future>, - { - 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(&self, future: F) -> Result - where - F: Future>, - { - #[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 - } - } -} diff --git a/crates/collab/src/main.rs b/crates/collab/src/main.rs index 08047c56e55c016f3fd2b34d0935fb33a61b5dad..030158c94d640ef8a9024a8b783685bac7d0dcdb 100644 --- a/crates/collab/src/main.rs +++ b/crates/collab/src/main.rs @@ -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::().expect("error loading config"); - setup_app_database(&config).await?; - } Some("seed") => { let config = envy::from_env::().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 >" + "usage: collab >" ))?; } }; @@ -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) -> String { format!("zed:{mode} v{VERSION} ({})", REVISION.unwrap_or("unknown")) } diff --git a/crates/collab_ui/src/collab_panel.rs b/crates/collab_ui/src/collab_panel.rs index 7137af21d315391383d3007c148807a7604a1155..2f1e2842cbd2f5024df0608578b7cb7f4bbc158d 100644 --- a/crates/collab_ui/src/collab_panel.rs +++ b/crates/collab_ui/src/collab_panel.rs @@ -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); }); diff --git a/crates/editor/src/actions.rs b/crates/editor/src/actions.rs index 0bf236769efd17c26ebd55d4dda010d454ba71e4..7d6f486974d1ef7e792bd79997aebd332c2336f4 100644 --- a/crates/editor/src/actions.rs +++ b/crates/editor/src/actions.rs @@ -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, + /// Name if using a named snippet + pub name: Option, + + /// Snippet body, if not using a named snippet + // todo(andrew): use `ListOrDirect` or similar for multiline snippet body + pub snippet: Option, +} + actions!( debugger, [ diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 223c0e574cff7daa9f50b07735b40e291185a37c..d173c1cb4aac782283a3832b5e411a0a44cc1f23 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -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.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, + ) -> Result<()> { + let insertion_ranges = self + .selections + .all::(&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, diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index 75aa29be7a31ef6a4707e538ea21a2ca45aff395..3bd5e6bf8f7947dfc9ac26f8ecbe9b6554151fcb 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -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 { diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index edb3778ff94809ef880ffa167f2ff410a3199a37..5e5749494017479b921a2bbdb2af8fb7d62c9bf4 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -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(); }); diff --git a/crates/extension/Cargo.toml b/crates/extension/Cargo.toml index a00406c43e796b1b2bafafc3d0481b09ee5fd43a..307a3a19bd5ec6502270ae2f579cbd6b6f378746 100644 --- a/crates/extension/Cargo.toml +++ b/crates/extension/Cargo.toml @@ -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 diff --git a/crates/extension/src/extension_builder.rs b/crates/extension/src/extension_builder.rs index b6d4cc0c4da3d1f7d998512f099eba6c9c04e1a5..8b9bf994d17e0594c719bed29907630fedf11497 100644 --- a/crates/extension/src/extension_builder.rs +++ b/crates/extension/src/extension_builder.rs @@ -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, ) -> 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, +) -> 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, } - 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 Result<()> { &extension_path, &mut manifest, CompileExtensionOptions { release: true }, + fs.clone(), ) .await .context("failed to compile extension")?; diff --git a/crates/extension_host/benches/extension_compilation_benchmark.rs b/crates/extension_host/benches/extension_compilation_benchmark.rs index 2a77be06a88d5d7ea13e59c629eb02bd097656df..605b98c67071155d8444639ef7043b9c8901161d 100644 --- a/crates/extension_host/benches/extension_compilation_benchmark.rs +++ b/crates/extension_host/benches/extension_compilation_benchmark.rs @@ -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 { +fn wasm_bytes(cx: &TestAppContext, manifest: &mut ExtensionManifest, fs: Arc) -> Vec { 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 &path, manifest, CompileExtensionOptions { release: true }, + fs, )) .unwrap(); std::fs::read(path.join("extension.wasm")).unwrap() diff --git a/crates/extension_host/src/extension_host.rs b/crates/extension_host/src/extension_host.rs index c52ea87df48bb88655b59e676e58d988061c57eb..97aafe8ebd81e8d284429a69edc88c60de8ed677 100644 --- a/crates/extension_host/src/extension_host.rs +++ b/crates/extension_host/src/extension_host.rs @@ -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 }); diff --git a/crates/languages/src/typescript.rs b/crates/languages/src/typescript.rs index b02fb40ac7d84eba03766bcdfc19fb0eee04a6ca..a7aa1bc49c0132b01d0fe45d94a29af4efac6602 100644 --- a/crates/languages/src/typescript.rs +++ b/crates/languages/src/typescript.rs @@ -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) -> Self { TypeScriptLspAdapter { fs, node } } + async fn tsdk_path(&self, adapter: &Arc) -> 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 { 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 { 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(), ), ], diff --git a/crates/snippet_provider/src/lib.rs b/crates/snippet_provider/src/lib.rs index 64711cfc3a7247f6250b65e4f7325dd0bfdc1dcb..5eff6c917f9b8198db6149ad07dc2fdf905a9223 100644 --- a/crates/snippet_provider/src/lib.rs +++ b/crates/snippet_provider/src/lib.rs @@ -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; fn file_stem_to_key(stem: &str) -> SnippetKind { if stem == "snippets" { diff --git a/crates/title_bar/src/collab.rs b/crates/title_bar/src/collab.rs index 3af2927464134db1707fb7a93c7fb980fa466c92..8a2d23dd26f81da469fe229eeed586ea8fe49189 100644 --- a/crates/title_bar/src/collab.rs +++ b/crates/title_bar/src/collab.rs @@ -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>>, 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(), ); diff --git a/crates/title_bar/src/title_bar.rs b/crates/title_bar/src/title_bar.rs index 0652744a36b2a9e0b09347553a6d16f6c5344dbe..945b28a02d1e3f7d6e358c2dad0107d7404aa84b 100644 --- a/crates/title_bar/src/title_bar.rs +++ b/crates/title_bar/src/title_bar.rs @@ -1,5 +1,5 @@ mod application_menu; -mod collab; +pub mod collab; mod onboarding_banner; pub mod platform_title_bar; mod platforms; diff --git a/crates/util/src/rel_path.rs b/crates/util/src/rel_path.rs index 8b6ae6e49a67ae1ef2d21b3b1e0c4708f407a5e3..5e20aacad5fe177cd1af65dc98aeb45565a3082e 100644 --- a/crates/util/src/rel_path.rs +++ b/crates/util/src/rel_path.rs @@ -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; diff --git a/script/create-migration b/script/create-migration deleted file mode 100755 index 187336be199ffc4d49f7f6e02b250090613a32fc..0000000000000000000000000000000000000000 --- a/script/create-migration +++ /dev/null @@ -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" diff --git a/typos.toml b/typos.toml index 6b1df15b40da0bded6d1f14bdf8b28e0b0ec649f..cfc4ec86a853d1aeb16ca41fefd1d9fe368659d1 100644 --- a/typos.toml +++ b/typos.toml @@ -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",