collab: Remove database migrations (#44436)

Marshall Bowers created

This PR removes the database schema migrations from the repo, as these
are now managed by Cloud.

There's a new `20251208000000_test_schema.sql` "migration" that we use
to create the database schema for the tests, similar to what we use for
SQLite.

Release Notes:

- N/A

Change summary

crates/collab/migrations/20210527024318_initial_schema.sql                                                  |  20 
crates/collab/migrations/20210607190313_create_access_tokens.sql                                            |   7 
crates/collab/migrations/20210805175147_create_chat_tables.sql                                              |  46 
crates/collab/migrations/20210916123647_add_nonce_to_channel_messages.sql                                   |   4 
crates/collab/migrations/20210920192001_add_interests_to_signups.sql                                        |   4 
crates/collab/migrations/20220421165757_drop_signups.sql                                                    |   1 
crates/collab/migrations/20220505144506_add_trigram_index_to_users.sql                                      |   2 
crates/collab/migrations/20220506130724_create_contacts.sql                                                 |  11 
crates/collab/migrations/20220518151305_add_invites_to_users.sql                                            |   9 
crates/collab/migrations/20220523232954_allow_user_deletes.sql                                              |   6 
crates/collab/migrations/20220620211403_create_projects.sql                                                 |  24 
crates/collab/migrations/20220913211150_create_signups.sql                                                  |  27 
crates/collab/migrations/20220929182110_add_metrics_id.sql                                                  |   2 
crates/collab/migrations/20221111092550_reconnection_support.sql                                            |  90 
crates/collab/migrations/20221125192125_add_added_to_mailing_list_to_signups.sql                            |   2 
crates/collab/migrations/20221207165001_add_connection_lost_to_room_participants.sql                        |   7 
crates/collab/migrations/20221213125710_index_room_participants_on_room_id.sql                              |   1 
crates/collab/migrations/20221214144346_change_epoch_from_uuid_to_integer.sql                               |  30 
crates/collab/migrations/20221219181850_project_reconnection_support.sql                                    |   3 
crates/collab/migrations/20230103200902_replace_is_completed_with_completed_scan_id.sql                     |   3 
crates/collab/migrations/20230202155735_followers.sql                                                       |  15 
crates/collab/migrations/20230508211523_add-repository-entries.sql                                          |  13 
crates/collab/migrations/20230511004019_add_repository_statuses.sql                                         |  15 
crates/collab/migrations/20230529164700_add_worktree_settings_files.sql                                     |  10 
crates/collab/migrations/20230605191135_remove_repository_statuses.sql                                      |   2 
crates/collab/migrations/20230616134535_add_is_external_to_worktree_entries.sql                             |   2 
crates/collab/migrations/20230727150500_add_channels.sql                                                    |  30 
crates/collab/migrations/20230819154600_add_channel_buffers.sql                                             |  40 
crates/collab/migrations/20230825190322_add_server_feature_flags.sql                                        |  16 
crates/collab/migrations/20230907114200_add_channel_messages.sql                                            |  19 
crates/collab/migrations/20230925210437_add_channel_changes.sql                                             |  19 
crates/collab/migrations/20230926102500_add_participant_index_to_room_participants.sql                      |   1 
crates/collab/migrations/20231004130100_create_notifications.sql                                            |  22 
crates/collab/migrations/20231009181554_add_release_channel_to_rooms.sql                                    |   1 
crates/collab/migrations/20231010114600_add_unique_index_on_rooms_channel_id.sql                            |   1 
crates/collab/migrations/20231011214412_add_guest_role.sql                                                  |   4 
crates/collab/migrations/20231017185833_projects_room_id_fkey_on_delete_cascade.sql                         |   8 
crates/collab/migrations/20231018102700_create_mentions.sql                                                 |  11 
crates/collab/migrations/20231024085546_move_channel_paths_to_channels_table.sql                            |  12 
crates/collab/migrations/20240103025509_add_role_to_room_participants.sql                                   |   1 
crates/collab/migrations/20240111085546_fix_column_name.sql                                                 |   1 
crates/collab/migrations/20240117150300_add_impersonator_to_access_tokens.sql                               |   1 
crates/collab/migrations/20240122174606_add_contributors.sql                                                |   5 
crates/collab/migrations/20240122224506_add_requires_zed_cla_column_to_channels.sql                         |   1 
crates/collab/migrations/20240129193601_fix_parent_path_index.sql                                           |   4 
crates/collab/migrations/20240203113741_add_reply_to_message.sql                                            |   1 
crates/collab/migrations/20240207041417_add_in_call_column_to_room_participants.sql                         |   3 
crates/collab/migrations/20240213200201_remove_unused_room_columns.sql                                      |   4 
crates/collab/migrations/20240214102900_add_extensions.sql                                                  |  22 
crates/collab/migrations/20240220234826_add_rate_buckets.sql                                                |  11 
crates/collab/migrations/20240221151017_add_edited_at_field_to_channel_message.sql                          |   1 
crates/collab/migrations/20240226163408_hosted_projects.sql                                                 |  11 
crates/collab/migrations/20240226164505_unique_channel_names.sql                                            |   3 
crates/collab/migrations/20240227215556_hosted_projects_in_projects.sql                                     |   3 
crates/collab/migrations/20240307163119_denormalize_buffer_ops.sql                                          |  17 
crates/collab/migrations/20240315182903_non_null_channel_role.sql                                           |   4 
crates/collab/migrations/20240315183903_channel_parent_path_not_null.sql                                    |   2 
crates/collab/migrations/20240320124800_add_extension_schema_version.sql                                    |   2 
crates/collab/migrations/20240321162658_add_devservers.sql                                                  |   7 
crates/collab/migrations/20240335123500_add_extension_wasm_api_version.sql                                  |   1 
crates/collab/migrations/20240402155003_add_dev_server_projects.sql                                         |   9 
crates/collab/migrations/20240409082755_create_embeddings.sql                                               |   9 
crates/collab/migrations/20240412165156_dev_servers_per_user.sql                                            |   7 
crates/collab/migrations/20240417192746_unique_remote_projects_by_paths.sql                                 |   3 
crates/collab/migrations/20240502150229_rename_to_dev_server_projects.sql                                   |  11 
crates/collab/migrations/20240502180204_remove_old_remote_projects.sql                                      |   2 
crates/collab/migrations/20240514164510_store_ssh_connect_string.sql                                        |   1 
crates/collab/migrations/20240715230940_add_worktrees_to_dev_server_projects.sql                            |   4 
crates/collab/migrations/20240729170526_add_billing_subscription.sql                                        |  12 
crates/collab/migrations/20240730014107_add_billing_customer.sql                                            |  18 
crates/collab/migrations/20240730122654_add_last_stripe_event_id.sql                                        |   2 
crates/collab/migrations/20240730182554_add_processed_stripe_events.sql                                     |  11 
crates/collab/migrations/20240731120800_add_stripe_cancel_at_to_billing_subscriptions.sql                   |   1 
crates/collab/migrations/20240812073542_add_accepted_tos_at.sql                                             |   1 
crates/collab/migrations/20240812204045_add_github_user_created_at_to_users.sql                             |   1 
crates/collab/migrations/20240816181658_add_enabled_for_all_to_feature_flags.sql                            |   1 
crates/collab/migrations/20240822215737_add_unique_constraint_on_github_user_id_on_users.sql                |   4 
crates/collab/migrations/20240823155956_add_is_fifo_to_worktree_entries.sql                                 |   2 
crates/collab/migrations/20241002120231_add_local_settings_kind.sql                                         |   1 
crates/collab/migrations/20241009190639_add_billing_preferences.sql                                         |   8 
crates/collab/migrations/20241019184824_adjust_symlink_data.sql                                             |   2 
crates/collab/migrations/20241021202606_add_custom_llm_monthly_allowance_in_cents_to_users.sql              |   1 
crates/collab/migrations/20241023201725_remove_dev_servers.sql                                              |   6 
crates/collab/migrations/20241121185750_add_breakpoints.sql                                                 |  11 
crates/collab/migrations/20250108184547_add_stripe_cancellation_reason_to_billing_subscriptions.sql         |   2 
crates/collab/migrations/20250113230049_expand_git_status_information.sql                                   |  13 
crates/collab/migrations/20250117100620_add_user_name.sql                                                   |   1 
crates/collab/migrations/20250204224004_add_has_overdue_invoices_to_billing_customers.sql                   |   2 
crates/collab/migrations/20250205192813_add_provides_fields_to_extension_versions.sql                       |  10 
crates/collab/migrations/20250205232017_add_conflicts_to_repositories.sql                                   |   2 
crates/collab/migrations/20250210223746_add_branch_summary.sql                                              |   2 
crates/collab/migrations/20250212060936_add_worktree_branch_summary.sql                                     |   1 
crates/collab/migrations/20250319182812_create_project_repositories.sql                                     |  32 
crates/collab/migrations/20250415164141_add_kind_and_period_to_billing_subscriptions.sql                    |   4 
crates/collab/migrations/20250422194500_add_trial_started_at_to_billing_customers.sql                       |   2 
crates/collab/migrations/20250423150129_add_head_commit_details_to_project_repositories.sql                 |   2 
crates/collab/migrations/20250425201930_add_model_request_overages_to_billing_preferences.sql               |   3 
crates/collab/migrations/20250530175450_add_channel_order.sql                                               |  16 
crates/collab/migrations/20250612153105_add_collaborator_commit_email.sql                                   |   4 
crates/collab/migrations/20250617082236_add_debug_adapter_provides_field_to_extensions.sql                  |   2 
crates/collab/migrations/20250618090000_add_agent_servers_provides_field_to_extensions.sql                  |   2 
crates/collab/migrations/20250702185129_add_cascading_delete_to_repository_entries.sql                      |  25 
crates/collab/migrations/20250707182700_add_access_tokens_cascade_delete_on_user.sql                        |   3 
crates/collab/migrations/20250804080620_language_server_capabilities.sql                                    |   5 
crates/collab/migrations/20250816124707_make_admin_required_on_users.sql                                    |   2 
crates/collab/migrations/20250816133027_add_orb_customer_id_to_billing_customers.sql                        |   2 
crates/collab/migrations/20250816135346_drop_rate_buckets_table.sql                                         |   1 
crates/collab/migrations/20250818192156_add_git_merge_message.sql                                           |   1 
crates/collab/migrations/20250819022421_add_orb_subscription_id_to_billing_subscriptions.sql                |   2 
crates/collab/migrations/20250819225916_make_stripe_fields_optional_on_billing_subscription.sql             |   3 
crates/collab/migrations/20250821133754_add_orb_subscription_status_and_period_to_billing_subscriptions.sql |   4 
crates/collab/migrations/20250827084812_worktree_in_servers.sql                                             |   2 
crates/collab/migrations/20250913035238_add_orb_cancellation_date_to_billing_subscriptions.sql              |   2 
crates/collab/migrations/20250914022147_add_orb_portal_url_to_billing_customers.sql                         |   2 
crates/collab/migrations/20250916173002_add_path_style_to_project.sql                                       |   1 
crates/collab/migrations/20251002214229_add_token_spend_in_cents_to_billing_subscriptions.sql               |   3 
crates/collab/migrations/20251008120000_add_is_hidden_to_worktree_entries.sql                               |   2 
crates/collab/migrations/20251110214057_drop_channel_messages.sql                                           |   3 
crates/collab/migrations/20251111161644_drop_embeddings.sql                                                 |   1 
crates/collab/migrations/20251117215316_add_external_id_to_billing_customers.sql                            |   4 
crates/collab/migrations/20251203234258_add_remote_urls_to_project_repositories.sql                         |   2 
crates/collab/migrations/20251208000000_test_schema.sql                                                     | 899 
crates/collab/migrations_llm/20240806182921_create_providers_and_models.sql                                 |  19 
crates/collab/migrations_llm/20240806213401_create_usages.sql                                               |  19 
crates/collab/migrations_llm/20240809130000_change_rate_limit_columns_to_bigint.sql                         |   4 
crates/collab/migrations_llm/20240809160000_add_pricing_columns_to_models.sql                               |   3 
crates/collab/migrations_llm/20240812184444_add_is_staff_to_usages.sql                                      |   1 
crates/collab/migrations_llm/20240812225346_create_lifetime_usages.sql                                      |   9 
crates/collab/migrations_llm/20240813002237_add_revoked_access_tokens_table.sql                             |   7 
crates/collab/migrations_llm/20241007173634_add_cache_token_counts.sql                                      |  11 
crates/collab/migrations_llm/20241007220716_drop_incorrect_usages_columns.sql                               |   3 
crates/collab/migrations_llm/20241008155620_create_monthly_usages.sql                                       |  13 
crates/collab/migrations_llm/20241010151249_create_billing_events.sql                                       |  12 
crates/collab/migrations_llm/20250404141155_add_granular_token_limits_to_models.sql                         |   3 
crates/collab/migrations_llm/20250415213005_add_subscription_usages.sql                                     |  10 
crates/collab/migrations_llm/20250416181354_add_plan_to_subscription_usages.sql                             |   4 
crates/collab/migrations_llm/20250425171838_add_subscription_usage_meters.sql                               |   8 
crates/collab/migrations_llm/20250429143553_add_mode_to_subscription_usage_meters.sql                       |   6 
crates/collab/migrations_llm/20250503162708_add_v2_subscription_usage_and_meter_tables.sql                  |  23 
crates/collab/migrations_llm/20250504132836_drop_legacy_subscription_usage_and_meter_tables.sql             |   2 
crates/collab/migrations_llm/20250521211721_drop_monthly_and_lifetime_usages_tables.sql                     |   2 
crates/collab/migrations_llm/20250521222416_drop_billing_events_table.sql                                   |   1 
typos.toml                                                                                                  |  12 
143 files changed, 902 insertions(+), 1,112 deletions(-)

Detailed changes

crates/collab/migrations/20210527024318_initial_schema.sql 🔗

@@ -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
-);

