Do not touch `updated_at` when upsert has no effect

:thinking: this may actually be something the framework should handle for you? Like if something has an update_default, it should only be applied if something is changing. We actually could solve for this in the update, i.e fields that are being set due to update_defaults would be set only if at least one other thing is changing…The difficulty is pairing that with atomics, i.e we don’t know if nothing is changing until we actually do the upsert. There are a few things we’d need to do to make this work, incrementally, that are on the roadmap that is in my brain :laughing:.

  1. add an expression variable that lets you refer to the thing you are replacing in an upsert.
  2. add an expression variable that corresponds to wether or not you are in an upsert.
  3. add an expression variable that corresponds to wether or not something is changing if you are in an upsert. # this one may or may not be reasonable

So then you could use an atomic_update to get this behavior in the short term, and then in the long term the framework can do this automatically. In a create, set the value, in an update, only set if something is changing.

change atomic_update(:updated_at, expr(
  if ash.updating? and ash.has_changes? do
    now()
  else
    updated_at
  end
))

But yeah none of that will happen in the short term. Someday :smiley: