Refactor the install/upgrade code to be more flexible.

Add xxx_installer::upgrade($version) method so that upgrade stanzas
are separate from install stanzas.  In the old code, to do an upgrade
meant that you had to re-evolve everything from the initial install
because we'd step through each version's changes.  But what we really
want is for the initial install to start off in the perfect initial
state, and the upgrades to do the work behind the scenes.  So now the
install() function gets things set up properly the first time, and the
upgrade() function does any work to catch you up to the latest code.
See gallery_installer.php for a good example.
This commit is contained in:
Bharat Mediratta
2009-06-23 12:00:49 -07:00
parent 342d5e1186
commit bfca0c7903
21 changed files with 429 additions and 449 deletions

View File

@@ -45,7 +45,11 @@ class Admin_Modules_Controller extends Admin_Controller {
} else if (!$info->active && $desired && !module::is_active($module_name)) {
$changes->activate[] = $module_name;
$activated_names[] = $info->name;
module::install($module_name);
if (module::is_installed($module_name)) {
module::upgrade($module_name);
} else {
module::install($module_name);
}
module::activate($module_name);
}
}