corrected design. Added support for better failure recovery

This commit is contained in:
seek3r 2000-10-31 19:51:56 +00:00
parent 614b455cc4
commit 9ece99425c

View File

@ -11,9 +11,14 @@
/* $Id$ */
function update_version_table($tableschanged = True){
global $currentver, $phpgw_info, $db, $tablechanges;
if ($tableschanged == True){$tablechanges = True;}
$db->query("update applications set app_version='".$currentver."' where (app_name='admin' or app_name='filemanager' or app_name='addressbook' or app_name='todo' or app_name='calendar' or app_name='email' or app_name='nntp' or app_name='cron_apps')");
}
function v7122000to8032000(){
global $currentver, $db;
$didupgrade = True;
if ($currentver == "7122000"){
echo " <tr bgcolor=\"e6e6e6\">\n";
// echo " <td>Upgrade from 7122000 to 8032000 is completed.</td>\n";
@ -24,7 +29,6 @@
}
function v8032000to8072000(){
global $currentver, $db;
$didupgrade = True;
if ($currentver == "8032000"){
echo " <tr bgcolor=\"e6e6e6\">\n";
// echo " <td>Upgrade from 8032000 to 8072000 is completed.</td>\n";
@ -36,7 +40,6 @@
function v8072000to8212000(){
global $currentver, $db;
$didupgrade = True;
if ($currentver == "8072000"){
$sql = "CREATE TABLE applications ("
@ -71,7 +74,6 @@
}
function v8212000to9052000(){
global $currentver, $db;
$didupgrade = True;
if ($currentver == "8212000"){
$db->query("alter table chat_channel change name name varchar(10) not null");
$db->query("alter table chat_messages change channel channel char(20) not null");
@ -89,7 +91,6 @@
}
function v9052000to9072000(){
global $currentver, $db;
$didupgrade = True;
if ($currentver == "9052000"){
echo " <tr bgcolor=\"e6e6e6\">\n";
// echo " <td>Upgrade from 9052000 to 9072000 is completed.</td>\n";
@ -100,9 +101,7 @@
}
function v9072000to0_9_1(){
global $currentver, $phpgw_info, $db;
$didupgrade = True;
if ($currentver == "9072000"){
$db->query("alter table accounts change con account_id int(11) DEFAULT '0' NOT NULL auto_increment");
$db->query("alter table accounts change loginid account_lid varchar(25) NOT NULL");
$db->query("alter table accounts change passwd account_pwd varchar(32) NOT NULL");
@ -193,14 +192,13 @@
echo " <td>Upgrade from 9072000 to 0.9.1 is completed.</td>\n";
echo " </tr>\n";
$currentver = "0.9.1";
update_version_table();
}
}
function v0_9_1to0_9_2(){
global $currentver, $phpgw_info, $db;
$didupgrade = True;
if ($currentver == "0.9.1"){
$db->query("alter table access_log change lo lo varchar(255)");
$db->query("alter table addressbook change ab_id ab_id int(11) NOT NULL auto_increment");
$db->query("alter table addressbook add ab_company_id int(10) unsigned");
@ -237,10 +235,11 @@
echo " <td>Upgrade from 0.9.1 to 0.9.2 is completed.</td>\n";
echo " </tr>\n";
$currentver = "0.9.2";
update_version_table();
}
}
function update_owner($table,$field){
function v0_9_2to0_9_3update_owner($table,$field){
global $db;
$db->query("select distinct($field) from $table");
if ($db->num_rows()) {
@ -256,18 +255,18 @@
$db->query("alter table $table change $field $field int(11) NOT NULL");
}
function v0_9_2to0_9_3pre6(){
function v0_9_2to0_9_3(){
global $currentver, $phpgw_info, $db;
$didupgrade = True;
// The 0.9.3pre1 is only temp until release
if ($currentver == "0.9.2" || $currentver == "0.9.3pre1" || $currentver == "0.9.3pre2" || $currentver == "0.9.3pre3" || $currentver == "0.9.3pre4") {
if ($currentver == "0.9.2" || $currentver == "0.9.3pre1") {
update_owner("addressbook","ab_owner");
update_owner("todo","todo_owner");
update_owner("webcal_entry","cal_create_by");
update_owner("webcal_entry_user","cal_login");
v0_9_2to0_9_3update_owner("addressbook","ab_owner");
v0_9_2to0_9_3update_owner("todo","todo_owner");
v0_9_2to0_9_3update_owner("webcal_entry","cal_create_by");
v0_9_2to0_9_3update_owner("webcal_entry_user","cal_login");
$currentver = "0.9.3pre2";
update_version_table();
}
if ($currentver == "0.9.3pre2") {
$db->query("select owner, newsgroup from users_newsgroups");
@ -285,10 +284,12 @@
$db->query("update applications set app_tables='newsgroups' where app_name='nntp'");
}
$currentver = "0.9.3pre3";
update_version_table();
}
if ($currentver == "0.9.3pre3") {
$db->query("alter table todo add todo_id_parent int(11) DEFAULT '0' NOT NULL");
$currentver = "0.9.3pre4";
update_version_table();
}
if ($currentver == "0.9.3pre4") {
@ -296,8 +297,8 @@
$db->query("create table domains (domain_id int NOT NULL auto_increment, domain_name varchar(255),"
. "domain_database varchar(255),domain_status enum('Active,Disabled'),primary key(domain_id))");
$currentver = "0.9.3pre5";
update_version_table();
}
if ($currentver == "0.9.3pre5") {
$db->query("CREATE TABLE categories (
cat_id int(9) DEFAULT '0' NOT NULL auto_increment,
@ -305,12 +306,13 @@
app_name varchar(25) NOT NULL,
cat_name varchar(150) NOT NULL,
cat_description text NOT NULL,
PRIMARY KEY (cat_id))");
PRIMARY KEY (cat_id))"
);
$currentver = "0.9.3pre6";
update_version_table();
}
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>Upgrade from 0.9.2 to $currentver is completed.</td>\n";
echo " <td>Upgrade from 0.9.2 to 0.9.3pre6 is completed.</td>\n";
echo " </tr>\n";
}
}
@ -319,6 +321,7 @@
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Table Upgrades</b></font></td>\n";
echo " </tr>\n";
v7122000to8032000();
v8032000to8072000();
v8072000to8212000();
@ -326,15 +329,12 @@
v9052000to9072000();
v9072000to0_9_1();
v0_9_1to0_9_2();
v0_9_2to0_9_3pre6();
v0_9_2to0_9_3();
$db->query("update applications set app_version='".$phpgw_info["server"]["version"]."' where (app_name='admin' or app_name='filemanager' or app_name='addressbook' or app_name='todo' or app_name='calendar' or app_name='email' or app_name='nntp' or app_name='cron_apps')");
if (!$didupgrade == True){
if (!$tablechanges == True){
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>No table changes were needed. The script only updated your version setting.</td>\n";
echo " </tr>\n";
}
echo "</table>\n";
?>