Add timestamps to existing table in db Ruby on Rails using rails g migration

408 Views Asked by At

Is there a

rails g migration AddTimestampsToModel something:something

that will generate

class AddTimestampsToModel < ActiveRecord::Migration[5.1]
  def change
    add_timestamps :model, null: false, default: -> { 'NOW()' }
  end
end

This code comes up in this topic but I don't have enough rating to comment on the response of one of the user.

Add timestamps to existing table in db Rails 5+

Answer in above link post

rails g migration AddTestToTest timestamps:timestamp null:false default: NOW()

asks for function and I am not sure what this means

0

There are 0 best solutions below