【发布时间】:2017-07-11 12:29:19
【问题描述】:
我有一个Info 表,其中有一个age 字段,这是一个int
但我想将类型更改为date,以便动态计算年龄。
所以我做了这个迁移:
class ChangeDateFormatInInfo < ActiveRecord::Migration[5.0]
def change
change_column :infos, :age, :date
end
end
但是有一个DatatypeMismatch
column "age" cannot be cast automatically to type date
所以我把它改成了:
change_column :infos, :age, :date, 'USING age::date'
但它仍然给了我
migrateTypeError: no implicit conversion of Symbol into Integer
我真的不明白,我告诉它转换它,那我做错了什么?
【问题讨论】:
标签: postgresql migration ruby-on-rails-5