Guest User

Untitled

a guest
May 22nd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. module ManualUpdate
  2. def self.by(login_name)
  3. ActiveRecord::Base.transaction do
  4. ActiveRecord::Base.current_user = User.find_by_login!(login_name)
  5. PaperTrail.whodunnit = login_name
  6.  
  7. puts "Running update..."
  8. yield
  9.  
  10. puts "Checking database validity..."
  11. site = "local" if Rails.env.development?
  12. unless Checker.check(:verbose => ENV["VERBOSE"],
  13. :site => site)
  14. puts "Check failed... rolling back."
  15. raise ActiveRecord::Rollback
  16. end
  17.  
  18. if ENV["DRY_RUN"]
  19. # note: DRY_RUN=1 must come before "ruby" on the command line!
  20. puts "Check passed, but DRY_RUN specified... rolling back."
  21. raise ActiveRecord::Rollback
  22. end
  23. puts "Check passed ... committed."
  24. end
  25. end
  26. end
Add Comment
Please, Sign In to add comment