Source
(defmethod maybe-update-schemas ((table schema-table) class)
;; Rucksack analyzes the new class definition; if it's different from the
;; previous version, a new schema is added to the schema table. From that
;; moment, when an instance of the redefined class is created it will be
;; saved with the new schema id.
;; This is called by the FINALIZE-INHERITANCE method for PERSISTENT-CLASS.
(let ((slots (mapcar #'slot-definition-name (class-persistent-slots class)))
(old-schema (find-schema-for-class table class)))
(if (null old-schema)
;; There is no schema yet: create the first one.
(create-schema table class 0 slots)
;; There is a schema already: create a new one if necessary.
(when (set-difference slots (persistent-slot-names old-schema))
;; Add a new schema for this class.
(create-schema table class (1+ (schema-version old-schema)) slots)
;; Mark all older versions as obsolete and compute their
;; slot diffs w.r.t. to the new schema
(dolist (schema (old-schemas-for-class table class))
(let ((old-slots (persistent-slot-names schema)))
(setf (schema-obsolete-p schema) t
(added-slot-names schema) (set-difference slots old-slots)
(discarded-slot-names schema) (set-difference old-slots slots))))))))
Source Context