{
TableChange change = (TableChange)changeIt.next();
if (change instanceof AddColumnChange)
{
AddColumnChange addColumnChange = (AddColumnChange)change;
if (addColumnChange.getNewColumn().isRequired() &&
(addColumnChange.getNewColumn().getDefaultValue() == null) &&
!addColumnChange.getNewColumn().isAutoIncrement())
{
requiresFullRebuild = true;
}
}
}
if (!requiresFullRebuild)
{
processTableStructureChanges(currentModel, desiredModel, sourceTable, targetTable, parameters, changes);
}
if (!changes.isEmpty())
{
// we can only copy the data if no required columns without default value and
// non-autoincrement have been added
boolean canMigrateData = true;
for (Iterator it = changes.iterator(); canMigrateData && it.hasNext();)
{
TableChange change = (TableChange)it.next();
if (change instanceof AddColumnChange)
{
AddColumnChange addColumnChange = (AddColumnChange)change;
if (addColumnChange.getNewColumn().isRequired() &&
!addColumnChange.getNewColumn().isAutoIncrement() &&
(addColumnChange.getNewColumn().getDefaultValue() == null))
{
_log.warn("Data cannot be retained in table " + change.getChangedTable().getName() +
" because of the addition of the required column " + addColumnChange.getNewColumn().getName());
canMigrateData = false;
}
}
}