[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-developers] About renaming columns in update functions
From: |
Sigurd Nes |
Subject: |
[Phpgroupware-developers] About renaming columns in update functions |
Date: |
Fri, 10 Feb 2006 10:25:35 +0100 (CET) |
This should something for the doc-team.
tables_update.inc.php
In order to do a successful renaming for a column in pgsql - one has to throw
in the table definition.
It is also wise to insulate the potentially damaging altering of the db in a
transaction.
example:
/**
* Update property version from 0.9.17.510 to 0.9.17.511
*/
$test[] = '0.9.17.510';
function property_upgrade0_9_17_510()
{
$table_def = array(
'fm_custom' => array(
'fd' => array(
'id' => array('type' => 'int','precision' =>
'4','nullable' => False),
'name' => array('type' => 'varchar','precision'
=> '100','nullable' => False),
'sql_text' => array('type' => 'text','nullable'
=> False),
'entry_date' => array('type' =>
'int','precision' => '4','nullable' => True),
'user_id' => array('type' => 'int','precision'
=> '4','nullable' => True)
),
'pk' => array('id'),
'fk' => array(),
'ix' => array(),
'uc' => array()
)
);
$GLOBALS['phpgw_setup']->oProc->m_aTables = $table_def;
$GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
$GLOBALS['phpgw_setup']->oProc->RenameColumn('fm_custom','sql','sql_text');
$GLOBALS['setup_info']['property']['currentver'] = '0.9.17.511';
$GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit();
return $GLOBALS['setup_info']['property']['currentver'];
}
Regards
Sigurd
- [Phpgroupware-developers] About renaming columns in update functions,
Sigurd Nes <=