Last active
December 5, 2021 22:39
-
-
Save thbar/4550834 to your computer and use it in GitHub Desktop.
Using ActiveRecord logger and transaction rollback to review data processing task before going live
This file contains hidden or 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
| namespace :data do | |
| task :console_logger do | |
| ActiveRecord::Base.logger = Logger.new(STDOUT) | |
| end | |
| task :do_some_tweaking, [:user_email, :confirmation] => [:environment, :console_logger] do |t, args| | |
| User.transaction do | |
| # ... | |
| raise "Rolling back after dry run - add CONFIRM to confirm!" unless args[:confirmation] == 'CONFIRM' | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment