I've got this code in one of my initializer files:

module TimestampsMonkeyPatch
  def timestamps
    column :created_at, 'timestamp with time zone'
    column :updated_at, 'timestamp with time zone'
  end
end

Sequel::Schema::CreateTableGenerator.prepend(TimestampsMonkeyPatch)


Would you be interested in adding this to sequel somehow, I'm guessing as a 
database extension?


On Thursday, June 17, 2010 at 11:00:41 AM UTC-4, Jeremy Evans wrote:
>
> On Jun 17, 4:04 am, Artyom Bolshakov <[email protected]> wrote: 
> > I need 'created_at' timestamp. What wrong with this code? 
> > 
> > class CreatePosts < Sequel::Migration 
> >   def up 
> >     create_table :posts do 
> >       plugin :timestamps, :update_on_create => true, :create 
> > => :created_on 
> >       primary_key :id 
> >       String :title 
> >       Text :body 
> >     end 
> >   end 
> > 
> >   def down 
> >     drop_table :posts 
> >   end 
> > end 
>
> plugin is a Model class method, it has nothing to do with migrations 
> or the schema generator.  Try this migration instead: 
>
> Sequel.migration do 
>   up do 
>     create_table :posts do 
>       primary_key :id 
>       String :title 
>       String :body, :text=>true 
>       DateTime :created_at 
>       DateTime :updated_at 
>     end 
>   end 
>
>   down{drop_table :post} 
> end 
>
> Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to