|
@@ -3443,7 +3443,7 @@ if (!array_key_exists($sAttCode, self::$m_aAttribDefs[$sClass]))
|
|
// Check that any defined field exists
|
|
// Check that any defined field exists
|
|
//
|
|
//
|
|
$aTableInfo = CMDBSource::GetTableInfo($sTable);
|
|
$aTableInfo = CMDBSource::GetTableInfo($sTable);
|
|
-
|
|
|
|
|
|
+ $aTableInfo['Fields'][$sKeyField]['used'] = true;
|
|
foreach(self::ListAttributeDefs($sClass) as $sAttCode=>$oAttDef)
|
|
foreach(self::ListAttributeDefs($sClass) as $sAttCode=>$oAttDef)
|
|
{
|
|
{
|
|
// Skip this attribute if not originaly defined in this class
|
|
// Skip this attribute if not originaly defined in this class
|
|
@@ -3451,6 +3451,9 @@ if (!array_key_exists($sAttCode, self::$m_aAttribDefs[$sClass]))
|
|
|
|
|
|
foreach($oAttDef->GetSQLColumns() as $sField => $sDBFieldType)
|
|
foreach($oAttDef->GetSQLColumns() as $sField => $sDBFieldType)
|
|
{
|
|
{
|
|
|
|
+ // Keep track of columns used by iTop
|
|
|
|
+ $aTableInfo['Fields'][$sField]['used'] = true;
|
|
|
|
+
|
|
$bIndexNeeded = $oAttDef->RequiresIndex();
|
|
$bIndexNeeded = $oAttDef->RequiresIndex();
|
|
$sFieldDefinition = "`$sField` ".($oAttDef->IsNullAllowed() ? "$sDBFieldType NULL" : "$sDBFieldType NOT NULL");
|
|
$sFieldDefinition = "`$sField` ".($oAttDef->IsNullAllowed() ? "$sDBFieldType NULL" : "$sDBFieldType NOT NULL");
|
|
if (!CMDBSource::IsField($sTable, $sField))
|
|
if (!CMDBSource::IsField($sTable, $sField))
|
|
@@ -3518,6 +3521,14 @@ 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";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
$aCondensedQueries = array();
|
|
$aCondensedQueries = array();
|