Update db

Apr 3, 2011 at 4:51 PM

I have a couple apps in the windows phone marketplace (Tasktick, QuickNote) that use Sterling. I would like to push out updates for these apps that include changing classes and adding new properties. However, I have noticed that whenever I change an object, my Sterling database breaks and I have to clear out the data for it to work.

How do I make changes to an object without losing all of my customers data? From what I have been reading, sounds like there isn't a good answer for this one.

Thanks for your help

Apr 4, 2011 at 12:12 PM

The intended strategy has been to version your objects and use a different database. For size reasons, Sterling doesn't store the attributes at the time it serializes so that of course means it has to reconstruct it based on the template of the object itself. If you search discussions you'll see a few talks around what people have successfully done to migrate a database from an older version when properties change - i.e. have the new class in a new namespace, etc.

The change is more complicated because it will likely break backwards compatibility because I'll have to order the properties in the stream - right now just the types are injected, so I have to trust the property order on the class object. By saving it I can then know what to expect from the stream and match it with the object and more gracefully handle changes to properties/etc. That will be in future versions to be more "automatic" but will require some thought to minimize any impact on backwards compatibility.

Apr 4, 2011 at 5:45 PM

It seems at a certain level Sterling is dependent on Isolated Storage, and Isolated Storage is not a relational or even an object database.

Unless Sterling goes to a model where the "Sterling Data File" IS the "database", we will always be forced to deal with the fact that what we call a database is really just some text written to a file.

So I see versioning to always be a case of, if previous records exist, copy them to the new format. This method does work. It doesn't "feel natural", but it doesn't "fight reality".