}
final StringBuilder sbSQL = new StringBuilder(100);
for (final PgSequence newSequence : newSchema.getSequences()) {
final PgSequence oldSequence =
oldSchema.getSequence(newSequence.getName());
if (oldSequence == null) {
continue;
}
sbSQL.setLength(0);
final String oldIncrement = oldSequence.getIncrement();
final String newIncrement = newSequence.getIncrement();
if (newIncrement != null
&& !newIncrement.equals(oldIncrement)) {
sbSQL.append("\n\tINCREMENT BY ");
sbSQL.append(newIncrement);
}
final String oldMinValue = oldSequence.getMinValue();
final String newMinValue = newSequence.getMinValue();
if (newMinValue == null && oldMinValue != null) {
sbSQL.append("\n\tNO MINVALUE");
} else if (newMinValue != null
&& !newMinValue.equals(oldMinValue)) {
sbSQL.append("\n\tMINVALUE ");
sbSQL.append(newMinValue);
}
final String oldMaxValue = oldSequence.getMaxValue();
final String newMaxValue = newSequence.getMaxValue();
if (newMaxValue == null && oldMaxValue != null) {
sbSQL.append("\n\tNO MAXVALUE");
} else if (newMaxValue != null
&& !newMaxValue.equals(oldMaxValue)) {
sbSQL.append("\n\tMAXVALUE ");
sbSQL.append(newMaxValue);
}
if (!arguments.isIgnoreStartWith()) {
final String oldStart = oldSequence.getStartWith();
final String newStart = newSequence.getStartWith();
if (newStart != null && !newStart.equals(oldStart)) {
sbSQL.append("\n\tRESTART WITH ");
sbSQL.append(newStart);
}
}
final String oldCache = oldSequence.getCache();
final String newCache = newSequence.getCache();
if (newCache != null && !newCache.equals(oldCache)) {
sbSQL.append("\n\tCACHE ");
sbSQL.append(newCache);
}
final boolean oldCycle = oldSequence.isCycle();
final boolean newCycle = newSequence.isCycle();
if (oldCycle && !newCycle) {
sbSQL.append("\n\tNO CYCLE");
} else if (!oldCycle && newCycle) {
sbSQL.append("\n\tCYCLE");
}
final String oldOwnedBy = oldSequence.getOwnedBy();
final String newOwnedBy = newSequence.getOwnedBy();
if (newOwnedBy != null && !newOwnedBy.equals(oldOwnedBy)) {
sbSQL.append("\n\tOWNED BY ");
sbSQL.append(newOwnedBy);
}
if (sbSQL.length() > 0) {
searchPathHelper.outputSearchPath(writer);
writer.println();
writer.print("ALTER SEQUENCE "
+ PgDiffUtils.getQuotedName(newSequence.getName()));
writer.print(sbSQL.toString());
writer.println(';');
}
if (oldSequence.getComment() == null
&& newSequence.getComment() != null
|| oldSequence.getComment() != null
&& newSequence.getComment() != null
&& !oldSequence.getComment().equals(
newSequence.getComment())) {
searchPathHelper.outputSearchPath(writer);
writer.println();
writer.print("COMMENT ON SEQUENCE ");
writer.print(PgDiffUtils.getQuotedName(newSequence.getName()));
writer.print(" IS ");
writer.print(newSequence.getComment());
writer.println(';');
} else if (oldSequence.getComment() != null
&& newSequence.getComment() == null) {
searchPathHelper.outputSearchPath(writer);
writer.println();
writer.print("COMMENT ON SEQUENCE ");
writer.print(newSequence.getName());