Commerce Server 2007 - Data Migration


In this article I will be discussing about various challenges we face during data migration from CS 2000 to CS 2007. Before getting into the issues let's discuss the basic process involved in the process of data migration. This article covers transactions data migration.

Commerce Server 2007 Migration Wizard:-

Commerce server 2007 comes with a migration wizard to migrate previous versions of commerce server to CS 2007. Commerce server 2007 underwent various design changes in the product. Previous versions of commerce are COM based. Most of the sub-systems in Commerce 2007 have been re-written in managed code. Commerce Server 2007 provides and extensible architecture to extent various sub systems. Commerce Server 2007 wizard works very similar to the runtime architecture. Entire order system of the site has been represented through OrderObjectMapping.xml and OrderPipeLineMapping.xml. Commerce server 2007 wizard follows the same structure to migrate the data from previous version of commerce server.

Various parts of Upgrade wizard:-

Upgrade wizard is a .Net win form application and work based on the configuration files for various configurations. Configuration file stores information very similar to the web.config of the runtime site. It stores information like Order System assemblies and adapter mapping information. Application configuration file store the path of the Storage Mapping File path and Order Migration mapping file. Order Migration mapping file is very similar to the Pipeline mapping file. Migration mapping file maps information between the order Type properties and keys of the legacy system marshaled data.

Migrating Discounts Applied:-

Commerce server 2007 stores various discounts applied information in a separate table. The wizard expects a separate list in the order form header marshaled data for applied discounts. Commerce Server 2000 and 2002 doesn't store information in a list, instead it stores the information in order form header in a flat hierarchy. Due to this design constraint, migration wizard doesn't provide out of box feature to migrate the same. One way to do the migration is through custom SQL migration. For this we need to grab the information from marshaled data to physical columns in the order form header table.

Following are the mapping information about in discounts in the migration mapping file.

<Collection Name="ItemLevelDiscountsApplied" DictionaryKey="_itemlevel_discounts_applied" KeyType="SimpleList" ReferTo="DiscountApplicationRecord" />

<Collection Name="OrderLevelDiscountsApplied" DictionaryKey="_orderlevel_discounts_applied" KeyType="SimpleList" ReferTo="DiscountApplicationRecord" />

Migration wizard expects discounts information in the above specified keys and the same is not available in earlier versions. We need to find the discount related information in the legacy marshaled data and import the same to the SQL tables. Previous version of commerce server stores all the information in blob and also stores some information in tables. Legacy commerce runtime looks in to the keys and checks the same against the target table column list. If the table has mapping columns, runtime will store the data in the appropriate columns. We can use this flexibility to migrate the data from marshaled data to SQL tables. We can create a sample VB application to read the Orders information through commerce API's. After exploring the data through the application, we can create the needed columns in the legacy commerce tables like Order Group, Order Form Header etc. Loading and saving the order back to the system through SaveAsOrder method will force the runtime to do data persistence. After this we can do SQL migration to CS 2007 tables.

Alternatively we can create appropriate lists in the legacy application marshaled data as expected by CS 2007 wizard through a sample VB application.

The same issue is there for Payment methods as well. We need to follow the above steps to migrate the same to CS 2007 

Exploring Legacy marshaled data – CS 2000 PInvoke API

I have created a sample visual basic application to do the discounts and payment methods migration. This application will be very useful to tweak the data stored in the legacy systems.