From efa2d7dedee55b61734a0186b19123b7c5210158 Mon Sep 17 00:00:00 2001 From: jengo Date: Thu, 3 May 2001 04:53:49 +0000 Subject: [PATCH] Cleaned up quite a bit in PostgreSQL create, upgrade and drop tables. --- setup/inc/phpgw_setup.inc.php | 2 +- setup/sql/pgsql_droptables.inc.php | 57 ++++++++++------------------ setup/sql/pgsql_upgrade_beta.inc.php | 11 ++++-- 3 files changed, 30 insertions(+), 40 deletions(-) diff --git a/setup/inc/phpgw_setup.inc.php b/setup/inc/phpgw_setup.inc.php index 6b7b4429fb..5518eb0032 100644 --- a/setup/inc/phpgw_setup.inc.php +++ b/setup/inc/phpgw_setup.inc.php @@ -272,7 +272,7 @@ if(ereg("([0-9]+)(pre)([0-9]+)",$ver[2],$regs)) if(($regs[1] == "10") && ($regs[3] >= "6")) $config_table="phpgw_config"; - $this->db->query("select config_value from $config_table where config_name='freshinstall'"); + @$this->db->query("select config_value from $config_table where config_name='freshinstall'"); $this->db->next_record(); $configed = $this->db->f("config_value"); if ($configed){ diff --git a/setup/sql/pgsql_droptables.inc.php b/setup/sql/pgsql_droptables.inc.php index 26e58cc224..781d0446df 100644 --- a/setup/sql/pgsql_droptables.inc.php +++ b/setup/sql/pgsql_droptables.inc.php @@ -11,49 +11,46 @@ /* $Id$ */ + // !! NOTE !! This should ONLY contain the current tables and sequences. Do NOT remove older tables + // That are no longer being used. People might have tables matching the same names in there installs. + $phpgw_setup->db->query("DROP TABLE phpgw_config"); $phpgw_setup->db->query("DROP TABLE phpgw_applications"); - $phpgw_setup->db->query("drop sequence phpgw_accounts_account_id_seq"); + $phpgw_setup->db->query("DROP TABLE phpgw_accounts"); + $phpgw_setup->db->query("drop sequence phpgw_accounts_account_id_seq"); + $phpgw_setup->db->query("DROP TABLE phpgw_preferences"); $phpgw_setup->db->query("DROP TABLE phpgw_sessions"); $phpgw_setup->db->query("DROP TABLE phpgw_app_sessions"); $phpgw_setup->db->query("DROP TABLE phpgw_acl"); $phpgw_setup->db->query("DROP TABLE phpgw_access_log"); - $phpgw_setup->db->query("drop sequence phpgw_categories_cat_id_seq"); - $phpgw_setup->db->query("DROP TABLE phpgw_categories"); - $phpgw_setup->db->query("drop sequence profiles_con_seq"); - $phpgw_setup->db->query("drop sequence phpgw_hooks_hook_id_seq"); - $phpgw_setup->db->query("DROP TABLE phpgw_hooks"); - $phpgw_setup->db->query("DROP TABLE profiles"); - $phpgw_setup->db->query("DROP TABLE addressbook"); - $phpgw_setup->db->query("drop sequence addressbook_id_seq"); - $phpgw_setup->db->query("drop sequence phpgw_addressbook_id_seq"); + $phpgw_setup->db->query("DROP TABLE phpgw_categories"); + $phpgw_setup->db->query("drop sequence phpgw_categories_cat_id_seq"); + + $phpgw_setup->db->query("DROP TABLE phpgw_hooks"); + $phpgw_setup->db->query("drop sequence phpgw_hooks_hook_id_seq"); + + $phpgw_setup->db->query("DROP TABLE profiles"); + $phpgw_setup->db->query("drop sequence profiles_con_seq"); + $phpgw_setup->db->query("DROP TABLE phpgw_addressbook"); $phpgw_setup->db->query("DROP TABLE phpgw_addressbook_extra"); - $phpgw_setup->db->query("DROP TABLE phpgw_cal"); + $phpgw_setup->db->query("drop sequence phpgw_addressbook_id_seq"); + $phpgw_setup->db->query("DROP TABLE phpgw_cal_user"); $phpgw_setup->db->query("DROP TABLE phpgw_cal_repeats"); $phpgw_setup->db->query("DROP TABLE phpgw_cal_holidays"); - + $phpgw_setup->db->query("drop sequence phpgw_cal_holidays_hol_id_seq"); $phpgw_setup->db->query("drop sequence phpgw_cal_cal_id_seq"); + $phpgw_setup->db->query("DROP TABLE phpgw_nextid"); - $phpgw_setup->db->query("drop sequence todo_todo_id_seq"); - $phpgw_setup->db->query("DROP TABLE todo"); $phpgw_setup->db->query("DROP TABLE phpgw_todo"); - $phpgw_setup->db->query("DROP sequence phpgw_todo_id_seq"); $phpgw_setup->db->query("DROP sequence phpgw_todo_todo_id_seq"); $phpgw_setup->db->query("DROP TABLE phpgw_cal"); - $phpgw_setup->db->query("DROP TABLE phpgw_cal_user"); - $phpgw_setup->db->query("DROP TABLE phpgw_cal_repeats"); - @$phpgw_setup->db->query("DROP TABLE calendar_entry"); - @$phpgw_setup->db->query("DROP TABLE calendar_entry_user"); - @$phpgw_setup->db->query("DROP TABLE calendar_entry_repeats"); - $phpgw_setup->db->query("DROP sequence phpgw_cal_id_seq"); - $phpgw_setup->db->query("drop sequence calendar_entry_cal_id_seq"); $phpgw_setup->db->query("drop sequence newsgroups_con_seq"); $phpgw_setup->db->query("DROP TABLE newsgroups"); @@ -61,19 +58,7 @@ $phpgw_setup->db->query("drop sequence news_msg_con_seq"); $phpgw_setup->db->query("DROP TABLE news_msg"); $phpgw_setup->db->query("DROP TABLE languages"); - $phpgw_setup->db->query("drop sequence categories_cat_id_seq"); - $phpgw_setup->db->query("DROP TABLE categories"); - $phpgw_setup->db->query("DROP sequence phpgw_notes_note_id_seq"); + $phpgw_setup->db->query("DROP TABLE phpgw_notes"); - - $phpgw_setup->db->query("DROP TABLE config"); - $phpgw_setup->db->query("DROP TABLE applications"); - $phpgw_setup->db->query("drop sequence groups_group_id_seq"); - $phpgw_setup->db->query("DROP TABLE groups"); - $phpgw_setup->db->query("drop sequence accounts_account_id_seq"); - $phpgw_setup->db->query("DROP TABLE accounts"); - $phpgw_setup->db->query("DROP TABLE preferences"); - $phpgw_setup->db->query("DROP sequence notes_note_id_seq"); - $phpgw_setup->db->query("DROP TABLE notes"); - + $phpgw_setup->db->query("DROP sequence phpgw_notes_note_id_seq"); ?> diff --git a/setup/sql/pgsql_upgrade_beta.inc.php b/setup/sql/pgsql_upgrade_beta.inc.php index de2b5b8a32..a06e05216e 100644 --- a/setup/sql/pgsql_upgrade_beta.inc.php +++ b/setup/sql/pgsql_upgrade_beta.inc.php @@ -2080,7 +2080,7 @@ account_type char(1), unique(account_lid) )"; - $phpgw_setup->db->query($sql); + $phpgw_setup->db->query($sql,__LINE__,__FILE__); $phpgw_setup->db->query("insert into phpgw_accounts select * from phpgw_accounts_temp",__LINE__,__FILE__); $phpgw_setup->db->query("drop table phpgw_accounts_temp",__LINE__,__FILE__); @@ -2095,6 +2095,8 @@ global $phpgw_info, $phpgw_setup; $phpgw_setup->db->query("create table phpgw_cal_temp as select * from phpgw_cal",__LINE__,__FILE__); + $phpgw_setup->db->query("drop table phpgw_cal",__LINE__,__FILE__); + $phpgw_setup->db->query("drop sequence phpgw_cal_cal_id_seq",__LINE__,__FILE__); $sql = "CREATE TABLE phpgw_cal ( cal_id serial, owner int DEFAULT 0 NOT NULL, @@ -2131,6 +2133,7 @@ $phpgw_setup->db->query("drop table phpgw_cal_temp",__LINE__,__FILE__); + $phpgw_setup->db->query("drop sequence phpgw_cal_holidays_hol_id_seq",__LINE__,__FILE__); $phpgw_setup->db->query("drop table phpgw_cal_holidays",__LINE__,__FILE__); $sql = "CREATE TABLE phpgw_cal_holidays ( @@ -2139,7 +2142,7 @@ name varchar(50) NOT NULL, date_time int4 DEFAULT 0 NOT NULL )"; - $phpgw_setup->db->query($sql); + $phpgw_setup->db->query($sql,__LINE__,__FILE__); $phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.11.007'; } @@ -2150,6 +2153,8 @@ global $phpgw_info, $phpgw_setup; $phpgw_setup->db->query("drop table phpgw_cal_holidays",__LINE__,__FILE__); + $phpgw_setup->db->query("drop sequence phpgw_cal_holidays_hol_id_seq",__LINE__,__FILE__); + $sql = "CREATE TABLE phpgw_cal_holidays ( hol_id serial, locale char(2) NOT NULL, @@ -2159,7 +2164,7 @@ occurence int DEFAULT 0, dow int DEFAULT 0 )"; - $phpgw_setup->db->query($sql); + $phpgw_setup->db->query($sql,__LINE__,__FILE__); $phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.11.008'; }