From bf5dc0d74dd482ded2d9e7e79ebd467eb88f4940 Mon Sep 17 00:00:00 2001 From: Marcello Costagliola Date: Tue, 6 Oct 2026 22:00:50 +0200 Subject: [PATCH] Create the room and creation time index only where it is missing The Rust port creates index_messages_on_room_id_and_created_at on boot, under the same name and on the same columns, with CREATE INDEX IF NOT EXISTS. On a database the port opened before this migration ran, db:prepare stopped with "index ... already exists" and the app didn't start. With if_not_exists the migration skips an index that is already there and creates it everywhere else. Databases that already ran the migration don't run it again, and the dumped schema is the same, so db/schema.rb doesn't change. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LwoX7uRy5vFZSNKJhSqMSG --- ...261004225000_add_room_id_and_created_at_index_to_messages.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/20261004225000_add_room_id_and_created_at_index_to_messages.rb b/db/migrate/20261004225000_add_room_id_and_created_at_index_to_messages.rb index a46b27b..b14c018 100644 --- a/db/migrate/20261004225000_add_room_id_and_created_at_index_to_messages.rb +++ b/db/migrate/20261004225000_add_room_id_and_created_at_index_to_messages.rb @@ -1,5 +1,5 @@ class AddRoomIdAndCreatedAtIndexToMessages < ActiveRecord::Migration[8.2] def change - add_index :messages, %i[ room_id created_at ] + add_index :messages, %i[ room_id created_at ], if_not_exists: true end end