# `AshVersioned.Resource.ManualIncrement`

Implements the core atomic primitive for `AshVersioned.Resource`s: mark the current
latest row as stale and insert a new version in a single transaction. This works for all
update actions and, if the resource has `archive` set, destroy actions.

Increment is implemented as a bulk update scoped to the current row's primary key and
latest flag. This acts as an optimistic locking signal so that a concurrent update that
commits earlier will force this to fail with `Ash.Error.Changes.StaleRecord` instead of
reinserting on top of already-stale data.

AshVersioned performs the increment in a transaction that does the following:

1. Captures the change timestamp
2. Updates the old version latest flag (to false) and the update timestamp
3. Clears the primary key
4. Copies the versioned resource's identity field
5. Increments the version number by 1
6. Sets the latest flag to true
7. Sets the creation and update timestamps to the captured change timestamp
8. Applies the actor attributions from the context
9. Copies all other writable or non-generated values from the old resource changeset or
   data to the new resource; this includes the archived field (if present)

# `update`

Increments a new version for the resource on update.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
