开发者

want to change columntype in a table through migration

Hi i have a t开发者_如何学Pythonable in which there are two columns from and to of type datatime i want to change the datatype from datetime to date. i dont know the exact command for chagning column type in migrations like rails g


From the command line, run:

rails generate migration change_data_type_for_table_column

Write your migration as:

change_table :table do |t|  
  t.change :column, :type 
end


Use change_column.

change_column(:table, :column, :date)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