Hi, I have some concerns about schema evolution when refactoring, more specifically when moving a property higher in the hierarchy class. SUMMARY : I want to move the property 'FirstName' from the class 'Son' to its parents class 'Father' CODE SAMPLE : (UpgradeHandler included)
PROBLEM : Such an upgrade works perfectly with DomainUpgradeMode.Perform, but fails with DomainUpgradeMode.PerformSafely : Xtensive.Storage.SchemaSynchronizationException: Cannot upgrade schema safely. Is there any way to perform such a schema evolution in DomainUpgradeMode.PerformSafely mode ? Am I missing something ? Kind regards, Auguste Updated at 04.09.2009 17:37:55
However, it is indeed possible to successfully move a property to the parent class by copying the child property (marked with [Recycled,Obsolete] attribute) to a new property with a different name in the parent class. But, this is NOT possible to do so and keep the same name for the property in the parent class. Therefore, my workaroud is to upgrade with the following sequence (DomainUpgradeMode.PerformSafely): [] Upgrade no 1 : Copy the property in child class to a new property in the parent class, with a new (temporary) name. Mark [Obsolete, Recycled] the property in the child class [] Upgrade no 2 : Rename the property in the parent class with the correct name. Are there any plans to support this feature in a single upgrade ? Best regards, Auguste This thread was imported from our support forum. The original discussion may contain more detailed answer. |
The exception is correct: copy hint implies old field must not be removed, but in fact it is. So our schema comparer discovers there is a field it must remove, but since this action was not explicitly hinted, it warns you. On the other hand, there is no easy way to describe such a field move: rename field hint support renaming in the same class only for now. So currently I suggest you a workaround for this: leave source field in model, but apply [Recycled] and [Obsolete] attributes to it. They will ensure appropriate field will be dropped on the last upgrade stage. We'll fix the issue with the nearest update. In fact, we must:
Issue to track: http://code.google.com/p/dataobjectsdot ... ail?id=376 |