Add rationale for preserving persisted data for alpha fields

This commit is contained in:
Jordan Liggitt 2019-06-25 08:16:06 -07:00
parent 836e76b7c6
commit 47f58b5491
1 changed files with 3 additions and 0 deletions

View File

@ -930,6 +930,9 @@ The preferred approach adds an alpha field to the existing object, and ensures i
3. Before persisting the object to storage, clear disabled alpha fields on create,
and on update if the existing object does not already have a value in the field.
This prevents new usage of the feature while it is disabled, while ensuring existing data is preserved.
Ensuring existing data is preserved is needed so that when the feature is enabled by default in a future version *n*
and data is unconditionally allowed to be persisted in the field, an *n-1* API server
(with the feature still disabled by default) will not drop the data on update.
The recommended place to do this is in the REST storage strategy's PrepareForCreate/PrepareForUpdate methods:
```go