E
E
eldar_web2016-06-04 15:03:09
Ruby on Rails
eldar_web, 2016-06-04 15:03:09

How can you create indexes with your own names in Ruby on Rails?

For example, I create indexes like this:

class AddIndexesToSubscriptionPeriods3 < ActiveRecord::Migration
  def change
    add_index :subscription_periods, [:period_start, :period_finish, :newspaper_id]
  end
end

And the migration does not work due to the fact that the name is long, which is automatically given.
How can you give your name?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
eldar_web, 2016-06-04
@eldar_web

add_index :subscription_periods, :period_start, name: 'name_index'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question