[elephant-devel] Schema evolution

Henrik Hjelte henrik at evahjelte.com
Thu Nov 1 17:28:53 UTC 2007


I am no expert at how elephant does this now, I've been digging more
in the low level areas.

But I think that after some time you really will want schema changes
to be saved, and to be able to have different versions of classes, and
to have a lazy update of instances. It makes working with the system
much more secure and easier, this is probably one of the top features
to ask for.

Is this really so hard to do? I don't think so. About the update
interface, Rucksack has a method, I have pasted it below. You could
even store a little function  (the source code) in the database, to be
evaluated/executed when updating old versions. That way you would
never be afraid to lose it somewhere in the source code.

Of course, triggering updates of all obsolete instances should also be
possible, that is trivial once the versioning is in place.

I am willing to help with adding a feature like this, but don't have
time to do it myself right now. Something for a student/ Lisp
gardener?

/Henrik Hjelte

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Updating persistent instances
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; When a persistent object must be loaded from disk, Rucksack loads the
;; schema nr and finds the corresponding schema.  If the schema is obsolete
;; (i.e. there is a schema for the same class with a higher version number),
;; Rucksack calls the generic function
UPDATE-PERSISTENT-INSTANCE-FOR-REDEFINED-CLASS
;; after calling ALLOCATE-INSTANCE for the current class version.  The generic
;; function is very similar to UPDATE-INSTANCE-FOR-REDEFINED-CLASS: it takes a
;; list of added slots, a list of deleted slots and a property list containing
;; the slot names and values for slots that were discarded and had values.

(defgeneric update-persistent-instance-for-redefined-class
    (instance added-slots discarded-slots property-list &key)
  (:method ((instance persistent-object) added-slots discarded-slots plist
            &key)



More information about the elephant-devel mailing list