How To Migrate Your Development And Test Database In One Command With Rails

If you’re using test driven development in your Ruby on Rails application, chances are, migrations are kind of annoying. You always have to remember to run rake db:test:prepare right after rake db:migrate. If you happen to forget, your tests will fail and you might not realize why, adding an additional few minutes of frustration to your day.

The solution to this is pretty simple, as I learned. Rake accepts multiple arguments, so you can migrate both your development and test database in one command like this:

$ rake db:migrate db:test:prepare

If you make this your default command for all migrations, your mind will be free to think about the more important things in life 😉

Enjoy the article? Join over 20,000+ Swift developers and enthusiasts who get my weekly updates.