Handing `created_at` and `updated_at`

I thought this would be trivial, but it turned out to be quite a headache. Can someone please teach or show me to do the following:

  • Add RLS policy to prevent authenticated users from inserting rows with updated_at and
    created_at
    values (it should just use the defaults: NULL and
    now()
    respectively)
  • Add RLS policy to prevent authenticated users from updating rows with (new) updated_at and
    created_at
    values
  • Add a trigger that automatically updates updated_at to
    now()
    when a row gets updated
Was this page helpful?