Excuse me for doing this in English..
I am now using a nice piece of code I found in the WB2.7 upgrade script.
I modified it a little bit so it would not display unneeded messages.
There is a function db_add_field:
<?php //used for colorcoding this code block
function db_add_field($field, $table, $desc) {
global $database;
$table = TABLE_PREFIX.$table;
$query = $database->query("DESCRIBE $table '$field'");
if(!$query || $query->numRows() == 0) { // add field
$query = $database->query("ALTER TABLE $table ADD $field $desc");
echo (mysql_error()?mysql_error().'<br />':'');
$query = $database->query("DESCRIBE $table '$field'");
echo (mysql_error()?mysql_error().'<br />':'');
}
}
When this is called it checks if the field exists, if not it is added.
Call it with a oneliner for each added field:
<?php //used for colorcoding this code block
// Safely add field that was added in v0.14
db_add_field("extrafield", "mod_my_module", "INTEGER UNSIGNED NOT NULL DEFAULT '0'");
// Safely add field that was added in v0.15
db_add_field("morefields", "mod_my_module", "VARCHAR(45) NOT NULL DEFAULT 'default value'");
For every update you can just add the lines for that update, but without the need of removing previous updates.
Ruud