开发者

want to change columntype in a table through migration

开发者 https://www.devze.com 2023-02-20 06:12 出处:网络
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

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

精彩评论

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