In Rails 3,
I created a table with a migration, then added a column with a migration which creates a has_many, belongs_to relationship….
I then ran rake db:migrate
I’d like to now add an Index because I forgot to add it before I can migrate. can I add that to one of the existing migration files (the create table one) or do I need to create a new migration for adding an index to an existing table?
Thanks
I usually create a new migration if I forget something like that (especially if I have already migrated in production). But if you are still in development, then you can alter your last migration file and use the redo rake command:
There is also:
Run this command to view all the different rake tasks:
Here is the section in the Rails Guide that talks about it:
http://guides.rubyonrails.org/migrations.html#rolling-back