change timesheet title and project title to varchar(255) to not loose content when creating a timesheet from eg. an InfoLog entry

also change description to varchar(16384), if there is no longer content already, to save full table scans
This commit is contained in:
Ralf Becker 2014-02-25 09:34:10 +00:00
parent 7044947083
commit a714cf7e6c
3 changed files with 45 additions and 7 deletions

View File

@ -6,7 +6,7 @@
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package timesheet * @package timesheet
* @subpackage setup * @subpackage setup
* @copyright (c) 2005-13 by Ralf Becker <RalfBecker-AT-outdoor-training.de> * @copyright (c) 2005-14 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$ * @version $Id$
*/ */
@ -17,7 +17,7 @@ if (!defined('TIMESHEET_APP'))
} }
$setup_info[TIMESHEET_APP]['name'] = TIMESHEET_APP; $setup_info[TIMESHEET_APP]['name'] = TIMESHEET_APP;
$setup_info[TIMESHEET_APP]['version'] = '1.9.001'; $setup_info[TIMESHEET_APP]['version'] = '1.9.002';
$setup_info[TIMESHEET_APP]['app_order'] = 5; $setup_info[TIMESHEET_APP]['app_order'] = 5;
$setup_info[TIMESHEET_APP]['tables'] = array('egw_timesheet','egw_timesheet_extra'); $setup_info[TIMESHEET_APP]['tables'] = array('egw_timesheet','egw_timesheet_extra');
$setup_info[TIMESHEET_APP]['enable'] = 1; $setup_info[TIMESHEET_APP]['enable'] = 1;
@ -56,3 +56,4 @@ $setup_info[TIMESHEET_APP]['depends'][] = array(
'appname' => 'etemplate', 'appname' => 'etemplate',
'versions' => Array('1.7','1.8','1.9') 'versions' => Array('1.7','1.8','1.9')
); );

View File

@ -6,7 +6,7 @@
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package timesheet * @package timesheet
* @subpackage setup * @subpackage setup
* @copyright (c) 2005-13 by Ralf Becker <RalfBecker-AT-outdoor-training.de> * @copyright (c) 2005-14 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$ * @version $Id$
*/ */
@ -15,9 +15,9 @@ $phpgw_baseline = array(
'egw_timesheet' => array( 'egw_timesheet' => array(
'fd' => array( 'fd' => array(
'ts_id' => array('type' => 'auto','nullable' => False,'comment' => 'id of the timesheet entry'), 'ts_id' => array('type' => 'auto','nullable' => False,'comment' => 'id of the timesheet entry'),
'ts_project' => array('type' => 'varchar','precision' => '80','comment' => 'project title'), 'ts_project' => array('type' => 'varchar','precision' => '255','comment' => 'project title'),
'ts_title' => array('type' => 'varchar','precision' => '80','nullable' => False,'comment' => 'title of the timesheet entry'), 'ts_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'comment' => 'title of the timesheet entry'),
'ts_description' => array('type' => 'text','comment' => 'description of the timesheet entry'), 'ts_description' => array('type' => 'varchar','precision' => '16384','comment' => 'description of the timesheet entry'),
'ts_start' => array('type' => 'int','meta' => 'timestamp','precision' => '8','nullable' => False,'comment' => 'timestamp of the startdate'), 'ts_start' => array('type' => 'int','meta' => 'timestamp','precision' => '8','nullable' => False,'comment' => 'timestamp of the startdate'),
'ts_duration' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0','comment' => 'duration of the timesheet-entry'), 'ts_duration' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0','comment' => 'duration of the timesheet-entry'),
'ts_quantity' => array('type' => 'float','precision' => '8','nullable' => False,'comment' => 'quantity'), 'ts_quantity' => array('type' => 'float','precision' => '8','nullable' => False,'comment' => 'quantity'),

View File

@ -6,7 +6,7 @@
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package timesheet * @package timesheet
* @subpackage setup * @subpackage setup
* @copyright (c) 2005-10 by Ralf Becker <RalfBecker-AT-outdoor-training.de> * @copyright (c) 2005-14 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$ * @version $Id$
*/ */
@ -79,3 +79,40 @@ function timesheet_upgrade1_8()
{ {
return $GLOBALS['setup_info']['timesheet']['currentver'] = '1.9.001'; return $GLOBALS['setup_info']['timesheet']['currentver'] = '1.9.001';
} }
/**
* Change titel and project title to varchar(255) to not loose content when creating a timesheet eg. from an InfoLog
*
* Change description to varchar(16384) to not force full table-scan on search
*
* @return string
*/
function timesheet_upgrade1_9_001()
{
$GLOBALS['egw_setup']->oProc->AlterColumn('egw_timesheet','ts_project',array(
'type' => 'varchar',
'precision' => '255',
'nullable' => False,
'comment' => 'project title'
));
$GLOBALS['egw_setup']->oProc->AlterColumn('egw_timesheet','ts_title',array(
'type' => 'varchar',
'precision' => '255',
'nullable' => False,
'comment' => 'title of the timesheet entry'
));
// change description to varchar(16384), if there is no longer content already
$max_description_length = $GLOBALS['egw']->db->query('SELECT MAX(CHAR_LENGTH(ts_description)) FROM egw_timesheet')->fetchColumn();
// returns NULL, if there are no rows!
if ((int)$max_description_length <= 16384 && $GLOBALS['egw_setup']->oProc->max_varchar_length >= 16384)
{
$GLOBALS['egw_setup']->oProc->AlterColumn('egw_timesheet','ts_description',array(
'type' => 'varchar',
'precision' => '16384',
'comment' => 'description of the timesheet entry'
));
}
return $GLOBALS['setup_info']['timesheet']['currentver'] = '1.9.002';
}