Hey guys,

I have a similar thread at http://www.ruby-forum.com/topic/169664, but I
decided to open a new thread since I felt the original one was not clear
from my end and didn't quite get to the bottom of the issue.

I created a test table with "created_at" and "created_on" as types
DATETIME and TIMESTAMP respectively. I then created a record and saved
it.

I then ran a bunch of methods on created_at and created_on seeing if
they behaved differently. Basically, I found that the ONLY DIFFERENCE
between the two types is that TIMESTAMP has to be defaulted to a value,
whereas DATETIME does not. This, however, has no effect with Rails, as
I'll explain...

So far there are two reasons people tell me that DATETIME is used over
TIMESTAMP (both, which I'll disprove):

1. TIMESTAMP *always* automatically updates itself with the current time
when the record updates, hence removing that logic from Rails. This is
NOT TRUE. TIMESTAMP can be entered into MySQL without this behavior
present. See: http://dev.mysql.com/doc/refman/5.0/en/timestamp.html

2. TIMESTAMP requires a default value, hence interfering with the magic
timestamp logic from Rails. This is NOT TRUE either. In my tests, Rails
populates the created_at/created_on field the same way as it would for
DATETIME, since it ignores the default timestamp value assigned to it
from the TIMESTAMP data type.

So what is the reasoning behind forcing Rails migrations into using
DATETIME for timestamps? And can TIMESTAMP really take the place of
DATETIME in the RoR framework?

So far, my answer is a definite yes, but the guys behind Rails are smart
and I'm probably missing something, I just don't know what, yet. Maybe
someone can shed some like on this monumental issue. =)
-- 
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 post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to