Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Design pattern for software updates

Is anybody aware of any design patterns around software updates? Specifically I'd like a pattern for converting old files/settings into the latest version.

The best solution I can think of would be to have a set of rules for how to convert from each version to the next version (e.g. v1.0 to v1.1, v1.1 to v1.2, ...). Then to convert files/settings to the latest version you would run all the conversion rules in order.

This doesn't strike me as a very elegant way of doing things - is there a better way?

like image 770
stormCloud Avatar asked Jun 23 '12 16:06

stormCloud


1 Answers

I worked in a system which included a versioning system to migrate a DB to the latest version, and it worked like that. The only improvement we did, is that we sometimes wanted to avoid going through all versions, since it was a lengthly process, so you could define migrations from any version to any version if you are in version 1.3 and want to migrate to the latest version and you have scripts to migrate from:

  1. 1.3 to 1.4
  2. 1.4 to 1.5
  3. 1.5 to 1.6
  4. 1.6 to 1.7
  5. 1.7 to 1.8
  6. 1.4 to 1.7

I'd detect automatically that it can use a single script to go over three versions 1.4 to 1.7 and use 1, 6 and 5. That's only worth it if the migration is lengthy though...

If you don't need to actually migrate the data, but just use it in the format of the latest version, you could achieve the same using the Adapter Pattern using object composition to transform an object with the "1.3" format to the "1.8" format using a chain of adapters in the middle.

In response to comment: Sadly, we had to do the 1.4 to 1.7 by hand. You'll need something pretty smart to be able to compose optimized updates scripts from the individual ones, without executing them sequentially.

like image 112
user1494736 Avatar answered Nov 16 '22 00:11

user1494736