diff --git a/src/main/java/org/snomed/snowstorm/core/data/services/CodeSystemUpgradeService.java b/src/main/java/org/snomed/snowstorm/core/data/services/CodeSystemUpgradeService.java index 7efb5a0f3..9cc83a772 100644 --- a/src/main/java/org/snomed/snowstorm/core/data/services/CodeSystemUpgradeService.java +++ b/src/main/java/org/snomed/snowstorm/core/data/services/CodeSystemUpgradeService.java @@ -136,6 +136,14 @@ public synchronized void upgrade(String id, CodeSystem codeSystem, Integer newDe } throw new IllegalArgumentException(errorMessage); } + if (codeSystem.getDependantVersionEffectiveTime() != null && newDependantVersion.compareTo(codeSystem.getDependantVersionEffectiveTime()) <= 0) { + String errorMessage = "The new dependant version must be after the current dependant version."; + if (job != null) { + job.setStatus(CodeSystemUpgradeJob.UpgradeStatus.FAILED); + job.setErrorMessage(errorMessage); + } + throw new IllegalStateException(errorMessage); + } CodeSystem parentCodeSystem = codeSystemService.findOneByBranchPath(parentPath); if (parentCodeSystem == null) { String errorMessage = String.format("The Code System to be upgraded must be on a branch which is the direct child of another Code System. " +