]> git.openstreetmap.org Git - rails.git/blob - config/initializers/postgresql_adapter.rb
Update to rails 4.1.1
[rails.git] / config / initializers / postgresql_adapter.rb
1 if defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
2   module ActiveRecord
3     module ConnectionAdapters
4       class PostgreSQLAdapter
5         def initialize_type_map_with_enums
6           OID.alias_type "format_enum", "text"
7           OID.alias_type "gpx_visibility_enum", "text"
8           OID.alias_type "note_status_enum", "text"
9           OID.alias_type "note_event_enum", "text"
10           OID.alias_type "nwr_enum", "text"
11           OID.alias_type "user_role_enum", "text"
12           OID.alias_type "user_status_enum", "text"
13
14           initialize_type_map_without_enums
15         end
16
17         alias_method_chain :initialize_type_map, :enums
18       end
19
20       class PostgreSQLColumn
21         def simplified_type_with_enum(field_type)
22           case field_type
23           when /_enum$/
24             :string
25           else
26             simplified_type_without_enum(field_type)
27           end
28         end
29
30         alias_method_chain :simplified_type, :enum
31       end
32     end
33   end
34 end