如果你说的是迁移的类型,例如string、integer、datetime等等,那么你需要ActiveRecord::ConnectionAdapters::TableDefinition,column方法.(Rails 5编辑:另请参见connection.add_column.)
截至本次更新,标准类型为:
:primary_key
:string
:text
:integer
:bigint
:float
:decimal
:numeric
:datetime
:time
:date
:binary
:boolean
对于每个数据库,:decimal
的实现是不同的,所以如果可能的话,我会避免使用它.只要数据库支持,就可以使用列表中不包含的类型(例如,MySQL中的:polygon
),但这不是数据库不可知的,也应该避免.