Rails ActiveRecord creates a datetime type on the DB for columns created_at
and updated_at
that are introduced in migration with t.timestamps
at least in MySQL.
The datetime
type is close to storing the time in a string on a DB without a time zone, and unless you have information about the time zone in which the AP (Rails) server that was running that data would not be able to handle it correctly.
If you want to save the time in the database, I think it would be better to use the timestamp
type, but Rails does not have that design.
datetime
instead of timestamp
for created_at
or updated_at
?
I am sorry that I do not know the specifications of rails, but I personally think the datetime type is appropriate to record the date and time in MySQL.
Tried to verify the difference between MySQL DATETIME and TIMESTAMP types - Qiita
The reason is that, as mentioned in this article, the timestamp type will potentially include the so-called 2038 problem.
There is a possibility that future version upgrades will help, but if you try to incorporate them into the system, they may be considered a certain risk.
© 2024 OneMinuteCode. All rights reserved.