in elastic-db-tools/src/main/java/com/microsoft/azure/elasticdb/shard/utils/SqlUtils.java [230:255]
public static List<StringBuilder> filterUpgradeCommands(List<UpgradeSteps> commandList,
Version targetVersion,
Version currentVersion) {
ArrayList<StringBuilder> list = new ArrayList<>();
for (UpgradeSteps s : commandList) {
// For every upgrade step, add it to the output list if its initial version
// satisfy one of the 3 criteria below:
// 1. If it is part of initial upgrade step (from version 0.0 to 1.0)
// which acquires SCH-M lock on ShardMapManagerGlobal
// 2. If initial version is greater than current store version
// and less than target version requested
// 3. If it is part of final upgrade step which releases SCH-M lock on ShardMapManagerGlobal
if ((s.getInitialMajorVersion() == MAJOR_NUMBER_FOR_INITIAL_UPGRADE_STEP)
|| ((currentVersion == null || s.getInitialMajorVersion() > currentVersion.getMajor()
|| (s.getInitialMajorVersion() == currentVersion.getMajor() && s.getInitialMinorVersion() >= currentVersion.getMinor()))
&& (s.getInitialMajorVersion() < targetVersion.getMajor() || (s.getInitialMajorVersion() == targetVersion.getMajor()
&& s.getInitialMinorVersion() < targetVersion.getMinor())))
|| (s.getInitialMajorVersion() == MAJOR_NUMBER_FOR_FINAL_UPGRADE_STEP)) {
list.add(s.getCommands());
}
}
return list;
}