Sha256: de481143da940d6741178d56a13b2145f1278c6276c2906d3172b62d94f4b262

Contents?: true

Size: 1.03 KB

Versions: 73

Compression:

Stored size: 1.03 KB

Contents

module ActiveRecord
  module ConnectionAdapters
    class PostgreSQLAdapter < AbstractAdapter
      module ReferentialIntegrity
        def supports_disable_referential_integrity? #:nodoc:
          true
        end

        def disable_referential_integrity #:nodoc:
          if supports_disable_referential_integrity?
            begin
              execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} DISABLE TRIGGER ALL" }.join(";"))
            rescue
              execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} DISABLE TRIGGER USER" }.join(";"))
            end
          end
          yield
        ensure
          if supports_disable_referential_integrity?
            begin
              execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} ENABLE TRIGGER ALL" }.join(";"))
            rescue
              execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} ENABLE TRIGGER USER" }.join(";"))
            end
          end
        end
      end
    end
  end
end

Version data entries

73 entries across 73 versions & 3 rubygems

Version Path
activerecord-4.1.16 lib/active_record/connection_adapters/postgresql/referential_integrity.rb
activerecord-4.1.16.rc1 lib/active_record/connection_adapters/postgresql/referential_integrity.rb
activerecord-4.1.15 lib/active_record/connection_adapters/postgresql/referential_integrity.rb
activerecord-4.1.15.rc1 lib/active_record/connection_adapters/postgresql/referential_integrity.rb
activerecord-4.1.14.2 lib/active_record/connection_adapters/postgresql/referential_integrity.rb
activerecord-4.1.14.1 lib/active_record/connection_adapters/postgresql/referential_integrity.rb
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/activerecord-4.1.13/lib/active_record/connection_adapters/postgresql/referential_integrity.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/activerecord-4.1.13/lib/active_record/connection_adapters/postgresql/referential_integrity.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/activerecord-4.1.13/lib/active_record/connection_adapters/postgresql/referential_integrity.rb
activerecord-4.1.14 lib/active_record/connection_adapters/postgresql/referential_integrity.rb
activerecord-4.1.14.rc2 lib/active_record/connection_adapters/postgresql/referential_integrity.rb
activerecord-4.1.14.rc1 lib/active_record/connection_adapters/postgresql/referential_integrity.rb
activerecord-4.1.13 lib/active_record/connection_adapters/postgresql/referential_integrity.rb
activerecord-4.1.13.rc1 lib/active_record/connection_adapters/postgresql/referential_integrity.rb
activerecord-4.1.12 lib/active_record/connection_adapters/postgresql/referential_integrity.rb
activerecord-4.1.12.rc1 lib/active_record/connection_adapters/postgresql/referential_integrity.rb
activerecord-4.1.11 lib/active_record/connection_adapters/postgresql/referential_integrity.rb
activerecord-4.1.10 lib/active_record/connection_adapters/postgresql/referential_integrity.rb
activerecord-4.1.10.rc4 lib/active_record/connection_adapters/postgresql/referential_integrity.rb
activerecord-4.1.10.rc3 lib/active_record/connection_adapters/postgresql/referential_integrity.rb