Gary Weaver
2014-Sep-03 21:49 UTC
Should a new foreign_key type be added to adapters so that add_reference/add_belongs_to could use that vs. hardcoding the integer type?
Although there is the undocumented `native_database_types` method that returns a hash in each ActiveRecord adapter included in Rails, e.g.: def native_database_types #:nodoc: NATIVE_DATABASE_TYPES end If you use the add_reference/add_belongs_to methods in a migration, they use the integer type rather than the primary_key type for foreign_keys, which is correct since the primary key type can define autoincrement, however you want the foreign key column type itself (e.g. integer, etc.) to match the primary key's type, so it seems like there should be another foreign_key type defined in each adapter. This way you could actually get the foreign_key type from the adapter in the add_reference/add_belongs_to methods and wouldn't need to instead use add_column as a workaround. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.