Keep the room_id index and date the migration in UTC

The composite index doesn't serve everything the room_id one did. In
SQLite that index is (room_id, rowid), so it also reads a room's messages
in id order, and it is the narrower one to count a room with. Keeping both,
as memberships already does, leaves those lookups as they were.

The migration was named after local time, two hours ahead of the UTC
timestamp Rails generates; it now carries a UTC one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NuTtwJKhb77Dv7EQqv2C3C
This commit is contained in:
Marcello Costagliola
2026-10-05 01:39:36 +02:00
parent 5cb4316133
commit 74bdbb0764
2 changed files with 2 additions and 2 deletions
@@ -1,6 +1,5 @@
class AddRoomIdAndCreatedAtIndexToMessages < ActiveRecord::Migration[8.2]
def change
add_index :messages, %i[ room_id created_at ]
remove_index :messages, :room_id
end
end
Generated
+2 -1
View File
@@ -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_10_05_010000) do
ActiveRecord::Schema[8.2].define(version: 2026_10_04_225000) do
create_table "accounts", force: :cascade do |t|
t.datetime "created_at", null: false
t.text "custom_styles"
@@ -102,6 +102,7 @@ ActiveRecord::Schema[8.2].define(version: 2026_10_05_010000) do
t.datetime "updated_at", null: false
t.index ["creator_id"], name: "index_messages_on_creator_id"
t.index ["room_id", "created_at"], name: "index_messages_on_room_id_and_created_at"
t.index ["room_id"], name: "index_messages_on_room_id"
end
create_table "push_subscriptions", force: :cascade do |t|