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+
rails g migration AddTestToTest timestamps:timestamp null:false default: NOW()
asks for function and I am not sure what this means