Created
March 10, 2014 08:42
Revisions
-
justin808 created this gist
Mar 10, 2014 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ def run_command_raise_if_error(command) puts "Executing: #{command}" result = %x[#{command}] raise "rake task failed..........\n#{result}" if result.include?('rake aborted!') end def run_rake_command_raise_if_error(command) run_command_raise_if_error("bundle exec rake #{command}") end namespace :db do desc "Migrate DBs for envs test, ci, development. Then setup parallel." task migrate_all: :environment do |t, args| unless Rails.env.development? raise "Can only run under development environment, but specified env was #{Rails.env}" end envs = %W(test ci development) envs.each do |env| run_rake_command_raise_if_error("RAILS_ENV=#{env} db:migrate") end run_rake_command_raise_if_error("parallel:create") run_rake_command_raise_if_error("parallel:prepare") run_rake_command_raise_if_error("parallel:rake[db:globals]") run_command_raise_if_error("annotate -e \[tests\] -i") end desc "Update seed data in all test/dev databases" task seed_all: :environment do |t, args| unless Rails.env.development? raise "Can only run under development environment, but specified env was #{Rails.env}" end envs = %W(test ci development) envs.each do |env| run_rake_command_raise_if_error("RAILS_ENV=#{env} db:seed") end run_rake_command_raise_if_error("parallel:rake[db:seed]") end end