]> git.openstreetmap.org Git - rails.git/blobdiff - config/initializers/postgresql_adapter.rb
Replace searching.gif with loader from iD
[rails.git] / config / initializers / postgresql_adapter.rb
index d8f84959cd83f18efc7d256e78fa04f1f91f31f2..ff1f7f87ad5ee1ea3d8c9491eb063a34915dfb84 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.
@@ -51,6 +58,33 @@ if defined?(ActiveRecord::ConnectionAdaptors::PostgreSQLAdaptor)
         rescue
           nil
         end
+
+        def initialize_type_map_with_enums
+          OID.alias_type "format_enum", "text"
+          OID.alias_type "gpx_visibility_enum", "text"
+          OID.alias_type "note_status_enum", "text"
+          OID.alias_type "note_event_enum", "text"
+          OID.alias_type "nwr_enum", "text"
+          OID.alias_type "user_role_enum", "text"
+          OID.alias_type "user_status_enum", "text"
+
+          initialize_type_map_without_enums
+        end
+
+        alias_method_chain :initialize_type_map, :enums
+      end
+
+      class PostgreSQLColumn
+        def simplified_type_with_enum(field_type)
+          case field_type
+          when /_enum$/
+            :string
+          else
+            simplified_type_without_enum(field_type)
+          end
+        end
+
+        alias_method_chain :simplified_type, :enum
       end
     end
   end