Class: ActiveRecord::ConnectionAdapters::PostgreSQLAdapter

Inherits:
AbstractAdapter
  • Object
show all
Defined in:
lib/rails3_pg_deferred_constraints/postgresql_adapter.rb

Instance Method Summary collapse

Instance Method Details

#defer_all_constraints(&block) ⇒ Object Also known as: disable_referential_integrity



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rails3_pg_deferred_constraints/postgresql_adapter.rb', line 14

def defer_all_constraints(&block)
  return unless supports_deferring_all_constraints?

  transaction do
    begin
      execute "SET CONSTRAINTS ALL DEFERRED"
      yield
    ensure
      execute "SET CONSTRAINTS ALL IMMEDIATE"
    end
  end
end