Need to store created_at and updated_at timestamps in Epoch instead of DateTime Format. Is there a way to alter the default behaviour, while having ORM to do it's job to maintain the timestamp.
When I use Rails Generator to generate my models
class CreateTenants < ActiveRecord::Migration[5.0]
def change
create_table :tenants do |t|
t.string :tenant_name
t.string :tenant_owner_name
t.string :tenant_address
t.string :tenant_email
t.integer :pincode
t.timestamps
end
end
end
Not the timestamp that translates to DateTime.
create_table "tenants", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "tenant_name"
t.string "tenant_owner_name"
t.string "tenant_address"
t.string "tenant_email"
t.integer "pincode"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
I know that I can directly create two columns, and manually alter the created_at and updated_at fields everytime the record is added/changed, But that's going to be lots of bad code redundant code introduced in the application.
What I need is to somehow store the timestamps in epoch format (Time since 1970 in Long) instead of DateTime.
Thanks