]> git.openstreetmap.org Git - rails.git/blobdiff - config/initializers/postgresql_adapter.rb
Merge branch 'master' into notes
[rails.git] / config / initializers / postgresql_adapter.rb
index d8f84959cd83f18efc7d256e78fa04f1f91f31f2..75971e4bf115980f294c7e591b299a8434c7591b 100644 (file)
@@ -1,7 +1,14 @@
-if defined?(ActiveRecord::ConnectionAdaptors::PostgreSQLAdaptor)
+if defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
   module ActiveRecord
     module ConnectionAdapters
       class PostgreSQLAdapter
+        def supports_disable_referential_integrity?() #:nodoc:
+          version = query("SHOW server_version")[0][0].split('.')
+          (version[0].to_i >= 9 || (version[0].to_i == 8 && version[1].to_i >= 1)) ? true : false
+        rescue
+          return false
+        end
+
         def pk_and_sequence_for(table)
           # First try looking for a sequence with a dependency on the
           # given table's primary key.