Tuesday, October 22, 2013

[Rails] Re: Is it a good idea to use timestamps

Matt Jones wrote in post #1125222:
> On Monday, 21 October 2013 13:24:47 UTC-4, desbest wrote:
>>
> Depends on your database - in MySQL the TIMESTAMP column type is limited
> to
> 2038, but in others (Postgres, for one) this isn't the case.
>
> If you declare your columns as :datetime in Rails migrations you'll get
> a
> type (regardless of database adapter) that doesn't have this problem.
>
> --Matt Jones

It's also important to understand the difference in behavior between
"timestamp" and "datetime" in MySQL. If a timestamp column is not
specifically specified in an update statement it will update itself to
the current system time automatically. The "datetime" data type will not
do that, rather it will keep its current value.

Basically, never use the "timestamp" data type in MySQL, unless you
really understand, and want its behavior. I never use it myself, and
Rails has no built-in support for it. If you ask for a date and time in
Rails migrations you'll get a "datetime" data type when using MySQL.
Trust the default ActiveRecord mappings.

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ad72f8397a0416e3c00e551a6c4b7642%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate