In this example we have a Human-class witch inherits from the Mammal class. Now we want to introduce a new Primate class and let the Human class inherit from it.
Unfortunately db4o doesn't support this kind of refactoring. We need to use a work-around. Basically we create a copy of the Human-class with the new Inheritance-hierarchy and the copy the existing data over.
Now the objects have the new inheritance hierarchy. You can delete the old Human-class.
IList<Human> allMammals = container.Query<Human>(); foreach (Human oldHuman in allMammals) { HumanNew newHuman = new HumanNew(""); newHuman.BodyTemperature = oldHuman.BodyTemperature; newHuman.IQ = oldHuman.IQ; newHuman.Name = oldHuman.Name; container.Store(newHuman); container.Delete(oldHuman); }
Dim allMammals As IList(Of Human) = container.Query(Of Human)() For Each oldHuman As Human In allMammals Dim newHuman As New HumanNew("") newHuman.BodyTemperature = oldHuman.BodyTemperature newHuman.IQ = oldHuman.IQ newHuman.Name = oldHuman.Name container.Store(newHuman) container.Delete(oldHuman) Next
Note that this example doesn't change existing references from the old instances to the new ones. You need to do this manually as well.