wizztjh
wizztjh

Reputation: 7041

how to write a rake task to bundle install then rake db:migrate then rake db:seed?

How to write a rake task that will bundle install then rake db:migrate then rake db:seed.

namespace 'install' do
  'bundle install'
  'rake db:migrate'
end

Upvotes: 4

Views: 3354

Answers (1)

Michael De Silva
Michael De Silva

Reputation: 3818

This should work but consider using Capistrano/Chef for deployment:

namespace :install do
  task :db_reset do
    # bundle install - I do not believe attempting this in a rake file
    # is recommended as one would need to ensure it is run in your application
    # directory and rvm has loaded correct version of ruby/gemsets (.rvmrc required)
    Rake::Task['db:migrate'].invoke
  end
end

alternatively, you can setup a shell alias to do

bundle install && bundle exec rake db:migrate && bundle exec rake db:seed

Upvotes: 4

Related Questions