Skip to content

Commit

Permalink
0001375: DB2 table needs reorg after changing the primary key
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Aug 8, 2013
1 parent 702b6ca commit 1e79b0a
Showing 1 changed file with 19 additions and 10 deletions.
Expand Up @@ -156,19 +156,20 @@ protected void processTableStructureChanges(Database currentModel, Database desi
if (change instanceof AddColumnChange) {
AddColumnChange addColumnChange = (AddColumnChange) change;

/* DB2 does not allow the GENERATED BY DEFAULT AS IDENTITY
clause in
the ALTER TABLE ADD COLUMN statement, so we have to rebuild
the table instead */
/*
* DB2 does not allow the GENERATED BY DEFAULT AS IDENTITY
* clause in the ALTER TABLE ADD COLUMN statement, so we have to
* rebuild the table instead
*/
if (!addColumnChange.getNewColumn().isAutoIncrement()) {
processChange(currentModel, desiredModel, addColumnChange, ddl);
changeIt.remove();
} else {
return;
}
}
}
}

for (Iterator<TableChange> changeIt = changes.iterator(); changeIt.hasNext();) {
TableChange change = changeIt.next();

Expand All @@ -180,15 +181,15 @@ protected void processTableStructureChanges(Database currentModel, Database desi
changeIt.remove();
}
}

for (Iterator<TableChange> changeIt = changes.iterator(); changeIt.hasNext();) {
TableChange change = changeIt.next();

if (change instanceof RemoveColumnChange) {
processChange(currentModel, desiredModel, (RemoveColumnChange)change, ddl);
changeIt.remove();
processChange(currentModel, desiredModel, (RemoveColumnChange) change, ddl);
changeIt.remove();
} else if (change instanceof CopyColumnValueChange) {
CopyColumnValueChange copyColumnChange = (CopyColumnValueChange)change;
CopyColumnValueChange copyColumnChange = (CopyColumnValueChange) change;
processChange(currentModel, desiredModel, copyColumnChange, ddl);
changeIt.remove();
}
Expand Down Expand Up @@ -280,4 +281,12 @@ protected void processChange(Database currentModel, Database desiredModel,
change.apply(currentModel, delimitedIdentifierModeOn);
}

@Override
protected void writeExternalPrimaryKeysCreateStmt(Table table, Column[] primaryKeyColumns,
StringBuilder ddl) {
super.writeExternalPrimaryKeysCreateStmt(table, primaryKeyColumns, ddl);
ddl.append("REORG TABLE ");
printlnIdentifier(getTableName(table.getName()), ddl);
printEndOfStatement(ddl);
}
}

0 comments on commit 1e79b0a

Please sign in to comment.