When you call the changeset function, you pass the struct that you have, which has the lock_version value at the time you fetched it from the database. In the changeset, this original struct is under the data field. That’s where the optimistic_lock function gets the current lock version from.
Ecto.Changeset.change(%SomeStruct{lock_version: 1})
# => lock version is at changeset.data.lock_version


















