* @param targetTable The target table
* @return The table
*/
protected Table getRealTargetTableFor(Database targetModel, Table sourceTable, Table targetTable) throws IOException
{
Table table = new Table();
table.setCatalog(targetTable.getCatalog());
table.setSchema(targetTable.getSchema());
table.setName(targetTable.getName());
table.setType(targetTable.getType());
for (int idx = 0; idx < targetTable.getColumnCount(); idx++)
{
try
{
table.addColumn((Column)targetTable.getColumn(idx).clone());
}
catch (CloneNotSupportedException ex)
{
throw new DdlUtilsException(ex);
}
}
boolean caseSensitive = getPlatform().isDelimitedIdentifierModeOn();
for (int idx = 0; idx < targetTable.getIndexCount(); idx++)
{
Index targetIndex = targetTable.getIndex(idx);
Index sourceIndex = sourceTable.findIndex(targetIndex.getName(), caseSensitive);
if (sourceIndex != null)
{
if ((caseSensitive && sourceIndex.equals(targetIndex)) ||
(!caseSensitive && sourceIndex.equalsIgnoreCase(targetIndex)))
{
table.addIndex(targetIndex);
}
}
}
return table;