diff --git a/db/migrate/20250819100545_update_quote_index.rb b/db/migrate/20250819100545_update_quote_index.rb new file mode 100644 index 0000000000..db4f5efc9f --- /dev/null +++ b/db/migrate/20250819100545_update_quote_index.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class UpdateQuoteIndex < ActiveRecord::Migration[8.0] + disable_ddl_transaction! + + def change + add_index :quotes, [:account_id, :quoted_account_id, :id], algorithm: :concurrently + remove_index :quotes, [:account_id, :quoted_account_id] + + add_index :quotes, [:quoted_status_id, :id], algorithm: :concurrently + remove_index :quotes, [:quoted_status_id] + end +end diff --git a/db/schema.rb b/db/schema.rb index cf8c74c8e2..b01ffcf5fb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2025_08_05_075010) do +ActiveRecord::Schema[8.0].define(version: 2025_08_19_100545) do # These are extensions that must be enabled in order to support this database enable_extension "pg_catalog.plpgsql" @@ -926,11 +926,11 @@ ActiveRecord::Schema[8.0].define(version: 2025_08_05_075010) do t.datetime "created_at", null: false t.datetime "updated_at", null: false t.boolean "legacy", default: false, null: false - t.index ["account_id", "quoted_account_id"], name: "index_quotes_on_account_id_and_quoted_account_id" + t.index ["account_id", "quoted_account_id", "id"], name: "index_quotes_on_account_id_and_quoted_account_id_and_id" t.index ["activity_uri"], name: "index_quotes_on_activity_uri", unique: true, where: "(activity_uri IS NOT NULL)" t.index ["approval_uri"], name: "index_quotes_on_approval_uri", where: "(approval_uri IS NOT NULL)" t.index ["quoted_account_id"], name: "index_quotes_on_quoted_account_id" - t.index ["quoted_status_id"], name: "index_quotes_on_quoted_status_id" + t.index ["quoted_status_id", "id"], name: "index_quotes_on_quoted_status_id_and_id" t.index ["status_id"], name: "index_quotes_on_status_id", unique: true end