rake db:test:prepare

Why is it necessary for me to run ‘rake db:test:prepare’ when I generate a new model?

Shouldn’t the ‘rake db:migrate’ also affect the test database? Why would anyone want to preserve the (broken) state of their test database?

Am I missing something?

Why is it necessary for me to run 'rake db:test:prepare' when I generate a new model?

it shouldn't be - if you run rake (which defaults to running rake test or rake spec depending in your setup) it runs rake db:test:prepare for you

Shouldn't the 'rake db:migrate' also affect the test database? Why would anyone want to preserve the (broken) state of their test database?

In general it is easier to clone the test database from the development database (via schema.rb) than try and replay migrations on both, particularly for an older application with logs of migrations

Fred

I do this in my bashrc:

alias migrate=‘bundle exec rake db:migrate; RAILS_ENV=test bundle exec rake db:migrate;’

Not sure of the syntax but you get the idea. I don’t use rake or rake spec, and prefer running a guard/spork combo. Hence whenever I want to run a migration, I just run ‘migrate’ and that’s it.

Dheeraj Kumar