想通过迁移更改表中的columntype

TH *_*idi 3 ruby-on-rails-3

嗨我有一个表格,其中有两列来自和来自类型datatime我希望将数据类型从datetime更改为date.我不知道像rails g这样的迁移中的chagning列类型的确切命令

Sye*_*aza 8

从命令行运行:

rails generate migration change_data_type_for_table_column

将您的迁移写为:

change_table :table do |t|  
  t.change :column, :type 
end
Run Code Online (Sandbox Code Playgroud)