Changeset 533 for trunk/contactcenter/setup/tables_update.inc.php
- Timestamp:
- 10/13/08 17:13:03 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/contactcenter/setup/tables_update.inc.php
r316 r533 70 70 function contactcenter_upgrade1_15() { 71 71 $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_cc_contact','last_status', array('type' => 'char', 'precision' => 1, 'default' => 'N')); 72 $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_cc_contact','category', array('type' => 'varchar', 'precision' => 20)); 73 $GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_cc_contact ADD COLUMN last_update int8 DEFAULT (date_part('epoch'::text, ('now'::text)::timestamp(3) with time zone) * (1000)::double precision)"); 72 $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_cc_contact','category', array('type' => 'varchar', 'precision' => 20)); 73 // Verify if last_update column exists..... 74 $GLOBALS['phpgw_setup']->oProc->m_oTranslator->_GetColumns($GLOBALS['phpgw_setup']->oProc,'phpgw_cc_contact', &$sColumns); 75 if(array_search("last_update",explode(",",$sColumns)) === FALSE) { 76 $GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_cc_contact ADD COLUMN last_update int8 DEFAULT (date_part('epoch'::text, ('now'::text)::timestamp(3) with time zone) * (1000)::double precision)"); 77 } 74 78 $GLOBALS['setup_info']['contactcenter']['currentver'] = '1.20'; 75 79 return $GLOBALS['setup_info']['contactcenter']['currentver']; … … 80 84 return $GLOBALS['setup_info']['contactcenter']['currentver']; 81 85 } 86 $test[] = '1.20.001'; 87 function contactcenter_upgrade1_20_001() { 88 $GLOBALS['setup_info']['contactcenter']['currentver'] = '1.21'; 89 // Verify if plpgsql language is installed. 90 $res = $GLOBALS['phpgw_setup']->db->query("select lanname from pg_language where lanname = 'plpgsql'"); 91 if(!strstr($res,'plpgsql')){ 92 $GLOBALS['phpgw_setup']->db->query("create language 'plpgsql'"); 93 } 94 // Verify if trigger Insert() for Shared Contacts exists, else create it..... 95 $res = $GLOBALS['phpgw_setup']->db->query("select tgname from pg_trigger where tgname = 'trig_share_catalog_insert'"); 96 if(!strstr($res,'trig_share_catalog_insert')){ 97 $GLOBALS['phpgw_setup']->db->query("create function share_catalog_insert() returns trigger as ' begin if ". 98 "new.acl_appname = ''contactcenter'' and new.acl_location <> ''run'' then ". 99 "insert into phpgw_cc_contact_rels (id_contact,id_related,id_typeof_contact_relation) ". 100 "values (new.acl_location::integer,new.acl_account,1); end if; return new; end;' language 'plpgsql';"); 101 102 $GLOBALS['phpgw_setup']->db->query("create trigger trig_share_catalog_insert after insert on phpgw_acl for " . 103 "each row execute procedure share_catalog_insert()"); 104 } 105 // Verify if trigger Delete() for Shared Contacts exists, else create it..... 106 $res = $GLOBALS['phpgw_setup']->db->query("select tgname from pg_trigger where tgname = 'trig_share_catalog_delete'"); 107 if(!strstr($res,'trig_share_catalog_delete')){ 108 $GLOBALS['phpgw_setup']->db->query("create function share_catalog_delete() returns trigger as ' begin if " . 109 "old.acl_appname = ''contactcenter'' then delete from phpgw_cc_contact_rels where " . 110 "id_contact=old.acl_location and id_related=old.acl_account and " . 111 "id_typeof_contact_relation=1; end if; return new; end;' language 'plpgsql'"); 112 113 $GLOBALS['phpgw_setup']->db->query("create trigger trig_share_catalog_delete after delete on phpgw_acl for " . 114 "each row execute procedure share_catalog_delete()"); 115 } 116 return $GLOBALS['setup_info']['contactcenter']['currentver']; 117 } 82 118 ?>
Note: See TracChangeset
for help on using the changeset viewer.