mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-18 16:18:47 +02:00
Improved the upgrade/toolkit: make sure that NULL is allowed for SQL columns found in the DB but not defined in the data model (attribute removed or renamed)
SVN:trunk[1637]
This commit is contained in:
@@ -3522,11 +3522,20 @@ if (!array_key_exists($sAttCode, self::$m_aAttribDefs[$sClass]))
|
||||
}
|
||||
}
|
||||
// Find out unused columns
|
||||
//
|
||||
foreach($aTableInfo['Fields'] as $sField => $aFieldData)
|
||||
{
|
||||
if (!isset($aFieldData['used']) || !$aFieldData['used'])
|
||||
{
|
||||
$aErrors[$sClass]['*'][] = "Column '$sField' in table '$sTable' is not used";
|
||||
if (!CMDBSource::IsNullAllowed($sTable, $sField))
|
||||
{
|
||||
// Allow null values so that new record can be inserted
|
||||
// without specifying the value of this unknown column
|
||||
$sFieldDefinition = "`$sField` ".CMDBSource::GetFieldType($sTable, $sField).' NULL';
|
||||
$aSugFix[$sClass][$sAttCode][] = "ALTER TABLE `$sTable` CHANGE `$sField` $sFieldDefinition";
|
||||
$aAlterTableItems[$sTable][$sField] = "CHANGE `$sField` $sFieldDefinition";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user