crates/collab/migrations/20210805175147_create_chat_tables.sql 🔗

@@ -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");

crates/collab/migrations/20220506130724_create_contacts.sql 🔗

@@ -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");

crates/collab/migrations/20220518151305_add_invites_to_users.sql 🔗

@@ -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");

crates/collab/migrations/20220523232954_allow_user_deletes.sql 🔗

@@ -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;

crates/collab/migrations/20220620211403_create_projects.sql 🔗

@@ -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");

crates/collab/migrations/20220913211150_create_signups.sql 🔗

@@ -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");

crates/collab/migrations/20221111092550_reconnection_support.sql 🔗

@@ -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");

crates/collab/migrations/20221207165001_add_connection_lost_to_room_participants.sql 🔗

@@ -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");

crates/collab/migrations/20221214144346_change_epoch_from_uuid_to_integer.sql 🔗

@@ -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");

crates/collab/migrations/20230202155735_followers.sql 🔗

@@ -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");

crates/collab/migrations/20230508211523_add-repository-entries.sql 🔗

@@ -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");

crates/collab/migrations/20230511004019_add_repository_statuses.sql 🔗

@@ -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");

crates/collab/migrations/20230529164700_add_worktree_settings_files.sql 🔗

@@ -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");

crates/collab/migrations/20230727150500_add_channels.sql 🔗

