Add timestamps to an existing table

前端 未结 21 1157
予麋鹿
予麋鹿 2020-12-12 14:34

I need to add timestamps (created_at & updated_at) to an existing table. I tried the following code but it didn\'t work.

class          


        
21条回答
  •  醉话见心
    2020-12-12 14:59

    I'm on rails 5.0 and none of these options worked.

    The only thing that worked was using the type to be :timestamp and not :datetime

    def change
        add_column :users, :created_at, :timestamp
        add_column :users, :updated_at, :timestamp
    end
    

提交回复
热议问题