Combine Multiple Rake Commands Without &&
Ordinarily, to successively run commands whose execution depends on the previous command's success, you would separate the commands with two &'s.
This includes rake commands:
rake db:migrate && rake db:redo && rake db:test:prepare
The downside to this, however, is that the Rails environment is loaded with each rake invocation. Thus, in this example the Rails environment is loaded three times.
This is slow. To speed up the process, we can load the Rails environment just once as follows:
rake db:migrate db:redo db:test:prepare
We still run all the tasks but don't have to wait an eternity for Rails to get its act together and load rake. Hooray!
Hat-tip @mrmicahcooper
Tweet