Skip to content

Commit

Permalink
Run seeds faster by not logging, skipping AR validation, and wrapping…
Browse files Browse the repository at this point in the history
… the load in a single transaction
  • Loading branch information
Matthew Beale committed Jul 17, 2009
1 parent 15c7b90 commit 8e0b4b0
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tasks/seed_fu_tasks.rake
Expand Up @@ -38,7 +38,18 @@ namespace :db do
potential_seed_files.each do |file|
pretty_name = file.sub("#{RAILS_ROOT}/", "")
puts "\n== Seed from #{pretty_name} " + ("=" * (60 - (17 + File.split(file).last.length)))
load file

old_level = ActiveRecord::Base.logger.level
begin
ActiveRecord::Base.validation_disabled = true
ActiveRecord::Base.logger.level = 7
ActiveRecord::Base.transaction do
load file
end
ensure
ActiveRecord::Base.validation_disabled = false
ActiveRecord::Base.logger.level = old_level
end
end
end
end
end

0 comments on commit 8e0b4b0

Please sign in to comment.