Sha256: 842d767a8e47b7632667a7059c85c9571c757efb13edabcf8ae6397b773ade16

Contents?: true

Size: 782 Bytes

Versions: 5

Compression:

Stored size: 782 Bytes

Contents

# frozen_string_literal: true
module DatabaseFlusher
  module ActiveRecord
    class PostgreSQLAdapter < AbstractAdapter
      private

      def disable_referential_integrity(*tables)
        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
        yield
      ensure
        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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
database_flusher-0.3.1 lib/database_flusher/active_record/adapters/postgresql_adapter.rb
database_flusher-0.3.0 lib/database_flusher/active_record/adapters/postgresql_adapter.rb
database_flusher-0.2.3 lib/database_flusher/active_record/adapters/postgresql_adapter.rb
database_flusher-0.2.2 lib/database_flusher/active_record/adapters/postgresql_adapter.rb
database_flusher-0.2.1 lib/database_flusher/active_record/adapters/postgresql_adapter.rb