Alex Rivera | Logout

Change a column type from Date to DateTime during ROR migration

Asked 2011-03-04T08:36:59.610
234

I need to change my column type from date to datetime for an app I am making. I don't care about the data as its still being developed.

How can I do this?

Edit
Report

1 Answer

81

Also, if you're using Rails 3 or newer you don't have to use the up and down methods. You can just use change:

class ChangeFormatInMyTable < ActiveRecord::Migration
  def change
    change_column :my_table, :my_column, :my_new_type
  end
end
answered 2012-12-01T17:36:25.853

Your Answer