mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
cleaned up code and added proper drop tables, which takes into account the sequence records
This commit is contained in:
parent
f7a113632d
commit
0ee9714eb5
@ -26,19 +26,21 @@
|
||||
$db->query("DROP TABLE profiles");
|
||||
$db->query("drop sequence addressbook_ab_id_seq");
|
||||
$db->query("DROP TABLE addressbook");
|
||||
$db->query("drop sequence webcal_entry_cal_id_seq");
|
||||
$db->query("drop sequence calendar_entry_cal_id_seq");
|
||||
$db->query("drop sequence todo_todo_id_seq");
|
||||
$db->query("DROP TABLE todo");
|
||||
$db->query("DROP TABLE calendar_entry");
|
||||
$db->query("DROP TABLE calendar_entry_repeats");
|
||||
$db->query("DROP TABLE webcal_entry_repeats");
|
||||
$db->query("DROP TABLE calendar_entry_user");
|
||||
$db->query("drop sequence newsgroups_con_seq");
|
||||
$db->query("DROP TABLE newsgroups");
|
||||
$db->query("DROP TABLE users_newsgroups");
|
||||
/* $db->query("DROP TABLE users_newsgroups");*/
|
||||
$db->query("DROP TABLE lang");
|
||||
$db->query("drop sequence news_msg_con_seq");
|
||||
$db->query("DROP TABLE news_msg");
|
||||
$db->query("DROP TABLE languages");
|
||||
$db->query("drop sequence categories_cat_id_seq");
|
||||
$db->query("DROP TABLE categories");
|
||||
$db->query("DROP sequence notes_note_id_seq");
|
||||
$db->query("DROP TABLE notes");
|
||||
?>
|
@ -591,92 +591,92 @@
|
||||
update_version_table();
|
||||
}
|
||||
if ($currentver == "0.9.7pre1") {
|
||||
$db2 = $db;
|
||||
$db3 = $db;
|
||||
$sql = "CREATE TABLE calendar_entry (
|
||||
cal_id serial,
|
||||
cal_owner int DEFAULT 0 NOT NULL,
|
||||
cal_group varchar(255) NULL,
|
||||
cal_datetime int4,
|
||||
cal_mdatetime int4,
|
||||
cal_duration int DEFAULT 0 NOT NULL,
|
||||
cal_priority int DEFAULT 2,
|
||||
cal_type varchar(10),
|
||||
cal_access varchar(10),
|
||||
cal_name varchar(80) NOT NULL,
|
||||
cal_description text)";
|
||||
$db->query($sql,__LINE__,__FILE__);
|
||||
$db->query("SELECT count(*) FROM webcal_entry",__LINE__,__FILE__);
|
||||
$db->next_record();
|
||||
if($db->f(0)) {
|
||||
$db->query("SELECT cal_id,cal_owner,cal_duration,cal_priority,cal_type,cal_access,cal_name,cal_description,cal_id,cal_date,cal_time,cal_mod_date,cal_mod_time FROM webcal_entry ORDER BY cal_id",__LINE__,__FILE__);
|
||||
while($db->next_record()) {
|
||||
$cal_id = $db->f("cal_id");
|
||||
$cal_owner = $db->f("cal_owner");
|
||||
$cal_duration = $db->f("cal_duration");
|
||||
$cal_priority = $db->f("cal_priority");
|
||||
$cal_type = $db->f("cal_type");
|
||||
$cal_access = $db->f("cal_access");
|
||||
$cal_name = $db->f("cal_name");
|
||||
$cal_description = $db->f("cal_description");
|
||||
$datetime = mktime(intval(strrev(substr(strrev($db->f("cal_time")),4))),intval(strrev(substr(strrev($db->f("cal_time")),2,2))),intval(strrev(substr(strrev($db->f("cal_time")),0,2))),intval(substr($db->f("cal_date"),4,2)),intval(substr($db->f("cal_date"),6,2)),intval(substr($db->f("cal_date"),0,4)));
|
||||
$moddatetime = mktime(intval(strrev(substr(strrev($db->f("cal_mod_time")),4))),intval(strrev(substr(strrev($db->f("cal_mod_time")),2,2))),intval(strrev(substr(strrev($db->f("cal_mod_time")),0,2))),intval(substr($db->f("cal_mod_date"),4,2)),intval(substr($db->f("cal_mod_date"),6,2)),intval(substr($db->f("cal_mod_date"),0,4)));
|
||||
$db2->query("SELECT groups FROM webcal_entry_groups WHERE cal_id=".$cal_id,__LINE__,__FILE__);
|
||||
$db2->next_record();
|
||||
$cal_group = $db2->f("groups");
|
||||
$db2->query("INSERT INTO calendar_entry(cal_id,cal_owner,cal_group,cal_datetime,cal_mdatetime,cal_duration,cal_priority,cal_type,cal_access,cal_name,cal_description) "
|
||||
."VALUES(".$cal_id.",'".$cal_owner."','".$cal_group."',".$datetime.",".$moddatetime.",".$cal_duration.",".$cal_priority.",'".$cal_type."','".$cal_access."','".$cal_name."','".$cal_description."')",__LINE__,__FILE__);
|
||||
}
|
||||
}
|
||||
$db->query("DROP TABLE webcal_entry_groups");
|
||||
$db->query("DROP TABLE webcal_entry");
|
||||
$db2 = $db;
|
||||
$db3 = $db;
|
||||
$sql = "CREATE TABLE calendar_entry (
|
||||
cal_id serial,
|
||||
cal_owner int DEFAULT 0 NOT NULL,
|
||||
cal_group varchar(255) NULL,
|
||||
cal_datetime int4,
|
||||
cal_mdatetime int4,
|
||||
cal_duration int DEFAULT 0 NOT NULL,
|
||||
cal_priority int DEFAULT 2,
|
||||
cal_type varchar(10),
|
||||
cal_access varchar(10),
|
||||
cal_name varchar(80) NOT NULL,
|
||||
cal_description text)";
|
||||
$db->query($sql,__LINE__,__FILE__);
|
||||
$db->query("SELECT count(*) FROM webcal_entry",__LINE__,__FILE__);
|
||||
$db->next_record();
|
||||
if($db->f(0)) {
|
||||
$db->query("SELECT cal_id,cal_owner,cal_duration,cal_priority,cal_type,cal_access,cal_name,cal_description,cal_id,cal_date,cal_time,cal_mod_date,cal_mod_time FROM webcal_entry ORDER BY cal_id",__LINE__,__FILE__);
|
||||
while($db->next_record()) {
|
||||
$cal_id = $db->f("cal_id");
|
||||
$cal_owner = $db->f("cal_owner");
|
||||
$cal_duration = $db->f("cal_duration");
|
||||
$cal_priority = $db->f("cal_priority");
|
||||
$cal_type = $db->f("cal_type");
|
||||
$cal_access = $db->f("cal_access");
|
||||
$cal_name = $db->f("cal_name");
|
||||
$cal_description = $db->f("cal_description");
|
||||
$datetime = mktime(intval(strrev(substr(strrev($db->f("cal_time")),4))),intval(strrev(substr(strrev($db->f("cal_time")),2,2))),intval(strrev(substr(strrev($db->f("cal_time")),0,2))),intval(substr($db->f("cal_date"),4,2)),intval(substr($db->f("cal_date"),6,2)),intval(substr($db->f("cal_date"),0,4)));
|
||||
$moddatetime = mktime(intval(strrev(substr(strrev($db->f("cal_mod_time")),4))),intval(strrev(substr(strrev($db->f("cal_mod_time")),2,2))),intval(strrev(substr(strrev($db->f("cal_mod_time")),0,2))),intval(substr($db->f("cal_mod_date"),4,2)),intval(substr($db->f("cal_mod_date"),6,2)),intval(substr($db->f("cal_mod_date"),0,4)));
|
||||
$db2->query("SELECT groups FROM webcal_entry_groups WHERE cal_id=".$cal_id,__LINE__,__FILE__);
|
||||
$db2->next_record();
|
||||
$cal_group = $db2->f("groups");
|
||||
$db2->query("INSERT INTO calendar_entry(cal_id,cal_owner,cal_group,cal_datetime,cal_mdatetime,cal_duration,cal_priority,cal_type,cal_access,cal_name,cal_description) "
|
||||
."VALUES(".$cal_id.",'".$cal_owner."','".$cal_group."',".$datetime.",".$moddatetime.",".$cal_duration.",".$cal_priority.",'".$cal_type."','".$cal_access."','".$cal_name."','".$cal_description."')",__LINE__,__FILE__);
|
||||
}
|
||||
}
|
||||
$db->query("DROP TABLE webcal_entry_groups");
|
||||
$db->query("DROP TABLE webcal_entry");
|
||||
|
||||
$sql = "CREATE TABLE calendar_entry_user (
|
||||
cal_id int DEFAULT 0 NOT NULL,
|
||||
cal_login int DEFAULT 0 NOT NULL,
|
||||
cal_status char(1) DEFAULT 'A')";
|
||||
$db->query($sql,__LINE__,__FILE__);
|
||||
$db->query("SELECT count(*) FROM webcal_entry_user",__LINE__,__FILE__);
|
||||
$db->next_record();
|
||||
if($db->f(0)) {
|
||||
$db->query("SELECT cal_id,cal_login,cal_status FROM webcal_entry_user ORDER BY cal_id",__LINE__,__FILE__);
|
||||
while($db->next_record()) {
|
||||
$cal_id = $db->f("cal_id");
|
||||
$cal_login = $db->f("cal_login");
|
||||
$cal_status = $db->f("cal_status");
|
||||
$db2->query("INSERT INTO calendar_entry_user(cal_id,cal_login,cal_status) VALUES(".$cal_id.",".$cal_login.",'".$cal_status."')",__LINE__,__FILE__);
|
||||
}
|
||||
}
|
||||
$db->query("DROP TABLE webcal_entry_user",__LINE__,__FILE__);
|
||||
$sql = "CREATE TABLE calendar_entry_user (
|
||||
cal_id int DEFAULT 0 NOT NULL,
|
||||
cal_login int DEFAULT 0 NOT NULL,
|
||||
cal_status char(1) DEFAULT 'A')";
|
||||
$db->query($sql,__LINE__,__FILE__);
|
||||
$db->query("SELECT count(*) FROM webcal_entry_user",__LINE__,__FILE__);
|
||||
$db->next_record();
|
||||
if($db->f(0)) {
|
||||
$db->query("SELECT cal_id,cal_login,cal_status FROM webcal_entry_user ORDER BY cal_id",__LINE__,__FILE__);
|
||||
while($db->next_record()) {
|
||||
$cal_id = $db->f("cal_id");
|
||||
$cal_login = $db->f("cal_login");
|
||||
$cal_status = $db->f("cal_status");
|
||||
$db2->query("INSERT INTO calendar_entry_user(cal_id,cal_login,cal_status) VALUES(".$cal_id.",".$cal_login.",'".$cal_status."')",__LINE__,__FILE__);
|
||||
}
|
||||
}
|
||||
$db->query("DROP TABLE webcal_entry_user",__LINE__,__FILE__);
|
||||
|
||||
$sql = "CREATE TABLE calendar_entry_repeats (
|
||||
cal_id int DEFAULT 0 NOT NULL,
|
||||
cal_type varchar(20),
|
||||
cal_end int4,
|
||||
cal_frequency int default 1,
|
||||
cal_days char(7))";
|
||||
$db->query($sql,__LINE__,__FILE__);
|
||||
$db->query("SELECT count(*) FROM webcal_entry_repeats",__LINE__,__FILE__);
|
||||
$db->next_record();
|
||||
if($db->f(0)) {
|
||||
$db->query("SELECT cal_id,cal_type,cal_end,cal_frequency,cal_days FROM webcal_entry_repeats ORDER BY cal_id",__LINE__,__FILE__);
|
||||
while($db->next_record()) {
|
||||
$cal_id = $db->f("cal_id");
|
||||
$cal_type = $db->f("cal_type");
|
||||
if(isset($db->Record["cal_end"])) {
|
||||
$enddate = mktime(0,0,0,intval(substr($db->f("cal_end"),4,2)),intval(substr($db->f("cal_end"),6,2)),intval(substr($db->f("cal_end"),0,4)));
|
||||
$useend = 1;
|
||||
} else {
|
||||
$enddate = 0;
|
||||
$useend = 0;
|
||||
}
|
||||
$cal_frequency = $db->f("cal_frequency");
|
||||
$cal_days = $db->f("cal_days");
|
||||
$db2->query("INSERT INTO calendar_entry_repeats(cal_id,cal_type,cal_use_end,cal_end,cal_frequency,cal_days) VALUES(".$cal_id.",'".$cal_type."',".$useend.",".$enddate.",".$cal_frequency.",'".$cal_days."')",__LINE__,__FILE__);
|
||||
}
|
||||
}
|
||||
$db->query("DROP TABLE webcal_entry_repeats",__LINE__,__FILE__);
|
||||
$db->query("UPDATE applications SET app_tables='calendar_entry,calendar_entry_user,calendar_entry_repeats' WHERE app_name='calendar'",__LINE__,__FILE__);
|
||||
$sql = "CREATE TABLE calendar_entry_repeats (
|
||||
cal_id int DEFAULT 0 NOT NULL,
|
||||
cal_type varchar(20),
|
||||
cal_end int4,
|
||||
cal_frequency int default 1,
|
||||
cal_days char(7))";
|
||||
$db->query($sql,__LINE__,__FILE__);
|
||||
$db->query("SELECT count(*) FROM webcal_entry_repeats",__LINE__,__FILE__);
|
||||
$db->next_record();
|
||||
if($db->f(0)) {
|
||||
$db->query("SELECT cal_id,cal_type,cal_end,cal_frequency,cal_days FROM webcal_entry_repeats ORDER BY cal_id",__LINE__,__FILE__);
|
||||
while($db->next_record()) {
|
||||
$cal_id = $db->f("cal_id");
|
||||
$cal_type = $db->f("cal_type");
|
||||
if(isset($db->Record["cal_end"])) {
|
||||
$enddate = mktime(0,0,0,intval(substr($db->f("cal_end"),4,2)),intval(substr($db->f("cal_end"),6,2)),intval(substr($db->f("cal_end"),0,4)));
|
||||
$useend = 1;
|
||||
} else {
|
||||
$enddate = 0;
|
||||
$useend = 0;
|
||||
}
|
||||
$cal_frequency = $db->f("cal_frequency");
|
||||
$cal_days = $db->f("cal_days");
|
||||
$db2->query("INSERT INTO calendar_entry_repeats(cal_id,cal_type,cal_use_end,cal_end,cal_frequency,cal_days) VALUES(".$cal_id.",'".$cal_type."',".$useend.",".$enddate.",".$cal_frequency.",'".$cal_days."')",__LINE__,__FILE__);
|
||||
}
|
||||
}
|
||||
$db->query("DROP TABLE webcal_entry_repeats",__LINE__,__FILE__);
|
||||
$db->query("UPDATE applications SET app_tables='calendar_entry,calendar_entry_user,calendar_entry_repeats' WHERE app_name='calendar'",__LINE__,__FILE__);
|
||||
|
||||
$currentver = "0.9.7pre2";
|
||||
update_version_table();
|
||||
@ -684,48 +684,46 @@
|
||||
|
||||
if ($currentver == "0.9.7pre2") {
|
||||
$db2 = $db;
|
||||
$sql = "CREATE TABLE TEMP AS SELECT * FROM calendar_entry";
|
||||
$db->query($sql,__LINE__,__FILE__);
|
||||
|
||||
$sql = "DROP TABLE calendar_entry";
|
||||
$db->query($sql,__LINE__,__FILE__);
|
||||
|
||||
$sql = "CREATE TABLE calendar_entry (
|
||||
cal_id serial,
|
||||
cal_owner int DEFAULT 0 NOT NULL,
|
||||
cal_group varchar(255) NULL,
|
||||
cal_datetime int4,
|
||||
cal_mdatetime int4,
|
||||
cal_edatetime int4,
|
||||
cal_priority int DEFAULT 2,
|
||||
cal_type varchar(10),
|
||||
cal_access varchar(10),
|
||||
cal_name varchar(80) NOT NULL,
|
||||
cal_description text)";
|
||||
$db->query($sql,__LINE__,__FILE__);
|
||||
$db->query("SELECT cal_id,cal_owner,cal_group,cal_datetime,cal_mdatetime,cal_duration,cal_priority,cal_type,cal_access,cal_name,cal_description FROM TEMP ORDER BY cal_id",__LINE__,__FILE__);
|
||||
while($db->next_record()) {
|
||||
$db2->query("SELECT preference_value FROM preferences WHERE preference_name='tz_offset' AND preference_appname='common' AND preference_owner=".$db->f("cal_owner"),__LINE__,__FILE__);
|
||||
$db2->next_record();
|
||||
$tz = $db2->f("preference_value");
|
||||
$cal_id = $db->f("cal_id");
|
||||
$cal_owner = $db->f("cal_owner");
|
||||
$cal_group = $db->f("cal_group");
|
||||
$cal_datetime = $db->f("cal_datetime") - ((60 * 60) * $tz);
|
||||
$cal_mdatetime = $db->f("cal_mdatetime") - ((60 * 60) * $tz);
|
||||
$cal_edatetime = $cal_datetime + (60 * $db->f("cal_duration"));
|
||||
$cal_priority = $db->f("cal_priority");
|
||||
$cal_type = $db->f("cal_type");
|
||||
$cal_access = $db->f("cal_access");
|
||||
$cal_name = $db->f("cal_name");
|
||||
$cal_description = $db->f("cal_description");
|
||||
$db2->query("INSERT INTO calendar_entry(cal_id,cal_owner,cal_group,cal_datetime,cal_mdatetime,cal_edatetime,cal_priority,cal_type,cal_access,cal_name,cal_description) VALUES(".$cal_id.",".$cal_owner.",'".$cal_group."',".cal_datetime.",".$cal_mdatetime.",".$cal_edatetime.",".$cal_priority.",'".$cal_type."','".$cal_access."','".$cal_name."','".$cal_description."')",__LINE__,__FILE__);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "DROP TABLE TEMP";
|
||||
$db->query($sql,__LINE__,__FILE__);
|
||||
|
||||
$sql = "CREATE TABLE TEMP AS SELECT * FROM calendar_entry";
|
||||
$db->query($sql,__LINE__,__FILE__);
|
||||
|
||||
$sql = "DROP TABLE calendar_entry";
|
||||
$db->query($sql,__LINE__,__FILE__);
|
||||
|
||||
$sql = "CREATE TABLE calendar_entry (
|
||||
cal_id serial,
|
||||
cal_owner int DEFAULT 0 NOT NULL,
|
||||
cal_group varchar(255) NULL,
|
||||
cal_datetime int4,
|
||||
cal_mdatetime int4,
|
||||
cal_edatetime int4,
|
||||
cal_priority int DEFAULT 2,
|
||||
cal_type varchar(10),
|
||||
cal_access varchar(10),
|
||||
cal_name varchar(80) NOT NULL,
|
||||
cal_description text)";
|
||||
$db->query($sql,__LINE__,__FILE__);
|
||||
$db->query("SELECT cal_id,cal_owner,cal_group,cal_datetime,cal_mdatetime,cal_duration,cal_priority,cal_type,cal_access,cal_name,cal_description FROM TEMP ORDER BY cal_id",__LINE__,__FILE__);
|
||||
while($db->next_record()) {
|
||||
$db2->query("SELECT preference_value FROM preferences WHERE preference_name='tz_offset' AND preference_appname='common' AND preference_owner=".$db->f("cal_owner"),__LINE__,__FILE__);
|
||||
$db2->next_record();
|
||||
$tz = $db2->f("preference_value");
|
||||
$cal_id = $db->f("cal_id");
|
||||
$cal_owner = $db->f("cal_owner");
|
||||
$cal_group = $db->f("cal_group");
|
||||
$cal_datetime = $db->f("cal_datetime") - ((60 * 60) * $tz);
|
||||
$cal_mdatetime = $db->f("cal_mdatetime") - ((60 * 60) * $tz);
|
||||
$cal_edatetime = $cal_datetime + (60 * $db->f("cal_duration"));
|
||||
$cal_priority = $db->f("cal_priority");
|
||||
$cal_type = $db->f("cal_type");
|
||||
$cal_access = $db->f("cal_access");
|
||||
$cal_name = $db->f("cal_name");
|
||||
$cal_description = $db->f("cal_description");
|
||||
$db2->query("INSERT INTO calendar_entry(cal_id,cal_owner,cal_group,cal_datetime,cal_mdatetime,cal_edatetime,cal_priority,cal_type,cal_access,cal_name,cal_description) VALUES(".$cal_id.",".$cal_owner.",'".$cal_group."',".cal_datetime.",".$cal_mdatetime.",".$cal_edatetime.",".$cal_priority.",'".$cal_type."','".$cal_access."','".$cal_name."','".$cal_description."')",__LINE__,__FILE__);
|
||||
}
|
||||
}
|
||||
$sql = "DROP TABLE TEMP";
|
||||
$db->query($sql,__LINE__,__FILE__);
|
||||
$currentver = "0.9.7pre3";
|
||||
update_version_table();
|
||||
}
|
||||
@ -733,7 +731,6 @@
|
||||
$currentver = "0.9.7";
|
||||
update_version_table();
|
||||
}
|
||||
|
||||
if ($oldversion != $currentver){
|
||||
echo " </tr><td>\n";
|
||||
echo " <tr bgcolor=\"e6e6e6\">\n";
|
||||
@ -801,36 +798,6 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
function v0_9_9to0_9_10(){
|
||||
global $currentver, $oldversion, $phpgw_info, $db;
|
||||
|
||||
if ($currentver == "0.9.9" || ereg ("^0\.9\.10pre", $currentver)){
|
||||
/*
|
||||
if ($currentver == "0.9.9") {
|
||||
// upgrade code starts here
|
||||
|
||||
// upgrade code ends here
|
||||
$currentver = "0.9.10pre1";
|
||||
update_version_table();
|
||||
}
|
||||
*/
|
||||
/*
|
||||
if ($currentver == "0.9.10pre1") {
|
||||
// upgrade code starts here
|
||||
|
||||
// upgrade code ends here
|
||||
$currentver = "0.9.10pre2";
|
||||
update_version_table();
|
||||
}
|
||||
*/
|
||||
if ($oldversion != $currentver){
|
||||
echo " </tr><td>\n";
|
||||
echo " <tr bgcolor=\"e6e6e6\">\n";
|
||||
echo " <td>Upgrade from $oldversion to $currentver is completed.</td>\n";
|
||||
echo " </tr>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
v0_9_1to0_9_2();
|
||||
v0_9_2to0_9_3();
|
||||
|
Loading…
Reference in New Issue
Block a user