Index name length error in Rails migrations using SQLite

When trying to process a rename_column database migration, I ran into the following error after running rake db:migrate:

Index name 'temp_index_altered_long_class_name_on_even_longer_class_name_id' on table 'altered_long_class_name' is too long; the limit is 64 characters

This is an issue with index name length when using sqlite. A simple fix is to remove the index prior to renaming the column, then add it back in afterwards, as follows:

remove_index :long_class_name, [:even_longer_class_name_id]
rename_column :long_class_name, :original_name, :new_name
add_index :long_class_name, [:even_longer_class_name_id], :name => "index_long_class_name_on_even_longer_class_name_id"