X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/8980da4381923d8099a11a1334baf3c3e625a484..5ddab68c11ad7ac85bf3b80e250aa4454292a53c:/config/initializers/postgresql_adapter.rb diff --git a/config/initializers/postgresql_adapter.rb b/config/initializers/postgresql_adapter.rb index 75971e4bf..ff1f7f87a 100644 --- a/config/initializers/postgresql_adapter.rb +++ b/config/initializers/postgresql_adapter.rb @@ -58,6 +58,33 @@ if defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) 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