Add timestamps to an existing table

前端 未结 21 1167
予麋鹿
予麋鹿 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 15:25

    For those who don't use Rails but do use activerecord, the following also adds a column to an existing model, example is for an integer field.

    ActiveRecord::Schema.define do
      change_table 'MYTABLE' do |table|
        add_column(:mytable, :my_field_name, :integer)
      end
    end
    

提交回复
热议问题