PUM/Gemstone – migration of instances …

When creating new versions of a model one might change already defined classes in that model and add or remove attributes from that class definition.

Gemstone is able to handle different versions of classes and allows the programmer to migrate instances of old class versions to a specific new version of that class.

The job of migration can be very difficult and this is my first attempt in PUM is to at least do the initialize stuff (in the initialize method) also in the migration support method. The generated code looks for all current attributes (in den new model) defined and if they are new, they simply initialize them with the value from that model.

migrateFrom: oldValue instVarMap: unusedParameter
	|  oldNames |

	oldNames := oldValue class allInstVarNames.

	(oldNames includes: #'studyMembership') ifFalse:[ studyMembership := StringKeyValueDictionary new ].
	(oldNames includes: #'quotas') ifFalse:[ quotas := Set new ].
	(oldNames includes: #'quotaFullAppointmentHandling') ifFalse:[ quotaFullAppointmentHandling := CATIEnumQuotaFullAppointmentHandling noHandling ].
This entry was posted in Smalltalk and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s