@@ -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;

crates/collab/migrations/20230819154600_add_channel_buffers.sql 🔗

@@ -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");

crates/collab/migrations/20230825190322_add_server_feature_flags.sql 🔗

@@ -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");

crates/collab/migrations/20230907114200_add_channel_messages.sql 🔗

@@ -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");

crates/collab/migrations/20230925210437_add_channel_changes.sql 🔗

@@ -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");

crates/collab/migrations/20231004130100_create_notifications.sql 🔗

@@ -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");

crates/collab/migrations/20231018102700_create_mentions.sql 🔗

@@ -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";

crates/collab/migrations/20231024085546_move_channel_paths_to_channels_table.sql 🔗

@@ -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");

crates/collab/migrations/20240214102900_add_extensions.sql 🔗

@@ -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");

crates/collab/migrations/20240220234826_add_rate_buckets.sql 🔗

@@ -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);

crates/collab/migrations/20240226163408_hosted_projects.sql 🔗

@@ -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);

crates/collab/migrations/20240307163119_denormalize_buffer_ops.sql 🔗

@@ -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;

crates/collab/migrations/20240321162658_add_devservers.sql 🔗

@@ -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);

crates/collab/migrations/20240402155003_add_dev_server_projects.sql 🔗

@@ -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);

crates/collab/migrations/20240409082755_create_embeddings.sql 🔗

