rails: date type and GetDate

Posted by cbrulak on Stack Overflow See other posts from Stack Overflow or by cbrulak
Published on 2010-05-31T17:58:21Z Indexed on 2010/05/31 18:03 UTC
Read the original article Hit count: 321

Filed under:
|

This is a follow up to this question: http://stackoverflow.com/questions/2930256/unique-responses-rails-gem

I'm going to create an index based on the user id, url and a date type.

I want date type (not datetime type) because I want the day, the 24 hour day to be part of the index to avoid duplication of page views counts on the same day.

In other words: A view only counts once in a day by a visitor.

I also want the default value of that column (viewdate) to be the function GETDATE().

This is what I have in my migration:

execute "ALTER TABLEpage_viewsADD COLUMN viewdate datetime DEFAULTGETDATE()`"

But the value viewdate is always empty. What am I missing?

(as an aside, any other suggestions for accomplishing this goal?)

© Stack Overflow or respective owner

Related posts about sql

Related posts about ruby-on-rails