Previous: , Up: API   [Contents][Index]


5.4 Misc

Syntax: migrations ((version data …) expr) …

Syntax to describe a collection of migrations to be used to be applied in order to upgrade some data to a newer version. This is designed to be used with the persistence system e.g. to upgrade actor portrait data or graph roots. However, it is generic enough to be used elsewhere.

The migrations syntax will generate a procedure with the signature (lambda (prev-version data ...) ...) and will return two values, the version its migrated to and the new data.

(define migrations
  ;; Version 0 -> 1: ignore what I'm given and return 'i-am-version-1
  ((1 something) (list 'i-am-version-1))
  ;; Version 1 -> 2: provide two values, 'i-am-version-2 and the something I got
  ((2 something) (list 'i-am-version-2 something))
  ;; Version 2 -> 3: Swap the two values around
  ((3 something something-else) (list something-else something))

When the upgrade procedure is called, it would return version 3 (as it ran the version 2 migration and so the new version is the next version, version 3). It’d also return the new data which would be a list of ('i-am-version-1 'i-am-version-2).