I generated a new rails migration:
rails generate migration some_new_column_to_table
edit: --
ran the migration:
rake db:migrate
updated test db:
rake db:test:prepare
realized I hadn't added anything to the change method, then
updated the migration file:
class AddSomeColumnToTable < ActiveRecord::Migration
def change
add_column :table, :some_column, :string
add_index :table, :some_column
end
end
ran the migration (again):
rake db:migrate
updated test db (again):
rake db:test:prepare
After running these commands "some_column" had not be added to the database. I found a solution to this problem here: rake db:migrate is not working
rake db:drop:all
rake db:create:all
rake db:migrate
Why did this fix the problem? How can I prevent it in the future?