Created
May 23, 2013 18:36
-
-
Save stuartc/5638370 to your computer and use it in GitHub Desktop.
WIP on forcing AR Migrations to not use transactions.
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
module NoTransactionBlock | |
module Nothing | |
def nothing | |
puts "CALLED" | |
end | |
end | |
module MigrationHelpers | |
def without_transaction_block(&block) | |
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.send(:include,Nothing) | |
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.class_eval do | |
alias_method :orig_begin_db_transaction, :begin_db_transaction | |
alias_method :orig_commit_db_transaction, :commit_db_transaction | |
alias_method :orig_rollback_db_transaction, :rollback_db_transaction | |
alias_method :begin_db_transaction, :nothing | |
alias_method :commit_db_transaction, :nothing | |
alias_method :rollback_db_transaction, :nothing | |
end | |
block.call | |
end | |
end | |
def self.included(base) | |
base.extend MigrationHelpers | |
end | |
end | |
include NoTransactionBlock |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment