#464 While upgrading iTop, copy the values from change/start_date to ticket/start_date (iif the current value is null)

SVN:trunk[1537]
This commit is contained in:
Romain Quetiez
2011-08-29 16:28:08 +00:00
parent 24244f1bac
commit 17aa1d1fc0

View File

@@ -18,6 +18,7 @@ SetupWebPage::AddModule(
),
'mandatory' => false,
'visible' => true,
'installer' => 'ChangeManagementInstaller',
// Components
//
@@ -43,4 +44,52 @@ SetupWebPage::AddModule(
)
);
// Module installation handler
//
class ChangeManagementInstaller extends ModuleInstallerAPI
{
public static function BeforeWritingConfig(Config $oConfiguration)
{
// If you want to override/force some configuration values, do it here
return $oConfiguration;
}
/**
* Handler called before creating or upgrading the database schema
* @param $oConfiguration Config The new configuration of the application
* @param $sPreviousVersion string PRevious version number of the module (empty string in case of first install)
* @param $sCurrentVersion string Current version number of the module
*/
public static function BeforeDatabaseCreation(Config $oConfiguration, $sPreviousVersion, $sCurrentVersion)
{
// If you want to migrate data from one format to another, do it here
}
/**
* Handler called after the creation/update of the database schema
* @param $oConfiguration Config The new configuration of the application
* @param $sPreviousVersion string PRevious version number of the module (empty string in case of first install)
* @param $sCurrentVersion string Current version number of the module
*/
public static function AfterDatabaseCreation(Config $oConfiguration, $sPreviousVersion, $sCurrentVersion)
{
// Bug #464 - start_date was both in Ticket and Change tables
//
$sSourceTable = 'change';
$sSourceKeyField = 'id';
$sTargetTable = 'ticket';
$sTargetKeyField = 'id';
$sField = 'start_date';
if (CMDBSource::IsField($sSourceTable, $sField) && CMDBSource::IsField($sTargetTable, $sField) && CMDBSource::IsField($sSourceTable, $sSourceKeyField) && CMDBSource::IsField($sTargetTable, $sTargetKeyField))
{
SetupWebPage::log_info("Issue #464 - Copying change/start_date into ticket/start_date");
$sRepair = "UPDATE `$sTargetTable`, `$sSourceTable` SET `$sTargetTable`.`$sField` = `$sSourceTable`.`$sField` WHERE `$sTargetTable`.`$sField` IS NULL AND`$sTargetTable`.`$sTargetKeyField` = `$sSourceTable`.`$sSourceKeyField`";
CMDBSource::Query($sRepair);
}
}
}
?>