X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/8af14faa49deed681fa835dd6bd3f77316b44a55..b0bc04abf1cc17228b114cc60021e42f8dcdd51e:/config/initializers/postgresql_adapter.rb diff --git a/config/initializers/postgresql_adapter.rb b/config/initializers/postgresql_adapter.rb index b9adf38bb..825feba8b 100644 --- a/config/initializers/postgresql_adapter.rb +++ b/config/initializers/postgresql_adapter.rb @@ -1,7 +1,14 @@ -if defined?(ActionRecord::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. @@ -52,6 +59,19 @@ if defined?(ActionRecord::ConnectionAdaptors::PostgreSQLAdaptor) nil end 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 end