On Aug 8, 6:19 am, Iain Barnett <[email protected]> wrote:
> Hi,
>
> I just realised I've done something stupid on a migration:
>
> DateTime :sent_on, :null=>false, :default=>Time.now
>
> Which sets the field to Thursday night when I ran the migration :-D
>
> Does anyone know what I should actually put to get the default I wanted? It's
> for a sqlite3 database if that's any help. I've tried passing in the sqlite
> function as a string, but it gets used literally.
>
> DateTime :sent_on, :null=>false, :default=>
> "(datetime('now','localtime'))"
>
> Any help is much appreciated.
Most databases can use Sequel::CURRENT_TIMESTAMP, but I don't believe
SQLite supports that. You just need to add a .lit, so that the string
is interpreted a literal SQL code instead of an SQL string:
DateTime :sent_on, :null=>false, :default=>
"(datetime('now','localtime'))".lit
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-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/sequel-talk?hl=en.