Is it possible to change column index in rails 3 migration?

I would say that you have the correct solution there as the index will need to be regenerated, hence why there is no update_index.


Hey here is a migration I just wrote up that works pretty well. I have a table 'scraped_episodes' with a column that is varchar(255) 'enclosureUrl'. I need to make this longer to long urls so this is what I used (Rails 3.2.13)

class ExpandEnclosureUrl < ActiveRecord::Migration
  def up
    # remove index cuz we need to
    remove_index :scraped_episodes, :enclosureUrl

    # change length to 2048 characters
    change_column :scraped_episodes, :enclosureUrl, :text, :limit=>2048

    # redo this index to only index the first 255 chars
    add_index :scraped_episodes, :enclosureUrl, :length => 255
  end

  def down
    # remove index cuz we need to
    remove_index :scraped_episodes, :enclosureUrl

    # use the same settings at when i first created this field
    change_column :scraped_episodes, :enclosureUrl, :string, :limit=>nil

    # use the same settings as when i first added this index
    add_index :scraped_episodes, :enclosureUrl
  end


end