if (newTable == null) {
continue;
}
for (final PgConstraint oldConstraint : oldTable.getConstraints()) {
final PgConstraint newConstraint =
newTable.getConstraint(oldConstraint.getName());
if (newConstraint == null) {
continue;
}
if (oldConstraint.getComment() == null
&& newConstraint.getComment() != null
|| oldConstraint.getComment() != null
&& newConstraint.getComment() != null
&& !oldConstraint.getComment().equals(
newConstraint.getComment())) {
searchPathHelper.outputSearchPath(writer);
writer.println();
writer.print("COMMENT ON ");
if (newConstraint.isPrimaryKeyConstraint()) {
writer.print("INDEX ");
writer.print(PgDiffUtils.getQuotedName(
newConstraint.getName()));
} else {
writer.print("CONSTRAINT ");
writer.print(PgDiffUtils.getQuotedName(
newConstraint.getName()));
writer.print(" ON ");
writer.print(PgDiffUtils.getQuotedName(
newConstraint.getTableName()));
}
writer.print(" IS ");
writer.print(newConstraint.getComment());
writer.println(';');
} else if (oldConstraint.getComment() != null
&& newConstraint.getComment() == null) {
searchPathHelper.outputSearchPath(writer);
writer.println();
writer.print("COMMENT ON ");
if (newConstraint.isPrimaryKeyConstraint()) {
writer.print("INDEX ");
writer.print(PgDiffUtils.getQuotedName(
newConstraint.getName()));
} else {
writer.print("CONSTRAINT ");
writer.print(PgDiffUtils.getQuotedName(
newConstraint.getName()));
writer.print(" ON ");
writer.print(PgDiffUtils.getQuotedName(
newConstraint.getTableName()));
}
writer.println(" IS NULL;");
}
}