Created
March 10, 2014 08:42
-
-
Save justin808/9461522 to your computer and use it in GitHub Desktop.
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 characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment