Add possibility to unpersist data one generation younger#71
Add possibility to unpersist data one generation younger#71kkafara wants to merge 1 commit intoscalapenos:masterfrom
Conversation
Allow `Persister` and `Migrator` with version `V` to unpersist data that have not only version `X <= V` but also `V + 1`
|
@agemooij did you manage to find few minutes to look at it? |
| /** | ||
| * A `Migrator[R, V]` can migrate raw values of type R from older | ||
| * versions to version `V` by applying a specific `Migration[R]` to it. | ||
| * versions to version `V` or from version one generation younger |
There was a problem hiding this comment.
I think it's better to use the word "newer" instead of "younger" to describe Versions with greater numbers than the older ones. It's just a vocabulary clarification, as we had misunderstanding discussing this.
| ) | ||
| } | ||
|
|
||
| def backFrom[NextV <: Version : VersionInfo](migration: Migration[R])(implicit isNextAfter: IsNextVersionAfter[NextV, V]): Migrator[R, V] = { |
There was a problem hiding this comment.
How about renaming this method to andBackFrom? This way it will gramatically point out that this method should be called only once and at the end of the to method calls:
from[V1](...).to[V2](...).to[V3].andBackFrom[V4](...)
Or even:
from[V1](...).andBackFrom[V4](...)
While this:
from[V1](...).to[V2](...).andBackFrom[V3](...).to[V3](...)
and this:
from[V1](...).to[V2](...).andBackFrom[V3](...).andBackFrom[V4](...)
would automatically look suspicious in code and would be easier to catch in code reviews.
There was a problem hiding this comment.
from[V1](...).to[V2](...).andBackFrom[V3](...).to[V3](...) - this is possible but will have no effect now
from[V1](...).to[V2](...).andBackFrom[V3](...).andBackFrom[V4](...) - this is impossible - will not compile in current version of code
| * It will always persist instances of T to version V but it will use the specified | ||
| * JsonMigrator[V] to migrate any values older than version V to version V before | ||
| * unpersisting them. | ||
| * JsonMigrator[V] to migrate any values older or or one generation younger |
#57
Allow
PersisterandMigratorwith versionVto unpersist data that have not only versionX <= Vbut alsoV + 1.Possible use-case scenario described in #57 (comment)