bcgov / bcgov/parks-data-register
Implement record versioning
- Dominant language
- JavaScript
- Stars
- 5
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
It is becoming apparent we need some form of record versioning to provide a better user experience. I am tracking my research into implementing it here, as I think it will be a fairly straightforward implementation.
Whenever a record gets saved after editing (minor/major/repealed), the record's `updateDate` field is updated with the current timestamp. The next time the record is edited and saved, the API can check the admin's `updateDate` with the one in the database. If the two match, then no changes have been made to the record while the admin was making edits. If they do not match, then someone else has saved a record intermediately and the admin's local version of the record may be out of date. They will have to pull from the database again before saving their changes to ensure their changes are up to date.

We can use the `updateDate` field to enforce some simple chronological versioning on our records. If we provide the version with the payload, the API can conditionally perform its PUT actions if the version provided is correct, otherwise return 400.
API PUT operations should require the version in the payload in the form of a `lastVersionDate` property. For the PUT to be successful, the `lastVersionDate` provided must equal the `updateDate` property on the existing `established` protected area record in the database. Upon finishing a successful put, the `updateDate` is updated to the current timestamp.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.