Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails migration for change column

We have script/generate migration add_fieldname_to_tablename fieldname:datatype syntax for adding new columns to a model.

On the same line, do we have a script/generate for changing the datatype of a column? Or should I write SQL directly into my vanilla migration?

I want to change a column from datetime to date.

like image 588
paddle42380 Avatar asked May 10 '10 00:05

paddle42380


1 Answers

I think this should work.

change_column :table_name, :column_name, :date 
like image 121
Alex Korban Avatar answered Sep 26 '22 02:09

Alex Korban