Roland Mas wrote:
> key-value pairs. One of the keys (okay, the only one normally) is
> "db-version", and the corresponding value is a version number with the
> same semantics as the one provided by dpkg for the ordering). When I
> need to upgrade something, I go the following steps:
>
> ,----[ One upgrade chunk ]
> | Begin transaction
> | Do stuff
> | Check that stuff went fine (and raise an exception/abort if not)
> | Update the value for db-version
> | Commit transaction
> `----
>
> This is of course only executed if current db-version is less than
> targeted version. So I have a series of upgrade chunks, arranged like
> this:
>
> ,----[ Upgrade script ]
> | $target version = 1.0
> | if (current-version < $target-version) {
> | Do the upgrade chunk for target=$target-version
> | }
> |
> | $target version = 1.1
> | if (current-version < $target-version) {
> | Do the upgrade chunk for target=$target-version
> | }
> |
> | $target version = 1.4
> | if (current-version < $target-version) {
> | Do the upgrade chunk for target=$target-version
> | }
> `----
>
> The postinst script always runs this upgrade script. So all the
> steps that were previously completed are not replayed, and you'll
> start at the first one that hasn't been successfully run yet.
Heh, that's funny, this is exactly the approach I use for mooix database
upgrades. Even my code looks scarily similar to yours, although I don't
have transactons and just try to make it all idempotent instead.
--
see shy jo
Attachment:
pgpCBXAG2Zo8R.pgp
Description: PGP signature