add_timestamps(table_name, **options)
public
Adds timestamps (created_at and updated_at) columns
to table_name. Additional options (like :null) are
forwarded to #add_column.
add_timestamps(:suppliers, null: true)
Show source
def add_timestamps(table_name, **options)
options[:null] = false if options[:null].nil?
if !options.key?(:precision) && supports_datetime_with_precision?
options[:precision] = 6
end
add_column table_name, :created_at, :datetime, **options
add_column table_name, :updated_at, :datetime, **options
end