rails add index specifc name
# Step 1: Generate a migration file
rails generate migration AddIndexToTableName
# Step 2: Open the generated migration file (located in db/migrate) and use the `add_index` method
class AddIndexToTableName < ActiveRecord::Migration[6.0]
def change
add_index :table_name, :column_name, name: "index_custom_name"
end
end
# Step 3: Run the migration to apply the changes to the database
rails db:migrate