I’m just starting to learn rails, and after going through Michael Hartl’s “Learn Rails by Example” I decided to try to create my own simple application with some similar functionality. After making a few different migrations, and running them successfully, I tried to add a four column index to a table. When I ran “bundle exec rake db:migrate” I got the error:
Index name 'temp_index_altered_events_on_user_id_and_message_id_and_date_and_address_id'
on table 'altered_events' is too long; the limit is 64 characters
I looked up the cause of that error and changed my migration to use:
add_index :events, ["user_id", "message_id", "date", "address_id"], :unique => true, :name => 'my_index'
I then reran “bundle exec rake db:migrate” and got the same error. I thought this was strange, and so I tried deleting the index line from the migration entirely, leaving the migration to simply create the new table. I tried again and was still getting the same error. I then deleted the migration file, tried generating an entirely new migration, and yet I still got the same error.
I’d really hate for this phantom migration to prevent me from moving on with this project. Does anyone know how I can make it forget about my past mistakes so that I can make some new ones?
To reset your database I would do
rake db:drop,rake db:create,rake:db:migrateto run all the migrations from scratch.This wouldn’t be the solution in production but is good enough for learning.