Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:26 pm
by Torrie Moore >> Tue, 7 Apr 2009 21:11:22 GMT
Hi Din
We are faced by this issue from time to time in production systems. We take the same approach as outlined by Patwos. In a little more detail
1) Add new properties with the required data types to the system. This will require a reorg as we are changing the structure of the data. This is what the reorg process does. It will retain the data in existing properties. This is normally done via a schema load.
2) Load and run a script (You can write a JadeScript) that will update the data in the system in your scenario, set the new integer property from the string property. We would run this using the JadLoadb utility. For example, something like the following would work in your scenario
vars
oObj : SomeClass;
begin
beginTransaction;
foreach oObj in SomeClass.instances do
if oObj.stringProperty.isInteger
// String property is an integer
oObj.intProperty := oObj.stringProperty.Integer;
else
// String could not be converted to an integer. - Stop processing and abort.
write "Cannot convert data - String does not convert to an integer;
abortTransaction;
break; // Stop processing
endif;
endforeach;
commitTransaction;
3) Load the new schemas that use the new property rather than the integer one. If the old property has been removed from the class in this schema file then it will be deleted. (Another reorg)
To make sure that this process is robust as possible we would take a copy of the production system into a test environment and run through this process to ensure that there will be no unexpected issues. We would then repeat the same process on the production system. Our updates are done via scripts (we use a bat files and the Jade command line utilities (jdbutilb, jadloadb, jadclient etc.) so that exactly the same process is applied to the test system as to the production system. The process will include a pre upgrade backup in case something goes wrong and a post upgrade backup. We need to be able to restore to how things were before the upgrade if something goes wrong (pre upgrade) and it's often useful to have a backup after the upgrade so if the system fails following the upgrade, we don't need to repeat the upgrade.
If there are any data updates during an upgrade process, we will log any change we make so that there is a record of exactly what the upgrade process has done. This is normally done to a text file using the JadeLog class.
Hope this helps.
Torrie