Enhanced fix for Trac #503. Don't drop the column before re-creating it, in case the data can be converted by MySQL.

SVN:1.2[1892]
This commit is contained in:
Denis Flaven
2012-03-14 16:15:53 +00:00
parent 26b6bfaf7f
commit 53b3ae8016

View File

@@ -899,13 +899,18 @@ EOF
{ {
if (CMDBSource::IsField($sTable, $sAttCode)) if (CMDBSource::IsField($sTable, $sAttCode))
{ {
$aRepairQueries[] = "ALTER TABLE `$sTable` DROP COLUMN `$sAttCode`;"; $aRepairQueries[] = "ALTER TABLE `$sTable` CHANGE `$sAttCode` `$sAttCode` $sColumnDef";
}
else
{
$aFieldDefs[] = "`$sAttCode` $sColumnDef";
} }
$aFieldDefs[] = "`$sAttCode` $sColumnDef";
} }
if (count($aFieldDefs) > 0)
$aRepairQueries[] = "ALTER TABLE `$sTable` ADD (".implode(',', $aFieldDefs).");"; {
$aRepairQueries[] = "ALTER TABLE `$sTable` ADD (".implode(',', $aFieldDefs).");";
}
// The triggers as well must be adjusted // The triggers as well must be adjusted
$aTriggersDefs = $this->GetTriggersDefinition(); $aTriggersDefs = $this->GetTriggersDefinition();