diff --git a/db/migrate/20260212102026_fix_notifications_ordered_index.rb b/db/migrate/20260212102026_fix_notifications_ordered_index.rb new file mode 100644 index 000000000..f7e3cfcac --- /dev/null +++ b/db/migrate/20260212102026_fix_notifications_ordered_index.rb @@ -0,0 +1,8 @@ +class FixNotificationsOrderedIndex < ActiveRecord::Migration[8.2] + def change + add_index :notifications, [ :user_id, :read_at, :updated_at ], + order: { read_at: :desc, updated_at: :desc }, + name: "index_notifications_on_user_id_and_read_at_and_updated_at" + remove_index :notifications, name: "index_notifications_on_user_id_and_read_at_and_created_at" + end +end diff --git a/db/schema.rb b/db/schema.rb index db1a2283d..a46444460 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.2].define(version: 2026_02_11_122517) do +ActiveRecord::Schema[8.2].define(version: 2026_02_12_102026) do create_table "accesses", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.datetime "accessed_at" t.uuid "account_id", null: false @@ -398,7 +398,7 @@ ActiveRecord::Schema[8.2].define(version: 2026_02_11_122517) do t.index ["creator_id"], name: "index_notifications_on_creator_id" t.index ["source_type", "source_id"], name: "index_notifications_on_source" t.index ["user_id", "card_id"], name: "index_notifications_on_user_id_and_card_id", unique: true - t.index ["user_id", "read_at", "created_at"], name: "index_notifications_on_user_id_and_read_at_and_created_at", order: { read_at: :desc, created_at: :desc } + t.index ["user_id", "read_at", "updated_at"], name: "index_notifications_on_user_id_and_read_at_and_updated_at", order: { read_at: :desc, updated_at: :desc } t.index ["user_id"], name: "index_notifications_on_user_id" end diff --git a/db/schema_sqlite.rb b/db/schema_sqlite.rb index 3486ca9d1..4254c30f1 100644 --- a/db/schema_sqlite.rb +++ b/db/schema_sqlite.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.2].define(version: 2026_02_11_122517) do +ActiveRecord::Schema[8.2].define(version: 2026_02_12_102026) do create_table "accesses", id: :uuid, force: :cascade do |t| t.datetime "accessed_at" t.uuid "account_id", null: false @@ -398,7 +398,7 @@ ActiveRecord::Schema[8.2].define(version: 2026_02_11_122517) do t.index ["creator_id"], name: "index_notifications_on_creator_id" t.index ["source_type", "source_id"], name: "index_notifications_on_source" t.index ["user_id", "card_id"], name: "index_notifications_on_user_id_and_card_id", unique: true - t.index ["user_id", "read_at", "created_at"], name: "index_notifications_on_user_id_and_read_at_and_created_at", order: { read_at: :desc, created_at: :desc } + t.index ["user_id", "read_at", "updated_at"], name: "index_notifications_on_user_id_and_read_at_and_updated_at", order: { read_at: :desc, updated_at: :desc } t.index ["user_id"], name: "index_notifications_on_user_id" end