Project

General

Profile

Collection version history » History » Version 17

Peter Amstutz, 09/06/2018 09:30 PM

1 1 Tom Clegg
h1. Collection version history
2
3
(draft)
4
5 7 Peter Amstutz
Background: desired API features (#13494, #13561) epic ticket is #13109
6 1 Tom Clegg
* Get current + previous versions of a collection with a single API call
7
* Search all current + previous versions of collections with a single API call
8
* Stable small numeric "version number" for each version of a given collection
9
10 8 Peter Amstutz
h2. Design
11
12 1 Tom Clegg
* Store all versions in the collection table (much easier to do paging)
13 7 Peter Amstutz
* New database column "current_version_uuid" for latest version this the same as "uuid"
14 2 Tom Clegg
* New database column indicates user-friendly version number (starting at 1) -- can be assigned safely after locking "current" row for update
15 3 Tom Clegg
* Assign version number to the current version -- this way {uuid,version} can be used as a permanent reference to a specific version
16 5 Peter Amstutz
* Flag "include_past_versions" for "list" API to include old versions (otherwise, filter on current_version_uuid=uuid -- might need to adjust indexes to maintain performance)
17 1 Tom Clegg
* Flag in site configuration to enable preserving old versions in database
18 7 Peter Amstutz
* Update owner_uuid of all old versions (in a transaction) when it changes in the current version
19 8 Peter Amstutz
* A permission link to the current version only implies permission to the most recent version (not the history)
20 1 Tom Clegg
* Prohibit permission links to old versions (should be handled by check "can only make links to things that are visible to you", which should not include old versions)
21
* Old versions may not be modified except for certain fields which must be synchronized with "current" version changes (owner_uuid, trash_at, delete_at).  Updating owner_uuid, trash_at, delete_at does not update modified_at so modified_at shows when the version was created
22
* Old versions with duplicate "name" does not conflict with (owner_uuid, name) uniqueness constraint
23 16 Tom Clegg
* The following changes introduce a new version: manifest_text (portable_data_hash), description, properties, name
24
* The following changes do not introduce a new version, and are copied to all past version records: replication_*, storage_classes_*, trash_at/delete_at/is_trashed, owner_uuid, uuid (update current_uuid to retain database consistency)
25 17 Peter Amstutz
* New collection operation "truncate history" which deletes all versions older than T (where T is a date or a version number?)
26 16 Tom Clegg
* New database column "preserve_version" defaults to @false@, and can be set to @true@ by a create or update API call. If an update request does not result in a new version, and @preserve_version==true@ before the update, then @preserve_version==true@ after the update (regardless of any value given in the update request).
27
* New configuration option "preserve_version_if_idle": 0=immediate, 600=10 minutes, -1=never.
28
* If the existing version is more than N (site-configurable) seconds old, *or* has @preserve_version==true@, then it is retained in the version history.
29
30
Example: given preserve_version_if_idle=600:
31
32
|time    |operation                   |versions in DB     |comment|
33
|    1   |create collection           |current            ||
34
|10000   |update manifest_text        |1, current         ||
35
|10001   |update manifest_text        |1, current         ||
36
|10002   |update preserve_version=true|1, current         ||
37
|10003   |update replication_desired=1|1, current         ||
38
|10004   |update manifest_text        |1, 2, current      ||
39
|10005   |update manifest_text        |1, 2, current      ||
40
|10006   |update manifest_text, preserve_version=true        |1, 2, current      ||
41
|10007   |update manifest_text, preserve_version=true        |1, 2, 3, current   ||
42
|10007   |update preserve_version=false|1, 2, 3, current  |ignored; preserve_version is still true|
43
|10008   |update manifest_text        |1, 2, 3, 4, current||
44
|10009   |update manifest_text        |1, 2, 3, 4, current||
45
|20000   |update manifest_text        |1, 2, 3, 4, 5, current||