Change a column type from Date to DateTime during ROR migration

后端 未结 5 968
名媛妹妹
名媛妹妹 2020-12-07 08:58

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?

5条回答
  •  不知归路
    2020-12-07 09:13

    There's a change_column method, just execute it in your migration with datetime as a new type.

    change_column(:my_table, :my_column, :my_new_type)
    

提交回复
热议问题