diff --git a/database/migrations/2026_06_30_114000_add_compound_index_to_messages_table.php b/database/migrations/2026_06_30_114000_add_compound_index_to_messages_table.php new file mode 100644 index 0000000..048b2cc --- /dev/null +++ b/database/migrations/2026_06_30_114000_add_compound_index_to_messages_table.php @@ -0,0 +1,37 @@ +index(['room_id', 'sent_at'], 'idx_room_sent_at'); + }); + } + + /** + * 回滚迁移,删除联合索引 + */ + public function down(): void + { + Schema::table('messages', function (Blueprint $table) { + $table->dropIndex('idx_room_sent_at'); + }); + } +};