@@ -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");

crates/collab/migrations/20240502150229_rename_to_dev_server_projects.sql 🔗

@@ -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;

crates/collab/migrations/20240729170526_add_billing_subscription.sql 🔗

@@ -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);

crates/collab/migrations/20240730014107_add_billing_customer.sql 🔗

@@ -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);

crates/collab/migrations/20240730182554_add_processed_stripe_events.sql 🔗

@@ -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);

crates/collab/migrations/20241009190639_add_billing_preferences.sql 🔗

@@ -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);

crates/collab/migrations/20241121185750_add_breakpoints.sql 🔗

@@ -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");

crates/collab/migrations/20250113230049_expand_git_status_information.sql 🔗

@@ -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;

crates/collab/migrations/20250205192813_add_provides_fields_to_extension_versions.sql 🔗

@@ -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;

crates/collab/migrations/20250319182812_create_project_repositories.sql 🔗

@@ -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");

crates/collab/migrations/20250530175450_add_channel_order.sql 🔗

@@ -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");

crates/collab/migrations/20250702185129_add_cascading_delete_to_repository_entries.sql 🔗

@@ -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;

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;

crates/collab/migrations_llm/20240806182921_create_providers_and_models.sql 🔗

@@ -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);

crates/collab/migrations_llm/20240806213401_create_usages.sql 🔗

@@ -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);

crates/collab/migrations_llm/20240812225346_create_lifetime_usages.sql 🔗

@@ -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);

crates/collab/migrations_llm/20241007173634_add_cache_token_counts.sql 🔗

@@ -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;

crates/collab/migrations_llm/20241008155620_create_monthly_usages.sql 🔗

@@ -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);

crates/collab/migrations_llm/20241010151249_create_billing_events.sql 🔗

@@ -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);

crates/collab/migrations_llm/20250415213005_add_subscription_usages.sql 🔗

@@ -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);

crates/collab/migrations_llm/20250425171838_add_subscription_usage_meters.sql 🔗

@@ -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);

crates/collab/migrations_llm/20250503162708_add_v2_subscription_usage_and_meter_tables.sql 🔗

@@ -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);

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",