volontariat/voluntary_proposition

View on GitHub
dummy/features/support/database_cleaner_patches.rb

Summary

Maintainability
A
0 mins
Test Coverage
#   Copyright (c) 2010-2011, Diaspora Inc.  This file is
#   licensed under the Affero General Public License version 3 or later.  See
#   the COPYRIGHT file.

# disable_referential_integrity doesn't work when using PostgreSQL
# with a non-root user.
# See http://kopongo.com/2008/7/25/postgres-ri_constrainttrigger-error
module ActiveRecord
  module ConnectionAdapters
    class PostgreSQLAdapter < AbstractAdapter
      def disable_referential_integrity(&block)
         transaction {
           begin
             execute "SET CONSTRAINTS ALL DEFERRED"
             yield
           ensure
             execute "SET CONSTRAINTS ALL IMMEDIATE"
           end
         }
      end
    end
  end
end