Reputation: 432
Hi i have a table 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
Upvotes: 3
Views: 4397
Reputation: 1098
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
Upvotes: 8
Reputation: 176552
Use change_column.
change_column(:table, :column, :date)
Upvotes: 2