From 3a1cb21913bb624e5d54fc779ad62585e37b8b49 Mon Sep 17 00:00:00 2001 From: Jeremy Wells Date: Thu, 10 May 2012 13:58:47 +1200 Subject: [PATCH] Fork migrations and schema loading --- lib/nitra.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/nitra.rb b/lib/nitra.rb index 8af92f4..9b60b10 100644 --- a/lib/nitra.rb +++ b/lib/nitra.rb @@ -53,21 +53,27 @@ def print_progress end def initialise_database + database_pids = [] + if load_schema - process_count.times do |index| + database_pids += process_count.times.map do |index| puts "initialising database #{index+1}..." unless quiet ENV["TEST_ENV_NUMBER"] = (index + 1).to_s - system("bundle exec rake db:drop db:create db:schema:load") + fork { exec("bundle exec rake db:drop db:create db:schema:load") } end end if migrate - process_count.times do |index| + database_pids += process_count.times.map do |index| puts "migrating database #{index+1}..." unless quiet ENV["TEST_ENV_NUMBER"] = (index + 1).to_s - system("bundle exec rake db:migrate") + fork { exec("bundle exec rake db:migrate") } end end + + database_pids.each do |pid| + Process.wait(pid) + end end def load_rails_environment