2

Using LHM (Large Hadron Migrator) there is syntax documentation to add indexes:

require 'lhm'
class SomeMigration < ActiveRecord::Migration
  def self.up
    Lhm.change_table :foos do |m|
      m.add_unique_index  [:bar_id, :baz] # add_index if you don't want uniqueness
    end
  end
  def self.down
    Lhm.change_table :foos do |m|
      m.remove_index  [:bar_id, :baz]
    end
  end
end

How can a specific name for the index be specified in LHM? For adding and removing

I am concerned I will hit the index name length limit as I am using many columns

Community
  • 1
  • 1
xxjjnn
  • 14,591
  • 19
  • 61
  • 94

1 Answers1

4
m.add_unique_index([:long_column, :super_long_column], 'shortened_index_name')

Link to LHM docs for #add_unique_index

jimworm
  • 2,731
  • 18
  • 26