On Sep 18, 5:25 am, byrnejb <[email protected]> wrote:
> On Sep 17, 5:10 am, Maciek <[email protected]> wrote:
>
> > Hi, I'm new to sequel and it took me a while to figure out how to set
> > timestamps on a model.
> > Is this the right way? Are there any better alternative ways?
>
> > class Category < Sequel::Model(:categories)
> >   plugin :timestamps, :update_on_create => true
> > end
>
> > Thanks
>
> That is the "web 2.0" way. It is not the "right" way.  The right way
> is to let the DBMS do its job and timestamp things itself when the
> rows are inserted.  That requires implementing a trigger and related
> function.  An example is given in the PostgreSQL docs 
> athttp://www.postgresql.org/docs/8.4/static/plpgsql-trigger.html.
>
> The reason being is that ALL audit data from an application is
> tainted. Only the DBMS itself can verify the time something happened
> and what connection id was used.

Well, you are correct.  My assumption was that the user was asking if
there were better ways of using the plugin, not of implementing
timestamps in a general sense.  If you want to create updated_at/
created_at triggers on PostgreSQL, my sequel_postgresql_triggers
extension makes things easy (http://github.com/jeremyevans/
sequel_postgresql_triggers).

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
-~----------~----~----~----~------~----~------~--~---

Reply via email to